This commit is contained in:
2025-11-20 12:05:07 +08:00
parent 44bea4dbb8
commit cf82707c8f
12 changed files with 1069 additions and 208 deletions

View File

@@ -15,6 +15,8 @@ namespace WulaFallenEmpire
volleyTargets[pawn] = target;
volleyEnabled[pawn] = target.IsValid;
Log.Message($"Set volley target for {pawn.Label}: {target.Thing?.Label ?? target.Cell.ToString()}");
}
public static void ClearVolleyTarget(Pawn pawn)
@@ -23,6 +25,8 @@ namespace WulaFallenEmpire
volleyTargets.Remove(pawn);
volleyEnabled.Remove(pawn);
Log.Message($"Cleared volley target for {pawn.Label}");
}
public static LocalTargetInfo GetVolleyTarget(Pawn pawn)
@@ -48,11 +52,36 @@ namespace WulaFallenEmpire
bool current = IsVolleyEnabled(pawn);
volleyEnabled[pawn] = !current;
Log.Message($"Toggled volley for {pawn.Label}: {!current}");
// 如果禁用齐射,清除目标
if (!volleyEnabled[pawn])
{
ClearVolleyTarget(pawn);
}
}
// 新增:检查齐射目标是否仍然有效
public static bool IsVolleyTargetValid(Pawn pawn)
{
if (!IsVolleyEnabled(pawn))
return false;
LocalTargetInfo target = GetVolleyTarget(pawn);
if (!target.IsValid)
return false;
// 检查目标是否还活着/存在
if (target.Thing != null)
{
if (target.Thing.Destroyed)
return false;
if (target.Thing is Pawn targetPawn && (targetPawn.Dead || targetPawn.Downed))
return false;
}
return true;
}
}
}