WulaFallenEmpireSettings.cs - 添加了 public bool enableDebugLogs = false; 字段和保存配置

 WulaLog.cs - 修改了DebugEnabled属性,仅检查enableDebugLogs设置(不检查DevMode)
 WulaFallenEmpireMod.cs - 在DoSettingsWindowContents中添加了UI复选框,显示"Enable Debug Logs"选项
 替换了所有848个Log.Message/Error/Warning调用为WulaLog.Debug()
This commit is contained in:
2025-12-15 13:05:50 +08:00
parent 9bdcd8e308
commit 98a0400c78
134 changed files with 1000 additions and 1019 deletions

View File

@@ -1,4 +1,4 @@
using RimWorld;
using RimWorld;
using Verse;
using RimWorld.Planet;
using System.Collections.Generic;
@@ -31,7 +31,7 @@ namespace WulaFallenEmpire
if (aircraftManager == null)
{
Log.Error("WULA_AircraftManagerNotFound".Translate());
WulaLog.Debug("WULA_AircraftManagerNotFound".Translate());
return;
}
@@ -40,12 +40,12 @@ namespace WulaFallenEmpire
{
// 成功消耗战机,发送消息
Messages.Message("WULA_AircraftStrikeInitiated".Translate(Props.requiredAircraftType.LabelCap), MessageTypeDefOf.PositiveEvent);
Log.Message("WULA_AircraftStrikeSuccess".Translate(Props.aircraftsPerUse, Props.requiredAircraftType.LabelCap));
WulaLog.Debug("WULA_AircraftStrikeSuccess".Translate(Props.aircraftsPerUse, Props.requiredAircraftType.LabelCap));
}
else
{
Messages.Message("WULA_NoAvailableAircraft".Translate(Props.requiredAircraftType.LabelCap), MessageTypeDefOf.NegativeEvent);
Log.Warning("WULA_AircraftStrikeFailed".Translate(Props.requiredAircraftType.LabelCap, parent.pawn.Faction?.Name ?? "WULA_UnknownFaction".Translate()));
WulaLog.Debug("WULA_AircraftStrikeFailed".Translate(Props.requiredAircraftType.LabelCap, parent.pawn.Faction?.Name ?? "WULA_UnknownFaction".Translate()));
}
}

View File

@@ -1,4 +1,4 @@
using RimWorld;
using RimWorld;
using Verse;
using System.Collections.Generic;
using RimWorld.Planet;
@@ -163,7 +163,7 @@ namespace WulaFallenEmpire
if (aircraftManager == null)
{
Log.Error("AircraftManagerNotFound".Translate());
WulaLog.Debug("AircraftManagerNotFound".Translate());
return;
}
@@ -205,21 +205,21 @@ namespace WulaFallenEmpire
// 检查地图是否有效
if (parent.Map == null)
{
Log.Error("TakeoffEffectMapNull".Translate());
WulaLog.Debug("TakeoffEffectMapNull".Translate());
return;
}
// 生成 Skyfaller
GenSpawn.Spawn(skyfaller, takeoffPos, parent.Map);
Log.Message("TakeoffSkyfallerCreated".Translate(takeoffPos));
WulaLog.Debug("TakeoffSkyfallerCreated".Translate(takeoffPos));
// 销毁原建筑
parent.Destroy(DestroyMode.Vanish);
}
catch (System.Exception ex)
{
Log.Error("TakeoffEffectError".Translate(ex.Message));
WulaLog.Debug("TakeoffEffectError".Translate(ex.Message));
// 如果Skyfaller创建失败直接销毁建筑
parent.Destroy(DestroyMode.Vanish);
}

View File

@@ -1,4 +1,4 @@
using RimWorld;
using RimWorld;
using Verse;
using System.Collections.Generic;
using RimWorld.Planet;
@@ -65,11 +65,11 @@ namespace WulaFallenEmpire
// 调试日志
if (Scribe.mode == LoadSaveMode.Saving)
{
Log.Message($"Saving aircraft data: {allFactionAircraftData.Count} faction entries, {cooldownEvents.Count} cooldown events");
WulaLog.Debug($"Saving aircraft data: {allFactionAircraftData.Count} faction entries, {cooldownEvents.Count} cooldown events");
}
else if (Scribe.mode == LoadSaveMode.PostLoadInit)
{
Log.Message($"Loaded aircraft data: {allFactionAircraftData.Count} faction entries, {cooldownEvents.Count} cooldown events");
WulaLog.Debug($"Loaded aircraft data: {allFactionAircraftData.Count} faction entries, {cooldownEvents.Count} cooldown events");
}
}
@@ -120,7 +120,7 @@ namespace WulaFallenEmpire
{
if (faction == null)
{
Log.Error("AddAircraftNullFaction".Translate());
WulaLog.Debug("AddAircraftNullFaction".Translate());
return;
}
@@ -128,7 +128,7 @@ namespace WulaFallenEmpire
data.totalCount += count;
data.availableCount += count;
Log.Message($"Added {count} {aircraftDef.LabelCap} to {faction.Name}. Total: {data.totalCount}, Available: {data.availableCount}");
WulaLog.Debug($"Added {count} {aircraftDef.LabelCap} to {faction.Name}. Total: {data.totalCount}, Available: {data.availableCount}");
}
// 尝试使用战机
@@ -150,7 +150,7 @@ namespace WulaFallenEmpire
cooldownEvents.Add(cooldownEvent);
Log.Message($"Used {count} {aircraftDef.LabelCap} from {faction.Name}. Available now: {data.availableCount}, Cooldown until: {cooldownEvent.endTick}");
WulaLog.Debug($"Used {count} {aircraftDef.LabelCap} from {faction.Name}. Available now: {data.availableCount}, Cooldown until: {cooldownEvent.endTick}");
return true;
}
@@ -187,7 +187,7 @@ namespace WulaFallenEmpire
if (cooldownEvent.aircraftDef != null)
{
Messages.Message("AircraftCooldownEnded".Translate(cooldownEvent.aircraftDef.LabelCap), MessageTypeDefOf.PositiveEvent);
Log.Message($"Cooldown ended for {cooldownEvent.aircraftCount} {cooldownEvent.aircraftDef.LabelCap}. Available now: {data.availableCount}");
WulaLog.Debug($"Cooldown ended for {cooldownEvent.aircraftCount} {cooldownEvent.aircraftDef.LabelCap}. Available now: {data.availableCount}");
}
}
}
@@ -203,22 +203,22 @@ namespace WulaFallenEmpire
// 调试方法:显示当前状态
public void DebugLogStatus()
{
Log.Message("=== Aircraft Manager Status ===");
Log.Message($"Total faction entries: {allFactionAircraftData.Count}");
WulaLog.Debug("=== Aircraft Manager Status ===");
WulaLog.Debug($"Total faction entries: {allFactionAircraftData.Count}");
var factions = allFactionAircraftData.Select(x => x.faction).Distinct();
foreach (var faction in factions)
{
Log.Message($"Faction: {faction?.Name ?? "Unknown"}");
WulaLog.Debug($"Faction: {faction?.Name ?? "Unknown"}");
var factionData = allFactionAircraftData.Where(x => x.faction == faction);
foreach (var data in factionData)
{
Log.Message($" {data.aircraftDef.LabelCap}: {data.availableCount}/{data.totalCount} available");
WulaLog.Debug($" {data.aircraftDef.LabelCap}: {data.availableCount}/{data.totalCount} available");
}
}
Log.Message($"Active cooldown events: {cooldownEvents.Count}");
Log.Message("===============================");
WulaLog.Debug($"Active cooldown events: {cooldownEvents.Count}");
WulaLog.Debug("===============================");
}
}
}

View File

