This commit is contained in:
2025-10-30 13:51:46 +08:00
parent f7f8b60096
commit 901a6a7301
5 changed files with 44 additions and 20 deletions

Binary file not shown.

View File

@@ -55,7 +55,7 @@
<comps>
<li Class="ArachnaeSwarm.CompProperties_AircraftStrike">
<requiredAircraftType>ARA_HiveCorvette_Entity</requiredAircraftType>
<aircraftCooldownTicks>5000</aircraftCooldownTicks> <!-- 2小时冷却 -->
<aircraftCooldownTicks>5000</aircraftCooldownTicks> <!-- 2小时冷却 -->
<aircraftsPerUse>1</aircraftsPerUse>
</li>
<li Class="ArachnaeSwarm.CompProperties_AbilitySpawnFlyOver">
@@ -65,21 +65,23 @@
<altitude>20</altitude>
<playFlyOverSound>true</playFlyOverSound>
<approachType>Perpendicular</approachType>
<!-- 扫射参数 -->
<enableGroundStrafing>true</enableGroundStrafing>
<strafeWidth>3</strafeWidth>
<strafeWidth>6</strafeWidth>
<strafeLength>25</strafeLength>
<strafeProjectile>Proj_ARA_HiveCorvette</strafeProjectile>
<strafeFireChance>0.23</strafeFireChance>
<!-- 新增:控制最终射弹数量 -->
<minStrafeProjectiles>4</minStrafeProjectiles>
<maxStrafeProjectiles>4</maxStrafeProjectiles>
<!-- 只传递信号,不传递具体参数 -->
<enableSectorSurveillance>true</enableSectorSurveillance>
<!-- 可视化 -->
<showStrafePreview>true</showStrafePreview>
<strafePreviewColor>(1.0,0.3,0.1,0.2)</strafePreviewColor>
<!-- 预览配置 -->
<showSectorPreview>true</showSectorPreview>
<sectorPreviewColor>(0.3,0.7,1.0,0.3)</sectorPreviewColor>
@@ -109,7 +111,7 @@
<comps>
<li Class="ArachnaeSwarm.CompProperties_AircraftStrike">
<requiredAircraftType>ARA_HiveCorvette_Entity</requiredAircraftType>
<aircraftCooldownTicks>5000</aircraftCooldownTicks> <!-- 2小时冷却 -->
<aircraftCooldownTicks>5000</aircraftCooldownTicks> <!-- 2小时冷却 -->
<aircraftsPerUse>1</aircraftsPerUse>
</li>
<li Class="ArachnaeSwarm.CompProperties_AbilitySpawnFlyOver">
@@ -119,22 +121,21 @@
<altitude>20</altitude>
<playFlyOverSound>true</playFlyOverSound>
<approachType>Perpendicular</approachType>
<!-- 扫射参数 -->
<enableSectorSurveillance>false</enableSectorSurveillance>
<enableGroundStrafing>true</enableGroundStrafing>
<strafeWidth>6</strafeWidth>
<strafeLength>15</strafeLength>
<strafeProjectile>Bullet_ARA_RW_Acid_Mortar</strafeProjectile>
<strafeFireChance>0.3</strafeFireChance>
<!-- 只传递信号,不传递具体参数 -->
<enableSectorSurveillance>true</enableSectorSurveillance>
<!-- 可视化 -->
<showStrafePreview>true</showStrafePreview>
<strafePreviewColor>(1.0,0.3,0.1,0.2)</strafePreviewColor>
<!-- 预览配置 -->
<showSectorPreview>true</showSectorPreview>
<sectorPreviewColor>(0.3,0.7,1.0,0.3)</sectorPreviewColor>
@@ -164,7 +165,7 @@
<comps>
<li Class="ArachnaeSwarm.CompProperties_AircraftStrike">
<requiredAircraftType>ARA_HiveCorvette_Entity</requiredAircraftType>
<aircraftCooldownTicks>5000</aircraftCooldownTicks> <!-- 2小时冷却 -->
<aircraftCooldownTicks>5000</aircraftCooldownTicks> <!-- 2小时冷却 -->
<aircraftsPerUse>1</aircraftsPerUse>
</li>
<li Class="ArachnaeSwarm.CompProperties_AbilitySpawnFlyOver">
@@ -174,13 +175,13 @@
<altitude>20</altitude>
<playFlyOverSound>true</playFlyOverSound>
<approachType>Perpendicular</approachType>
<!-- 只传递信号,不传递具体参数 -->
<enableSectorSurveillance>true</enableSectorSurveillance>
<!-- 预览配置 -->
<showSectorPreview>true</showSectorPreview>
<strafeWidth>4</strafeWidth> <!-- 用于预览的近似宽度 -->
<strafeWidth>4</strafeWidth> <!-- 用于预览的近似宽度 -->
<sectorPreviewColor>(0.3,0.7,1.0,0.3)</sectorPreviewColor>
</li>
</comps>

