暂存
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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; // 抛射体定义
|
||||
|
||||
// 地面扫射可视化
|
||||
|
||||
Reference in New Issue
Block a user