@@ -1,4 +1,4 @@
using RimWorld;
using RimWorld;
using Verse;
using System.Collections.Generic;
@@ -73,7 +73,7 @@ namespace WulaFallenEmpire
}
catch (System.Exception ex)
{
Log.Error($"[BlockedByFlyOverFacility] Error in ExtraLabelMouseAttachment: {ex}");
WulaLog.Debug($"[BlockedByFlyOverFacility] Error in ExtraLabelMouseAttachment: {ex}");
return "航道状态检查错误";
}
}
@@ -119,13 +119,13 @@ namespace WulaFallenEmpire
}
}
Log.Message($"[BlockedByFlyOverFacility] Found {flyOversWithFacilities.Count} FlyOvers with facilities");
WulaLog.Debug($"[BlockedByFlyOverFacility] Found {flyOversWithFacilities.Count} FlyOvers with facilities");
return flyOversWithFacilities;
}
catch (System.Exception ex)
{
Log.Error($"[BlockedByFlyOverFacility] Error in GetFlyOversWithFacilities: {ex}");
WulaLog.Debug($"[BlockedByFlyOverFacility] Error in GetFlyOversWithFacilities: {ex}");
return new List<FlyOver>();
}
}
@@ -136,7 +136,7 @@ namespace WulaFallenEmpire
// 在应用前再次检查,确保安全
if (HasFlyOverWithFacilities())
{
Log.Warning($"[BlockedByFlyOverFacility] Attempted to use ability while FlyOvers are present");
WulaLog.Debug($"[BlockedByFlyOverFacility] Attempted to use ability while FlyOvers are present");
Messages.Message(Props.blockedMessage, parent.pawn, MessageTypeDefOf.RejectInput);
return;
}

View File

@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using RimWorld;
using Verse;
@@ -51,7 +51,7 @@ namespace WulaFallenEmpire
foreach (FlyOver flyOver in flyOversWithFacilities)
{
flyOver.EmergencyDestroy();
Log.Message($"[DestroyFlyOverByFacilities] Destroyed FlyOver with facilities at {flyOver.Position}");
WulaLog.Debug($"[DestroyFlyOverByFacilities] Destroyed FlyOver with facilities at {flyOver.Position}");
}
if (flyOversWithFacilities.Count > 0)
@@ -126,7 +126,7 @@ namespace WulaFallenEmpire
}
catch (System.Exception ex)
{
Log.Error($"[DestroyFlyOverByFacilities] Error in ExtraLabelMouseAttachment: {ex}");
WulaLog.Debug($"[DestroyFlyOverByFacilities] Error in ExtraLabelMouseAttachment: {ex}");
return "Error checking FlyOver status";
}
}

View File

@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using RimWorld;
using Verse;
using Verse.AI;
@@ -127,14 +127,14 @@ namespace WulaFallenEmpire
if (Props.useCyclicDrops)
{
ticksUntilNextDrop = (int)(Props.cyclicDropIntervalHours * 2500f); // 1小时 = 2500 ticks
Log.Message($"Cyclic drops initialized: {Props.cyclicDropIntervalHours} hours interval");
WulaLog.Debug($"Cyclic drops initialized: {Props.cyclicDropIntervalHours} hours interval");
}
// 初始化信号等待状态
if (Props.waitForExternalSignal)
{
waitingForSignal = true;
Log.Message($"Waiting for external signal: {Props.externalSignalTag}");
WulaLog.Debug($"Waiting for external signal: {Props.externalSignalTag}");
}
}
@@ -151,7 +151,7 @@ namespace WulaFallenEmpire
if (pawn != null)
{
pawns.Add(pawn);
Log.Message($"Generated pawn: {pawn.Label} ({pawnKindCount.pawnKindDef.defName})");
WulaLog.Debug($"Generated pawn: {pawn.Label} ({pawnKindCount.pawnKindDef.defName})");
}
}
}
@@ -162,7 +162,7 @@ namespace WulaFallenEmpire
{
if (pawnKindDef == null)
{
Log.Error("Attempted to generate pawn with null PawnKindDef");
WulaLog.Debug("Attempted to generate pawn with null PawnKindDef");
return null;
}
@@ -213,12 +213,12 @@ namespace WulaFallenEmpire
pawn.mindState.SetupLastHumanMeatTick();
}
Log.Message($"Successfully generated pawn: {pawn.LabelCap} from {pawnKindDef.defName}");
WulaLog.Debug($"Successfully generated pawn: {pawn.LabelCap} from {pawnKindDef.defName}");
return pawn;
}
catch (System.Exception ex)
{
Log.Error($"Failed to generate pawn from {pawnKindDef.defName}: {ex}");
WulaLog.Debug($"Failed to generate pawn from {pawnKindDef.defName}: {ex}");
return null;
}
}
@@ -282,7 +282,7 @@ namespace WulaFallenEmpire
// 重置计时器
ticksUntilNextDrop = (int)(Props.cyclicDropIntervalHours * 2500f);
Log.Message($"Cyclic drop completed, next drop in {Props.cyclicDropIntervalHours} hours");
WulaLog.Debug($"Cyclic drop completed, next drop in {Props.cyclicDropIntervalHours} hours");
}
}
@@ -291,7 +291,7 @@ namespace WulaFallenEmpire
{
if (parent is FlyOver flyOver && waitingForSignal)
{
Log.Message($"External signal received, triggering drop pods");
WulaLog.Debug($"External signal received, triggering drop pods");
DropPods(flyOver);
waitingForSignal = false;
}
@@ -313,12 +313,12 @@ namespace WulaFallenEmpire
Map map = flyOver.Map;
if (map == null)
{
Log.Error("FlyOver DropPods: Map is null");
WulaLog.Debug("FlyOver DropPods: Map is null");
return;
}
IntVec3 dropCenter = GetDropCenter(flyOver);
Log.Message($"DropPods triggered at progress {flyOver.currentProgress}, center: {dropCenter}");
WulaLog.Debug($"DropPods triggered at progress {flyOver.currentProgress}, center: {dropCenter}");
// 如果在投掷时生成 Pawn现在生成
if (Props.generatePawnsOnDrop && Props.pawnKinds != null)
@@ -351,7 +351,7 @@ namespace WulaFallenEmpire
if (!thingsToDrop.Any())
{
Log.Warning("No items to drop from FlyOver drop pods");
WulaLog.Debug("No items to drop from FlyOver drop pods");
return;
}
@@ -377,7 +377,7 @@ namespace WulaFallenEmpire
SendDropLetter(thingsToDrop, dropCenter, map);
}
Log.Message($"Drop pods completed: {thingsToDrop.Count} items dropped, including {pawns.Count} pawns");
WulaLog.Debug($"Drop pods completed: {thingsToDrop.Count} items dropped, including {pawns.Count} pawns");
// 清空已投掷的物品列表,避免重复投掷
items.Clear();
@@ -464,7 +464,7 @@ namespace WulaFallenEmpire
// 创建 Lord
Lord lord = LordMaker.MakeNewLord(faction, lordJob, Find.CurrentMap, factionPawns);
Log.Message($"Assigned assault lord job to {factionPawns.Count} pawns of faction {faction.Name}");
WulaLog.Debug($"Assigned assault lord job to {factionPawns.Count} pawns of faction {faction.Name}");
}
}

View File