View File

@@ -517,11 +517,11 @@
<altitudeLayer>MetaOverlays</altitudeLayer>
<comps>
<li Class="ArachnaeSwarm.CompProperties_GroundStrafing">
<projectileDef>Proj_ARA_HiveCorvette</projectileDef>
<projectileDef>Projectile_CatastropheMissile</projectileDef>
<range>50</range>
</li>
<li Class="ArachnaeSwarm.CompProperties_SectorSurveillance">
<projectileDef>Bullet_ARA_HiveCorvette</projectileDef>
<projectileDef>Bullet_RW_Missile_AR_Gun</projectileDef>
<sectorAngle>30</sectorAngle> <!-- 扇形角度 -->
<sectorRange>50</sectorRange> <!-- 射程 -->
<shotCount>3</shotCount> <!-- 发射次数 -->
@@ -571,7 +571,7 @@
<altitudeLayer>MetaOverlays</altitudeLayer>
<comps>
<li Class="ArachnaeSwarm.CompProperties_GroundStrafing">
<projectileDef>Bullet_ARA_RW_Acid_Mortar</projectileDef>
<projectileDef>Proj_ARA_HiveCorvette</projectileDef>
<range>15</range>
</li>
<li Class="ArachnaeSwarm.CompProperties_SectorSurveillance">

View File

@@ -392,16 +392,37 @@ namespace ArachnaeSwarm
private List<IntVec3> PreprocessStrafingTargets(List<IntVec3> potentialTargets, float fireChance)
{
List<IntVec3> confirmedTargets = new List<IntVec3>();
List<IntVec3> missedCells = new List<IntVec3>();
foreach (IntVec3 cell in potentialTargets)
{
// 使用概率决定这个单元格是否会被射击
if (Rand.Value <= fireChance)
{
confirmedTargets.Add(cell);
}
else
{
missedCells.Add(cell);
}
}
// 应用最小和最大射弹数限制
if (Props.maxStrafeProjectiles > -1 && confirmedTargets.Count > Props.maxStrafeProjectiles)
{
// 如果超出最大值,随机丢弃一些目标
confirmedTargets = confirmedTargets.InRandomOrder().Take(Props.maxStrafeProjectiles).ToList();
}
Log.Message($"Strafing Preprocess: {confirmedTargets.Count}/{potentialTargets.Count} cells confirmed ({fireChance:P0} chance)");
if (Props.minStrafeProjectiles > -1 && confirmedTargets.Count < Props.minStrafeProjectiles)
{
// 如果不足最小值,从之前未选中的格子里补充
int needed = Props.minStrafeProjectiles - confirmedTargets.Count;
if (needed > 0 && missedCells.Count > 0)
{
confirmedTargets.AddRange(missedCells.InRandomOrder().Take(Mathf.Min(needed, missedCells.Count)));
}
}
Log.Message($"Strafing Preprocess: {confirmedTargets.Count}/{potentialTargets.Count} cells confirmed after min/max adjustment.");
return confirmedTargets;
}

View File

@@ -32,6 +32,8 @@ namespace ArachnaeSwarm
public int strafeWidth = 3; // 扫射宽度(用于预览)
public int strafeLength = 15; // 扫射长度
public float strafeFireChance = 0.7f; // 扫射发射概率
public int minStrafeProjectiles = -1; // 新增:最小射弹数
public int maxStrafeProjectiles = -1; // 新增:最大射弹数
public ThingDef strafeProjectile; // 抛射体定义
// 地面扫射可视化