@@ -1,4 +1,4 @@
using RimWorld;
using RimWorld;
using System.Collections.Generic;
using UnityEngine;
using Verse;
@@ -147,7 +147,7 @@ namespace WulaFallenEmpire
if (successfulSpawns < escortsToSpawn)
{
Log.Message($"Spawned {successfulSpawns}/{escortsToSpawn} escorts (some positions were too close to existing escorts)");
WulaLog.Debug($"Spawned {successfulSpawns}/{escortsToSpawn} escorts (some positions were too close to existing escorts)");
}
}
@@ -210,7 +210,7 @@ namespace WulaFallenEmpire
ThingDef escortDef = SelectEscortDef();
if (escortDef == null)
{
Log.Error("FlyOver Escort: No valid escort def found");
WulaLog.Debug("FlyOver Escort: No valid escort def found");
return null;
}
@@ -220,7 +220,7 @@ namespace WulaFallenEmpire
if (!escortStart.InBounds(mainFlyOver.Map) || !escortEnd.InBounds(mainFlyOver.Map))
{
Log.Warning("FlyOver Escort: Escort start or end position out of bounds");
WulaLog.Debug("FlyOver Escort: Escort start or end position out of bounds");
return null;
}
@@ -247,7 +247,7 @@ namespace WulaFallenEmpire
}
catch (System.Exception ex)
{
Log.Error($"Error creating FlyOver escort: {ex}");
WulaLog.Debug($"Error creating FlyOver escort: {ex}");
return null;
}
}

View File

@@ -1,4 +1,4 @@
// CompAbilityEffect_RequireFlyOverFacility.cs
// CompAbilityEffect_RequireFlyOverFacility.cs
using System.Collections.Generic;
using System.Linq;
using RimWorld;
@@ -22,7 +22,7 @@ namespace WulaFallenEmpire
if (availableFlyOvers.Count == 0)
{
Log.Error($"[RequireFlyOverFacility] No valid FlyOver found with required facility: {Props.requiredFacility}");
WulaLog.Debug($"[RequireFlyOverFacility] No valid FlyOver found with required facility: {Props.requiredFacility}");
return;
}
@@ -62,7 +62,7 @@ namespace WulaFallenEmpire
catch (System.Exception ex)
{
// 捕获异常避免UI崩溃
Log.Error($"[RequireFlyOverFacility] Error in ExtraLabelMouseAttachment: {ex}");
WulaLog.Debug($"[RequireFlyOverFacility] Error in ExtraLabelMouseAttachment: {ex}");
return "设施检查错误";
}
}
@@ -123,7 +123,7 @@ namespace WulaFallenEmpire
}
catch (System.Exception ex)
{
Log.Error($"[RequireFlyOverFacility] Error in GetValidFlyOvers: {ex}");
WulaLog.Debug($"[RequireFlyOverFacility] Error in GetValidFlyOvers: {ex}");
return new List<FlyOver>();
}
}

View File

@@ -1,4 +1,4 @@
// CompFlyOverFacilities.cs
// CompFlyOverFacilities.cs
using System.Collections.Generic;
using RimWorld;
using Verse;
@@ -41,7 +41,7 @@ namespace WulaFallenEmpire
}
catch (System.Exception ex)
{
Log.Error($"[FlyOverFacilities] Error in AnyFlyOverHasFacilities: {ex}");
WulaLog.Debug($"[FlyOverFacilities] Error in AnyFlyOverHasFacilities: {ex}");
return false;
}
}
@@ -71,7 +71,7 @@ namespace WulaFallenEmpire
}
catch (System.Exception ex)
{
Log.Error($"[FlyOverFacilities] Error in GetAllFlyOversWithFacilities: {ex}");
WulaLog.Debug($"[FlyOverFacilities] Error in GetAllFlyOversWithFacilities: {ex}");
return result;
}
}
@@ -100,7 +100,7 @@ namespace WulaFallenEmpire
{
// 只在初次生成时激活所有定义的设施
activeFacilities.AddRange(Props.availableFacilities);
Log.Message($"[FlyOverFacilities] Initialized with {activeFacilities.Count} facilities: {string.Join(", ", activeFacilities)}");
WulaLog.Debug($"[FlyOverFacilities] Initialized with {activeFacilities.Count} facilities: {string.Join(", ", activeFacilities)}");
}
}
@@ -127,7 +127,7 @@ namespace WulaFallenEmpire
activeFacilities = new List<string>();
// 在加载后重新添加默认设施
activeFacilities.AddRange(Props.availableFacilities);
Log.Message($"[FlyOverFacilities] Reinitialized after load with {activeFacilities.Count} facilities");
WulaLog.Debug($"[FlyOverFacilities] Reinitialized after load with {activeFacilities.Count} facilities");
}
}

View File

@@ -1,4 +1,4 @@
using RimWorld;
using RimWorld;
using Verse;
using System.Collections.Generic;
using System.Linq;
@@ -21,7 +21,7 @@ namespace WulaFallenEmpire
if (availableFlyOvers.Count == 0)
{
Log.Error($"[GlobalFlyOverCooldown] No available FlyOver with BombardmentFacility found");
WulaLog.Debug($"[GlobalFlyOverCooldown] No available FlyOver with BombardmentFacility found");
return;
}
@@ -31,14 +31,14 @@ namespace WulaFallenEmpire
if (facilitiesComp == null)
{
Log.Error($"[GlobalFlyOverCooldown] Selected FlyOver has no CompFlyOverFacilities");
WulaLog.Debug($"[GlobalFlyOverCooldown] Selected FlyOver has no CompFlyOverFacilities");
return;
}
// 设置冷却时间
SetCooldown(selectedFlyOver, Props.globalCooldownTicks);
Log.Message($"[GlobalFlyOverCooldown] Set cooldown on FlyOver at {selectedFlyOver.Position} for {Props.globalCooldownTicks} ticks");
WulaLog.Debug($"[GlobalFlyOverCooldown] Set cooldown on FlyOver at {selectedFlyOver.Position} for {Props.globalCooldownTicks} ticks");
}
public override bool GizmoDisabled(out string reason)
@@ -73,7 +73,7 @@ namespace WulaFallenEmpire
}
catch (System.Exception ex)
{
Log.Error($"[GlobalFlyOverCooldown] Error in ExtraLabelMouseAttachment: {ex}");
WulaLog.Debug($"[GlobalFlyOverCooldown] Error in ExtraLabelMouseAttachment: {ex}");
return "WULA_GlobalFlyOverCooldown.FacilityStatusError".Translate();
}
}
@@ -144,7 +144,7 @@ namespace WulaFallenEmpire
}
catch (System.Exception ex)
{
Log.Error($"[GlobalFlyOverCooldown] Error in GetAvailableFlyOvers: {ex}");
WulaLog.Debug($"[GlobalFlyOverCooldown] Error in GetAvailableFlyOvers: {ex}");
return new List<FlyOver>();
}
}
@@ -188,7 +188,7 @@ namespace WulaFallenEmpire
}
catch (System.Exception ex)
{
Log.Error($"[GlobalFlyOverCooldown] Error in GetTotalFlyOvers: {ex}");
WulaLog.Debug($"[GlobalFlyOverCooldown] Error in GetTotalFlyOvers: {ex}");
return new List<FlyOver>();
}
}
@@ -214,7 +214,7 @@ namespace WulaFallenEmpire
var cooldownComp = flyOver.GetComp<CompFlyOverCooldown>();
if (cooldownComp == null)
{
Log.Error($"[GlobalFlyOverCooldown] FlyOver at {flyOver.Position} has no CompFlyOverCooldown");
WulaLog.Debug($"[GlobalFlyOverCooldown] FlyOver at {flyOver.Position} has no CompFlyOverCooldown");
return;
}

View File

@@ -1,4 +1,4 @@
using RimWorld;
using RimWorld;
using Verse;
namespace WulaFallenEmpire
@@ -39,7 +39,7 @@ namespace WulaFallenEmpire
int actualCooldown = cooldownTicks > 0 ? cooldownTicks : Props.baseCooldownTicks;
cooldownEndTick = Find.TickManager.TicksGame + actualCooldown;
Log.Message($"[FlyOverCooldown] Cooldown started for {actualCooldown} ticks, ends at tick {cooldownEndTick}");
WulaLog.Debug($"[FlyOverCooldown] Cooldown started for {actualCooldown} ticks, ends at tick {cooldownEndTick}");
}
// 强制结束冷却

View File

@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using RimWorld;
using UnityEngine;
using Verse;
@@ -33,7 +33,7 @@ namespace WulaFallenEmpire
currentLongitudinalOffset = Props.longitudinalInitialOffset;
}
Log.Message($"GroundStrafing: Initialized with {confirmedTargetCells.Count} targets, " +
WulaLog.Debug($"GroundStrafing: Initialized with {confirmedTargetCells.Count} targets, " +
$"Lateral Offset: {currentLateralOffsetAngle:F1}°, " +
$"Longitudinal Offset: {currentLongitudinalOffset:F1}");
}
@@ -52,7 +52,7 @@ namespace WulaFallenEmpire
// 定期状态输出
if (Find.TickManager.TicksGame % 120 == 0 && confirmedTargetCells.Count > 0)
{
Log.Message($"GroundStrafing: {firedCells.Count}/{confirmedTargetCells.Count + firedCells.Count} targets fired, " +
WulaLog.Debug($"GroundStrafing: {firedCells.Count}/{confirmedTargetCells.Count + firedCells.Count} targets fired, " +
$"Lateral: {currentLateralOffsetAngle:F1}°, Longitudinal: {currentLongitudinalOffset:F1}");
}
}
@@ -84,7 +84,7 @@ namespace WulaFallenEmpire
if (firedCells.Count == 1)
{
Log.Message($"First strafing shot at {targetCell}, " +
WulaLog.Debug($"First strafing shot at {targetCell}, " +
$"Lateral offset: {currentLateralOffsetAngle:F1}°, " +
$"Longitudinal offset: {currentLongitudinalOffset:F1}");
}
@@ -235,7 +235,7 @@ namespace WulaFallenEmpire
{
if (Props.projectileDef == null)
{
Log.Error("No projectile defined for ground strafing");
WulaLog.Debug("No projectile defined for ground strafing");
return false;
}
@@ -279,7 +279,7 @@ namespace WulaFallenEmpire
}
catch (System.Exception ex)
{
Log.Error($"Error launching ground strafing projectile: {ex}");
WulaLog.Debug($"Error launching ground strafing projectile: {ex}");
}
return false;
@@ -320,13 +320,13 @@ namespace WulaFallenEmpire
confirmedTargetCells.AddRange(targets);
Log.Message($"GroundStrafing: Set {confirmedTargetCells.Count} targets, " +
WulaLog.Debug($"GroundStrafing: Set {confirmedTargetCells.Count} targets, " +
$"Lateral Mode: {Props.lateralOffsetMode}, " +
$"Longitudinal Mode: {Props.longitudinalOffsetMode}");
if (confirmedTargetCells.Count > 0)
{
Log.Message($"First target: {confirmedTargetCells[0]}, Last target: {confirmedTargetCells[confirmedTargetCells.Count - 1]}");
WulaLog.Debug($"First target: {confirmedTargetCells[0]}, Last target: {confirmedTargetCells[confirmedTargetCells.Count - 1]}");
}
}
@@ -345,10 +345,10 @@ namespace WulaFallenEmpire
// 修改:调试方法
public void DebugOffsetStatus()
{
Log.Message($"GroundStrafing Offset Status:");
Log.Message($" Lateral - Angle: {currentLateralOffsetAngle:F1}°, Mode: {Props.lateralOffsetMode}");
Log.Message($" Longitudinal - Offset: {currentLongitudinalOffset:F1}, Mode: {Props.longitudinalOffsetMode}");
Log.Message($" Shots Fired: {shotsFired}, Forward Phase: {isForwardPhase}");
WulaLog.Debug($"GroundStrafing Offset Status:");
WulaLog.Debug($" Lateral - Angle: {currentLateralOffsetAngle:F1}°, Mode: {Props.lateralOffsetMode}");
WulaLog.Debug($" Longitudinal - Offset: {currentLongitudinalOffset:F1}, Mode: {Props.longitudinalOffsetMode}");
WulaLog.Debug($" Shots Fired: {shotsFired}, Forward Phase: {isForwardPhase}");
}
}

View File

@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using RimWorld;
using UnityEngine;
using Verse;
@@ -52,23 +52,23 @@ namespace WulaFallenEmpire
currentLongitudinalOffset = Props.longitudinalInitialOffset;
}
Log.Message($"SectorSurveillance: Initialized - Angle: {Props.sectorAngle}°, Range: {Props.sectorRange}, Shots: {Props.shotCount}, Interval: {Props.shotInterval}s");
Log.Message($"SectorSurveillance: ProjectileDef = {Props.projectileDef?.defName ?? "NULL"}");
Log.Message($"SectorSurveillance: Parent = {parent?.def?.defName ?? "NULL"} at {parent?.Position.ToString() ?? "NULL"}");
Log.Message($"SectorSurveillance: Max Projectiles = {Props.maxProjectiles}, Remaining = {remainingProjectiles}");
Log.Message($"SectorSurveillance: Lateral Mode: {Props.lateralOffsetMode}, Longitudinal Mode: {Props.longitudinalOffsetMode}");
WulaLog.Debug($"SectorSurveillance: Initialized - Angle: {Props.sectorAngle}°, Range: {Props.sectorRange}, Shots: {Props.shotCount}, Interval: {Props.shotInterval}s");
WulaLog.Debug($"SectorSurveillance: ProjectileDef = {Props.projectileDef?.defName ?? "NULL"}");
WulaLog.Debug($"SectorSurveillance: Parent = {parent?.def?.defName ?? "NULL"} at {parent?.Position.ToString() ?? "NULL"}");
WulaLog.Debug($"SectorSurveillance: Max Projectiles = {Props.maxProjectiles}, Remaining = {remainingProjectiles}");
WulaLog.Debug($"SectorSurveillance: Lateral Mode: {Props.lateralOffsetMode}, Longitudinal Mode: {Props.longitudinalOffsetMode}");
InitializeFactionCache();
}
private void InitializeFactionCache()
{
Log.Message($"SectorSurveillance: Initializing faction cache...");
WulaLog.Debug($"SectorSurveillance: Initializing faction cache...");
if (parent.Faction != null)
{
cachedFaction = parent.Faction;
Log.Message($"SectorSurveillance: Using parent.Faction: {cachedFaction?.Name ?? "NULL"}");
WulaLog.Debug($"SectorSurveillance: Using parent.Faction: {cachedFaction?.Name ?? "NULL"}");
}
else
{
@@ -76,21 +76,21 @@ namespace WulaFallenEmpire
if (flyOver?.caster != null && flyOver.caster.Faction != null)
{
cachedFaction = flyOver.caster.Faction;
Log.Message($"SectorSurveillance: Using caster.Faction: {cachedFaction?.Name ?? "NULL"}");
WulaLog.Debug($"SectorSurveillance: Using caster.Faction: {cachedFaction?.Name ?? "NULL"}");
}
else if (flyOver?.faction != null)
{
cachedFaction = flyOver.faction;
Log.Message($"SectorSurveillance: Using flyOver.faction: {cachedFaction?.Name ?? "NULL"}");
WulaLog.Debug($"SectorSurveillance: Using flyOver.faction: {cachedFaction?.Name ?? "NULL"}");
}
else
{
Log.Error($"SectorSurveillance: CRITICAL - No faction found!");
WulaLog.Debug($"SectorSurveillance: CRITICAL - No faction found!");
}
}
factionInitialized = true;
Log.Message($"SectorSurveillance: Faction cache initialized: {cachedFaction?.Name ?? "NULL"}");
WulaLog.Debug($"SectorSurveillance: Faction cache initialized: {cachedFaction?.Name ?? "NULL"}");
}
private Faction GetEffectiveFaction()
@@ -102,7 +102,7 @@ namespace WulaFallenEmpire
if (cachedFaction == null)
{
Log.Warning("SectorSurveillance: Cached faction is null, reinitializing...");
WulaLog.Debug("SectorSurveillance: Cached faction is null, reinitializing...");
InitializeFactionCache();
}
@@ -118,8 +118,8 @@ namespace WulaFallenEmpire
if (Find.TickManager.TicksGame % 60 == 0)
{
Faction currentFaction = GetEffectiveFaction();
Log.Message($"SectorSurveillance Status: Frames={totalFramesProcessed}, TargetsFound={totalTargetsFound}, ShotsFired={totalShotsFired}, ActiveTargets={activeTargets.Count}, Cooldowns={shotCooldowns.Count}, Faction={currentFaction?.Name ?? "NULL"}, RemainingProjectiles={remainingProjectiles}, AmmoExhausted={ammoExhausted}");
Log.Message($"SectorSurveillance Offsets: Lateral={currentLateralOffsetAngle:F1}°, Longitudinal={currentLongitudinalOffset:F1}, TotalShots={shotsFired}");
WulaLog.Debug($"SectorSurveillance Status: Frames={totalFramesProcessed}, TargetsFound={totalTargetsFound}, ShotsFired={totalShotsFired}, ActiveTargets={activeTargets.Count}, Cooldowns={shotCooldowns.Count}, Faction={currentFaction?.Name ?? "NULL"}, RemainingProjectiles={remainingProjectiles}, AmmoExhausted={ammoExhausted}");
WulaLog.Debug($"SectorSurveillance Offsets: Lateral={currentLateralOffsetAngle:F1}°, Longitudinal={currentLongitudinalOffset:F1}, TotalShots={shotsFired}");
}
UpdateShotCooldowns();
@@ -165,7 +165,7 @@ namespace WulaFallenEmpire
foreach (Pawn pawn in toRemove)
{
shotCooldowns.Remove(pawn);
Log.Message($"SectorSurveillance: Cooldown finished for {pawn?.Label ?? "NULL"}");
WulaLog.Debug($"SectorSurveillance: Cooldown finished for {pawn?.Label ?? "NULL"}");
}
}
@@ -178,11 +178,11 @@ namespace WulaFallenEmpire
}
List<Pawn> enemiesInSector = GetEnemiesInSector();
Log.Message($"SectorSurveillance: Found {enemiesInSector.Count} enemies in sector");
WulaLog.Debug($"SectorSurveillance: Found {enemiesInSector.Count} enemies in sector");
if (enemiesInSector.Count > 0)
{
Log.Message($"SectorSurveillance: Enemies in sector: {string.Join(", ", enemiesInSector.ConvertAll(p => p.Label))}");
WulaLog.Debug($"SectorSurveillance: Enemies in sector: {string.Join(", ", enemiesInSector.ConvertAll(p => p.Label))}");
}
foreach (Pawn enemy in enemiesInSector)
@@ -194,7 +194,7 @@ namespace WulaFallenEmpire
!shotCooldowns.ContainsKey(enemy))
{
activeTargets[enemy] = Props.shotCount;
Log.Message($"SectorSurveillance: Starting attack sequence on {enemy.Label} at {enemy.Position} - {Props.shotCount} shots");
WulaLog.Debug($"SectorSurveillance: Starting attack sequence on {enemy.Label} at {enemy.Position} - {Props.shotCount} shots");
}
}
}
@@ -231,26 +231,26 @@ namespace WulaFallenEmpire
if (!IsInSector(enemy.Position))
{
Log.Message($"SectorSurveillance: Target {enemy.Label} left sector, cancelling attack");
WulaLog.Debug($"SectorSurveillance: Target {enemy.Label} left sector, cancelling attack");
completedTargets.Add(enemy);
continue;
}
if (shotCooldowns.ContainsKey(enemy))
{
Log.Message($"SectorSurveillance: Target {enemy.Label} in cooldown, skipping this frame");
WulaLog.Debug($"SectorSurveillance: Target {enemy.Label} in cooldown, skipping this frame");
continue;
}
// 检查剩余射弹数量
if (remainingProjectiles == 0)
{
Log.Message($"SectorSurveillance: Ammo exhausted, cannot fire at {enemy.Label}");
WulaLog.Debug($"SectorSurveillance: Ammo exhausted, cannot fire at {enemy.Label}");
ammoExhausted = true;
break; // 跳出循环,不再发射任何射弹
}
Log.Message($"SectorSurveillance: Attempting to fire at {enemy.Label}, remaining shots: {remainingShots}, remaining projectiles: {remainingProjectiles}");
WulaLog.Debug($"SectorSurveillance: Attempting to fire at {enemy.Label}, remaining shots: {remainingShots}, remaining projectiles: {remainingProjectiles}");
if (LaunchProjectileAt(enemy))
{
totalShotsFired++;
@@ -261,13 +261,13 @@ namespace WulaFallenEmpire
if (remainingProjectiles > 0)
{
remainingProjectiles--;
Log.Message($"SectorSurveillance: Remaining projectiles: {remainingProjectiles}");
WulaLog.Debug($"SectorSurveillance: Remaining projectiles: {remainingProjectiles}");
// 检查是否耗尽弹药
if (remainingProjectiles == 0)
{
ammoExhausted = true;
Log.Message($"SectorSurveillance: AMMO EXHAUSTED - No more projectiles available");
WulaLog.Debug($"SectorSurveillance: AMMO EXHAUSTED - No more projectiles available");
}
}
@@ -277,18 +277,18 @@ namespace WulaFallenEmpire
int cooldownTicks = Mathf.RoundToInt(Props.shotInterval * 60f);
shotCooldowns[enemy] = cooldownTicks;
Log.Message($"SectorSurveillance: Successfully fired at {enemy.Label}, {remainingShots} shots remaining, cooldown: {cooldownTicks} ticks");
WulaLog.Debug($"SectorSurveillance: Successfully fired at {enemy.Label}, {remainingShots} shots remaining, cooldown: {cooldownTicks} ticks");
if (remainingShots <= 0)
{
attackedPawns.Add(enemy);
completedTargets.Add(enemy);
Log.Message($"SectorSurveillance: Completed attack sequence on {enemy.Label}");
WulaLog.Debug($"SectorSurveillance: Completed attack sequence on {enemy.Label}");
}
}
else
{
Log.Error($"SectorSurveillance: Failed to fire projectile at {enemy.Label}");
WulaLog.Debug($"SectorSurveillance: Failed to fire projectile at {enemy.Label}");
}
}
@@ -299,13 +299,13 @@ namespace WulaFallenEmpire
if (enemy != null)
{
activeTargets.Remove(enemy);
Log.Message($"SectorSurveillance: Removed {enemy.Label} from active targets");
WulaLog.Debug($"SectorSurveillance: Removed {enemy.Label} from active targets");
}
else
{
// 如果目标已不存在,直接从字典中移除对应的键
activeTargets.Remove(enemy);
Log.Message($"SectorSurveillance: Removed null target from active targets");
WulaLog.Debug($"SectorSurveillance: Removed null target from active targets");
}
}
}
@@ -448,14 +448,14 @@ namespace WulaFallenEmpire
if (map == null)
{
Log.Error("SectorSurveillance: Map is null!");
WulaLog.Debug("SectorSurveillance: Map is null!");
return enemies;
}
FlyOver flyOver = parent as FlyOver;
if (flyOver == null)
{
Log.Error("SectorSurveillance: Parent is not a FlyOver!");
WulaLog.Debug("SectorSurveillance: Parent is not a FlyOver!");
return enemies;
}
@@ -464,7 +464,7 @@ namespace WulaFallenEmpire
float range = Props.sectorRange;
float halfAngle = Props.sectorAngle * 0.5f;
Log.Message($"SectorSurveillance: Checking sector - Center: {center}, Direction: {flightDirection}, Range: {range}, HalfAngle: {halfAngle}");
WulaLog.Debug($"SectorSurveillance: Checking sector - Center: {center}, Direction: {flightDirection}, Range: {range}, HalfAngle: {halfAngle}");
int totalEnemiesChecked = 0;
@@ -480,12 +480,12 @@ namespace WulaFallenEmpire
if (inSector)
{
enemies.Add(pawn);
Log.Message($"SectorSurveillance: Valid target found - {pawn.Label} at {pawn.Position}, in sector: {inSector}");
WulaLog.Debug($"SectorSurveillance: Valid target found - {pawn.Label} at {pawn.Position}, in sector: {inSector}");
}
}
}
Log.Message($"SectorSurveillance: Checked {totalEnemiesChecked} pawns, found {enemies.Count} valid targets in sector");
WulaLog.Debug($"SectorSurveillance: Checked {totalEnemiesChecked} pawns, found {enemies.Count} valid targets in sector");
return enemies;
}
@@ -493,32 +493,32 @@ namespace WulaFallenEmpire
{
if (pawn == null)
{
Log.Message("SectorSurveillance: IsValidTarget - pawn is null");
WulaLog.Debug("SectorSurveillance: IsValidTarget - pawn is null");
return false;
}
// 关键修复检查pawn是否已被销毁或死亡
if (pawn.Destroyed || pawn.Dead || !pawn.Spawned)
{
Log.Message($"SectorSurveillance: IsValidTarget - {pawn.Label} is destroyed/dead/unspawned");
WulaLog.Debug($"SectorSurveillance: IsValidTarget - {pawn.Label} is destroyed/dead/unspawned");
return false;
}
if (pawn.Downed)
{
Log.Message($"SectorSurveillance: IsValidTarget - {pawn.Label} is downed");
WulaLog.Debug($"SectorSurveillance: IsValidTarget - {pawn.Label} is downed");
return false;
}
Faction effectiveFaction = GetEffectiveFaction();
if (effectiveFaction == null)
{
Log.Error($"SectorSurveillance: IsValidTarget - No effective faction found for {pawn.Label}");
WulaLog.Debug($"SectorSurveillance: IsValidTarget - No effective faction found for {pawn.Label}");
return false;
}
bool hostile = pawn.HostileTo(effectiveFaction);
Log.Message($"SectorSurveillance: IsValidTarget - {pawn.Label} from {pawn.Faction?.Name ?? "NULL"} is hostile to {effectiveFaction.Name}: {hostile}");
WulaLog.Debug($"SectorSurveillance: IsValidTarget - {pawn.Label} from {pawn.Faction?.Name ?? "NULL"} is hostile to {effectiveFaction.Name}: {hostile}");
return hostile;
}
@@ -528,7 +528,7 @@ namespace WulaFallenEmpire
FlyOver flyOver = parent as FlyOver;
if (flyOver == null)
{
Log.Error("SectorSurveillance: IsInSector - Parent is not a FlyOver!");
WulaLog.Debug("SectorSurveillance: IsInSector - Parent is not a FlyOver!");
return false;
}
@@ -539,7 +539,7 @@ namespace WulaFallenEmpire
float distance = targetVector.magnitude;
if (distance > Props.sectorRange)
{
Log.Message($"SectorSurveillance: IsInSector - Target at {targetPos} is out of range: {distance:F1} > {Props.sectorRange}");
WulaLog.Debug($"SectorSurveillance: IsInSector - Target at {targetPos} is out of range: {distance:F1} > {Props.sectorRange}");
return false;
}
@@ -548,7 +548,7 @@ namespace WulaFallenEmpire
bool inAngle = angle <= Props.sectorAngle * 0.5f;
Log.Message($"SectorSurveillance: IsInSector - Target at {targetPos}, distance: {distance:F1}, angle: {angle:F1}°, inAngle: {inAngle}");
WulaLog.Debug($"SectorSurveillance: IsInSector - Target at {targetPos}, distance: {distance:F1}, angle: {angle:F1}°, inAngle: {inAngle}");
return inAngle;
}
@@ -557,11 +557,11 @@ namespace WulaFallenEmpire
{
if (Props.projectileDef == null)
{
Log.Error("SectorSurveillance: No projectile defined for sector surveillance");
WulaLog.Debug("SectorSurveillance: No projectile defined for sector surveillance");
return false;
}
Log.Message($"SectorSurveillance: LaunchProjectileAt - Starting launch for target {target?.Label ?? "NULL"}");
WulaLog.Debug($"SectorSurveillance: LaunchProjectileAt - Starting launch for target {target?.Label ?? "NULL"}");
try
{
@@ -574,33 +574,33 @@ namespace WulaFallenEmpire
IntVec3 spawnCell = offsetSpawnPos.ToIntVec3();
Log.Message($"SectorSurveillance: Spawn position - World: {offsetSpawnPos}, Cell: {spawnCell}, Lateral Offset: {currentLateralOffsetAngle:F1}°, Longitudinal Offset: {currentLongitudinalOffset:F1}");
WulaLog.Debug($"SectorSurveillance: Spawn position - World: {offsetSpawnPos}, Cell: {spawnCell}, Lateral Offset: {currentLateralOffsetAngle:F1}°, Longitudinal Offset: {currentLongitudinalOffset:F1}");
if (parent.Map == null)
{
Log.Error("SectorSurveillance: Map is null during projectile launch");
WulaLog.Debug("SectorSurveillance: Map is null during projectile launch");
return false;
}
if (!spawnCell.InBounds(parent.Map))
{
Log.Error($"SectorSurveillance: Spawn cell {spawnCell} is out of bounds");
WulaLog.Debug($"SectorSurveillance: Spawn cell {spawnCell} is out of bounds");
return false;
}
Log.Message($"SectorSurveillance: Attempting to spawn projectile: {Props.projectileDef.defName}");
WulaLog.Debug($"SectorSurveillance: Attempting to spawn projectile: {Props.projectileDef.defName}");
Projectile projectile = (Projectile)GenSpawn.Spawn(Props.projectileDef, spawnCell, parent.Map);
if (projectile != null)
{
Log.Message($"SectorSurveillance: Projectile spawned successfully: {projectile}");
WulaLog.Debug($"SectorSurveillance: Projectile spawned successfully: {projectile}");
Thing launcher = GetLauncher();
Vector3 launchPos = offsetSpawnPos;
LocalTargetInfo targetInfo = new LocalTargetInfo(target);
Log.Message($"SectorSurveillance: Launching projectile - Launcher: {launcher?.def?.defName ?? "NULL"}, LaunchPos: {launchPos}, Target: {targetInfo.Cell}");
WulaLog.Debug($"SectorSurveillance: Launching projectile - Launcher: {launcher?.def?.defName ?? "NULL"}, LaunchPos: {launchPos}, Target: {targetInfo.Cell}");
projectile.Launch(
launcher,
@@ -617,19 +617,19 @@ namespace WulaFallenEmpire
CreateOffsetEffect(offsetSpawnPos, directionToTarget);
}
Log.Message($"SectorSurveillance: Projectile launched successfully");
WulaLog.Debug($"SectorSurveillance: Projectile launched successfully");
return true;
}
else
{
Log.Error("SectorSurveillance: Failed to spawn projectile - GenSpawn.Spawn returned null");
WulaLog.Debug("SectorSurveillance: Failed to spawn projectile - GenSpawn.Spawn returned null");
return false;
}
}
catch (System.Exception ex)
{
Log.Error($"SectorSurveillance: Exception launching projectile: {ex}");
Log.Error($"SectorSurveillance: Stack trace: {ex.StackTrace}");
WulaLog.Debug($"SectorSurveillance: Exception launching projectile: {ex}");
WulaLog.Debug($"SectorSurveillance: Stack trace: {ex.StackTrace}");
return false;
}
}
@@ -653,11 +653,11 @@ namespace WulaFallenEmpire
FlyOver flyOver = parent as FlyOver;
//if (flyOver != null && flyOver.caster != null)
//{
// Log.Message($"SectorSurveillance: Using caster as launcher: {flyOver.caster.Label}");
// WulaLog.Debug($"SectorSurveillance: Using caster as launcher: {flyOver.caster.Label}");
// return flyOver.caster;
//}
Log.Message($"SectorSurveillance: Using parent as launcher: {parent.Label}");
WulaLog.Debug($"SectorSurveillance: Using parent as launcher: {parent.Label}");
return parent;
}
@@ -732,10 +732,10 @@ namespace WulaFallenEmpire
// 新增:调试方法
public void DebugOffsetStatus()
{
Log.Message($"SectorSurveillance Offset Status:");
Log.Message($" Lateral - Angle: {currentLateralOffsetAngle:F1}°, Mode: {Props.lateralOffsetMode}");
Log.Message($" Longitudinal - Offset: {currentLongitudinalOffset:F1}, Mode: {Props.longitudinalOffsetMode}");
Log.Message($" Shots Fired: {shotsFired}, Forward Phase: {isForwardPhase}");
WulaLog.Debug($"SectorSurveillance Offset Status:");
WulaLog.Debug($" Lateral - Angle: {currentLateralOffsetAngle:F1}°, Mode: {Props.lateralOffsetMode}");
WulaLog.Debug($" Longitudinal - Offset: {currentLongitudinalOffset:F1}, Mode: {Props.longitudinalOffsetMode}");
WulaLog.Debug($" Shots Fired: {shotsFired}, Forward Phase: {isForwardPhase}");
}
}

View File

@@ -1,4 +1,4 @@
using RimWorld;
using RimWorld;
using Verse;
namespace WulaFallenEmpire
@@ -43,7 +43,7 @@ namespace WulaFallenEmpire
// 检查是否有有效的信件内容
if (Props.letterLabel.NullOrEmpty() && Props.letterText.NullOrEmpty())
{
Log.Warning($"CompSendLetterAfterTicks: No letter content defined for {parent.def.defName}");
WulaLog.Debug($"CompSendLetterAfterTicks: No letter content defined for {parent.def.defName}");
return;
}
@@ -63,11 +63,11 @@ namespace WulaFallenEmpire
letterSent = true;
Log.Message($"Letter sent from {parent.def.defName} after {ticksPassed} ticks");
WulaLog.Debug($"Letter sent from {parent.def.defName} after {ticksPassed} ticks");
}
catch (System.Exception ex)
{
Log.Error($"Error sending letter from {parent.def.defName}: {ex}");
WulaLog.Debug($"Error sending letter from {parent.def.defName}: {ex}");
}
}

View File

@@ -1,4 +1,4 @@
using RimWorld;
using RimWorld;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
@@ -47,8 +47,8 @@ namespace WulaFallenEmpire
base.Initialize(props);
ticksUntilNextAttack = Props.ticksBetweenAttacks;
Log.Message($"Ship Artillery initialized: {Props.ticksBetweenAttacks} ticks between attacks, {Props.attackRadius} radius");
Log.Message($"Faction Discrimination: {Props.useFactionDiscrimination}, Target Faction: {Props.targetFaction?.defName ?? "None"}, Micro Tracking: {Props.useMicroTracking}");
WulaLog.Debug($"Ship Artillery initialized: {Props.ticksBetweenAttacks} ticks between attacks, {Props.attackRadius} radius");
WulaLog.Debug($"Faction Discrimination: {Props.useFactionDiscrimination}, Target Faction: {Props.targetFaction?.defName ?? "None"}, Micro Tracking: {Props.useMicroTracking}");
}
public override void CompTick()
@@ -117,9 +117,9 @@ namespace WulaFallenEmpire
if (DebugSettings.godMode && cachedTargets.Count > 0)
{
Log.Message($"Target Cache Updated: Found {cachedTargets.Count} targets");
WulaLog.Debug($"Target Cache Updated: Found {cachedTargets.Count} targets");
var stats = GetTargetStatistics();
Log.Message($"Target Statistics - Pawns: {stats.pawnCount}, Owned Buildings: {stats.ownedBuildingCount}, Unowned Buildings: {stats.unownedBuildingCount}, Walls: {stats.wallCount}, Others: {stats.otherCount}");
WulaLog.Debug($"Target Statistics - Pawns: {stats.pawnCount}, Owned Buildings: {stats.ownedBuildingCount}, Unowned Buildings: {stats.unownedBuildingCount}, Walls: {stats.wallCount}, Others: {stats.otherCount}");
}
}
@@ -240,12 +240,12 @@ namespace WulaFallenEmpire
if (!currentTarget.IsValid || !currentTarget.InBounds(flyOver.Map))
{
Log.Warning("Ship Artillery: Invalid target selected, skipping attack");
WulaLog.Debug("Ship Artillery: Invalid target selected, skipping attack");
ticksUntilNextAttack = Props.ticksBetweenAttacks;
return;
}
Log.Message($"Ship Artillery starting attack on target area: {currentTarget} (attack radius: {Props.attackRadius})");
WulaLog.Debug($"Ship Artillery starting attack on target area: {currentTarget} (attack radius: {Props.attackRadius})");
// 修复3在一轮炮击中只进行一次目标选择
currentVolleyCenter = currentTarget;
@@ -297,7 +297,7 @@ namespace WulaFallenEmpire
attackEffecter = Props.attackEffect.Spawn();
}
Log.Message($"Ship Artillery started firing at area {currentTarget}");
WulaLog.Debug($"Ship Artillery started firing at area {currentTarget}");
// 发送攻击通知
if (Props.sendAttackLetter)
@@ -390,7 +390,7 @@ namespace WulaFallenEmpire
if (DebugSettings.godMode)
{
Log.Message($"Generated {currentVolleyTargets.Count} targets for volley around {currentVolleyCenter}");
WulaLog.Debug($"Generated {currentVolleyTargets.Count} targets for volley around {currentVolleyCenter}");
}
}
@@ -401,7 +401,7 @@ namespace WulaFallenEmpire
ThingDef shellDef = SelectShellDef();
if (shellDef == null)
{
Log.Error("Ship Artillery: No valid shell def found");
WulaLog.Debug("Ship Artillery: No valid shell def found");
return;
}
@@ -410,7 +410,7 @@ namespace WulaFallenEmpire
float distanceFromCenter = shellTarget.DistanceTo(currentVolleyCenter);
if (DebugSettings.godMode)
{
Log.Message($"Ship Artillery fired shell at {shellTarget} (distance from center: {distanceFromCenter:F1})");
WulaLog.Debug($"Ship Artillery fired shell at {shellTarget} (distance from center: {distanceFromCenter:F1})");
}
if (Props.attackSound != null)
@@ -420,7 +420,7 @@ namespace WulaFallenEmpire
}
catch (System.Exception ex)
{
Log.Error($"Error firing ship artillery shell: {ex}");
WulaLog.Debug($"Error firing ship artillery shell: {ex}");
}
}
@@ -429,7 +429,7 @@ namespace WulaFallenEmpire
{
if (cachedTargets.Count == 0)
{
Log.Warning("MicroTracking: No targets available, falling back to random target");
WulaLog.Debug("MicroTracking: No targets available, falling back to random target");
return SelectRandomTargetInRadius(currentVolleyCenter, flyOver.Map, Props.attackRadius);
}
@@ -456,7 +456,7 @@ namespace WulaFallenEmpire
selectedThing is Building building ?
(building.Faction == null ? "Unowned Building" : "Owned Building") : "Other";
Log.Message($"MicroTracking: Targeting {selectedThing?.Label ?? "unknown"} ({targetType}) at {targetCell}, final target: {offsetTarget}");
WulaLog.Debug($"MicroTracking: Targeting {selectedThing?.Label ?? "unknown"} ({targetType}) at {targetCell}, final target: {offsetTarget}");
}
return offsetTarget;
@@ -586,11 +586,11 @@ namespace WulaFallenEmpire
if (DebugSettings.godMode)
{
float actualDistance = potentialTarget.DistanceTo(center);
Log.Message($"Found valid target at {potentialTarget} (distance from center: {actualDistance:F1})");
WulaLog.Debug($"Found valid target at {potentialTarget} (distance from center: {actualDistance:F1})");
if (ignoreProtectionForThisTarget)
{
Log.Warning($"Protection ignored for target selection! May target player assets.");
WulaLog.Debug($"Protection ignored for target selection! May target player assets.");
}
}
@@ -600,7 +600,7 @@ namespace WulaFallenEmpire
}
// 回退:使用地图随机位置
Log.Warning("Could not find valid target in radius, using fallback");
WulaLog.Debug("Could not find valid target in radius, using fallback");
CellRect mapRect = CellRect.WholeMap(map);
for (int i = 0; i < 5; i++)
{
@@ -749,7 +749,7 @@ namespace WulaFallenEmpire
ticksUntilNextAttack = Props.ticksBetweenAttacks;
}
Log.Message($"Ship Artillery attack ended");
WulaLog.Debug($"Ship Artillery attack ended");
}
private void SendAttackLetter(FlyOver flyOver)
@@ -768,7 +768,7 @@ namespace WulaFallenEmpire
}
catch (System.Exception ex)
{
Log.Error($"Error sending ship artillery letter: {ex}");
WulaLog.Debug($"Error sending ship artillery letter: {ex}");
}
}
@@ -827,20 +827,20 @@ namespace WulaFallenEmpire
if (parent is FlyOver flyOver)
{
IntVec3 flyOverPos = GetFlyOverPosition(flyOver);
Log.Message($"FlyOver - DrawPos: {flyOver.DrawPos}, Position: {flyOver.Position}, Calculated: {flyOverPos}");
Log.Message($"Current Target: {currentTarget}, Distance: {flyOverPos.DistanceTo(currentTarget):F1}");
WulaLog.Debug($"FlyOver - DrawPos: {flyOver.DrawPos}, Position: {flyOver.Position}, Calculated: {flyOverPos}");
WulaLog.Debug($"Current Target: {currentTarget}, Distance: {flyOverPos.DistanceTo(currentTarget):F1}");
// 显示派系甄别信息
Faction targetFaction = GetTargetFaction(flyOver);
Log.Message($"Faction Discrimination: {Props.useFactionDiscrimination}, Target Faction: {targetFaction?.def.defName ?? "None"}");
Log.Message($"Micro Tracking: {Props.useMicroTracking}, Targets Found: {cachedTargets.Count}");
WulaLog.Debug($"Faction Discrimination: {Props.useFactionDiscrimination}, Target Faction: {targetFaction?.def.defName ?? "None"}");
WulaLog.Debug($"Micro Tracking: {Props.useMicroTracking}, Targets Found: {cachedTargets.Count}");
// 显示目标统计
var stats = GetTargetStatistics();
Log.Message($"Target Stats - Pawns: {stats.pawnCount}, Owned Buildings: {stats.ownedBuildingCount}, Unowned Buildings: {stats.unownedBuildingCount}, Walls: {stats.wallCount}, Others: {stats.otherCount}");
WulaLog.Debug($"Target Stats - Pawns: {stats.pawnCount}, Owned Buildings: {stats.ownedBuildingCount}, Unowned Buildings: {stats.unownedBuildingCount}, Walls: {stats.wallCount}, Others: {stats.otherCount}");
// 显示炮击信息
Log.Message($"Volley - Center: {currentVolleyCenter}, Targets: {currentVolleyTargets.Count}, Index: {currentVolleyIndex}");
WulaLog.Debug($"Volley - Center: {currentVolleyCenter}, Targets: {currentVolleyTargets.Count}, Index: {currentVolleyIndex}");
}
}
};
@@ -864,7 +864,7 @@ namespace WulaFallenEmpire
thing is Building building ?
(building.Faction == null ? "Unowned Building" : "Owned Building") : "Other";
Log.Message($"Cached Target: {thing?.Label ?? "Unknown"} ({type}) at {target.Cell}, Weight: {weight:F2}");
WulaLog.Debug($"Cached Target: {thing?.Label ?? "Unknown"} ({type}) at {target.Cell}, Weight: {weight:F2}");
}
}
}
@@ -881,7 +881,7 @@ namespace WulaFallenEmpire
{
for (int i = 0; i < currentVolleyTargets.Count; i++)
{
Log.Message($"Volley Target {i}: {currentVolleyTargets[i]} ({(i == currentVolleyIndex ? "NEXT" : "queued")})");
WulaLog.Debug($"Volley Target {i}: {currentVolleyTargets[i]} ({(i == currentVolleyIndex ? "NEXT" : "queued")})");
}
}
};
@@ -896,7 +896,7 @@ namespace WulaFallenEmpire
if (parent is FlyOver flyOver)
{
UpdateTargetCache(flyOver);
Log.Message($"Force updated target cache: {cachedTargets.Count} targets found");
WulaLog.Debug($"Force updated target cache: {cachedTargets.Count} targets found");
}
}
};

View File

@@ -1,4 +1,4 @@
using RimWorld;
using RimWorld;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
@@ -64,7 +64,7 @@ namespace WulaFallenEmpire
}
catch (System.Exception ex)
{
Log.Error($"Error spawning fly over: {ex}");
WulaLog.Debug($"Error spawning fly over: {ex}");
}
}
@@ -84,7 +84,7 @@ namespace WulaFallenEmpire
ThingDef flyOverDef = Props.flyOverDef ?? DefDatabase<ThingDef>.GetNamedSilentFail("ARA_HiveShip");
if (flyOverDef == null)
{
Log.Warning("No fly over def specified for standard fly over");
WulaLog.Debug("No fly over def specified for standard fly over");
return;
}
@@ -105,7 +105,7 @@ namespace WulaFallenEmpire
ThingDef flyOverDef = Props.flyOverDef ?? DefDatabase<ThingDef>.GetNamedSilentFail("ARA_HiveCorvette");
if (flyOverDef == null)
{
Log.Warning("No fly over def specified for ground strafing fly over");
WulaLog.Debug("No fly over def specified for ground strafing fly over");
return;
}
@@ -146,7 +146,7 @@ namespace WulaFallenEmpire
ThingDef flyOverDef = Props.flyOverDef ?? DefDatabase<ThingDef>.GetNamedSilentFail("ARA_HiveCorvette");
if (flyOverDef == null)
{
Log.Warning("No fly over def specified for sector surveillance fly over");
WulaLog.Debug("No fly over def specified for sector surveillance fly over");
return;
}