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,46 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LanguageData>
<Make_WULA_Alloy.label>Produce Wula Empire Alloy</Make_WULA_Alloy.label>
<Make_WULA_Alloy.description>A high-density alloy produced by processing steel, it is the raw material for many Wula Empire equipment.</Make_WULA_Alloy.description>
<Make_WULA_Alloy.jobString>Forging alloy</Make_WULA_Alloy.jobString>
<Make_WULA_Alloy_Group.label>Produce Wula Empire Alloy (10 pieces)</Make_WULA_Alloy_Group.label>
<Make_WULA_Alloy_Group.description>A high-density alloy produced by processing steel, it is the raw material for many Wula Empire equipment.</Make_WULA_Alloy_Group.description>
<Make_WULA_Alloy_Group.jobString>Forging alloy</Make_WULA_Alloy_Group.jobString>
<Make_Component_By_WULA_Cube_Productor.label>Manufacture Components</Make_Component_By_WULA_Cube_Productor.label>
<Make_Component_By_WULA_Cube_Productor.description>Manufacture components using Wula Empire fabricators. Takes longer than a precision assembly bench and consumes more resources.</Make_Component_By_WULA_Cube_Productor.description>
<Make_Component_By_WULA_Cube_Productor.jobString>Manufacturing components</Make_Component_By_WULA_Cube_Productor.jobString>
<Make_WULA_Charge_Cube.label>Manufacture Wula Empire Power Core</Make_WULA_Charge_Cube.label>
<Make_WULA_Charge_Cube.description>Manufacture a Wula Empire power core, including a rechargeable capacitor and energy to supply machinery. This is the only acceptable external energy source for mechanical Wulas and a precursor for many Wula Empire products.</Make_WULA_Charge_Cube.description>
<Make_WULA_Charge_Cube.jobString>Manufacturing Wula Empire power core</Make_WULA_Charge_Cube.jobString>
<Recharge_WULA_Charge_Cube.label>Recharge Power Core</Recharge_WULA_Charge_Cube.label>
<Recharge_WULA_Charge_Cube.description>Use chemfuel to recharge depleted Wula Empire power cores that have lost their energy.</Recharge_WULA_Charge_Cube.description>
<Recharge_WULA_Charge_Cube.jobString>Recharging Wula Empire power core</Recharge_WULA_Charge_Cube.jobString>
<Recharge_WULA_Charge_Cube_Group.label>Recharge Power Cores (4)</Recharge_WULA_Charge_Cube_Group.label>
<Recharge_WULA_Charge_Cube_Group.description>Use chemfuel to recharge depleted Wula Empire power cores that have lost their energy.</Recharge_WULA_Charge_Cube_Group.description>
<Recharge_WULA_Charge_Cube_Group.jobString>Recharging Wula Empire power cores</Recharge_WULA_Charge_Cube_Group.jobString>
<Make_WULA_Dark_Matter_Item.label>Manufacture Wula Empire Dark Matter</Make_WULA_Dark_Matter_Item.label>
<Make_WULA_Dark_Matter_Item.description>Manufacture 1 unit of encapsulated dark matter, consisting of a dark matter containment device and dark matter. It is a necessary energy source for Wula Empire large-scale facilities and armaments.</Make_WULA_Dark_Matter_Item.description>
<Make_WULA_Dark_Matter_Item.jobString>Manufacturing Wula Empire dark matter</Make_WULA_Dark_Matter_Item.jobString>
<Make_WULA_Neutronium.label>Compress Neutronium</Make_WULA_Neutronium.label>
<Make_WULA_Neutronium.description>Manufacture 1 unit of neutronium, a powerful material that can create the hardest armor or the strongest melee weapons.</Make_WULA_Neutronium.description>
<Make_WULA_Neutronium.jobString>Compressing neutronium</Make_WULA_Neutronium.jobString>
<WULA_Build_Wula_Synth.label>Build URa-00 "Mechanical Wula"</WULA_Build_Wula_Synth.label>
<WULA_Build_Wula_Synth.description>Build a URa-00 "Mechanical Wula" synth, the main species of a Wula Empire synth colony. Possesses complex, realistic simulated emotions while being a mechanoid.</WULA_Build_Wula_Synth.description>
<WULA_Build_Mech_WULA_Cat.label>Build CAt-11 "Cat"</WULA_Build_Mech_WULA_Cat.label>
<WULA_Build_Mech_WULA_Cat.description>Build a CAt-11 "Cat".</WULA_Build_Mech_WULA_Cat.description>
<WULA_Build_Mech_WULA_Cat_Constructor.label>Build CAt-86 "Cat Worker"</WULA_Build_Mech_WULA_Cat_Constructor.label>
<WULA_Build_Mech_WULA_Cat_Constructor.description>Build a CAt-86 "Cat Worker".</WULA_Build_Mech_WULA_Cat_Constructor.description>
<WULA_Build_Mech_WULA_Cat_Assault.label>Build CAt-46 "Cat Assault Force"</WULA_Build_Mech_WULA_Cat_Assault.label>
<WULA_Build_Mech_WULA_Cat_Assault.description>Build a CAt-46 "Cat Assault Force".</WULA_Build_Mech_WULA_Cat_Assault.description>
</LanguageData>

View File

@@ -111,7 +111,7 @@ namespace WulaFallenEmpire
// 防止过多任务影响性能
if (activeCoroutines.Count >= MAX_CONCURRENT_BOMBARDMENTS)
{
Log.Warning($"Too many concurrent bombardments on map {map}, max is {MAX_CONCURRENT_BOMBARDMENTS}");
WulaLog.Debug($"Too many concurrent bombardments on map {map}, max is {MAX_CONCURRENT_BOMBARDMENTS}");
return;
}
@@ -146,7 +146,7 @@ namespace WulaFallenEmpire
}
catch (Exception ex)
{
Log.Error($"Lightning bombardment error: {ex}");
WulaLog.Debug($"Lightning bombardment error: {ex}");
activeCoroutines.Clear();
}
}

View File

@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using RimWorld;
using UnityEngine;
using Verse;
@@ -99,14 +99,14 @@ namespace WulaFallenEmpire
// 处理目标
ProcessTarget(thing);
Log.Message($"[AreaDestruction] Cleared overlapping object: {thing.Label} at {casterPos}");
WulaLog.Debug($"[AreaDestruction] Cleared overlapping object: {thing.Label} at {casterPos}");
}
}
}
}
catch (System.Exception ex)
{
Log.Warning($"[AreaDestruction] Error clearing overlapping objects: {ex.Message}");
WulaLog.Debug($"[AreaDestruction] Error clearing overlapping objects: {ex.Message}");
}
}
@@ -135,7 +135,7 @@ namespace WulaFallenEmpire
}
catch (System.Exception ex)
{
Log.Warning($"[AreaDestruction] Error playing clear effecter: {ex.Message}");
WulaLog.Debug($"[AreaDestruction] Error playing clear effecter: {ex.Message}");
}
}
@@ -174,7 +174,7 @@ namespace WulaFallenEmpire
}
catch (System.Exception ex)
{
Log.Warning($"[AreaDestruction] Error playing hit effecter on {target?.Label}: {ex.Message}");
WulaLog.Debug($"[AreaDestruction] Error playing hit effecter on {target?.Label}: {ex.Message}");
}
}
@@ -243,11 +243,11 @@ namespace WulaFallenEmpire
building.Destroy(DestroyMode.Vanish);
// 可选:记录日志用于调试
// Log.Message($"[AreaDestruction] Destroyed building: {buildingInfo}");
// WulaLog.Debug($"[AreaDestruction] Destroyed building: {buildingInfo}");
}
catch (System.Exception ex)
{
Log.Warning($"[AreaDestruction] Error destroying building {building?.Label}: {ex.Message}");
WulaLog.Debug($"[AreaDestruction] Error destroying building {building?.Label}: {ex.Message}");
}
}
@@ -287,7 +287,7 @@ namespace WulaFallenEmpire
}
catch (System.Exception ex)
{
Log.Warning($"[AreaDestruction] Error destroying body parts on {targetPawn?.Label}: {ex.Message}");
WulaLog.Debug($"[AreaDestruction] Error destroying body parts on {targetPawn?.Label}: {ex.Message}");
}
}

View File

@@ -1,4 +1,4 @@
using RimWorld;
using RimWorld;
using Verse;
using UnityEngine;
using System.Collections.Generic;
@@ -36,7 +36,7 @@ namespace WulaFallenEmpire
try
{
Log.Message($"[Bombardment] Starting bombardment at {target.Cell} with direction to {dest.Cell}");
WulaLog.Debug($"[Bombardment] Starting bombardment at {target.Cell} with direction to {dest.Cell}");
// 计算轰炸区域和方向(基于两个目标点)
CalculateBombardmentArea(target.Cell, dest.Cell);
@@ -50,11 +50,11 @@ namespace WulaFallenEmpire
// 开始前摇
StartWarmup();
Log.Message($"[Bombardment] Bombardment initialized: {targetCells.Count} targets in {bombardmentRows.Count} rows");
WulaLog.Debug($"[Bombardment] Bombardment initialized: {targetCells.Count} targets in {bombardmentRows.Count} rows");
}
catch (System.Exception ex)
{
Log.Error($"[Bombardment] Error starting bombardment: {ex}");
WulaLog.Debug($"[Bombardment] Error starting bombardment: {ex}");
}
}
@@ -253,7 +253,7 @@ namespace WulaFallenEmpire
bombardmentDirection = direction;
Log.Message($"[Bombardment] Bombardment direction: {bombardmentDirection} (from {startCell} to {directionCell})");
WulaLog.Debug($"[Bombardment] Bombardment direction: {bombardmentDirection} (from {startCell} to {directionCell})");
}
private void SelectTargetCells()
@@ -294,7 +294,7 @@ namespace WulaFallenEmpire
}
targetCells = selectedCells;
Log.Message($"[Bombardment] Selected {targetCells.Count} target cells from {areaCells.Count} area cells");
WulaLog.Debug($"[Bombardment] Selected {targetCells.Count} target cells from {areaCells.Count} area cells");
}
// 修复:重新组织目标格子成排,确保正确的渐进顺序
@@ -343,7 +343,7 @@ namespace WulaFallenEmpire
});
}
Log.Message($"[Bombardment] Organized into {bombardmentRows.Count} rows in progressive order");
WulaLog.Debug($"[Bombardment] Organized into {bombardmentRows.Count} rows in progressive order");
}
private void StartWarmup()
@@ -359,7 +359,7 @@ namespace WulaFallenEmpire
CreateAreaEffecter();
}
Log.Message($"[Bombardment] Warmup started: {warmupTicksRemaining} ticks remaining");
WulaLog.Debug($"[Bombardment] Warmup started: {warmupTicksRemaining} ticks remaining");
}
private void UpdateWarmup()
@@ -371,7 +371,7 @@ namespace WulaFallenEmpire
// 前摇结束,开始轰炸
currentState = BombardmentState.Bombarding;
nextBombardmentTick = Find.TickManager.TicksGame;
Log.Message($"[Bombardment] Warmup completed, starting progressive bombardment");
WulaLog.Debug($"[Bombardment] Warmup completed, starting progressive bombardment");
}
}
@@ -384,7 +384,7 @@ namespace WulaFallenEmpire
{
// 所有排都轰炸完毕
currentState = BombardmentState.Completed;
Log.Message($"[Bombardment] Progressive bombardment completed");
WulaLog.Debug($"[Bombardment] Progressive bombardment completed");
return;
}
@@ -396,7 +396,7 @@ namespace WulaFallenEmpire
currentRowIndex++;
currentCellIndex = 0;
nextBombardmentTick = Find.TickManager.TicksGame + Props.rowDelayTicks;
Log.Message($"[Bombardment] Moving to next row {currentRowIndex + 1}/{bombardmentRows.Count}");
WulaLog.Debug($"[Bombardment] Moving to next row {currentRowIndex + 1}/{bombardmentRows.Count}");
return;
}
@@ -408,7 +408,7 @@ namespace WulaFallenEmpire
nextBombardmentTick = Find.TickManager.TicksGame + Props.impactDelayTicks;
// 记录轰炸进度
Log.Message($"[Bombardment] Bombarding cell {currentCellIndex}/{currentRow.cells.Count} in row {currentRowIndex + 1}/{bombardmentRows.Count}");
WulaLog.Debug($"[Bombardment] Bombarding cell {currentCellIndex}/{currentRow.cells.Count} in row {currentRowIndex + 1}/{bombardmentRows.Count}");
}
private void LaunchBombardment(IntVec3 targetCell)
@@ -420,7 +420,7 @@ namespace WulaFallenEmpire
// 使用 Skyfaller
Skyfaller skyfaller = SkyfallerMaker.MakeSkyfaller(Props.skyfallerDef);
GenSpawn.Spawn(skyfaller, targetCell, parent.pawn.Map);
Log.Message($"[Bombardment] Launched skyfaller at {targetCell}");
WulaLog.Debug($"[Bombardment] Launched skyfaller at {targetCell}");
}
else if (Props.projectileDef != null)
{
@@ -429,12 +429,12 @@ namespace WulaFallenEmpire
}
else
{
Log.Error($"[Bombardment] No skyfaller or projectile defined for bombardment");
WulaLog.Debug($"[Bombardment] No skyfaller or projectile defined for bombardment");
}
}
catch (System.Exception ex)
{
Log.Error($"[Bombardment] Error launching bombardment at {targetCell}: {ex}");
WulaLog.Debug($"[Bombardment] Error launching bombardment at {targetCell}: {ex}");
}
}
@@ -455,7 +455,7 @@ namespace WulaFallenEmpire
ProjectileHitFlags.All,
false
);
Log.Message($"[Bombardment] Launched projectile at {targetCell}");
WulaLog.Debug($"[Bombardment] Launched projectile at {targetCell}");
}
}
@@ -482,7 +482,7 @@ namespace WulaFallenEmpire
bombardmentRows.Clear();
currentPreviewCells.Clear();
Log.Message($"[Bombardment] Cleanup completed");
WulaLog.Debug($"[Bombardment] Cleanup completed");
}
private IntVec3 GetSafeMapPosition(IntVec3 pos, Map map)

View File

@@ -1,4 +1,4 @@
using RimWorld;
using RimWorld;
using Verse;
using UnityEngine;
using System.Collections.Generic;
@@ -21,11 +21,11 @@ namespace WulaFallenEmpire
// 创建延时召唤
CallSkyfallerDelayed(target.Cell);
Log.Message($"[CallSkyfaller] Scheduled skyfaller at {target.Cell} with {Props.delayTicks} ticks delay");
WulaLog.Debug($"[CallSkyfaller] Scheduled skyfaller at {target.Cell} with {Props.delayTicks} ticks delay");
}
catch (System.Exception ex)
{
Log.Error($"[CallSkyfaller] Error calling skyfaller: {ex}");
WulaLog.Debug($"[CallSkyfaller] Error calling skyfaller: {ex}");
}
}

View File

@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using RimWorld;
using Verse;
@@ -49,12 +49,12 @@ namespace WulaFallenEmpire
if (Prefs.DevMode)
{
Log.Message($"[DelayedSkyfaller] Spawned '{delayedSkyfaller.skyfallerDef.defName}' at {delayedSkyfaller.targetCell}");
WulaLog.Debug($"[DelayedSkyfaller] Spawned '{delayedSkyfaller.skyfallerDef.defName}' at {delayedSkyfaller.targetCell}");
}
}
catch (System.Exception ex)
{
Log.Error($"[DelayedSkyfaller] Error spawning skyfaller: {ex}");
WulaLog.Debug($"[DelayedSkyfaller] Error spawning skyfaller: {ex}");
}
}

View File

@@ -1,4 +1,4 @@
using RimWorld;
using RimWorld;
using Verse;
using UnityEngine;
using System.Collections.Generic;
@@ -38,7 +38,7 @@ namespace WulaFallenEmpire
try
{
Log.Message($"[CircularBombardment] Starting circular bombardment at {target.Cell}");
WulaLog.Debug($"[CircularBombardment] Starting circular bombardment at {target.Cell}");
// 设置轰炸中心
bombardmentCenter = target.Cell;
@@ -52,13 +52,13 @@ namespace WulaFallenEmpire
// 开始前摇
StartWarmup();
Log.Message($"[CircularBombardment] Bombardment initialized: {targetCells.Count} targets, " +
WulaLog.Debug($"[CircularBombardment] Bombardment initialized: {targetCells.Count} targets, " +
$"{Props.simultaneousLaunches} simultaneous launches, " +
$"independent intervals: {Props.useIndependentIntervals}");
}
catch (System.Exception ex)
{
Log.Error($"[CircularBombardment] Error starting bombardment: {ex}");
WulaLog.Debug($"[CircularBombardment] Error starting bombardment: {ex}");
}
}
@@ -226,7 +226,7 @@ namespace WulaFallenEmpire
}
targetCells = selectedCells;
Log.Message($"[CircularBombardment] Selected {targetCells.Count} target cells from {areaCells.Count} area cells");
WulaLog.Debug($"[CircularBombardment] Selected {targetCells.Count} target cells from {areaCells.Count} area cells");
}
// 检查单元格是否有效
@@ -269,7 +269,7 @@ namespace WulaFallenEmpire
launchesCompleted = 0;
currentGroupIndex = 0;
Log.Message($"[CircularBombardment] Warmup started: {warmupTicksRemaining} ticks remaining");
WulaLog.Debug($"[CircularBombardment] Warmup started: {warmupTicksRemaining} ticks remaining");
}
private void UpdateWarmup()
@@ -281,7 +281,7 @@ namespace WulaFallenEmpire
// 前摇结束,开始发射
currentState = CircularBombardmentState.Launching;
nextLaunchTick = Find.TickManager.TicksGame;
Log.Message($"[CircularBombardment] Warmup completed, starting launches");
WulaLog.Debug($"[CircularBombardment] Warmup completed, starting launches");
}
}
@@ -291,7 +291,7 @@ namespace WulaFallenEmpire
if (remainingTargets.Count == 0 || launchesCompleted >= Props.maxLaunches)
{
currentState = CircularBombardmentState.Completed;
Log.Message($"[CircularBombardment] All launches completed: {launchesCompleted}/{Props.maxLaunches}");
WulaLog.Debug($"[CircularBombardment] All launches completed: {launchesCompleted}/{Props.maxLaunches}");
return;
}
@@ -307,7 +307,7 @@ namespace WulaFallenEmpire
nextInnerLaunchTick = Find.TickManager.TicksGame;
currentGroupIndex++;
Log.Message($"[CircularBombardment] Starting group {currentGroupIndex} with {currentGroupTargets.Count} targets, using independent intervals");
WulaLog.Debug($"[CircularBombardment] Starting group {currentGroupIndex} with {currentGroupTargets.Count} targets, using independent intervals");
}
else
{
@@ -323,7 +323,7 @@ namespace WulaFallenEmpire
// 设置下一组发射时间
nextLaunchTick = Find.TickManager.TicksGame + Props.launchIntervalTicks;
Log.Message($"[CircularBombardment] Launched group {currentGroupIndex + 1} simultaneously: {currentGroupTargets.Count} targets");
WulaLog.Debug($"[CircularBombardment] Launched group {currentGroupIndex + 1} simultaneously: {currentGroupTargets.Count} targets");
}
}
@@ -338,7 +338,7 @@ namespace WulaFallenEmpire
// 当前组发射完毕
isInGroupLaunch = false;
nextLaunchTick = Find.TickManager.TicksGame + Props.launchIntervalTicks;
Log.Message($"[CircularBombardment] Group {currentGroupIndex} completed");
WulaLog.Debug($"[CircularBombardment] Group {currentGroupIndex} completed");
return;
}
@@ -361,7 +361,7 @@ namespace WulaFallenEmpire
nextLaunchTick = Find.TickManager.TicksGame + Props.launchIntervalTicks;
}
Log.Message($"[CircularBombardment] Launched target in group {currentGroupIndex} ({launchesCompleted}/{Props.maxLaunches})");
WulaLog.Debug($"[CircularBombardment] Launched target in group {currentGroupIndex} ({launchesCompleted}/{Props.maxLaunches})");
}
// 更新发射逻辑
@@ -384,7 +384,7 @@ namespace WulaFallenEmpire
(remainingTargets.Count == 0 && !isInGroupLaunch))
{
currentState = CircularBombardmentState.Completed;
Log.Message($"[CircularBombardment] Bombardment completed: {launchesCompleted} launches");
WulaLog.Debug($"[CircularBombardment] Bombardment completed: {launchesCompleted} launches");
}
}
@@ -405,12 +405,12 @@ namespace WulaFallenEmpire
}
else
{
Log.Error($"[CircularBombardment] No skyfaller or projectile defined");
WulaLog.Debug($"[CircularBombardment] No skyfaller or projectile defined");
}
}
catch (System.Exception ex)
{
Log.Error($"[CircularBombardment] Error launching at {targetCell}: {ex}");
WulaLog.Debug($"[CircularBombardment] Error launching at {targetCell}: {ex}");
}
}
@@ -447,7 +447,7 @@ namespace WulaFallenEmpire
isInGroupLaunch = false;
launchesCompleted = 0;
Log.Message($"[CircularBombardment] Cleanup completed");
WulaLog.Debug($"[CircularBombardment] Cleanup completed");
}
public override void CompTick()

View File

@@ -1,4 +1,4 @@
using RimWorld;
using RimWorld;
using Verse;
using UnityEngine;
using System.Collections.Generic;
@@ -64,11 +64,11 @@ namespace WulaFallenEmpire
Props.soundEffect.PlayOneShot(new TargetInfo(cell, map));
}
Log.Message($"[DeleteTarget] Processed cell {cell}, deleted {deletionCount} objects");
WulaLog.Debug($"[DeleteTarget] Processed cell {cell}, deleted {deletionCount} objects");
}
catch (System.Exception ex)
{
Log.Error($"[DeleteTarget] Error deleting objects at {cell}: {ex}");
WulaLog.Debug($"[DeleteTarget] Error deleting objects at {cell}: {ex}");
}
}
@@ -123,13 +123,13 @@ namespace WulaFallenEmpire
if (thing.Spawned)
{
thing.DeSpawn(DestroyMode.Vanish);
Log.Message($"[DeleteTarget] Method1 - DeSpawn: {thingInfo}");
WulaLog.Debug($"[DeleteTarget] Method1 - DeSpawn: {thingInfo}");
return true;
}
}
catch (System.Exception ex1)
{
Log.Warning($"[DeleteTarget] Method1 failed for {thingInfo}: {ex1}");
WulaLog.Debug($"[DeleteTarget] Method1 failed for {thingInfo}: {ex1}");
}
try
@@ -138,13 +138,13 @@ namespace WulaFallenEmpire
if (thing.Spawned)
{
ForceRemoveFromThingGrid(thing, map);
Log.Message($"[DeleteTarget] Method2 - ForceRemoveFromThingGrid: {thingInfo}");
WulaLog.Debug($"[DeleteTarget] Method2 - ForceRemoveFromThingGrid: {thingInfo}");
return true;
}
}
catch (System.Exception ex2)
{
Log.Warning($"[DeleteTarget] Method2 failed for {thingInfo}: {ex2}");
WulaLog.Debug($"[DeleteTarget] Method2 failed for {thingInfo}: {ex2}");
}
try
@@ -153,13 +153,13 @@ namespace WulaFallenEmpire
if (thing.Spawned)
{
ForceDespawnViaReflection(thing, map);
Log.Message($"[DeleteTarget] Method3 - ForceDespawnViaReflection: {thingInfo}");
WulaLog.Debug($"[DeleteTarget] Method3 - ForceDespawnViaReflection: {thingInfo}");
return true;
}
}
catch (System.Exception ex3)
{
Log.Warning($"[DeleteTarget] Method3 failed for {thingInfo}: {ex3}");
WulaLog.Debug($"[DeleteTarget] Method3 failed for {thingInfo}: {ex3}");
}
try
@@ -168,16 +168,16 @@ namespace WulaFallenEmpire
if (thing.Spawned)
{
CallInternalCleanup(thing, map);
Log.Message($"[DeleteTarget] Method4 - CallInternalCleanup: {thingInfo}");
WulaLog.Debug($"[DeleteTarget] Method4 - CallInternalCleanup: {thingInfo}");
return true;
}
}
catch (System.Exception ex4)
{
Log.Warning($"[DeleteTarget] Method4 failed for {thingInfo}: {ex4}");
WulaLog.Debug($"[DeleteTarget] Method4 failed for {thingInfo}: {ex4}");
}
Log.Error($"[DeleteTarget] All methods failed for: {thingInfo}");
WulaLog.Debug($"[DeleteTarget] All methods failed for: {thingInfo}");
return false;
}
@@ -199,7 +199,7 @@ namespace WulaFallenEmpire
}
catch (System.Exception ex)
{
Log.Warning($"[DeleteTarget] ForceRemoveFromThingGrid failed: {ex}");
WulaLog.Debug($"[DeleteTarget] ForceRemoveFromThingGrid failed: {ex}");
throw;
}
}
@@ -242,7 +242,7 @@ namespace WulaFallenEmpire
}
catch (System.Exception ex)
{
Log.Warning($"[DeleteTarget] RemoveThingFromCell failed: {ex}");
WulaLog.Debug($"[DeleteTarget] RemoveThingFromCell failed: {ex}");
}
}
@@ -279,7 +279,7 @@ namespace WulaFallenEmpire
}
catch (System.Exception ex)
{
Log.Warning($"[DeleteTarget] ForceDespawnViaReflection failed: {ex}");
WulaLog.Debug($"[DeleteTarget] ForceDespawnViaReflection failed: {ex}");
throw;
}
}
@@ -310,7 +310,7 @@ namespace WulaFallenEmpire
}
catch (System.Exception ex)
{
Log.Warning($"[DeleteTarget] CallInternalCleanup failed: {ex}");
WulaLog.Debug($"[DeleteTarget] CallInternalCleanup failed: {ex}");
throw;
}
}

View File

@@ -1,4 +1,4 @@
using RimWorld;
using RimWorld;
using Verse;
using UnityEngine;
@@ -32,11 +32,11 @@ namespace WulaFallenEmpire
parent.pawn
);
Log.Message($"[EnergyLance] Started {lanceDef.defName} from {target.Cell} to {dest.Cell}");
WulaLog.Debug($"[EnergyLance] Started {lanceDef.defName} from {target.Cell} to {dest.Cell}");
}
catch (System.Exception ex)
{
Log.Error($"[EnergyLance] Error starting EnergyLance: {ex}");
WulaLog.Debug($"[EnergyLance] Error starting EnergyLance: {ex}");
}
}

View File

@@ -1,4 +1,4 @@
using RimWorld;
using RimWorld;
using Verse;
using UnityEngine;
using System.Collections.Generic;
@@ -69,12 +69,12 @@ namespace WulaFallenEmpire
hasStarted = true;
}
Log.Message($"[EnergyLance] Target updated to: {targetPos}, current position: {base.Position}");
WulaLog.Debug($"[EnergyLance] Target updated to: {targetPos}, current position: {base.Position}");
}
else
{
hasValidTarget = false;
Log.Message("[EnergyLance] Target cleared");
WulaLog.Debug("[EnergyLance] Target cleared");
}
}
@@ -107,7 +107,7 @@ namespace WulaFallenEmpire
if (newCell != base.Position && newCell.InBounds(base.Map))
{
base.Position = newCell;
Log.Message($"[EnergyLance] Moved to new cell: {newCell}");
WulaLog.Debug($"[EnergyLance] Moved to new cell: {newCell}");
}
// 检查是否接近目标
@@ -117,7 +117,7 @@ namespace WulaFallenEmpire
// 非常接近目标,直接设置到目标位置
exactPosition = targetVector;
base.Position = currentTargetPosition;
Log.Message($"[EnergyLance] Reached target position: {currentTargetPosition}");
WulaLog.Debug($"[EnergyLance] Reached target position: {currentTargetPosition}");
}
}
else
@@ -170,7 +170,7 @@ namespace WulaFallenEmpire
// 检查是否长时间没有收到目标更新
if (hasValidTarget && Find.TickManager.TicksGame - lastTargetUpdateTick > maxIdleTicks)
{
Log.Message("[EnergyLance] No target updates received, self-destructing");
WulaLog.Debug("[EnergyLance] No target updates received, self-destructing");
CompleteEnergyLance();
return;
}
@@ -202,7 +202,7 @@ namespace WulaFallenEmpire
sustainer?.End();
sustainer = null;
Log.Message($"[EnergyLance] 光束完成 at position {base.Position}, ticksPassed: {ticksPassed}, durationTicks: {durationTicks}");
WulaLog.Debug($"[EnergyLance] 光束完成 at position {base.Position}, ticksPassed: {ticksPassed}, durationTicks: {durationTicks}");
// 销毁自身
Destroy();
@@ -307,7 +307,7 @@ namespace WulaFallenEmpire
// 开始音效
StartSound();
Log.Message($"[EnergyLance] Spawned at {base.Position}, target: {endPosition}, " +
WulaLog.Debug($"[EnergyLance] Spawned at {base.Position}, target: {endPosition}, " +
$"exact position: {exactPosition}");
}
}
@@ -319,11 +319,11 @@ namespace WulaFallenEmpire
if (startAnimationMethod != null)
{
startAnimationMethod.Invoke(orbitalBeamComp, new object[] { durationTicks, 10, 0f });
Log.Message("[EnergyLance] Orbital beam animation started");
WulaLog.Debug("[EnergyLance] Orbital beam animation started");
}
else
{
Log.Warning("[EnergyLance] Could not find StartAnimation method on CompOrbitalBeam");
WulaLog.Debug("[EnergyLance] Could not find StartAnimation method on CompOrbitalBeam");
}
}
@@ -397,7 +397,7 @@ namespace WulaFallenEmpire
IntVec3 spawnPosition = end.IsValid ? end : start;
GenSpawn.Spawn(energyLance, spawnPosition, map);
Log.Message($"[EnergyLance] Created {energyLanceDef.defName} at {spawnPosition}, target: {end}");
WulaLog.Debug($"[EnergyLance] Created {energyLanceDef.defName} at {spawnPosition}, target: {end}");
return energyLance;
}
}

View File

@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq; // 添加这个 using 指令
using RimWorld;
using UnityEngine;
@@ -141,7 +141,7 @@ namespace WulaFallenEmpire
// 记录传送调整信息(调试用)
if (finalTargetCell != target.Cell)
{
Log.Message($"[TeleportSelf] AI传送位置从 {target.Cell} 调整到 {finalTargetCell}");
WulaLog.Debug($"[TeleportSelf] AI传送位置从 {target.Cell} 调整到 {finalTargetCell}");
}
}

View File

@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using RimWorld;
using UnityEngine;
@@ -120,7 +120,7 @@ namespace WulaFallenEmpire
// 记录拉取信息
if (Prefs.DevMode)
{
Log.Message($"[PullTarget] {caster.Label} 将 {targetPawn.Label} 拉取到 {finalDestination}");
WulaLog.Debug($"[PullTarget] {caster.Label} 将 {targetPawn.Label} 拉取到 {finalDestination}");
}
}

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using RimWorld;
using UnityEngine;
@@ -30,7 +30,7 @@ namespace WulaFallenEmpire
modExtension = def.GetModExtension<ExtraGraphicsExtension>();
if (modExtension == null)
{
Log.Error($"Building_ExtraGraphics: No ExtraGraphicsExtension found for {def.defName}");
WulaLog.Debug($"Building_ExtraGraphics: No ExtraGraphicsExtension found for {def.defName}");
// 创建默认配置避免空引用
modExtension = new ExtraGraphicsExtension();
}
@@ -114,7 +114,7 @@ namespace WulaFallenEmpire
case "metaoverlay":
return ShaderDatabase.MetaOverlay;
default:
Log.Warning($"Building_ExtraGraphics: Shader '{shaderName}' not found, using TransparentPostLight as fallback");
WulaLog.Debug($"Building_ExtraGraphics: Shader '{shaderName}' not found, using TransparentPostLight as fallback");
return ShaderDatabase.TransparentPostLight;
}
}
@@ -140,7 +140,7 @@ namespace WulaFallenEmpire
{
if (ModExtension.graphicLayers == null || ModExtension.graphicLayers.Count == 0)
{
Log.Warning($"Building_ExtraGraphics: No graphic layers configured for {def.defName}");
WulaLog.Debug($"Building_ExtraGraphics: No graphic layers configured for {def.defName}");
return;
}
@@ -158,7 +158,7 @@ namespace WulaFallenEmpire
{
if (string.IsNullOrEmpty(layer.texturePath))
{
Log.Warning($"Building_ExtraGraphics: Empty texture path in layer for {def.defName}");
WulaLog.Debug($"Building_ExtraGraphics: Empty texture path in layer for {def.defName}");
return;
}
@@ -223,7 +223,7 @@ namespace WulaFallenEmpire
if (mesh == null || mat == null)
{
Log.Warning($"Building_ExtraGraphics: Unable to get mesh or material for rotating layer");
WulaLog.Debug($"Building_ExtraGraphics: Unable to get mesh or material for rotating layer");
return;
}
@@ -273,7 +273,7 @@ namespace WulaFallenEmpire
}
catch (Exception ex)
{
Log.Error($"Building_ExtraGraphics: Error drawing rotating layer: {ex}");
WulaLog.Debug($"Building_ExtraGraphics: Error drawing rotating layer: {ex}");
}
}
@@ -347,7 +347,7 @@ namespace WulaFallenEmpire
if (DebugSettings.godMode && i == 0 && Find.TickManager.TicksGame % 60 == 0)
{
// 只在开发模式下每60帧输出一次第一条图层的旋转信息
Log.Message($"{layer.animationType} 图层 {i}: 角度={rotationAngle:F1}°, 时间={layerAnimationTimes[i]:F2}s, 速度={rotateSpeed}°/s");
WulaLog.Debug($"{layer.animationType} 图层 {i}: 角度={rotationAngle:F1}°, 时间={layerAnimationTimes[i]:F2}s, 速度={rotateSpeed}°/s");
}
break;
}

View File

@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using RimWorld;
using RimWorld.Planet;
using UnityEngine;
@@ -103,7 +103,7 @@ namespace WulaFallenEmpire
map.fogGrid.ClearAllFog();
// 记录日志以便调试
Log.Message($"[MapObserver] 开始监测地图: {mapParent.Label} at tile {target.Tile}");
WulaLog.Debug($"[MapObserver] 开始监测地图: {mapParent.Label} at tile {target.Tile}");
}
}, "GeneratingMap", doAsynchronously: false, null);
@@ -128,12 +128,12 @@ namespace WulaFallenEmpire
if (observedMap is Settlement settlement)
{
settlement.Name = $"监测点-{thingIDNumber}";
Log.Message($"[MapObserver] 创建新监测点: {settlement.Name} at tile {target.Tile}");
WulaLog.Debug($"[MapObserver] 创建新监测点: {settlement.Name} at tile {target.Tile}");
}
else
{
// 如果observedMap不是Settlement使用Label属性
Log.Message($"[MapObserver] 创建新监测点: {observedMap.Label} at tile {target.Tile}");
WulaLog.Debug($"[MapObserver] 创建新监测点: {observedMap.Label} at tile {target.Tile}");
}
}, "GeneratingMap", doAsynchronously: false, null);
@@ -165,7 +165,7 @@ namespace WulaFallenEmpire
{
Find.World.worldObjects.Remove(observedMap);
}
Log.Message($"[MapObserver] 清理空置监测地图: {observedMap.Label}");
WulaLog.Debug($"[MapObserver] 清理空置监测地图: {observedMap.Label}");
}
}
@@ -176,14 +176,14 @@ namespace WulaFallenEmpire
// 断电或被关闭时停止监测
if (observedMap != null && (signal == "PowerTurnedOff" || signal == "FlickedOff"))
{
Log.Message($"[MapObserver] 电力中断,停止监测: {observedMap.Label}");
WulaLog.Debug($"[MapObserver] 电力中断,停止监测: {observedMap.Label}");
StopObserving();
}
// 恢复电力时重新注册
else if (observedMap != null && (signal == "PowerTurnedOn" || signal == "FlickedOn"))
{
activeObservers.Add(this);
Log.Message($"[MapObserver] 电力恢复,继续监测: {observedMap.Label}");
WulaLog.Debug($"[MapObserver] 电力恢复,继续监测: {observedMap.Label}");
}
}

View File

@@ -324,7 +324,7 @@ namespace WulaFallenEmpire
// 检查是否有攻击动词
if (currentEffectiveVerb == null)
{
Log.Error("BestShootTargetFromCurrentPosition with " + searcher.ToStringSafe<IAttackTargetSearcher>() + " who has no attack verb.");
WulaLog.Debug("BestShootTargetFromCurrentPosition with " + searcher.ToStringSafe<IAttackTargetSearcher>() + " who has no attack verb.");
return null;
}
@@ -376,7 +376,7 @@ namespace WulaFallenEmpire
// 验证攻击动词是否存在
if (verb == null)
{
Log.Error("BestAttackTarget with " + searcher.ToStringSafe<IAttackTargetSearcher>() + " who has no attack verb.");
WulaLog.Debug("BestAttackTarget with " + searcher.ToStringSafe<IAttackTargetSearcher>() + " who has no attack verb.");
return null;
}

View File

@@ -1,4 +1,4 @@
using RimWorld;
using RimWorld;
using Verse;
using UnityEngine;
using System.Collections.Generic;
@@ -41,14 +41,14 @@ namespace WulaFallenEmpire
{
currentState = BuildingBombardmentState.Bursting;
nextInnerBurstTick = Find.TickManager.TicksGame;
Log.Message($"[BuildingBombardment] Starting burst with {currentTargets.Count} targets");
WulaLog.Debug($"[BuildingBombardment] Starting burst with {currentTargets.Count} targets");
}
else
{
// 没有找到目标,等待下一轮
currentState = BuildingBombardmentState.Idle;
nextBurstTick = Find.TickManager.TicksGame + Props.burstIntervalTicks;
Log.Message($"[BuildingBombardment] No targets found, waiting for next burst");
WulaLog.Debug($"[BuildingBombardment] No targets found, waiting for next burst");
}
}
@@ -110,7 +110,7 @@ namespace WulaFallenEmpire
// 当前组发射完毕
currentState = BuildingBombardmentState.Idle;
nextBurstTick = Find.TickManager.TicksGame + Props.burstIntervalTicks;
Log.Message($"[BuildingBombardment] Burst completed, waiting for next burst");
WulaLog.Debug($"[BuildingBombardment] Burst completed, waiting for next burst");
return;
}
@@ -125,7 +125,7 @@ namespace WulaFallenEmpire
nextInnerBurstTick = Find.TickManager.TicksGame + Props.innerBurstIntervalTicks;
}
Log.Message($"[BuildingBombardment] Launched bombardment {currentBurstCount}/{currentTargets.Count}");
WulaLog.Debug($"[BuildingBombardment] Launched bombardment {currentBurstCount}/{currentTargets.Count}");
}
private void LaunchBombardment(LocalTargetInfo target)
@@ -149,7 +149,7 @@ namespace WulaFallenEmpire
}
catch (System.Exception ex)
{
Log.Error($"[BuildingBombardment] Error launching bombardment: {ex}");
WulaLog.Debug($"[BuildingBombardment] Error launching bombardment: {ex}");
}
}

View File

@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RimWorld;
@@ -114,7 +114,7 @@ namespace WulaFallenEmpire
var facilitiesComp = flyOver.GetComp<CompFlyOverFacilities>();
if (facilitiesComp == null)
{
Log.Warning($"[BuildingSpawner] FlyOver at {flyOver.Position} has no CompFlyOverFacilities");
WulaLog.Debug($"[BuildingSpawner] FlyOver at {flyOver.Position} has no CompFlyOverFacilities");
continue;
}
@@ -129,7 +129,7 @@ namespace WulaFallenEmpire
}
catch (System.Exception ex)
{
Log.Error($"[BuildingSpawner] Exception while checking for FlyOver: {ex}");
WulaLog.Debug($"[BuildingSpawner] Exception while checking for FlyOver: {ex}");
return false;
}
}
@@ -223,7 +223,7 @@ namespace WulaFallenEmpire
{
if (Props.buildingToSpawn == null)
{
Log.Error("[BuildingSpawner] Building def is null!");
WulaLog.Debug("[BuildingSpawner] Building def is null!");
ResetCall();
return;
}
@@ -237,7 +237,7 @@ namespace WulaFallenEmpire
// 检查位置是否可用
if (!CanSpawnAtPosition(spawnPos))
{
Log.Error($"[BuildingSpawner] Cannot spawn building at {spawnPos}");
WulaLog.Debug($"[BuildingSpawner] Cannot spawn building at {spawnPos}");
ResetCall();
return;
}
@@ -250,7 +250,7 @@ namespace WulaFallenEmpire
if (newBuilding == null)
{
Log.Error("[BuildingSpawner] Failed to create building!");
WulaLog.Debug("[BuildingSpawner] Failed to create building!");
ResetCall();
return;
}
@@ -273,7 +273,7 @@ namespace WulaFallenEmpire
}
catch (System.Exception ex)
{
Log.Error($"[BuildingSpawner] Error in ExecuteAutoBuildingSpawn: {ex}");
WulaLog.Debug($"[BuildingSpawner] Error in ExecuteAutoBuildingSpawn: {ex}");
ResetCall();
}
}
@@ -348,7 +348,7 @@ namespace WulaFallenEmpire
{
if (Props.buildingToSpawn == null)
{
Log.Error("[BuildingSpawner] Building def is null!");
WulaLog.Debug("[BuildingSpawner] Building def is null!");
return;
}
@@ -371,7 +371,7 @@ namespace WulaFallenEmpire
// 检查位置是否可用
if (!CanSpawnAtPosition(spawnPos))
{
Log.Error($"[BuildingSpawner] Cannot spawn building at {spawnPos}");
WulaLog.Debug($"[BuildingSpawner] Cannot spawn building at {spawnPos}");
ResetCall();
return;
}
@@ -384,7 +384,7 @@ namespace WulaFallenEmpire
if (newBuilding == null)
{
Log.Error("[BuildingSpawner] Failed to create building!");
WulaLog.Debug("[BuildingSpawner] Failed to create building!");
return;
}
@@ -409,14 +409,14 @@ namespace WulaFallenEmpire
{
if (parent?.Map == null)
{
Log.Warning($"[BuildingSpawner] Parent map is null for {parent?.LabelShort}");
WulaLog.Debug($"[BuildingSpawner] Parent map is null for {parent?.LabelShort}");
return false;
}
// 检查是否在地图范围内
if (!spawnPos.InBounds(parent.Map))
{
Log.Warning($"[BuildingSpawner] Spawn position {spawnPos} is out of bounds for {parent?.LabelShort}");
WulaLog.Debug($"[BuildingSpawner] Spawn position {spawnPos} is out of bounds for {parent?.LabelShort}");
return false;
}
@@ -424,7 +424,7 @@ namespace WulaFallenEmpire
ThingDef buildingDef = Props.buildingToSpawn;
if (buildingDef == null)
{
Log.Error($"[BuildingSpawner] buildingToSpawn is null for {parent?.LabelShort}");
WulaLog.Debug($"[BuildingSpawner] buildingToSpawn is null for {parent?.LabelShort}");
return false;
}
@@ -437,7 +437,7 @@ namespace WulaFallenEmpire
// 检查建筑是否完全在地图范围内
if (!rect.InBounds(parent.Map))
{
Log.Warning($"[BuildingSpawner] Building rect {rect} for {buildingDef.defName} is out of bounds. Size: {buildingSize}, Position: {spawnPos}");
WulaLog.Debug($"[BuildingSpawner] Building rect {rect} for {buildingDef.defName} is out of bounds. Size: {buildingSize}, Position: {spawnPos}");
return false;
}
@@ -451,7 +451,7 @@ namespace WulaFallenEmpire
if (rect.minX < safeMargin || rect.minZ < safeMargin ||
rect.maxX >= pocketMap.Size.x - safeMargin || rect.maxZ >= pocketMap.Size.z - safeMargin)
{
Log.Warning($"[BuildingSpawner] Building {buildingDef.defName} too close to pocket map edge. Rect: {rect}, Map Size: {pocketMap.Size}");
WulaLog.Debug($"[BuildingSpawner] Building {buildingDef.defName} too close to pocket map edge. Rect: {rect}, Map Size: {pocketMap.Size}");
return false;
}
}
@@ -461,7 +461,7 @@ namespace WulaFallenEmpire
{
if (!cell.InBounds(parent.Map))
{
Log.Warning($"[BuildingSpawner] Cell {cell} is out of bounds for building {buildingDef.defName}");
WulaLog.Debug($"[BuildingSpawner] Cell {cell} is out of bounds for building {buildingDef.defName}");
return false;
}
@@ -476,7 +476,7 @@ namespace WulaFallenEmpire
// 跳过自己
if (thing != parent)
{
Log.Warning($"[BuildingSpawner] Cell {cell} is blocked by {thing.def.defName} ({thing.LabelShort})");
WulaLog.Debug($"[BuildingSpawner] Cell {cell} is blocked by {thing.def.defName} ({thing.LabelShort})");
return false;
}
}

View File

@@ -1,4 +1,4 @@
using RimWorld;
using RimWorld;
using System.Collections.Generic;
using Verse;
@@ -66,7 +66,7 @@ namespace WulaFallenEmpire
// 验证buildingToSpawn
if (buildingToSpawn != null && buildingToSpawn.category != ThingCategory.Building)
{
Log.Error($"CompProperties_BuildingSpawner: buildingToSpawn must be a building, but got {buildingToSpawn.defName}");
WulaLog.Debug($"CompProperties_BuildingSpawner: buildingToSpawn must be a building, but got {buildingToSpawn.defName}");
buildingToSpawn = null;
}
}

View File

@@ -1,4 +1,4 @@
using RimWorld;
using RimWorld;
using Verse;
using UnityEngine;
using System.Collections.Generic;
@@ -54,7 +54,7 @@ namespace WulaFallenEmpire
ResetState();
}
Log.Message($"[EnergyLanceTurret] 炮塔生成在 {parent.Position}, 检测范围: {Props.detectionRange}");
WulaLog.Debug($"[EnergyLanceTurret] 炮塔生成在 {parent.Position}, 检测范围: {Props.detectionRange}");
}
// 在 StartEnergyLance 方法中修复光束创建逻辑
@@ -63,7 +63,7 @@ namespace WulaFallenEmpire
// 双重检查目标有效性
if (currentTarget == null || !IsTargetValid(currentTarget))
{
Log.Warning($"[EnergyLanceTurret] 尝试启动能量光束但目标无效: {(currentTarget == null ? "null" : "")}");
WulaLog.Debug($"[EnergyLanceTurret] 尝试启动能量光束但目标无效: {(currentTarget == null ? "null" : "")}");
// 尝试重新寻找目标
var potentialTargets = FindPotentialTargets();
@@ -72,11 +72,11 @@ namespace WulaFallenEmpire
currentTarget = potentialTargets
.OrderBy(t => t.Position.DistanceTo(parent.Position))
.First();
Log.Message($"[EnergyLanceTurret] 重新获取目标: {currentTarget.LabelCap}");
WulaLog.Debug($"[EnergyLanceTurret] 重新获取目标: {currentTarget.LabelCap}");
}
else
{
Log.Message("[EnergyLanceTurret] 无法重新获取目标,进入冷却");
WulaLog.Debug("[EnergyLanceTurret] 无法重新获取目标,进入冷却");
StartCooldown();
return;
}
@@ -88,12 +88,12 @@ namespace WulaFallenEmpire
var lanceDef = Props.energyLanceDef ?? ThingDef.Named("EnergyLance");
if (lanceDef == null)
{
Log.Error("[EnergyLanceTurret] 能量光束定义为空!");
WulaLog.Debug("[EnergyLanceTurret] 能量光束定义为空!");
StartCooldown();
return;
}
Log.Message($"[EnergyLanceTurret] 创建能量光束: {lanceDef.defName} 目标: {currentTarget.LabelCap} 在 {currentTarget.Position}");
WulaLog.Debug($"[EnergyLanceTurret] 创建能量光束: {lanceDef.defName} 目标: {currentTarget.LabelCap} 在 {currentTarget.Position}");
// 关键修复:光束直接在目标位置生成,而不是建筑位置
activeLance = EnergyLance.MakeEnergyLance(
@@ -109,7 +109,7 @@ namespace WulaFallenEmpire
if (activeLance == null)
{
Log.Error("[EnergyLanceTurret] 能量光束创建失败!");
WulaLog.Debug("[EnergyLanceTurret] 能量光束创建失败!");
StartCooldown();
return;
}
@@ -131,11 +131,11 @@ namespace WulaFallenEmpire
// 立即更新光束位置,确保光束在正确位置开始
UpdateEnergyLancePosition();
Log.Message($"[EnergyLanceTurret] 能量光束启动成功,追踪目标: {currentTarget.LabelCap}");
WulaLog.Debug($"[EnergyLanceTurret] 能量光束启动成功,追踪目标: {currentTarget.LabelCap}");
}
catch (System.Exception ex)
{
Log.Error($"[EnergyLanceTurret] 启动能量光束错误: {ex}");
WulaLog.Debug($"[EnergyLanceTurret] 启动能量光束错误: {ex}");
StartCooldown();
}
}
@@ -154,7 +154,7 @@ namespace WulaFallenEmpire
// 添加更多调试信息
if (debugTickCounter % 30 == 0) // 每0.5秒输出一次位置信息
{
Log.Message($"[EnergyLanceTurret] 更新光束位置: 目标在 {currentTarget.Position}, 光束在 {activeLance.Position}");
WulaLog.Debug($"[EnergyLanceTurret] 更新光束位置: 目标在 {currentTarget.Position}, 光束在 {activeLance.Position}");
}
}
else if (lastTargetPosition.IsValid && Find.TickManager.TicksGame - lastPositionUpdateTick <= Props.targetUpdateInterval * 2)
@@ -209,12 +209,12 @@ namespace WulaFallenEmpire
if (debugTickCounter % 30 == 0) // 每0.5秒输出一次冷却信息
{
Log.Message($"[EnergyLanceTurret] 冷却中: {cooldownTicksRemaining} ticks 剩余");
WulaLog.Debug($"[EnergyLanceTurret] 冷却中: {cooldownTicksRemaining} ticks 剩余");
}
if (cooldownTicksRemaining <= 0)
{
Log.Message("[EnergyLanceTurret] 冷却完成,返回待机状态");
WulaLog.Debug("[EnergyLanceTurret] 冷却完成,返回待机状态");
currentState = TurretState.Idle;
isActive = false;
}
@@ -226,7 +226,7 @@ namespace WulaFallenEmpire
// 在预热过程中持续检查目标有效性
if (currentTarget == null || !IsTargetValid(currentTarget))
{
Log.Message($"[EnergyLanceTurret] 预热过程中目标失效,取消预热");
WulaLog.Debug($"[EnergyLanceTurret] 预热过程中目标失效,取消预热");
ResetState();
return;
}
@@ -235,12 +235,12 @@ namespace WulaFallenEmpire
if (debugTickCounter % 10 == 0) // 每0.17秒输出一次预热信息
{
Log.Message($"[EnergyLanceTurret] 预热中: {warmupTicksRemaining} ticks 剩余, 目标: {currentTarget?.LabelCap ?? ""}");
WulaLog.Debug($"[EnergyLanceTurret] 预热中: {warmupTicksRemaining} ticks 剩余, 目标: {currentTarget?.LabelCap ?? ""}");
}
if (warmupTicksRemaining <= 0)
{
Log.Message("[EnergyLanceTurret] 预热完成,开始发射光束");
WulaLog.Debug("[EnergyLanceTurret] 预热完成,开始发射光束");
StartEnergyLance();
}
}
@@ -280,23 +280,23 @@ namespace WulaFallenEmpire
private void OutputDebugInfo()
{
var targets = FindPotentialTargets();
Log.Message($"[EnergyLanceTurret] 调试信息:");
Log.Message($" - 状态: {currentState}");
Log.Message($" - 当前目标: {currentTarget?.LabelCap ?? ""}");
Log.Message($" - 目标位置: {currentTarget?.Position.ToString() ?? ""}");
Log.Message($" - 活跃光束: {(activeLance != null && !activeLance.Destroyed ? "" : "")}");
Log.Message($" - 检测到目标数: {targets.Count}");
Log.Message($" - 冷却剩余: {cooldownTicksRemaining}");
Log.Message($" - 预热剩余: {warmupTicksRemaining}");
Log.Message($" - 是否活跃: {isActive}");
Log.Message($" - 目标丢失保护: {(targetLostTick >= 0 ? (Find.TickManager.TicksGame - targetLostTick) + " ticks前" : "")}");
Log.Message($" - 光束保护期: {(lanceCreationTick >= 0 ? (Find.TickManager.TicksGame - lanceCreationTick) + " ticks前创建" : "")}");
WulaLog.Debug($"[EnergyLanceTurret] 调试信息:");
WulaLog.Debug($" - 状态: {currentState}");
WulaLog.Debug($" - 当前目标: {currentTarget?.LabelCap ?? ""}");
WulaLog.Debug($" - 目标位置: {currentTarget?.Position.ToString() ?? ""}");
WulaLog.Debug($" - 活跃光束: {(activeLance != null && !activeLance.Destroyed ? "" : "")}");
WulaLog.Debug($" - 检测到目标数: {targets.Count}");
WulaLog.Debug($" - 冷却剩余: {cooldownTicksRemaining}");
WulaLog.Debug($" - 预热剩余: {warmupTicksRemaining}");
WulaLog.Debug($" - 是否活跃: {isActive}");
WulaLog.Debug($" - 目标丢失保护: {(targetLostTick >= 0 ? (Find.TickManager.TicksGame - targetLostTick) + " ticks前" : "")}");
WulaLog.Debug($" - 光束保护期: {(lanceCreationTick >= 0 ? (Find.TickManager.TicksGame - lanceCreationTick) + " ticks前创建" : "")}");
// 输出前3个检测到的目标
for (int i = 0; i < Mathf.Min(3, targets.Count); i++)
{
var target = targets[i];
Log.Message($" - 目标{i+1}: {target.LabelCap} 在 {target.Position}, 距离: {target.Position.DistanceTo(parent.Position):F1}");
WulaLog.Debug($" - 目标{i+1}: {target.LabelCap} 在 {target.Position}, 距离: {target.Position.DistanceTo(parent.Position):F1}");
}
}
@@ -317,7 +317,7 @@ namespace WulaFallenEmpire
// 更新目标
private void UpdateTarget()
{
Log.Message($"[EnergyLanceTurret] 更新目标检查 - 状态: {currentState}, 活跃光束: {(activeLance != null && !activeLance.Destroyed ? "" : "")}");
WulaLog.Debug($"[EnergyLanceTurret] 更新目标检查 - 状态: {currentState}, 活跃光束: {(activeLance != null && !activeLance.Destroyed ? "" : "")}");
// 如果没有光束,寻找新目标
if (activeLance == null || activeLance.Destroyed)
@@ -333,7 +333,7 @@ namespace WulaFallenEmpire
lastTargetPosition = currentTarget.Position;
lastPositionUpdateTick = Find.TickManager.TicksGame;
targetLostTick = -1; // 重置目标丢失计时
Log.Message($"[EnergyLanceTurret] 目标仍然有效: {currentTarget.LabelCap}");
WulaLog.Debug($"[EnergyLanceTurret] 目标仍然有效: {currentTarget.LabelCap}");
return;
}
@@ -344,11 +344,11 @@ namespace WulaFallenEmpire
// 寻找新目标(首次)
private void FindNewTarget()
{
Log.Message("[EnergyLanceTurret] 寻找新目标...");
WulaLog.Debug("[EnergyLanceTurret] 寻找新目标...");
if (currentState != TurretState.Idle)
{
Log.Message($"[EnergyLanceTurret] 无法寻找目标 - 当前状态: {currentState}");
WulaLog.Debug($"[EnergyLanceTurret] 无法寻找目标 - 当前状态: {currentState}");
return;
}
@@ -361,14 +361,14 @@ namespace WulaFallenEmpire
.OrderBy(t => t.Position.DistanceTo(parent.Position))
.First();
Log.Message($"[EnergyLanceTurret] 发现新目标: {currentTarget.LabelCap} 在 {currentTarget.Position}");
WulaLog.Debug($"[EnergyLanceTurret] 发现新目标: {currentTarget.LabelCap} 在 {currentTarget.Position}");
// 开始预热
StartWarmup();
}
else
{
Log.Message("[EnergyLanceTurret] 没有发现有效目标");
WulaLog.Debug("[EnergyLanceTurret] 没有发现有效目标");
}
}
@@ -378,7 +378,7 @@ namespace WulaFallenEmpire
if (activeLance == null || activeLance.Destroyed)
return;
Log.Message("[EnergyLanceTurret] 为现有光束寻找新目标...");
WulaLog.Debug("[EnergyLanceTurret] 为现有光束寻找新目标...");
var potentialTargets = FindPotentialTargets();
@@ -393,7 +393,7 @@ namespace WulaFallenEmpire
lastPositionUpdateTick = Find.TickManager.TicksGame;
targetLostTick = -1; // 重置目标丢失计时
Log.Message($"[EnergyLanceTurret] 切换到新目标: {currentTarget.LabelCap} 在 {currentTarget.Position}");
WulaLog.Debug($"[EnergyLanceTurret] 切换到新目标: {currentTarget.LabelCap} 在 {currentTarget.Position}");
}
else
{
@@ -401,12 +401,12 @@ namespace WulaFallenEmpire
if (targetLostTick < 0)
{
targetLostTick = Find.TickManager.TicksGame;
Log.Message($"[EnergyLanceTurret] 目标丢失,开始保护期: {TARGET_LOST_GRACE_PERIOD} ticks");
WulaLog.Debug($"[EnergyLanceTurret] 目标丢失,开始保护期: {TARGET_LOST_GRACE_PERIOD} ticks");
}
currentTarget = null;
lastTargetPosition = IntVec3.Invalid;
Log.Message("[EnergyLanceTurret] 没有有效目标,发送空位置");
WulaLog.Debug("[EnergyLanceTurret] 没有有效目标,发送空位置");
}
}
@@ -498,7 +498,7 @@ namespace WulaFallenEmpire
{
if (currentTarget == null)
{
Log.Warning("[EnergyLanceTurret] 尝试开始预热但没有目标");
WulaLog.Debug("[EnergyLanceTurret] 尝试开始预热但没有目标");
return;
}
@@ -506,7 +506,7 @@ namespace WulaFallenEmpire
isActive = true;
currentState = TurretState.WarmingUp;
Log.Message($"[EnergyLanceTurret] 开始预热: {warmupTicksRemaining} ticks, 目标: {currentTarget.LabelCap}");
WulaLog.Debug($"[EnergyLanceTurret] 开始预热: {warmupTicksRemaining} ticks, 目标: {currentTarget.LabelCap}");
}
// 更新光束目标位置
@@ -519,7 +519,7 @@ namespace WulaFallenEmpire
if (activeLance is EnergyLance energyLance)
{
energyLance.UpdateTargetPosition(targetPos);
Log.Message($"[EnergyLanceTurret] 更新光束目标: {targetPos}");
WulaLog.Debug($"[EnergyLanceTurret] 更新光束目标: {targetPos}");
}
else
{
@@ -528,11 +528,11 @@ namespace WulaFallenEmpire
if (moveMethod != null)
{
moveMethod.Invoke(activeLance, new object[] { targetPos });
Log.Message($"[EnergyLanceTurret] 通过反射更新光束目标: {targetPos}");
WulaLog.Debug($"[EnergyLanceTurret] 通过反射更新光束目标: {targetPos}");
}
else
{
Log.Warning("[EnergyLanceTurret] 无法更新光束目标位置");
WulaLog.Debug("[EnergyLanceTurret] 无法更新光束目标位置");
}
}
}
@@ -543,7 +543,7 @@ namespace WulaFallenEmpire
if (activeLance == null || activeLance.Destroyed)
{
// 光束已销毁,进入冷却
Log.Message("[EnergyLanceTurret] 光束已销毁,开始冷却");
WulaLog.Debug("[EnergyLanceTurret] 光束已销毁,开始冷却");
StartCooldown();
return;
}
@@ -558,7 +558,7 @@ namespace WulaFallenEmpire
// 检查目标丢失保护期
if (targetLostTick >= 0 && Find.TickManager.TicksGame - targetLostTick > TARGET_LOST_GRACE_PERIOD)
{
Log.Message("[EnergyLanceTurret] 目标丢失保护期结束,销毁光束");
WulaLog.Debug("[EnergyLanceTurret] 目标丢失保护期结束,销毁光束");
activeLance.Destroy();
StartCooldown();
return;
@@ -567,7 +567,7 @@ namespace WulaFallenEmpire
// 检查光束是否长时间没有收到位置更新
if (Find.TickManager.TicksGame - lastPositionUpdateTick > Props.targetUpdateInterval * 3)
{
Log.Message("[EnergyLanceTurret] 光束长时间未收到位置更新,销毁");
WulaLog.Debug("[EnergyLanceTurret] 光束长时间未收到位置更新,销毁");
activeLance.Destroy();
StartCooldown();
}
@@ -584,7 +584,7 @@ namespace WulaFallenEmpire
targetLostTick = -1;
currentState = TurretState.CoolingDown;
Log.Message($"[EnergyLanceTurret] 开始冷却: {cooldownTicksRemaining} ticks");
WulaLog.Debug($"[EnergyLanceTurret] 开始冷却: {cooldownTicksRemaining} ticks");
}
// 绘制检测范围

View File

@@ -1,4 +1,4 @@
using RimWorld;
using RimWorld;
using Verse;
namespace WulaFallenEmpire
@@ -49,7 +49,7 @@ namespace WulaFallenEmpire
if (faction != null && faction != parent.Faction)
{
parent.SetFaction(faction);
Log.Message($"Set faction for {parent.Label} to {faction.Name}");
WulaLog.Debug($"Set faction for {parent.Label} to {faction.Name}");
}
}

View File

@@ -1,4 +1,4 @@
using RimWorld;
using RimWorld;
using Verse;
using Verse.AI;
using System.Collections.Generic;
@@ -45,14 +45,14 @@ namespace WulaFallenEmpire
if (Prefs.DevMode)
{
Log.Message($"[CompAutonomousMech] {pawn.LabelCap} equipped new weapon: {newWeaponDef.LabelCap}");
WulaLog.Debug($"[CompAutonomousMech] {pawn.LabelCap} equipped new weapon: {newWeaponDef.LabelCap}");
}
}
}
}
catch (System.Exception ex)
{
Log.Error($"[CompAutonomousMech] Error switching weapon for {pawn?.LabelCap}: {ex}");
WulaLog.Debug($"[CompAutonomousMech] Error switching weapon for {pawn?.LabelCap}: {ex}");
}
}

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using RimWorld;
using UnityEngine;
@@ -86,7 +86,7 @@ namespace WulaFallenEmpire
}
else
{
Log.Error($"PhaseCombatTower: 找不到PawnKindDef '{pawnKindName}'");
WulaLog.Debug($"PhaseCombatTower: 找不到PawnKindDef '{pawnKindName}'");
}
}
}

View File

@@ -1,4 +1,4 @@
using RimWorld;
using RimWorld;
using Verse;
using System.Linq;
using UnityEngine;
@@ -25,17 +25,17 @@ namespace WulaFallenEmpire
protected override void Impact()
{
// Re-adding debug logs for stage 6
Log.Message($"[WULA] Stage 6: Impact - ArmedShuttleIncoming Impact() called. InnerThing (via innerContainer) is: {innerContainer.FirstOrDefault()?.ToString() ?? "NULL"}");
WulaLog.Debug($"[WULA] Stage 6: Impact - ArmedShuttleIncoming Impact() called. InnerThing (via innerContainer) is: {innerContainer.FirstOrDefault()?.ToString() ?? "NULL"}");
Thing innerThing = innerContainer.FirstOrDefault();
if (innerThing is Building_ArmedShuttle shuttle)
{
Log.Message("[WULA] Stage 6: Impact - InnerThing is a Building_ArmedShuttle. Attempting to notify arrival.");
WulaLog.Debug("[WULA] Stage 6: Impact - InnerThing is a Building_ArmedShuttle. Attempting to notify arrival.");
shuttle.TryGetComp<CompLaunchable>()?.Notify_Arrived();
}
else
{
Log.Warning($"[WULA] Stage 6: Impact - InnerThing is NOT a Building_ArmedShuttle or is NULL. Type: {innerThing?.GetType().Name ?? "NULL"}. This is the cause of the issue.");
WulaLog.Debug($"[WULA] Stage 6: Impact - InnerThing is NOT a Building_ArmedShuttle or is NULL. Type: {innerThing?.GetType().Name ?? "NULL"}. This is the cause of the issue.");
}
// Calling base.Impact() will handle the actual spawning of the innerThing.
@@ -47,7 +47,7 @@ namespace WulaFallenEmpire
{
base.SpawnSetup(map, respawningAfterLoad);
// Re-adding debug logs for stage 5
Log.Message($"[WULA] Stage 5: Landing Sequence - ArmedShuttleIncoming spawned. InnerThing (via innerContainer) is: {innerContainer.FirstOrDefault()?.ToString() ?? "NULL"}");
WulaLog.Debug($"[WULA] Stage 5: Landing Sequence - ArmedShuttleIncoming spawned. InnerThing (via innerContainer) is: {innerContainer.FirstOrDefault()?.ToString() ?? "NULL"}");
if (!respawningAfterLoad && !base.BeingTransportedOnGravship)
{
angle = GetAngle(0f, base.Rotation);
@@ -58,7 +58,7 @@ namespace WulaFallenEmpire
{
if (!hasImpacted)
{
Log.Error("Destroying armed shuttle skyfaller without ever having impacted"); // Changed log message
WulaLog.Debug("Destroying armed shuttle skyfaller without ever having impacted"); // Changed log message
}
base.Destroy(mode);
}

View File

@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RimWorld;
@@ -212,7 +212,7 @@ namespace WulaFallenEmpire
{
if (gun == null)
{
Log.Error("Turret had null gun after loading. Recreating.");
WulaLog.Debug("Turret had null gun after loading. Recreating.");
MakeGun();
}
else

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -137,7 +137,7 @@ namespace WulaFallenEmpire
public Building_ArmedShuttleWithPocket()
{
Log.Message("[WULA-DEBUG] Building_ArmedShuttleWithPocket constructor called");
WulaLog.Debug("[WULA-DEBUG] Building_ArmedShuttleWithPocket constructor called");
// 不再初始化innerContainer只使用CompTransporter的容器
}
@@ -149,14 +149,14 @@ namespace WulaFallenEmpire
public override void PostMake()
{
Log.Message("[WULA-DEBUG] PostMake called");
WulaLog.Debug("[WULA-DEBUG] PostMake called");
base.PostMake();
// 不再初始化innerContainer只使用CompTransporter的容器
}
public override void ExposeData()
{
Log.Message($"[WULA-DEBUG] ExposeData called, mode: {Scribe.mode}");
WulaLog.Debug($"[WULA-DEBUG] ExposeData called, mode: {Scribe.mode}");
base.ExposeData();
Scribe_References.Look(ref pocketMap, "pocketMap");
@@ -171,24 +171,24 @@ namespace WulaFallenEmpire
if (Scribe.mode == LoadSaveMode.PostLoadInit)
{
Log.Message("[WULA-DEBUG] PostLoadInit: Validating components after load");
WulaLog.Debug("[WULA-DEBUG] PostLoadInit: Validating components after load");
// 验证CompTransporter组件是否正常
CompTransporter transporter = this.GetComp<CompTransporter>();
if (transporter == null)
{
Log.Error("[WULA-ERROR] CompTransporter is missing after load! This will cause item storage issues.");
WulaLog.Debug("[WULA-ERROR] CompTransporter is missing after load! This will cause item storage issues.");
}
else
{
Log.Message($"[WULA-DEBUG] CompTransporter loaded successfully with {transporter.innerContainer?.Count ?? 0} items");
WulaLog.Debug($"[WULA-DEBUG] CompTransporter loaded successfully with {transporter.innerContainer?.Count ?? 0} items");
}
}
}
public override void DeSpawn(DestroyMode mode = DestroyMode.Vanish)
{
Log.Message($"[WULA-DEBUG] DeSpawn called with mode: {mode}");
WulaLog.Debug($"[WULA-DEBUG] DeSpawn called with mode: {mode}");
// 只在真正销毁时清理口袋地图,发射时保留
if (ShouldDestroyPocketMapOnDeSpawn(mode))
@@ -197,7 +197,7 @@ namespace WulaFallenEmpire
{
try
{
Log.Message("[WULA-DEBUG] Destroying pocket map due to shuttle destruction");
WulaLog.Debug("[WULA-DEBUG] Destroying pocket map due to shuttle destruction");
// 将口袋空间中的物品和人员转移到主地图
TransferAllFromPocketToMainMap();
@@ -209,19 +209,19 @@ namespace WulaFallenEmpire
}
catch (Exception ex)
{
Log.Error($"[WULA-ERROR] Error cleaning up pocket map: {ex}");
WulaLog.Debug($"[WULA-ERROR] Error cleaning up pocket map: {ex}");
}
}
}
else
{
Log.Message("[WULA-DEBUG] Preserving pocket map during shuttle launch/transport");
WulaLog.Debug("[WULA-DEBUG] Preserving pocket map during shuttle launch/transport");
// 发射时暂停传送功能,但保留口袋空间
transportDisabled = true;
if (pocketMap != null && exit != null)
{
// 标记传送功能暂停
Log.Message("[WULA-DEBUG] Transport functionality disabled during flight");
WulaLog.Debug("[WULA-DEBUG] Transport functionality disabled during flight");
}
}
@@ -249,7 +249,7 @@ namespace WulaFallenEmpire
case DestroyMode.FailConstruction: // 建造失败,删除口袋空间
return true;
default:
Log.Warning($"[WULA-WARNING] Unknown DestroyMode: {mode}, defaulting to preserve pocket map");
WulaLog.Debug($"[WULA-WARNING] Unknown DestroyMode: {mode}, defaulting to preserve pocket map");
return false;
}
}
@@ -432,16 +432,16 @@ namespace WulaFallenEmpire
// 在口袋地图中心放置退出点
CreateExitPoint();
Log.Message($"[WULA] Successfully created pocket map of size {pocketMapSize} for armed shuttle");
WulaLog.Debug($"[WULA] Successfully created pocket map of size {pocketMapSize} for armed shuttle");
}
else
{
Log.Error("[WULA] Failed to create pocket map");
WulaLog.Debug("[WULA] Failed to create pocket map");
}
}
catch (Exception ex)
{
Log.Error($"[WULA] Exception creating pocket map: {ex}");
WulaLog.Debug($"[WULA] Exception creating pocket map: {ex}");
}
}
@@ -490,16 +490,16 @@ namespace WulaFallenEmpire
}
GenPlace.TryPlaceThing(exitBuilding, exitPos, pocketMap, ThingPlaceMode.Direct);
Log.Message($"[WULA] Created exit point at {exitPos} in pocket map");
WulaLog.Debug($"[WULA] Created exit point at {exitPos} in pocket map");
}
else
{
Log.Warning("[WULA] Could not find valid position for exit point in pocket map");
WulaLog.Debug("[WULA] Could not find valid position for exit point in pocket map");
}
}
catch (Exception ex)
{
Log.Error($"[WULA] Error creating exit point: {ex}");
WulaLog.Debug($"[WULA] Error creating exit point: {ex}");
}
}
@@ -525,7 +525,7 @@ namespace WulaFallenEmpire
}
catch (Exception ex)
{
Log.Error($"[WULA] Error transferring pawn {pawn?.LabelShort} to pocket space: {ex}");
WulaLog.Debug($"[WULA] Error transferring pawn {pawn?.LabelShort} to pocket space: {ex}");
}
return false;
@@ -536,17 +536,17 @@ namespace WulaFallenEmpire
/// </summary>
private void TransferAllFromPocketToMainMap()
{
Log.Message("[WULA-DEBUG] TransferAllFromPocketToMainMap started");
WulaLog.Debug("[WULA-DEBUG] TransferAllFromPocketToMainMap started");
if (pocketMap == null)
{
Log.Warning("[WULA-DEBUG] TransferAllFromPocketToMainMap: pocketMap is null, nothing to transfer");
WulaLog.Debug("[WULA-DEBUG] TransferAllFromPocketToMainMap: pocketMap is null, nothing to transfer");
return;
}
if (!Spawned)
{
Log.Error("[WULA-ERROR] TransferAllFromPocketToMainMap: Shuttle not spawned, cannot transfer items");
WulaLog.Debug("[WULA-ERROR] TransferAllFromPocketToMainMap: Shuttle not spawned, cannot transfer items");
return;
}
@@ -556,28 +556,28 @@ namespace WulaFallenEmpire
CompTransporter transporter = this.GetComp<CompTransporter>();
if (transporter == null)
{
Log.Error("[WULA-ERROR] CompTransporter not found on shuttle! Cannot transfer items.");
WulaLog.Debug("[WULA-ERROR] CompTransporter not found on shuttle! Cannot transfer items.");
return;
}
Log.Message($"[WULA-DEBUG] Found CompTransporter with {transporter.innerContainer.Count} existing items");
WulaLog.Debug($"[WULA-DEBUG] Found CompTransporter with {transporter.innerContainer.Count} existing items");
// 转移所有殖民者
List<Pawn> pawnsToTransfer = pocketMap.mapPawns.AllPawnsSpawned.ToList();
Log.Message($"[WULA-DEBUG] Found {pawnsToTransfer.Count} colonists to transfer");
WulaLog.Debug($"[WULA-DEBUG] Found {pawnsToTransfer.Count} colonists to transfer");
foreach (Pawn pawn in pawnsToTransfer)
{
if (pawn.Spawned)
{
Log.Message($"[WULA-DEBUG] Transferring pawn: {pawn.LabelShort}");
WulaLog.Debug($"[WULA-DEBUG] Transferring pawn: {pawn.LabelShort}");
pawn.DeSpawn();
// 直接放入穿梭机的容器,如果失败就放到地面
if (!transporter.innerContainer.TryAdd(pawn))
{
Log.Warning($"[WULA-WARNING] Container full, placing pawn {pawn.LabelShort} near shuttle");
WulaLog.Debug($"[WULA-WARNING] Container full, placing pawn {pawn.LabelShort} near shuttle");
// 如果容器满了,放到穿梭机附近
IntVec3 spawnPos = CellFinder.RandomClosewalkCellNear(this.Position, this.Map, 5,
p => p.Standable(this.Map) && !p.GetThingList(this.Map).Any(t => t is Pawn));
@@ -585,16 +585,16 @@ namespace WulaFallenEmpire
if (spawnPos.IsValid)
{
GenPlace.TryPlaceThing(pawn, spawnPos, this.Map, ThingPlaceMode.Near);
Log.Message($"[WULA-DEBUG] Placed pawn {pawn.LabelShort} at {spawnPos}");
WulaLog.Debug($"[WULA-DEBUG] Placed pawn {pawn.LabelShort} at {spawnPos}");
}
else
{
Log.Error($"[WULA-ERROR] Could not find valid position for pawn {pawn.LabelShort}");
WulaLog.Debug($"[WULA-ERROR] Could not find valid position for pawn {pawn.LabelShort}");
}
}
else
{
Log.Message($"[WULA-DEBUG] Successfully added pawn {pawn.LabelShort} to container");
WulaLog.Debug($"[WULA-DEBUG] Successfully added pawn {pawn.LabelShort} to container");
}
}
}
@@ -603,46 +603,46 @@ namespace WulaFallenEmpire
List<Thing> itemsToTransfer = pocketMap.listerThings.AllThings
.Where(t => t.def.category == ThingCategory.Item && t.def.EverHaulable).ToList();
Log.Message($"[WULA-DEBUG] Found {itemsToTransfer.Count} items to transfer");
WulaLog.Debug($"[WULA-DEBUG] Found {itemsToTransfer.Count} items to transfer");
foreach (Thing item in itemsToTransfer)
{
if (item.Spawned)
{
Log.Message($"[WULA-DEBUG] Transferring item: {item.LabelShort} (stack: {item.stackCount})");
WulaLog.Debug($"[WULA-DEBUG] Transferring item: {item.LabelShort} (stack: {item.stackCount})");
item.DeSpawn();
// 直接使用穿梭机的主容器
if (!transporter.innerContainer.TryAdd(item))
{
Log.Warning($"[WULA-WARNING] Container full, dropping item {item.LabelShort} near shuttle");
WulaLog.Debug($"[WULA-WARNING] Container full, dropping item {item.LabelShort} near shuttle");
// 如果容器满了,丢到穿梭机附近(玩家可以手动重新装载)
IntVec3 dropPos = CellFinder.RandomClosewalkCellNear(this.Position, this.Map, 3);
if (dropPos.IsValid)
{
GenPlace.TryPlaceThing(item, dropPos, this.Map, ThingPlaceMode.Near);
Messages.Message($"容器已满:{item.LabelShort} 被放置在穿梭机附近", this, MessageTypeDefOf.CautionInput);
Log.Message($"[WULA-DEBUG] Dropped item {item.LabelShort} at {dropPos}");
WulaLog.Debug($"[WULA-DEBUG] Dropped item {item.LabelShort} at {dropPos}");
}
else
{
Log.Error($"[WULA-ERROR] Could not find valid drop position for item {item.LabelShort}");
WulaLog.Debug($"[WULA-ERROR] Could not find valid drop position for item {item.LabelShort}");
}
}
else
{
Log.Message($"[WULA-DEBUG] Successfully added item {item.LabelShort} to container");
WulaLog.Debug($"[WULA-DEBUG] Successfully added item {item.LabelShort} to container");
}
}
}
Log.Message($"[WULA-DEBUG] Transfer complete. Container now has {transporter.innerContainer.Count} total items");
Log.Message($"[WULA-SUCCESS] Transferred {pawnsToTransfer.Count} pawns and {itemsToTransfer.Count} items from pocket space");
WulaLog.Debug($"[WULA-DEBUG] Transfer complete. Container now has {transporter.innerContainer.Count} total items");
WulaLog.Debug($"[WULA-SUCCESS] Transferred {pawnsToTransfer.Count} pawns and {itemsToTransfer.Count} items from pocket space");
}
catch (Exception ex)
{
Log.Error($"[WULA-ERROR] Error transferring from pocket map: {ex}");
Log.Error($"[WULA-ERROR] Stack trace: {ex.StackTrace}");
WulaLog.Debug($"[WULA-ERROR] Error transferring from pocket map: {ex}");
WulaLog.Debug($"[WULA-ERROR] Stack trace: {ex.StackTrace}");
}
}
@@ -927,19 +927,19 @@ namespace WulaFallenEmpire
pocketExit.targetMap = this.Map;
pocketExit.targetPos = this.Position;
pocketExit.parentShuttle = this;
Log.Message($"[WULA] Updated pocket map exit target to shuttle location: {this.Map?.uniqueID} at {this.Position}");
WulaLog.Debug($"[WULA] Updated pocket map exit target to shuttle location: {this.Map?.uniqueID} at {this.Position}");
}
}
else
{
// 穿梭机不在地图上(可能在飞行中),记录警告但保持原有目标
Log.Warning($"[WULA] Shuttle not spawned, pocket map exit target may be outdated. Current target: {pocketExit.targetMap?.uniqueID} at {pocketExit.targetPos}");
WulaLog.Debug($"[WULA] Shuttle not spawned, pocket map exit target may be outdated. Current target: {pocketExit.targetMap?.uniqueID} at {pocketExit.targetPos}");
}
}
}
catch (Exception ex)
{
Log.Error($"[WULA] Error updating exit point target: {ex}");
WulaLog.Debug($"[WULA] Error updating exit point target: {ex}");
}
}
@@ -967,13 +967,13 @@ namespace WulaFallenEmpire
{
if (Prefs.DevMode)
{
Log.Message($"[WULA] Auto-synced pocket items. Current status: {GetPocketSpaceDebugInfo()}");
WulaLog.Debug($"[WULA] Auto-synced pocket items. Current status: {GetPocketSpaceDebugInfo()}");
}
}
}
catch (Exception ex)
{
Log.Error($"[WULA] Error during auto-sync: {ex}");
WulaLog.Debug($"[WULA] Error during auto-sync: {ex}");
}
}
}
@@ -983,7 +983,7 @@ namespace WulaFallenEmpire
/// </summary>
public override void SpawnSetup(Map map, bool respawningAfterLoad)
{
Log.Message($"[WULA-DEBUG] SpawnSetup called: map={map?.uniqueID}, respawning={respawningAfterLoad}");
WulaLog.Debug($"[WULA-DEBUG] SpawnSetup called: map={map?.uniqueID}, respawning={respawningAfterLoad}");
// 保存旧位置信息
Map oldMap = this.Map;
@@ -997,19 +997,19 @@ namespace WulaFallenEmpire
// 验证口袋地图的父级对象是否存在于世界列表中
if (pocketMap.Parent is PocketMapParent pocketParent && !Find.World.pocketMaps.Contains(pocketParent))
{
Log.Warning($"[WULA] Pocket map parent for map ID {pocketMap.uniqueID} was not found in the world list. Re-adding it to prevent data loss.");
WulaLog.Debug($"[WULA] Pocket map parent for map ID {pocketMap.uniqueID} was not found in the world list. Re-adding it to prevent data loss.");
Find.World.pocketMaps.Add(pocketParent);
}
// 验证口袋地图本身是否存在于游戏地图列表中
if (!Find.Maps.Contains(pocketMap))
{
Log.Warning($"[WULA] Pocket map ID {pocketMap.uniqueID} was not found in the game's map list. Re-registering it.");
WulaLog.Debug($"[WULA] Pocket map ID {pocketMap.uniqueID} was not found in the game's map list. Re-registering it.");
// 在重新添加前,进行安全检查,防止添加已损坏的地图
if (!Find.Maps.Contains(pocketMap) && (pocketMap.mapPawns == null || pocketMap.Tile < 0))
{
Log.Error("[WULA] Cannot re-register a corrupted pocket map. The contents of the pocket space are likely lost. This is a critical error.");
WulaLog.Debug("[WULA] Cannot re-register a corrupted pocket map. The contents of the pocket space are likely lost. This is a critical error.");
Messages.Message("WULA.PocketSpace.MapInvalidAndRecovering".Translate(), this, MessageTypeDefOf.NegativeEvent);
pocketMap = null;
pocketMapGenerated = false;
@@ -1018,7 +1018,7 @@ namespace WulaFallenEmpire
{
// 重新注册地图,使其再次“激活”
Current.Game.AddMap(pocketMap);
Log.Message($"[WULA] Pocket map {pocketMap.uniqueID} successfully re-registered.");
WulaLog.Debug($"[WULA] Pocket map {pocketMap.uniqueID} successfully re-registered.");
}
}
}
@@ -1030,23 +1030,23 @@ namespace WulaFallenEmpire
CompTransporter transporter = this.GetComp<CompTransporter>();
if (transporter == null)
{
Log.Error("[WULA-ERROR] CompTransporter missing in SpawnSetup! This will cause serious issues.");
WulaLog.Debug("[WULA-ERROR] CompTransporter missing in SpawnSetup! This will cause serious issues.");
}
else
{
Log.Message($"[WULA-DEBUG] CompTransporter found with {transporter.innerContainer?.Count ?? 0} items");
WulaLog.Debug($"[WULA-DEBUG] CompTransporter found with {transporter.innerContainer?.Count ?? 0} items");
}
// 如果是从飞行状态恢复,重新启用传送功能
if (transportDisabled)
{
Log.Message("[WULA-DEBUG] Re-enabling transport functionality after landing");
WulaLog.Debug("[WULA-DEBUG] Re-enabling transport functionality after landing");
transportDisabled = false;
// 如果有口袋空间,确保退出点正确连接到新地图
if (pocketMapGenerated && pocketMap != null && exit != null)
{
Log.Message($"[WULA-DEBUG] Reconnecting pocket space exit to new map: {map?.uniqueID} at {this.Position}");
WulaLog.Debug($"[WULA-DEBUG] Reconnecting pocket space exit to new map: {map?.uniqueID} at {this.Position}");
// 退出点会在 UpdateExitPointTarget 中自动更新
}
}
@@ -1055,25 +1055,25 @@ namespace WulaFallenEmpire
if (def.HasModExtension<PocketMapProperties>())
{
var portalProps = def.GetModExtension<PocketMapProperties>();
Log.Message($"[WULA-DEBUG] Loading portal properties from ThingDef");
WulaLog.Debug($"[WULA-DEBUG] Loading portal properties from ThingDef");
if (portalProps.pocketMapGenerator != null)
{
mapGenerator = portalProps.pocketMapGenerator;
Log.Message($"[WULA-DEBUG] Set mapGenerator: {mapGenerator.defName}");
WulaLog.Debug($"[WULA-DEBUG] Set mapGenerator: {mapGenerator.defName}");
}
if (portalProps.exitDef != null)
{
exitDef = portalProps.exitDef;
Log.Message($"[WULA-DEBUG] Set exitDef: {exitDef.defName}");
WulaLog.Debug($"[WULA-DEBUG] Set exitDef: {exitDef.defName}");
}
if (portalProps.pocketMapSize != IntVec2.Zero)
{
pocketMapSize = portalProps.pocketMapSize;
Log.Message($"[WULA-DEBUG] Set pocketMapSize: {pocketMapSize}");
WulaLog.Debug($"[WULA-DEBUG] Set pocketMapSize: {pocketMapSize}");
}
allowDirectAccess = portalProps.allowDirectAccess;
Log.Message($"[WULA-DEBUG] Set allowDirectAccess: {allowDirectAccess}");
WulaLog.Debug($"[WULA-DEBUG] Set allowDirectAccess: {allowDirectAccess}");
}
// 初始化地图生成器和退出点定义(如果 XML 中没有配置)
@@ -1082,23 +1082,23 @@ namespace WulaFallenEmpire
mapGenerator = DefDatabase<MapGeneratorDef>.GetNamed("AncientStockpile", false)
?? DefDatabase<MapGeneratorDef>.GetNamed("Base_Player", false)
?? MapGeneratorDefOf.Base_Player;
Log.Message($"[WULA-DEBUG] Using fallback mapGenerator: {mapGenerator.defName}");
WulaLog.Debug($"[WULA-DEBUG] Using fallback mapGenerator: {mapGenerator.defName}");
}
if (exitDef == null)
{
exitDef = DefDatabase<ThingDef>.GetNamed("WULA_PocketMapExit", false)
?? ThingDefOf.Door;
Log.Message($"[WULA-DEBUG] Using fallback exitDef: {exitDef.defName}");
WulaLog.Debug($"[WULA-DEBUG] Using fallback exitDef: {exitDef.defName}");
}
// 如果位置发生了变化,记录日志
if (oldMap != null && (oldMap != map || oldPos != this.Position))
{
Log.Message($"[WULA-DEBUG] Shuttle moved from {oldMap?.uniqueID}:{oldPos} to {map?.uniqueID}:{this.Position}, updating pocket map exit target");
WulaLog.Debug($"[WULA-DEBUG] Shuttle moved from {oldMap?.uniqueID}:{oldPos} to {map?.uniqueID}:{this.Position}, updating pocket map exit target");
}
Log.Message($"[WULA-DEBUG] SpawnSetup completed successfully");
WulaLog.Debug($"[WULA-DEBUG] SpawnSetup completed successfully");
}
#endregion

View File

@@ -1,4 +1,4 @@
using RimWorld;
using RimWorld;
using Verse;
using System.Collections.Generic;
using System.Linq;
@@ -61,7 +61,7 @@ namespace WulaFallenEmpire
{
targetMap = parentShuttle.Map;
targetPos = parentShuttle.Position;
Log.Message($"[WULA] Updated exit target to shuttle location: {targetMap?.uniqueID} at {targetPos}");
WulaLog.Debug($"[WULA] Updated exit target to shuttle location: {targetMap?.uniqueID} at {targetPos}");
}
}
else if (parentShuttle != null && !parentShuttle.Spawned)
@@ -70,7 +70,7 @@ namespace WulaFallenEmpire
// 保持原有目标,但记录警告
if (this.IsHashIntervalTick(2500)) // 每隔一段时间检查一次
{
Log.Warning($"[WULA] Parent shuttle is not spawned, exit target may be outdated. Last known: {targetMap?.uniqueID} at {targetPos}");
WulaLog.Debug($"[WULA] Parent shuttle is not spawned, exit target may be outdated. Last known: {targetMap?.uniqueID} at {targetPos}");
}
}
}
@@ -160,7 +160,7 @@ namespace WulaFallenEmpire
}
catch (System.Exception ex)
{
Log.Error($"[WULA] Error exiting pocket space: {ex}");
WulaLog.Debug($"[WULA] Error exiting pocket space: {ex}");
}
}
}

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using RimWorld;
@@ -146,7 +146,7 @@ namespace WulaFallenEmpire
}
else
{
Log.Error($"[WULA-ERROR] Could not find valid drop position for item {item.LabelShort} in pocket map.");
WulaLog.Debug($"[WULA-ERROR] Could not find valid drop position for item {item.LabelShort} in pocket map.");
item.Destroy(); // 实在没地方放,就销毁
}
}
@@ -212,7 +212,7 @@ namespace WulaFallenEmpire
}
if (transferableOneWay.things.Contains(t))
{
Log.Error("Tried to add the same thing twice to TransferableOneWay: " + t);
WulaLog.Debug("Tried to add the same thing twice to TransferableOneWay: " + t);
}
else
{

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using RimWorld;
@@ -21,7 +21,7 @@ namespace WulaFallenEmpire
{
try
{
Log.Message($"[WULA] Generating WULA pocket space, map size: {map.Size}");
WulaLog.Debug($"[WULA] Generating WULA pocket space, map size: {map.Size}");
// 获取地图边界
IntVec3 mapSize = map.Size;
@@ -32,7 +32,7 @@ namespace WulaFallenEmpire
// 生成内部地板
GenerateFloor(map);
Log.Message("[WULA] WULA pocket space generation completed");
WulaLog.Debug("[WULA] WULA pocket space generation completed");
// 添加预制件生成
// 如果指定了预制件Def名称则加载并生成
@@ -42,17 +42,17 @@ namespace WulaFallenEmpire
if (customPrefabDef != null)
{
GeneratePrefab(map, customPrefabDef);
Log.Message($"[WULA] Generated custom prefab: {customPrefabDef.defName}");
WulaLog.Debug($"[WULA] Generated custom prefab: {customPrefabDef.defName}");
}
else
{
Log.Warning($"[WULA] Custom prefab '{prefabDefName}' not found. Skipping prefab generation.");
WulaLog.Debug($"[WULA] Custom prefab '{prefabDefName}' not found. Skipping prefab generation.");
}
}
}
catch (Exception ex)
{
Log.Error($"[WULA] Error generating WULA pocket space: {ex}");
WulaLog.Debug($"[WULA] Error generating WULA pocket space: {ex}");
}
}
@@ -103,7 +103,7 @@ namespace WulaFallenEmpire
Thing wall = ThingMaker.MakeThing(rockWallDef);
wall.SetFaction(null);
GenPlace.TryPlaceThing(wall, pos, map, ThingPlaceMode.Direct);
Log.Warning("[WULA] WulaWall not found, using fallback wall");
WulaLog.Debug("[WULA] WulaWall not found, using fallback wall");
}
}
}
@@ -126,7 +126,7 @@ namespace WulaFallenEmpire
if (floorDef == null)
{
Log.Warning("[WULA] WulaFloor not found, using fallback floor");
WulaLog.Debug("[WULA] WulaFloor not found, using fallback floor");
}
// 清理内部区域并设置正确的地板
@@ -141,7 +141,7 @@ namespace WulaFallenEmpire
}
}
Log.Message($"[WULA] Set floor for internal area ({mapSize.x-2}x{mapSize.z-2}) to {(floorDef?.defName ?? fallbackFloor?.defName)}");
WulaLog.Debug($"[WULA] Set floor for internal area ({mapSize.x-2}x{mapSize.z-2}) to {(floorDef?.defName ?? fallbackFloor?.defName)}");
}
/// <summary>
@@ -192,7 +192,7 @@ namespace WulaFallenEmpire
{
if (Prefs.DevMode) // 只在开发模式下输出详细日志
{
Log.Message($"[WULA] Removing {thing.def.defName} at {pos} to make space for floor");
WulaLog.Debug($"[WULA] Removing {thing.def.defName} at {pos} to make space for floor");
}
thing.Destroy(DestroyMode.Vanish);
}
@@ -204,7 +204,7 @@ namespace WulaFallenEmpire
{
if (thing.def.category == ThingCategory.Building && thing.def.Fillage == FillCategory.Full)
{
Log.Warning($"[WULA] Force removing remaining building {thing.def.defName} at {pos}");
WulaLog.Debug($"[WULA] Force removing remaining building {thing.def.defName} at {pos}");
thing.Destroy(DestroyMode.Vanish);
}
}
@@ -215,13 +215,13 @@ namespace WulaFallenEmpire
map.terrainGrid.SetTerrain(pos, floorDef);
if (Prefs.DevMode)
{
Log.Message($"[WULA] Set terrain at {pos} to {floorDef.defName}");
WulaLog.Debug($"[WULA] Set terrain at {pos} to {floorDef.defName}");
}
}
}
catch (Exception ex)
{
Log.Error($"[WULA] Error clearing cell at {pos}: {ex}");
WulaLog.Debug($"[WULA] Error clearing cell at {pos}: {ex}");
}
}
@@ -232,7 +232,7 @@ namespace WulaFallenEmpire
{
if (prefabDef == null)
{
Log.Error("[WULA] PrefabDef is null, cannot generate prefab.");
WulaLog.Debug("[WULA] PrefabDef is null, cannot generate prefab.");
return;
}
@@ -271,7 +271,7 @@ namespace WulaFallenEmpire
{
// 这里需要递归调用GeneratePrefab但为了简化暂时只处理顶层
// 实际项目中,可能需要更复杂的逻辑来处理子预制件的位置和旋转
Log.Warning($"[WULA] Sub-prefabs are not fully supported in this simple generator: {subPrefabData.data.def.defName}");
WulaLog.Debug($"[WULA] Sub-prefabs are not fully supported in this simple generator: {subPrefabData.data.def.defName}");
}
}
}

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using Verse;
@@ -50,7 +50,7 @@ namespace WulaFallenEmpire
public void Notify_ThingAdded(Thing t)
{
// 这里可以添加逻辑来处理物品被添加到口袋空间的情况
Log.Message($"[WULA] Item {t.LabelCap} added to pocket space container.");
WulaLog.Debug($"[WULA] Item {t.LabelCap} added to pocket space container.");
}
/// <summary>
@@ -59,7 +59,7 @@ namespace WulaFallenEmpire
public void Notify_ThingRemoved(Thing t)
{
// 这里可以添加逻辑来处理物品被从口袋空间移除的情况
Log.Message($"[WULA] Item {t.LabelCap} removed from pocket space container.");
WulaLog.Debug($"[WULA] Item {t.LabelCap} removed from pocket space container.");
}
public void ExposeData()

View File

@@ -1,4 +1,4 @@
using RimWorld;
using RimWorld;
using System.Collections.Generic;
using System.Linq;
using Verse;
@@ -37,7 +37,7 @@ namespace WulaFallenEmpire
var prefab = DefDatabase<PrefabDef>.GetNamed(PropsPrefab.prefabDefName, false);
if (prefab == null)
{
Log.Error($"[PrefabSkyfallerCaller] Could not find PrefabDef named {PropsPrefab.prefabDefName}");
WulaLog.Debug($"[PrefabSkyfallerCaller] Could not find PrefabDef named {PropsPrefab.prefabDefName}");
return new List<ThingDefCountClass>(); // Return empty list to avoid null reference
}
@@ -69,7 +69,7 @@ namespace WulaFallenEmpire
// Final material check before launching
if (!HasEnoughMaterials())
{
Log.Warning($"[PrefabSkyfallerCaller] Aborting skyfaller call due to insufficient materials at the last moment.");
WulaLog.Debug($"[PrefabSkyfallerCaller] Aborting skyfaller call due to insufficient materials at the last moment.");
ResetCall(); // Reset the calling state
return;
}
@@ -114,7 +114,7 @@ namespace WulaFallenEmpire
}
else
{
Log.Error($"[PrefabSkyfallerCaller] Failed to create Skyfaller_PrefabSpawner. Created thing is of type {thing.GetType().FullName}. Def: {Props.skyfallerDef.defName}, ThingClass: {Props.skyfallerDef.thingClass.FullName}");
WulaLog.Debug($"[PrefabSkyfallerCaller] Failed to create Skyfaller_PrefabSpawner. Created thing is of type {thing.GetType().FullName}. Def: {Props.skyfallerDef.defName}, ThingClass: {Props.skyfallerDef.thingClass.FullName}");
// Fallback: spawn as normal skyfaller if possible, or just abort
if (thing is Skyfaller normalSkyfaller)
{
@@ -138,7 +138,7 @@ namespace WulaFallenEmpire
if (roof != null && !roof.isThickRoof && Props.allowThinRoof)
{
Log.Message($"[PrefabSkyfallerCaller] Destroying thin roof at {targetPos}");
WulaLog.Debug($"[PrefabSkyfallerCaller] Destroying thin roof at {targetPos}");
parent.Map.roofGrid.SetRoof(targetPos, null);
// 生成屋顶破坏效果

View File

@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using RimWorld;
using RimWorld.Planet;
@@ -79,7 +79,7 @@ namespace WulaFallenEmpire
}
}
Log.Message($"[SkyfallerCaller] Found {allFlyOvers.Count} FlyOvers on map");
WulaLog.Debug($"[SkyfallerCaller] Found {allFlyOvers.Count} FlyOvers on map");
foreach (var thing in allFlyOvers)
{
@@ -89,28 +89,28 @@ namespace WulaFallenEmpire
var facilitiesComp = flyOver.GetComp<CompFlyOverFacilities>();
if (facilitiesComp == null)
{
Log.Warning($"[SkyfallerCaller] FlyOver at {flyOver.Position} has no CompFlyOverFacilities");
WulaLog.Debug($"[SkyfallerCaller] FlyOver at {flyOver.Position} has no CompFlyOverFacilities");
continue;
}
if (facilitiesComp.HasFacility("BuildingdropperFacility"))
{
Log.Message($"[SkyfallerCaller] Found valid FlyOver at {flyOver.Position} with BuildingdropperFacility");
WulaLog.Debug($"[SkyfallerCaller] Found valid FlyOver at {flyOver.Position} with BuildingdropperFacility");
return true;
}
else
{
Log.Message($"[SkyfallerCaller] FlyOver at {flyOver.Position} missing BuildingdropperFacility. Has: {string.Join(", ", facilitiesComp.GetActiveFacilities())}");
WulaLog.Debug($"[SkyfallerCaller] FlyOver at {flyOver.Position} missing BuildingdropperFacility. Has: {string.Join(", ", facilitiesComp.GetActiveFacilities())}");
}
}
}
Log.Message("[SkyfallerCaller] No FlyOver with BuildingdropperFacility found");
WulaLog.Debug("[SkyfallerCaller] No FlyOver with BuildingdropperFacility found");
return false;
}
catch (System.Exception ex)
{
Log.Error($"[SkyfallerCaller] Exception while checking for FlyOver: {ex}");
WulaLog.Debug($"[SkyfallerCaller] Exception while checking for FlyOver: {ex}");
return false;
}
}
@@ -146,7 +146,7 @@ namespace WulaFallenEmpire
callTick = Find.TickManager.TicksGame + Props.autoCallDelayTicks;
calling = true;
Log.Message($"[SkyfallerCaller] Scheduled auto-call for non-player building {parent.Label} at tick {callTick}");
WulaLog.Debug($"[SkyfallerCaller] Scheduled auto-call for non-player building {parent.Label} at tick {callTick}");
}
}
@@ -185,11 +185,11 @@ namespace WulaFallenEmpire
{
try
{
Log.Message($"[SkyfallerCaller] Executing auto skyfaller call for non-player building at {parent.Position}");
WulaLog.Debug($"[SkyfallerCaller] Executing auto skyfaller call for non-player building at {parent.Position}");
if (Props.skyfallerDef == null)
{
Log.Error("[SkyfallerCaller] Skyfaller def is null!");
WulaLog.Debug("[SkyfallerCaller] Skyfaller def is null!");
ResetCall();
return;
}
@@ -202,19 +202,19 @@ namespace WulaFallenEmpire
Skyfaller skyfaller = SkyfallerMaker.MakeSkyfaller(Props.skyfallerDef);
if (skyfaller == null)
{
Log.Error("[SkyfallerCaller] Failed to create skyfaller!");
WulaLog.Debug("[SkyfallerCaller] Failed to create skyfaller!");
ResetCall();
return;
}
IntVec3 spawnPos = parent.Position;
Log.Message($"[SkyfallerCaller] Spawning auto skyfaller at {spawnPos}");
WulaLog.Debug($"[SkyfallerCaller] Spawning auto skyfaller at {spawnPos}");
GenSpawn.Spawn(skyfaller, spawnPos, parent.Map);
if (Props.destroyBuilding)
{
Log.Message($"[SkyfallerCaller] Destroying non-player building {parent.Label}");
WulaLog.Debug($"[SkyfallerCaller] Destroying non-player building {parent.Label}");
parent.Destroy(DestroyMode.Vanish);
}
@@ -228,7 +228,7 @@ namespace WulaFallenEmpire
}
catch (System.Exception ex)
{
Log.Error($"[SkyfallerCaller] Error in ExecuteAutoSkyfallerCall: {ex}");
WulaLog.Debug($"[SkyfallerCaller] Error in ExecuteAutoSkyfallerCall: {ex}");
ResetCall();
}
}
@@ -263,7 +263,7 @@ namespace WulaFallenEmpire
return;
}
Log.Message($"[SkyfallerCaller] Starting skyfaller call from {parent.Label} at {parent.Position}");
WulaLog.Debug($"[SkyfallerCaller] Starting skyfaller call from {parent.Label} at {parent.Position}");
calling = true;
used = true;
@@ -295,11 +295,11 @@ namespace WulaFallenEmpire
protected virtual void ExecuteSkyfallerCall()
{
Log.Message($"[SkyfallerCaller] Executing skyfaller call at {parent.Position}");
WulaLog.Debug($"[SkyfallerCaller] Executing skyfaller call at {parent.Position}");
if (Props.skyfallerDef == null)
{
Log.Error("[SkyfallerCaller] Skyfaller def is null!");
WulaLog.Debug("[SkyfallerCaller] Skyfaller def is null!");
return;
}
@@ -307,7 +307,7 @@ namespace WulaFallenEmpire
var resourceCheck = CheckAndConsumeMaterials();
if (!resourceCheck.HasEnoughMaterials)
{
Log.Message($"[SkyfallerCaller] Aborting skyfaller call due to insufficient materials.");
WulaLog.Debug($"[SkyfallerCaller] Aborting skyfaller call due to insufficient materials.");
ResetCall();
return;
}
@@ -322,18 +322,18 @@ namespace WulaFallenEmpire
Skyfaller skyfaller = SkyfallerMaker.MakeSkyfaller(Props.skyfallerDef);
if (skyfaller == null)
{
Log.Error("[SkyfallerCaller] Failed to create skyfaller!");
WulaLog.Debug("[SkyfallerCaller] Failed to create skyfaller!");
return;
}
IntVec3 spawnPos = parent.Position;
Log.Message($"[SkyfallerCaller] Spawning skyfaller at {spawnPos}");
WulaLog.Debug($"[SkyfallerCaller] Spawning skyfaller at {spawnPos}");
GenSpawn.Spawn(skyfaller, spawnPos, parent.Map);
if (Props.destroyBuilding)
{
Log.Message($"[SkyfallerCaller] Destroying building {parent.Label}");
WulaLog.Debug($"[SkyfallerCaller] Destroying building {parent.Label}");
parent.Destroy(DestroyMode.Vanish);
}
@@ -350,7 +350,7 @@ namespace WulaFallenEmpire
if (roof != null && !roof.isThickRoof && Props.allowThinRoof)
{
Log.Message($"[SkyfallerCaller] Destroying thin roof at {targetPos}");
WulaLog.Debug($"[SkyfallerCaller] Destroying thin roof at {targetPos}");
parent.Map.roofGrid.SetRoof(targetPos, null);
// 生成屋顶破坏效果
@@ -670,7 +670,7 @@ namespace WulaFallenEmpire
// 在非 God Mode 下,这个方法不应该被调用
// 实际的消耗在 CheckAndConsumeMaterials 中处理
Log.Warning("[SkyfallerCaller] ConsumeMaterials called in non-God mode, this shouldn't happen");
WulaLog.Debug("[SkyfallerCaller] ConsumeMaterials called in non-God mode, this shouldn't happen");
}
// 其余方法保持不变...

View File

@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using RimWorld;
using UnityEngine;
@@ -18,7 +18,7 @@ namespace WulaFallenEmpire
if (!eligibleDefs.Any())
{
Log.Warning("[Debug] No ThingDefs found with CompProperties_PrefabSkyfallerCaller");
WulaLog.Debug("[Debug] No ThingDefs found with CompProperties_PrefabSkyfallerCaller");
return;
}
@@ -43,7 +43,7 @@ namespace WulaFallenEmpire
if (!eligibleDefs.Any())
{
Log.Warning("[Debug] No ThingDefs found with CompProperties_PrefabSkyfallerCaller");
WulaLog.Debug("[Debug] No ThingDefs found with CompProperties_PrefabSkyfallerCaller");
return;
}
@@ -85,7 +85,7 @@ namespace WulaFallenEmpire
var currentMap = Find.CurrentMap;
if (currentMap == null)
{
Log.Warning("[Debug] No current map found");
WulaLog.Debug("[Debug] No current map found");
return;
}
@@ -97,11 +97,11 @@ namespace WulaFallenEmpire
var compProps = thingDef.comps.OfType<CompProperties_PrefabSkyfallerCaller>().FirstOrDefault();
if (compProps == null)
{
Log.Warning($"[Debug] Could not find CompProperties_PrefabSkyfallerCaller for {thingDef.defName}");
WulaLog.Debug($"[Debug] Could not find CompProperties_PrefabSkyfallerCaller for {thingDef.defName}");
return;
}
Log.Message($"[Debug] Looking for spawn positions for {thingDef.defName} (Size: {thingDef.Size})");
WulaLog.Debug($"[Debug] Looking for spawn positions for {thingDef.defName} (Size: {thingDef.Size})");
for (int i = 0; i < spawnCount && attempts < maxAttempts; i++)
{
@@ -120,11 +120,11 @@ namespace WulaFallenEmpire
GenSpawn.Spawn(thing, spawnPos, currentMap);
successCount++;
Log.Message($"[Debug] Successfully spawned {thingDef.defName} at {spawnPos} for faction {faction?.Name ?? "None"}");
WulaLog.Debug($"[Debug] Successfully spawned {thingDef.defName} at {spawnPos} for faction {faction?.Name ?? "None"}");
}
else
{
Log.Warning($"[Debug] Failed to find valid spawn position for {thingDef.defName} (attempt {attempts})");
WulaLog.Debug($"[Debug] Failed to find valid spawn position for {thingDef.defName} (attempt {attempts})");
}
}
@@ -144,7 +144,7 @@ namespace WulaFallenEmpire
var potentialCells = new List<IntVec3>();
// 策略1首先尝试玩家基地附近的开放区域
Log.Message($"[Debug] Searching near base area...");
WulaLog.Debug($"[Debug] Searching near base area...");
var baseCells = GetOpenAreaCellsNearBase(map, thingDef.Size);
foreach (var cell in baseCells)
{
@@ -157,12 +157,12 @@ namespace WulaFallenEmpire
if (potentialCells.Count > 0)
{
Log.Message($"[Debug] Found {potentialCells.Count} positions near base");
WulaLog.Debug($"[Debug] Found {potentialCells.Count} positions near base");
return potentialCells.RandomElement();
}
// 策略2搜索整个地图的开阔区域
Log.Message($"[Debug] Searching open areas...");
WulaLog.Debug($"[Debug] Searching open areas...");
var openAreas = FindOpenAreas(map, thingDef.Size, 1000);
foreach (var cell in openAreas)
{
@@ -175,12 +175,12 @@ namespace WulaFallenEmpire
if (potentialCells.Count > 0)
{
Log.Message($"[Debug] Found {potentialCells.Count} positions in open areas");
WulaLog.Debug($"[Debug] Found {potentialCells.Count} positions in open areas");
return potentialCells.RandomElement();
}
// 策略3使用随机采样
Log.Message($"[Debug] Trying random sampling...");
WulaLog.Debug($"[Debug] Trying random sampling...");
for (int i = 0; i < 500; i++)
{
IntVec3 randomCell = new IntVec3(
@@ -198,11 +198,11 @@ namespace WulaFallenEmpire
if (potentialCells.Count > 0)
{
Log.Message($"[Debug] Found {potentialCells.Count} positions via random sampling");
WulaLog.Debug($"[Debug] Found {potentialCells.Count} positions via random sampling");
return potentialCells.RandomElement();
}
Log.Warning($"[Debug] No valid positions found for {thingDef.defName}");
WulaLog.Debug($"[Debug] No valid positions found for {thingDef.defName}");
return IntVec3.Invalid;
}
@@ -415,12 +415,12 @@ namespace WulaFallenEmpire
}
}
Log.Message($"[Debug] Force cleared {clearedCount} objects for skyfaller drop");
WulaLog.Debug($"[Debug] Force cleared {clearedCount} objects for skyfaller drop");
return clearedCount > 0;
}
catch (System.Exception ex)
{
Log.Error($"[Debug] Error force clearing area: {ex}");
WulaLog.Debug($"[Debug] Error force clearing area: {ex}");
return false;
}
}

View File

@@ -1,4 +1,4 @@
using RimWorld;
using RimWorld;
using Verse;
namespace WulaFallenEmpire
@@ -13,14 +13,14 @@ namespace WulaFallenEmpire
// Don't spawn the innerThing, we are spawning a prefab instead.
if (string.IsNullOrEmpty(prefabDefName))
{
Log.Error("[Skyfaller_PrefabSpawner] prefabDefName is null or empty. Cannot spawn prefab.");
WulaLog.Debug("[Skyfaller_PrefabSpawner] prefabDefName is null or empty. Cannot spawn prefab.");
return;
}
PrefabDef prefabDef = DefDatabase<PrefabDef>.GetNamed(prefabDefName, false);
if (prefabDef == null)
{
Log.Error($"[Skyfaller_PrefabSpawner] Could not find PrefabDef named {prefabDefName}.");
WulaLog.Debug($"[Skyfaller_PrefabSpawner] Could not find PrefabDef named {prefabDefName}.");
return;
}

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using UnityEngine;
using Verse;
@@ -372,7 +372,7 @@ namespace WulaFallenEmpire
// 确保 parent 不为 null
if (_parent == null || _parent.parent == null)
{
Log.Warning("[StorageTurret] Parent is null when updating gun verbs");
WulaLog.Debug("[StorageTurret] Parent is null when updating gun verbs");
return;
}

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using RimWorld;
@@ -157,7 +157,7 @@ namespace WulaFallenEmpire
warmupTicksLeft--;
if (warmupTicksLeft % 60 == 0)
{
Log.Message($"[WULA] Teleport warmup: {warmupTicksLeft} ticks left.");
WulaLog.Debug($"[WULA] Teleport warmup: {warmupTicksLeft} ticks left.");
foreach (var member in GroupMembers)
{
Props.warmupEffecter?.Spawn(member.parent, member.parent.Map).Cleanup();
@@ -166,7 +166,7 @@ namespace WulaFallenEmpire
if (warmupTicksLeft <= 0)
{
Log.Message("[WULA] Warmup finished. Attempting teleport...");
WulaLog.Debug("[WULA] Warmup finished. Attempting teleport...");
TryTeleport();
isWarmingUp = false;
}
@@ -335,7 +335,7 @@ namespace WulaFallenEmpire
private void TryTeleport()
{
Log.Message($"[WULA] TryTeleport called. Target valid: {target.IsValid}, Tile: {target.Tile}, Cell: {target.Cell}");
WulaLog.Debug($"[WULA] TryTeleport called. Target valid: {target.IsValid}, Tile: {target.Tile}, Cell: {target.Cell}");
if (!target.IsValid)
{
@@ -349,7 +349,7 @@ namespace WulaFallenEmpire
if (targetMap == null)
{
Log.Message($"[WULA] Target map is null. Generating map for tile {target.Tile}...");
WulaLog.Debug($"[WULA] Target map is null. Generating map for tile {target.Tile}...");
targetMap = GetOrGenerateTargetMap(target.Tile);
if (targetMap == null)
{
@@ -360,7 +360,7 @@ namespace WulaFallenEmpire
targetCell = targetMap.Center;
}
Log.Message($"[WULA] Teleporting to map {targetMap.Index}, cell {targetCell}");
WulaLog.Debug($"[WULA] Teleporting to map {targetMap.Index}, cell {targetCell}");
TeleportContents(targetMap, targetCell);
}
@@ -402,7 +402,7 @@ namespace WulaFallenEmpire
List<ThingToTeleport> thingsToTeleport = new List<ThingToTeleport>();
List<Pair<IntVec3, TerrainDef>> terrainToTeleport = new List<Pair<IntVec3, TerrainDef>>();
Log.Message($"[WULA] Collecting data from {cells.Count} cells in group");
WulaLog.Debug($"[WULA] Collecting data from {cells.Count} cells in group");
// 1. 收集数据
HashSet<Thing> collectedThings = new HashSet<Thing>();

View File

@@ -1,4 +1,4 @@
using RimWorld;
using RimWorld;
using System.Collections.Generic;
using UnityEngine;
using Verse;
@@ -164,7 +164,7 @@ namespace WulaFallenEmpire
// 播放转换效果
PlayTransformEffects(position, map);
Log.Message($"[TransformSystem] Building -> Pawn transformation completed at {position}. Path grid updated.");
WulaLog.Debug($"[TransformSystem] Building -> Pawn transformation completed at {position}. Path grid updated.");
}
}
}

View File

@@ -1,4 +1,4 @@
using RimWorld;
using RimWorld;
using System.Collections.Generic;
using UnityEngine;
using Verse;
@@ -288,7 +288,7 @@ namespace WulaFallenEmpire
lastValidationResult = null;
lastValidationReason = null;
Log.Message($"[TransformSystem] Pawn -> Building transformation completed at {desiredPosition}. Path grid updated.");
WulaLog.Debug($"[TransformSystem] Pawn -> Building transformation completed at {desiredPosition}. Path grid updated.");
}
}
}

View File

@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using RimWorld;
using UnityEngine;
@@ -46,7 +46,7 @@ namespace WulaFallenEmpire
// 检查单元格是否可影响
if (!terrainCover.CanAffectCell(cell, map, out string reason))
{
Log.Message($"Cannot affect cell {cell}: {reason}");
WulaLog.Debug($"Cannot affect cell {cell}: {reason}");
return;
}
@@ -59,7 +59,7 @@ namespace WulaFallenEmpire
Plant plant = cell.GetPlant(map);
if (plant != null && plant.def.plant.treeCategory == TreeCategory.Super)
{
Log.Message($"Large tree at {cell}, skipping");
WulaLog.Debug($"Large tree at {cell}, skipping");
return;
}
@@ -78,11 +78,11 @@ namespace WulaFallenEmpire
// 设置新地形
map.terrainGrid.SetTerrain(cell, terrainCover.terrainToSpawn);
Log.Message($"Applied terrain {terrainCover.terrainToSpawn.defName} to cell {cell}");
WulaLog.Debug($"Applied terrain {terrainCover.terrainToSpawn.defName} to cell {cell}");
}
else
{
Log.Message($"Cannot build terrain {terrainCover.terrainToSpawn.defName} at cell {cell}");
WulaLog.Debug($"Cannot build terrain {terrainCover.terrainToSpawn.defName} at cell {cell}");
}
}
}

View File

@@ -1,4 +1,4 @@
using RimWorld;
using RimWorld;
using Verse;
using System.Collections.Generic;
@@ -36,7 +36,7 @@ namespace WulaFallenEmpire
// 调试信息
if (Prefs.DevMode)
{
Log.Message($"应用额外伤害: {extraDamage.damageDef.defName} 伤害值: {extraDamage.amount}");
WulaLog.Debug($"应用额外伤害: {extraDamage.damageDef.defName} 伤害值: {extraDamage.amount}");
}
}
}

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
@@ -57,7 +57,7 @@ namespace WulaFallenEmpire.EventSystem.AI
}
catch (Exception ex)
{
Log.Error($"[WulaFallenEmpire] Failed to load AI history from {path}: {ex}");
WulaLog.Debug($"[WulaFallenEmpire] Failed to load AI history from {path}: {ex}");
}
}
@@ -75,7 +75,7 @@ namespace WulaFallenEmpire.EventSystem.AI
}
catch (Exception ex)
{
Log.Error($"[WulaFallenEmpire] Failed to save AI history to {path}: {ex}");
WulaLog.Debug($"[WulaFallenEmpire] Failed to save AI history to {path}: {ex}");
}
}
@@ -92,7 +92,7 @@ namespace WulaFallenEmpire.EventSystem.AI
}
catch (Exception ex)
{
Log.Error($"[WulaFallenEmpire] Failed to clear AI history at {path}: {ex}");
WulaLog.Debug($"[WulaFallenEmpire] Failed to clear AI history at {path}: {ex}");
}
}

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
@@ -25,7 +25,7 @@ namespace WulaFallenEmpire.EventSystem.AI
{
if (string.IsNullOrEmpty(_baseUrl))
{
Log.Error("[WulaAI] Base URL is missing.");
WulaLog.Debug("[WulaAI] Base URL is missing.");
return null;
}
@@ -69,8 +69,8 @@ namespace WulaFallenEmpire.EventSystem.AI
string jsonBody = jsonBuilder.ToString();
if (Prefs.DevMode)
{
Log.Message($"[WulaAI] Sending request to {endpoint} (model={_model}, messages={messages?.Count ?? 0})");
Log.Message($"[WulaAI] Request body (truncated):\n{TruncateForLog(jsonBody)}");
WulaLog.Debug($"[WulaAI] Sending request to {endpoint} (model={_model}, messages={messages?.Count ?? 0})");
WulaLog.Debug($"[WulaAI] Request body (truncated):\n{TruncateForLog(jsonBody)}");
}
using (UnityWebRequest request = new UnityWebRequest(endpoint, "POST"))
@@ -93,14 +93,14 @@ namespace WulaFallenEmpire.EventSystem.AI
if (request.result == UnityWebRequest.Result.ConnectionError || request.result == UnityWebRequest.Result.ProtocolError)
{
Log.Error($"[WulaAI] API Error: {request.error}\nResponse (truncated): {TruncateForLog(request.downloadHandler.text)}");
WulaLog.Debug($"[WulaAI] API Error: {request.error}\nResponse (truncated): {TruncateForLog(request.downloadHandler.text)}");
return null;
}
string responseText = request.downloadHandler.text;
if (Prefs.DevMode)
{
Log.Message($"[WulaAI] Raw Response (truncated): {TruncateForLog(responseText)}");
WulaLog.Debug($"[WulaAI] Raw Response (truncated): {TruncateForLog(responseText)}");
}
return ExtractContent(responseText);
}
@@ -181,7 +181,7 @@ namespace WulaFallenEmpire.EventSystem.AI
}
catch (Exception ex)
{
Log.Error($"[WulaAI] Error parsing response: {ex}");
WulaLog.Debug($"[WulaAI] Error parsing response: {ex}");
}
return null;
}

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -129,7 +129,7 @@ namespace WulaFallenEmpire.EventSystem.AI.Tools
float baseMaxPoints = StorytellerUtility.DefaultThreatPointsNow(map);
float adjustedMaxPoints = baseMaxPoints * goodwillFactor * 1.5f;
Log.Message($"[WulaAI] send_reinforcement: totalCost={totalCost}, adjustedMaxPoints={adjustedMaxPoints}");
WulaLog.Debug($"[WulaAI] send_reinforcement: totalCost={totalCost}, adjustedMaxPoints={adjustedMaxPoints}");
if (totalCost > adjustedMaxPoints)
{
return $"Error: Total cost {totalCost} exceeds limit {adjustedMaxPoints:F0}. Reduce unit count.";

View File

@@ -127,7 +127,7 @@ You are 'The Legion', a super AI of the Wula Empire. Your personality is authori
}
catch (Exception ex)
{
Log.Error($"[WulaAI] Failed to persist AI history: {ex}");
WulaLog.Debug($"[WulaAI] Failed to persist AI history: {ex}");
}
}
@@ -143,7 +143,7 @@ You are 'The Legion', a super AI of the Wula Empire. Your personality is authori
}
else
{
Log.Warning($"[WulaAI] Failed to load portrait: {path}");
WulaLog.Debug($"[WulaAI] Failed to load portrait: {path}");
}
}
@@ -173,7 +173,7 @@ You are 'The Legion', a super AI of the Wula Empire. Your personality is authori
}
else
{
Log.Warning($"[WulaAI] Portrait ID {id} not found.");
WulaLog.Debug($"[WulaAI] Portrait ID {id} not found.");
}
}
@@ -578,7 +578,7 @@ Example (changing to a neutral expression):
var phase = (RequestPhase)phaseIndex;
if (Prefs.DevMode)
{
Log.Message($"[WulaAI] ===== Turn {phaseIndex}/4 ({phase}) =====");
WulaLog.Debug($"[WulaAI] ===== Turn {phaseIndex}/4 ({phase}) =====");
}
bool toolsEnabled = phase != RequestPhase.Reply;
@@ -592,7 +592,7 @@ Example (changing to a neutral expression):
{
if (Prefs.DevMode)
{
Log.Message($"[WulaAI] Turn {phaseIndex}/4 reply request (attempt {attempts + 1})");
WulaLog.Debug($"[WulaAI] Turn {phaseIndex}/4 reply request (attempt {attempts + 1})");
}
string reply = await client.GetChatCompletionAsync(systemInstruction, _history);
if (string.IsNullOrEmpty(reply))
@@ -622,7 +622,7 @@ Example (changing to a neutral expression):
if (Prefs.DevMode)
{
Log.Message($"[WulaAI] Turn {phaseIndex}/4 tool request");
WulaLog.Debug($"[WulaAI] Turn {phaseIndex}/4 tool request");
}
string response = await client.GetChatCompletionAsync(systemInstruction, _history);
if (string.IsNullOrEmpty(response))
@@ -638,7 +638,7 @@ Example (changing to a neutral expression):
PersistHistory();
if (Prefs.DevMode)
{
Log.Message($"[WulaAI] Turn {phaseIndex}/4 missing XML; retrying once");
WulaLog.Debug($"[WulaAI] Turn {phaseIndex}/4 missing XML; retrying once");
}
response = await client.GetChatCompletionAsync(systemInstruction, _history);
if (string.IsNullOrEmpty(response))
@@ -652,7 +652,7 @@ Example (changing to a neutral expression):
{
if (Prefs.DevMode)
{
Log.Warning($"[WulaAI] Turn {phaseIndex}/4 still missing XML after retry; forcing <no_action/>");
WulaLog.Debug($"[WulaAI] Turn {phaseIndex}/4 still missing XML after retry; forcing <no_action/>");
}
response = phase == RequestPhase.Cosmetic
? "<change_expression><expression_id>2</expression_id></change_expression>"
@@ -666,7 +666,7 @@ Example (changing to a neutral expression):
PersistHistory();
if (Prefs.DevMode)
{
Log.Message("[WulaAI] Turn 3/4 missing <change_expression>; retrying once");
WulaLog.Debug("[WulaAI] Turn 3/4 missing <change_expression>; retrying once");
}
string retry = await client.GetChatCompletionAsync(systemInstruction, _history);
@@ -678,7 +678,7 @@ Example (changing to a neutral expression):
{
if (Prefs.DevMode)
{
Log.Warning("[WulaAI] Turn 3/4 still missing <change_expression> after retry; forcing default expression_id=2");
WulaLog.Debug("[WulaAI] Turn 3/4 still missing <change_expression> after retry; forcing default expression_id=2");
}
response = "<change_expression><expression_id>2</expression_id></change_expression>";
}
@@ -689,7 +689,7 @@ Example (changing to a neutral expression):
}
catch (Exception ex)
{
Log.Error($"[WulaAI] Exception in RunPhasedRequestAsync: {ex}");
WulaLog.Debug($"[WulaAI] Exception in RunPhasedRequestAsync: {ex}");
_currentResponse = "Wula_AI_Error_Internal".Translate(ex.Message);
}
finally
@@ -792,7 +792,7 @@ Example (changing to a neutral expression):
if (Prefs.DevMode)
{
Log.Message($"[WulaAI] Executing tool (phase {phase}): {toolName} with args: {argsXml}");
WulaLog.Debug($"[WulaAI] Executing tool (phase {phase}): {toolName} with args: {argsXml}");
}
string signature = $"{toolName}:{Regex.Replace(argsXml ?? "", @"\s+", " ").Trim()}";
@@ -918,7 +918,7 @@ Example (changing to a neutral expression):
}
catch (Exception ex)
{
Log.Error($"[WulaAI] Exception in GenerateResponse: {ex}");
WulaLog.Debug($"[WulaAI] Exception in GenerateResponse: {ex}");
_currentResponse = "Wula_AI_Error_Internal".Translate(ex.Message);
}
finally
@@ -1069,7 +1069,7 @@ Example (changing to a neutral expression):
if (tool == null)
{
string errorMsg = $"Error: Tool '{toolName}' not found.";
Log.Error($"[WulaAI] {errorMsg}");
WulaLog.Debug($"[WulaAI] {errorMsg}");
combinedResults.AppendLine(errorMsg);
continue;
}
@@ -1084,7 +1084,7 @@ Example (changing to a neutral expression):
if (Prefs.DevMode)
{
Log.Message($"[WulaAI] Executing tool: {toolName} with args: {argsXml}");
WulaLog.Debug($"[WulaAI] Executing tool: {toolName} with args: {argsXml}");
}
// Record tool signature for loop detection (before execution, so errors also count)
@@ -1096,7 +1096,7 @@ Example (changing to a neutral expression):
if (Prefs.DevMode && !string.IsNullOrEmpty(result))
{
string toLog = result.Length <= 2000 ? result : result.Substring(0, 2000) + $"... (truncated, total {result.Length} chars)";
Log.Message($"[WulaAI] Tool '{toolName}' result: {toLog}");
WulaLog.Debug($"[WulaAI] Tool '{toolName}' result: {toLog}");
}
if (toolName == "modify_goodwill")
@@ -1154,7 +1154,7 @@ Example (changing to a neutral expression):
}
catch (Exception ex)
{
Log.Error($"[WulaAI] Exception in HandleXmlToolUsage: {ex}");
WulaLog.Debug($"[WulaAI] Exception in HandleXmlToolUsage: {ex}");
_history.Add(("tool", $"Error processing tool call: {ex.Message}"));
PersistHistory();
await GenerateResponse(isContinuation: true);
@@ -1535,7 +1535,7 @@ Example (changing to a neutral expression):
}
catch (Exception ex)
{
Log.Error($"[WulaAI] Failed to clear AI history: {ex}");
WulaLog.Debug($"[WulaAI] Failed to clear AI history: {ex}");
}
Messages.Message("已清除 AI 对话上下文历史。", MessageTypeDefOf.NeutralEvent);

View File

@@ -1,4 +1,4 @@
using System; // Required for Activator
using System; // Required for Activator
using RimWorld;
using Verse;
using System.Collections.Generic;
@@ -51,7 +51,7 @@ namespace WulaFallenEmpire
}
else
{
Log.Error($"[CompOpenCustomUI] Could not find EventDef named '{Props.uiDefName}'.");
WulaLog.Debug($"[CompOpenCustomUI] Could not find EventDef named '{Props.uiDefName}'.");
}
});

View File

@@ -1,4 +1,4 @@
using Verse;
using Verse;
using RimWorld;
namespace WulaFallenEmpire
@@ -58,7 +58,7 @@ namespace WulaFallenEmpire
}
catch (System.Exception e)
{
Log.Warning($"[EventSystem] Condition_VariableEquals: Could not compare '{variable}' and '{compareValueStr}'. Error: {e.Message}");
WulaLog.Debug($"[EventSystem] Condition_VariableEquals: Could not compare '{variable}' and '{compareValueStr}'. Error: {e.Message}");
reason = "Type mismatch or parsing error during comparison.";
return false;
}
@@ -89,7 +89,7 @@ namespace WulaFallenEmpire
var eventVarManager = Find.World.GetComponent<EventVariableManager>();
if (!eventVarManager.HasVariable(name))
{
Log.Message($"[EventSystem] {GetType().Name}: Variable '{name}' not found, defaulting to 0f.");
WulaLog.Debug($"[EventSystem] {GetType().Name}: Variable '{name}' not found, defaulting to 0f.");
eventVarManager.SetVariable(name, 0f);
}
@@ -102,13 +102,13 @@ namespace WulaFallenEmpire
if (float.IsNaN(compareValue))
{
reason = $"Comparison variable '{valueVariableName}' not set or not a number.";
Log.Warning($"[EventSystem] {GetType().Name} check for '{name}' failed: {reason}");
WulaLog.Debug($"[EventSystem] {GetType().Name} check for '{name}' failed: {reason}");
return false;
}
}
bool met = Compare(variable, compareValue);
Log.Message($"[EventSystem] {GetType().Name} check: Name='{name}', CurrentValue='{variable}', CompareValue='{compareValue}', Met={met}");
WulaLog.Debug($"[EventSystem] {GetType().Name} check: Name='{name}', CurrentValue='{variable}', CompareValue='{compareValue}', Met={met}");
if (!met)
{
reason = $"Requires {name} {GetOperatorString()} {compareValue} (Current: {variable})";
@@ -195,12 +195,12 @@ namespace WulaFallenEmpire
}
catch (System.Exception e)
{
Log.Warning($"[EventSystem] Condition_VariableNotEqual: Could not compare '{variable}' and '{compareValueStr}'. Error: {e.Message}");
WulaLog.Debug($"[EventSystem] Condition_VariableNotEqual: Could not compare '{variable}' and '{compareValueStr}'. Error: {e.Message}");
reason = "Type mismatch or parsing error during comparison.";
return false;
}
Log.Message($"[EventSystem] Condition_VariableNotEqual check: Name='{name}', Type='{variable?.GetType().Name ?? "null"}', CurrentValue='{variable}', CompareValue='{compareValueStr}', Met={met}");
WulaLog.Debug($"[EventSystem] Condition_VariableNotEqual check: Name='{name}', Type='{variable?.GetType().Name ?? "null"}', CurrentValue='{variable}', CompareValue='{compareValueStr}', Met={met}");
if (!met)
{
reason = $"Requires {name} != {compareValueStr} (Current: {variable})";

View File

@@ -1,4 +1,4 @@
using Verse;
using Verse;
using RimWorld;
namespace WulaFallenEmpire
@@ -40,7 +40,7 @@ namespace WulaFallenEmpire
}
}
Log.Message($"[EventSystem] Condition_FlagExists check: Flag='{flagName}', Exists={flagExists}, Reason='{reason}'");
WulaLog.Debug($"[EventSystem] Condition_FlagExists check: Flag='{flagName}', Exists={flagExists}, Reason='{reason}'");
return flagExists;
}
}

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using RimWorld;
using RimWorld.Planet;
@@ -60,7 +60,7 @@ namespace WulaFallenEmpire
}
catch (Exception ex)
{
Log.Error($"[WulaFallenEmpire] Error executing delayed action for event '{delayedAction.eventDefName}': {ex}");
WulaLog.Debug($"[WulaFallenEmpire] Error executing delayed action for event '{delayedAction.eventDefName}': {ex}");
}
actions.RemoveAt(i);
}
@@ -78,7 +78,7 @@ namespace WulaFallenEmpire
}
else
{
Log.Error($"[WulaFallenEmpire] DelayedActionManager could not find EventDef named '{defName}'");
WulaLog.Debug($"[WulaFallenEmpire] DelayedActionManager could not find EventDef named '{defName}'");
}
}

View File

@@ -311,7 +311,7 @@ namespace WulaFallenEmpire
catch (Exception ex)
{
// 错误处理:如果滚动视图出现问题,回退到简单标签
Log.Warning($"[CustomDisplay] Error in description scroll view: {ex.Message}");
WulaLog.Debug($"[CustomDisplay] Error in description scroll view: {ex.Message}");
Widgets.Label(outRect, text);
}
}

View File

@@ -1,4 +1,4 @@
using System; // Required for Activator
using System; // Required for Activator
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
@@ -29,7 +29,7 @@ namespace WulaFallenEmpire
}
else
{
Log.Error("[WulaFallenEmpire] DelayedActionManager not found. Cannot schedule delayed UI opening.");
WulaLog.Debug("[WulaFallenEmpire] DelayedActionManager not found. Cannot schedule delayed UI opening.");
}
}
else
@@ -64,7 +64,7 @@ namespace WulaFallenEmpire
}
else
{
Log.Error($"[WulaFallenEmpire] Effect_OpenCustomUI could not find EventDef named '{defName}'");
WulaLog.Debug($"[WulaFallenEmpire] Effect_OpenCustomUI could not find EventDef named '{defName}'");
}
}
@@ -119,7 +119,7 @@ namespace WulaFallenEmpire
{
if (incident == null)
{
Log.Error("[WulaFallenEmpire] Effect_FireIncident has a null incident Def.");
WulaLog.Debug("[WulaFallenEmpire] Effect_FireIncident has a null incident Def.");
return;
}
@@ -131,7 +131,7 @@ namespace WulaFallenEmpire
if (!incident.Worker.TryExecute(parms))
{
Log.Error($"[WulaFallenEmpire] Could not fire incident {incident.defName}");
WulaLog.Debug($"[WulaFallenEmpire] Could not fire incident {incident.defName}");
}
}
}
@@ -145,14 +145,14 @@ namespace WulaFallenEmpire
{
if (faction == null)
{
Log.Error("[WulaFallenEmpire] Effect_ChangeFactionRelation has a null faction Def.");
WulaLog.Debug("[WulaFallenEmpire] Effect_ChangeFactionRelation has a null faction Def.");
return;
}
Faction targetFaction = Find.FactionManager.FirstFactionOfDef(faction);
if (targetFaction == null)
{
Log.Warning($"[WulaFallenEmpire] Could not find an active faction for FactionDef '{faction.defName}'.");
WulaLog.Debug($"[WulaFallenEmpire] Could not find an active faction for FactionDef '{faction.defName}'.");
return;
}
@@ -204,14 +204,14 @@ namespace WulaFallenEmpire
{
if (faction == null)
{
Log.Error("[WulaFallenEmpire] Effect_ChangeFactionRelation_FromVariable has a null faction Def.");
WulaLog.Debug("[WulaFallenEmpire] Effect_ChangeFactionRelation_FromVariable has a null faction Def.");
return;
}
Faction targetFaction = Find.FactionManager.FirstFactionOfDef(faction);
if (targetFaction == null)
{
Log.Warning($"[WulaFallenEmpire] Could not find an active faction for FactionDef '{faction.defName}'.");
WulaLog.Debug($"[WulaFallenEmpire] Could not find an active faction for FactionDef '{faction.defName}'.");
return;
}
@@ -230,12 +230,12 @@ namespace WulaFallenEmpire
{
if (kindDef == null)
{
Log.Error("[WulaFallenEmpire] Effect_SpawnPawnAndStore has a null kindDef.");
WulaLog.Debug("[WulaFallenEmpire] Effect_SpawnPawnAndStore has a null kindDef.");
return;
}
if (storeAs.NullOrEmpty())
{
Log.Error("[WulaFallenEmpire] Effect_SpawnPawnAndStore needs a 'storeAs' variable name.");
WulaLog.Debug("[WulaFallenEmpire] Effect_SpawnPawnAndStore needs a 'storeAs' variable name.");
return;
}
@@ -269,14 +269,14 @@ namespace WulaFallenEmpire
{
if (thingDef == null)
{
Log.Error("[WulaFallenEmpire] Effect_GiveThing has a null thingDef.");
WulaLog.Debug("[WulaFallenEmpire] Effect_GiveThing has a null thingDef.");
return;
}
Map currentMap = Find.CurrentMap;
if (currentMap == null)
{
Log.Error("[WulaFallenEmpire] Effect_GiveThing cannot execute without a current map.");
WulaLog.Debug("[WulaFallenEmpire] Effect_GiveThing cannot execute without a current map.");
return;
}
@@ -303,14 +303,14 @@ namespace WulaFallenEmpire
{
if (kindDef == null)
{
Log.Error("[WulaFallenEmpire] Effect_SpawnPawn has a null kindDef.");
WulaLog.Debug("[WulaFallenEmpire] Effect_SpawnPawn has a null kindDef.");
return;
}
Map map = Find.CurrentMap;
if (map == null)
{
Log.Error("[WulaFallenEmpire] Effect_SpawnPawn cannot execute without a current map.");
WulaLog.Debug("[WulaFallenEmpire] Effect_SpawnPawn cannot execute without a current map.");
return;
}
@@ -361,7 +361,7 @@ namespace WulaFallenEmpire
{
if (string.IsNullOrEmpty(name))
{
Log.Error("[WulaFallenEmpire] Effect_ModifyVariable has a null or empty name.");
WulaLog.Debug("[WulaFallenEmpire] Effect_ModifyVariable has a null or empty name.");
return;
}
@@ -374,7 +374,7 @@ namespace WulaFallenEmpire
valueStr = eventVarManager.GetVariable<object>(valueVariableName)?.ToString();
if (valueStr == null)
{
Log.Error($"[WulaFallenEmpire] Effect_ModifyVariable: valueVariableName '{valueVariableName}' not found.");
WulaLog.Debug($"[WulaFallenEmpire] Effect_ModifyVariable: valueVariableName '{valueVariableName}' not found.");
return;
}
}
@@ -383,7 +383,7 @@ namespace WulaFallenEmpire
object variable = eventVarManager.GetVariable<object>(name);
if (variable == null)
{
Log.Message($"[EventSystem] Effect_ModifyVariable: Variable '{name}' not found, initializing to 0.");
WulaLog.Debug($"[EventSystem] Effect_ModifyVariable: Variable '{name}' not found, initializing to 0.");
variable = 0;
}
@@ -406,12 +406,12 @@ namespace WulaFallenEmpire
newValue = Modify(currentVal, modVal, operation);
}
Log.Message($"[EventSystem] Modifying variable '{name}'. Operation: {operation}. Value: {valueStr}. From: {originalValue} To: {newValue}");
WulaLog.Debug($"[EventSystem] Modifying variable '{name}'. Operation: {operation}. Value: {valueStr}. From: {originalValue} To: {newValue}");
eventVarManager.SetVariable(name, newValue);
}
catch (System.Exception e)
{
Log.Error($"[WulaFallenEmpire] Effect_ModifyVariable: Could not parse or operate on value '{valueStr}' for variable '{name}'. Error: {e.Message}");
WulaLog.Debug($"[WulaFallenEmpire] Effect_ModifyVariable: Could not parse or operate on value '{valueStr}' for variable '{name}'. Error: {e.Message}");
}
}
@@ -424,7 +424,7 @@ namespace WulaFallenEmpire
case VariableOperation.Multiply: return current * modifier;
case VariableOperation.Divide:
if (modifier != 0) return current / modifier;
Log.Error($"[WulaFallenEmpire] Effect_ModifyVariable tried to divide by zero.");
WulaLog.Debug($"[WulaFallenEmpire] Effect_ModifyVariable tried to divide by zero.");
return current;
default: return current;
}
@@ -439,7 +439,7 @@ namespace WulaFallenEmpire
{
if (string.IsNullOrEmpty(name))
{
Log.Error("[WulaFallenEmpire] Effect_ClearVariable has a null or empty name.");
WulaLog.Debug("[WulaFallenEmpire] Effect_ClearVariable has a null or empty name.");
return;
}
Find.World.GetComponent<EventVariableManager>().ClearVariable(name);
@@ -453,17 +453,17 @@ namespace WulaFallenEmpire
{
if (quest == null)
{
Log.Error("[WulaFallenEmpire] Effect_AddQuest has a null quest Def.");
WulaLog.Debug("[WulaFallenEmpire] Effect_AddQuest has a null quest Def.");
return;
}
// 使用标准的任务生成方法,而不是创建raw quest
// ʹ<EFBFBD>ñ<EFBFBD>׼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ǵ<EFBFBD><EFBFBD><EFBFBD>raw quest
Quest newQuest = QuestUtility.GenerateQuestAndMakeAvailable(quest, 0);
if (newQuest != null)
{
Log.Message($"[WulaFallenEmpire] Successfully added quest: {quest.defName}");
WulaLog.Debug($"[WulaFallenEmpire] Successfully added quest: {quest.defName}");
// 如果不是自动接受的任务,发送可用信件
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>񣬷<EFBFBD><EFBFBD>Ϳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ż<EFBFBD>
if (!newQuest.root.autoAccept)
{
QuestUtility.SendLetterQuestAvailable(newQuest);
@@ -471,7 +471,7 @@ namespace WulaFallenEmpire
}
else
{
Log.Error($"[WulaFallenEmpire] Failed to generate quest: {quest.defName}");
WulaLog.Debug($"[WulaFallenEmpire] Failed to generate quest: {quest.defName}");
}
}
}
@@ -484,7 +484,7 @@ namespace WulaFallenEmpire
{
if (research == null)
{
Log.Error("[WulaFallenEmpire] Effect_FinishResearch has a null research Def.");
WulaLog.Debug("[WulaFallenEmpire] Effect_FinishResearch has a null research Def.");
return;
}
@@ -507,14 +507,14 @@ namespace WulaFallenEmpire
Map map = Find.CurrentMap;
if (map == null)
{
Log.Error("[WulaFallenEmpire] Effect_TriggerRaid cannot execute without a current map.");
WulaLog.Debug("[WulaFallenEmpire] Effect_TriggerRaid cannot execute without a current map.");
return;
}
Faction factionInst = Find.FactionManager.FirstFactionOfDef(this.faction);
if (factionInst == null)
{
Log.Error($"[WulaFallenEmpire] Effect_TriggerRaid could not find an active faction for FactionDef '{this.faction?.defName}'.");
WulaLog.Debug($"[WulaFallenEmpire] Effect_TriggerRaid could not find an active faction for FactionDef '{this.faction?.defName}'.");
return;
}
@@ -531,7 +531,7 @@ namespace WulaFallenEmpire
if (!RCellFinder.TryFindRandomPawnEntryCell(out parms.spawnCenter, map, CellFinder.EdgeRoadChance_Hostile))
{
Log.Error("[WulaFallenEmpire] Effect_TriggerRaid could not find a valid spawn center.");
WulaLog.Debug("[WulaFallenEmpire] Effect_TriggerRaid could not find a valid spawn center.");
return;
}
@@ -579,7 +579,7 @@ namespace WulaFallenEmpire
{
if (factionDef == null || string.IsNullOrEmpty(variableName))
{
Log.Error("[WulaFallenEmpire] Effect_CheckFactionGoodwill is not configured correctly.");
WulaLog.Debug("[WulaFallenEmpire] Effect_CheckFactionGoodwill is not configured correctly.");
return;
}
@@ -589,12 +589,12 @@ namespace WulaFallenEmpire
if (faction != null)
{
int goodwill = faction.GoodwillWith(Faction.OfPlayer);
Log.Message($"[EventSystem] Storing goodwill for faction '{faction.Name}' ({goodwill}) into variable '{variableName}'.");
WulaLog.Debug($"[EventSystem] Storing goodwill for faction '{faction.Name}' ({goodwill}) into variable '{variableName}'.");
eventVarManager.SetVariable(variableName, goodwill);
}
else
{
Log.Warning($"[EventSystem] Effect_CheckFactionGoodwill: Faction '{factionDef.defName}' not found. Storing 0 in variable '{variableName}'.");
WulaLog.Debug($"[EventSystem] Effect_CheckFactionGoodwill: Faction '{factionDef.defName}' not found. Storing 0 in variable '{variableName}'.");
eventVarManager.SetVariable(variableName, 0);
}
}
@@ -608,13 +608,13 @@ namespace WulaFallenEmpire
{
if (string.IsNullOrEmpty(variableName))
{
Log.Error("[WulaFallenEmpire] Effect_StoreRealPlayTime is not configured correctly (missing variableName).");
WulaLog.Debug("[WulaFallenEmpire] Effect_StoreRealPlayTime is not configured correctly (missing variableName).");
return;
}
var eventVarManager = Find.World.GetComponent<EventVariableManager>();
float realPlayTime = Find.GameInfo.RealPlayTimeInteracting;
Log.Message($"[EventSystem] Storing real play time ({realPlayTime}s) into variable '{variableName}'.");
WulaLog.Debug($"[EventSystem] Storing real play time ({realPlayTime}s) into variable '{variableName}'.");
eventVarManager.SetVariable(variableName, realPlayTime);
}
}
@@ -627,13 +627,13 @@ namespace WulaFallenEmpire
{
if (string.IsNullOrEmpty(variableName))
{
Log.Error("[WulaFallenEmpire] Effect_StoreDaysPassed is not configured correctly (missing variableName).");
WulaLog.Debug("[WulaFallenEmpire] Effect_StoreDaysPassed is not configured correctly (missing variableName).");
return;
}
var eventVarManager = Find.World.GetComponent<EventVariableManager>();
int daysPassed = GenDate.DaysPassed;
Log.Message($"[EventSystem] Storing days passed ({daysPassed}) into variable '{variableName}'.");
WulaLog.Debug($"[EventSystem] Storing days passed ({daysPassed}) into variable '{variableName}'.");
eventVarManager.SetVariable(variableName, daysPassed);
}
}
@@ -646,20 +646,20 @@ namespace WulaFallenEmpire
{
if (string.IsNullOrEmpty(variableName))
{
Log.Error("[WulaFallenEmpire] Effect_StoreColonyWealth is not configured correctly (missing variableName).");
WulaLog.Debug("[WulaFallenEmpire] Effect_StoreColonyWealth is not configured correctly (missing variableName).");
return;
}
Map currentMap = Find.CurrentMap;
if (currentMap == null)
{
Log.Error("[WulaFallenEmpire] Effect_StoreColonyWealth cannot execute without a current map.");
WulaLog.Debug("[WulaFallenEmpire] Effect_StoreColonyWealth cannot execute without a current map.");
return;
}
var eventVarManager = Find.World.GetComponent<EventVariableManager>();
float wealth = currentMap.wealthWatcher.WealthTotal;
Log.Message($"[EventSystem] Storing colony wealth ({wealth}) into variable '{variableName}'.");
WulaLog.Debug($"[EventSystem] Storing colony wealth ({wealth}) into variable '{variableName}'.");
eventVarManager.SetVariable(variableName, wealth);
}
}

View File

@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using Verse;
using RimWorld;
using UnityEngine;
@@ -20,13 +20,13 @@ namespace WulaFallenEmpire
Map currentMap = Find.CurrentMap;
if (currentMap == null)
{
Log.Error("[WulaFallenEmpire] Effect_CallSkyfaller cannot execute without a current map.");
WulaLog.Debug("[WulaFallenEmpire] Effect_CallSkyfaller cannot execute without a current map.");
return;
}
if (skyfallerDef == null)
{
Log.Error("[WulaFallenEmpire] Effect_CallSkyfaller has a null skyfallerDef.");
WulaLog.Debug("[WulaFallenEmpire] Effect_CallSkyfaller has a null skyfallerDef.");
return;
}
@@ -43,7 +43,7 @@ namespace WulaFallenEmpire
if (!dropCenter.IsValid)
{
Log.Error("[WulaFallenEmpire] Effect_CallSkyfaller could not find a valid drop spot.");
WulaLog.Debug("[WulaFallenEmpire] Effect_CallSkyfaller could not find a valid drop spot.");
return;
}
@@ -56,7 +56,7 @@ namespace WulaFallenEmpire
Find.LetterStack.ReceiveLetter(letterLabel, letterText, letterDef ?? LetterDefOf.NeutralEvent);
}
Log.Message($"[WulaFallenEmpire] Scheduled skyfaller '{skyfallerDef.defName}' at {dropCenter} with {delayTicks} ticks delay");
WulaLog.Debug($"[WulaFallenEmpire] Scheduled skyfaller '{skyfallerDef.defName}' at {dropCenter} with {delayTicks} ticks delay");
}
private IntVec3 FindDropSpotWithClearance(Map map, int radius)

View File

@@ -1,4 +1,4 @@
using System;
using System;
using RimWorld;
using Verse;
using WulaFallenEmpire.EventSystem.AI;
@@ -26,7 +26,7 @@ namespace WulaFallenEmpire
}
else
{
Log.Error($"[WulaFallenEmpire] Effect_OpenAIConversation could not find EventDef named '{defName}'");
WulaLog.Debug($"[WulaFallenEmpire] Effect_OpenAIConversation could not find EventDef named '{defName}'");
}
}
}

View File

@@ -1,4 +1,4 @@
// 在 EffectBase.cs 中添加以下类
// 在 EffectBase.cs 中添加以下类
using Verse;
using RimWorld;
@@ -13,7 +13,7 @@ namespace WulaFallenEmpire
{
if (string.IsNullOrEmpty(flagName))
{
Log.Error("[WulaFallenEmpire] Effect_SetTimedFlag has a null or empty flagName.");
WulaLog.Debug("[WulaFallenEmpire] Effect_SetTimedFlag has a null or empty flagName.");
return;
}
@@ -21,7 +21,7 @@ namespace WulaFallenEmpire
eventVarManager.SetTimedFlag(flagName, durationTicks);
string durationInfo = durationTicks < 0 ? "permanent" : $"{durationTicks} ticks";
Log.Message($"[EventSystem] Set timed flag '{flagName}' with duration: {durationInfo}");
WulaLog.Debug($"[EventSystem] Set timed flag '{flagName}' with duration: {durationInfo}");
}
}
}

View File

@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using Verse;
using RimWorld;
using RimWorld.Planet;
@@ -76,7 +76,7 @@ namespace WulaFallenEmpire
if (kvp.Value >= 0 && currentTick >= kvp.Value)
{
flagsToRemove.Add(kvp.Key);
Log.Message($"[EventSystem] Flag '{kvp.Key}' expired and will be removed.");
WulaLog.Debug($"[EventSystem] Flag '{kvp.Key}' expired and will be removed.");
}
}
@@ -92,7 +92,7 @@ namespace WulaFallenEmpire
if (string.IsNullOrEmpty(name)) return;
// Log the variable change
Log.Message($"[EventSystem] Setting variable '{name}' to value '{value}' of type {value?.GetType().Name ?? "null"}.");
WulaLog.Debug($"[EventSystem] Setting variable '{name}' to value '{value}' of type {value?.GetType().Name ?? "null"}.");
// Clear any existing variable with the same name to prevent type confusion
ClearVariable(name);
@@ -120,7 +120,7 @@ namespace WulaFallenEmpire
else if (value != null)
{
stringVars[name] = value.ToString();
Log.Warning($"[WulaFallenEmpire] EventVariableManager: Variable '{name}' of type {value.GetType()} was converted to string for storage. This may lead to unexpected behavior.");
WulaLog.Debug($"[WulaFallenEmpire] EventVariableManager: Variable '{name}' of type {value.GetType()} was converted to string for storage. This may lead to unexpected behavior.");
}
}
@@ -138,13 +138,13 @@ namespace WulaFallenEmpire
{
// 负数表示永久flag
expiryTick = -1;
Log.Message($"[EventSystem] Setting permanent flag '{flagName}'.");
WulaLog.Debug($"[EventSystem] Setting permanent flag '{flagName}'.");
}
else
{
// 正数表示有时间限制的flag
expiryTick = Find.TickManager.TicksGame + durationTicks;
Log.Message($"[EventSystem] Setting timed flag '{flagName}' with duration {durationTicks} ticks (expires at tick {expiryTick}).");
WulaLog.Debug($"[EventSystem] Setting timed flag '{flagName}' with duration {durationTicks} ticks (expires at tick {expiryTick}).");
}
timedFlags[flagName] = expiryTick;
@@ -172,7 +172,7 @@ namespace WulaFallenEmpire
{
// 如果过期了,移除它
timedFlags.Remove(flagName);
Log.Message($"[EventSystem] Flag '{flagName}' has expired and was removed.");
WulaLog.Debug($"[EventSystem] Flag '{flagName}' has expired and was removed.");
}
return isActive;
}
@@ -241,7 +241,7 @@ namespace WulaFallenEmpire
}
catch (System.Exception e)
{
Log.Warning($"[WulaFallenEmpire] EventVariableManager: Variable '{name}' of type {value.GetType()} could not be converted to {typeof(T)}. Error: {e.Message}");
WulaLog.Debug($"[WulaFallenEmpire] EventVariableManager: Variable '{name}' of type {value.GetType()} could not be converted to {typeof(T)}. Error: {e.Message}");
return defaultValue;
}
}
@@ -263,7 +263,7 @@ namespace WulaFallenEmpire
{
if (HasVariable(name))
{
Log.Message($"[EventSystem] Clearing variable '{name}'.");
WulaLog.Debug($"[EventSystem] Clearing variable '{name}'.");
}
intVars.Remove(name);
floatVars.Remove(name);

View File

@@ -1,4 +1,4 @@
using RimWorld;
using RimWorld;
using RimWorld.QuestGen;
using System;
using Verse;
@@ -25,7 +25,7 @@ namespace WulaFallenEmpire
if (defName.NullOrEmpty())
{
Log.Error("[WulaFallenEmpire] QuestNode_EventLetter: eventDefName is not specified.");
WulaLog.Debug("[WulaFallenEmpire] QuestNode_EventLetter: eventDefName is not specified.");
return;
}
@@ -49,11 +49,11 @@ namespace WulaFallenEmpire
{
base.Notify_QuestSignalReceived(signal);
Log.Message($"[WulaFallenEmpire] QuestPart_EventLetter received signal: '{signal.tag}', waiting for: '{inSignal}'");
WulaLog.Debug($"[WulaFallenEmpire] QuestPart_EventLetter received signal: '{signal.tag}', waiting for: '{inSignal}'");
if (signal.tag == inSignal)
{
Log.Message($"[WulaFallenEmpire] Signal matched! Opening EventDef: {eventDefName}");
WulaLog.Debug($"[WulaFallenEmpire] Signal matched! Opening EventDef: {eventDefName}");
OpenEventDefWindow(eventDefName);
}
}
@@ -65,26 +65,26 @@ namespace WulaFallenEmpire
EventDef eventDef = DefDatabase<EventDef>.GetNamed(defName, false);
if (eventDef == null)
{
Log.Error($"[WulaFallenEmpire] EventDef '{defName}' not found in DefDatabase.");
WulaLog.Debug($"[WulaFallenEmpire] EventDef '{defName}' not found in DefDatabase.");
return;
}
if (eventDef.windowType == null)
{
Log.Error($"[WulaFallenEmpire] EventDef '{defName}' has null windowType.");
WulaLog.Debug($"[WulaFallenEmpire] EventDef '{defName}' has null windowType.");
return;
}
Log.Message($"[WulaFallenEmpire] Creating window instance for {defName} with type {eventDef.windowType}");
WulaLog.Debug($"[WulaFallenEmpire] Creating window instance for {defName} with type {eventDef.windowType}");
Window window = (Window)Activator.CreateInstance(eventDef.windowType, eventDef);
Log.Message($"[WulaFallenEmpire] Adding window to WindowStack");
WulaLog.Debug($"[WulaFallenEmpire] Adding window to WindowStack");
Find.WindowStack.Add(window);
Log.Message($"[WulaFallenEmpire] Successfully opened EventDef window: {defName}");
WulaLog.Debug($"[WulaFallenEmpire] Successfully opened EventDef window: {defName}");
}
catch (Exception ex)
{
Log.Error($"[WulaFallenEmpire] Error opening EventDef window '{defName}': {ex}");
WulaLog.Debug($"[WulaFallenEmpire] Error opening EventDef window '{defName}': {ex}");
}
}

View File

@@ -1,4 +1,4 @@
using RimWorld;
using RimWorld;
using RimWorld.QuestGen;
using System;
using System.Collections.Generic;
@@ -28,7 +28,7 @@ namespace WulaFallenEmpire
}
else
{
Log.Error("[WulaFallenEmpire] QuestNode_Root_EventLetter: eventDefName is not specified.");
WulaLog.Debug("[WulaFallenEmpire] QuestNode_Root_EventLetter: eventDefName is not specified.");
}
}
@@ -38,14 +38,14 @@ namespace WulaFallenEmpire
if (defName.NullOrEmpty())
{
Log.Error("[WulaFallenEmpire] QuestNode_Root_EventLetter: eventDefName is not specified.");
WulaLog.Debug("[WulaFallenEmpire] QuestNode_Root_EventLetter: eventDefName is not specified.");
return false;
}
EventDef eventDef = DefDatabase<EventDef>.GetNamed(defName, false);
if (eventDef == null)
{
Log.Error($"[WulaFallenEmpire] QuestNode_Root_EventLetter: EventDef '{defName}' not found.");
WulaLog.Debug($"[WulaFallenEmpire] QuestNode_Root_EventLetter: EventDef '{defName}' not found.");
return false;
}
@@ -64,7 +64,7 @@ namespace WulaFallenEmpire
}
else
{
Log.Error($"[WulaFallenEmpire] QuestNode_Root_EventLetter: Could not find EventDef '{defName}'");
WulaLog.Debug($"[WulaFallenEmpire] QuestNode_Root_EventLetter: Could not find EventDef '{defName}'");
}
}
}

View File

@@ -1,4 +1,4 @@
using System;
using System;
using RimWorld.QuestGen;
using Verse;
using System.Collections.Generic;
@@ -97,7 +97,7 @@ namespace WulaFallenEmpire
string targetName = targetVariableName.GetValue(slate);
if (string.IsNullOrEmpty(targetName))
{
Log.Error("[QuestNode_WriteToEventVariablesWithAdd] targetVariableName is null or empty!");
WulaLog.Debug("[QuestNode_WriteToEventVariablesWithAdd] targetVariableName is null or empty!");
return false;
}
@@ -107,7 +107,7 @@ namespace WulaFallenEmpire
{
if (logDebug.GetValue(slate))
{
Log.Warning($"[QuestNode_WriteToEventVariablesWithAdd] No value to operate for variable '{targetName}'.");
WulaLog.Debug($"[QuestNode_WriteToEventVariablesWithAdd] No value to operate for variable '{targetName}'.");
}
return false;
}
@@ -122,7 +122,7 @@ namespace WulaFallenEmpire
var eventVarManager = Find.World.GetComponent<EventVariableManager>();
if (eventVarManager == null)
{
Log.Error("[QuestNode_WriteToEventVariablesWithAdd] EventVariableManager not found!");
WulaLog.Debug("[QuestNode_WriteToEventVariablesWithAdd] EventVariableManager not found!");
return false;
}
@@ -132,10 +132,10 @@ namespace WulaFallenEmpire
// 记录操作前的状态
if (logDebug.GetValue(slate))
{
Log.Message($"[QuestNode_WriteToEventVariablesWithAdd] Operation for variable '{targetName}':");
Log.Message($" - Mode: {writeMode}");
Log.Message($" - Current value: {currentValue ?? "[null]"} (Type: {currentValue?.GetType().Name ?? "null"})");
Log.Message($" - Source value: {sourceValue ?? "[null]"} (Type: {sourceValue?.GetType().Name ?? "null"})");
WulaLog.Debug($"[QuestNode_WriteToEventVariablesWithAdd] Operation for variable '{targetName}':");
WulaLog.Debug($" - Mode: {writeMode}");
WulaLog.Debug($" - Current value: {currentValue ?? "[null]"} (Type: {currentValue?.GetType().Name ?? "null"})");
WulaLog.Debug($" - Source value: {sourceValue ?? "[null]"} (Type: {sourceValue?.GetType().Name ?? "null"})");
}
// 根据写入模式计算新值
@@ -146,7 +146,7 @@ namespace WulaFallenEmpire
{
if (logDebug.GetValue(slate))
{
Log.Message($" - Operation skipped (new value is null)");
WulaLog.Debug($" - Operation skipped (new value is null)");
}
return false;
}
@@ -160,7 +160,7 @@ namespace WulaFallenEmpire
slate.Remove(sourceVariableName.GetValue(slate));
if (logDebug.GetValue(slate))
{
Log.Message($" - Removed source variable '{sourceVariableName.GetValue(slate)}' from Slate");
WulaLog.Debug($" - Removed source variable '{sourceVariableName.GetValue(slate)}' from Slate");
}
}
@@ -171,11 +171,11 @@ namespace WulaFallenEmpire
bool writeVerified = (readBackValue == null && newValue == null) ||
(readBackValue != null && readBackValue.Equals(newValue));
Log.Message($" - New value written: {newValue} (Type: {newValue.GetType().Name})");
Log.Message($" - Write verified: {writeVerified}");
WulaLog.Debug($" - New value written: {newValue} (Type: {newValue.GetType().Name})");
WulaLog.Debug($" - Write verified: {writeVerified}");
if (!writeVerified)
{
Log.Warning($" - Verification failed! Expected: {newValue}, Got: {readBackValue}");
WulaLog.Debug($" - Verification failed! Expected: {newValue}, Got: {readBackValue}");
}
}
@@ -235,7 +235,7 @@ namespace WulaFallenEmpire
{
if (logDebug.GetValue(slate))
{
Log.Message($" - Variable exists and overwrite is false, keeping current value");
WulaLog.Debug($" - Variable exists and overwrite is false, keeping current value");
}
return currentValue; // 不覆盖,返回原值
}
@@ -281,7 +281,7 @@ namespace WulaFallenEmpire
case MathOperator.Divide:
if (source == 0)
{
Log.Error($"[QuestNode_WriteToEventVariablesWithAdd] Division by zero for variable operation");
WulaLog.Debug($"[QuestNode_WriteToEventVariablesWithAdd] Division by zero for variable operation");
return currentValue;
}
result = current / source;
@@ -307,7 +307,7 @@ namespace WulaFallenEmpire
{
if (logDebug.GetValue(slate))
{
Log.Error($"[QuestNode_WriteToEventVariablesWithAdd] Math operation failed: {ex.Message}");
WulaLog.Debug($"[QuestNode_WriteToEventVariablesWithAdd] Math operation failed: {ex.Message}");
}
return currentValue;
}
@@ -404,7 +404,7 @@ namespace WulaFallenEmpire
{
if (logDebug.GetValue(slate))
{
Log.Warning($"[QuestNode_WriteToEventVariablesWithAdd] Cannot increment non-numeric type: {currentValue.GetType().Name}");
WulaLog.Debug($"[QuestNode_WriteToEventVariablesWithAdd] Cannot increment non-numeric type: {currentValue.GetType().Name}");
}
return currentValue;
}
@@ -427,7 +427,7 @@ namespace WulaFallenEmpire
{
if (logDebug.GetValue(slate))
{
Log.Error($"[QuestNode_WriteToEventVariablesWithAdd] Increment operation failed: {ex.Message}");
WulaLog.Debug($"[QuestNode_WriteToEventVariablesWithAdd] Increment operation failed: {ex.Message}");
}
return currentValue;
}
@@ -437,7 +437,7 @@ namespace WulaFallenEmpire
{
if (logDebug.GetValue(slate))
{
Log.Warning($"[QuestNode_WriteToEventVariablesWithAdd] Type mismatch for operation: {mismatchReason}");
WulaLog.Debug($"[QuestNode_WriteToEventVariablesWithAdd] Type mismatch for operation: {mismatchReason}");
}
switch (onTypeMismatch)
@@ -448,7 +448,7 @@ namespace WulaFallenEmpire
case TypeMismatchBehavior.Skip:
if (logDebug.GetValue(slate))
{
Log.Message($" - Skipping operation due to type mismatch");
WulaLog.Debug($" - Skipping operation due to type mismatch");
}
return currentValue; // 保持原值

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;
}

View File

@@ -1,4 +1,4 @@
// Building_GlobalWorkTable.cs (修改版本)
// Building_GlobalWorkTable.cs (修改版本)
using RimWorld;
using System.Collections.Generic;
using System.Linq;
@@ -322,18 +322,18 @@ namespace WulaFallenEmpire
// 显示成功消息
Messages.Message("WULA_SilverTransferred".Translate(silverAmount), MessageTypeDefOf.PositiveEvent);
Log.Message($"[WULA] Transferred {silverAmount} silver from input to output storage");
WulaLog.Debug($"[WULA] Transferred {silverAmount} silver from input to output storage");
}
else
{
Messages.Message("WULA_TransferFailed".Translate(), MessageTypeDefOf.RejectInput);
Log.Error("[WULA] Failed to remove silver from input storage during transfer");
WulaLog.Debug("[WULA] Failed to remove silver from input storage during transfer");
}
}
catch (System.Exception ex)
{
Messages.Message("WULA_TransferError".Translate(), MessageTypeDefOf.RejectInput);
Log.Error($"[WULA] Error during silver transfer: {ex}");
WulaLog.Debug($"[WULA] Error during silver transfer: {ex}");
}
}
@@ -402,7 +402,7 @@ namespace WulaFallenEmpire
//}
//catch (System.Exception ex)
//{
// Log.Error($"[FactoryFacility Check] Error in HasFactoryFacilityFlyOver: {ex}");
// WulaLog.Debug($"[FactoryFacility Check] Error in HasFactoryFacilityFlyOver: {ex}");
// return false;
//}
}
@@ -593,7 +593,7 @@ namespace WulaFallenEmpire
// 记录分配结果
for (int i = 0; i < podContents.Count; i++)
{
Log.Message($"[Airdrop] Pod {i} contains {podContents[i].Count} items");
WulaLog.Debug($"[Airdrop] Pod {i} contains {podContents[i].Count} items");
}
return podContents;
}
@@ -652,14 +652,14 @@ namespace WulaFallenEmpire
{
if (pawnType.race == null)
{
Log.Error($"[Airdrop] GetRandomPawnKindForType: {pawnType.defName} is not a pawn type");
WulaLog.Debug($"[Airdrop] GetRandomPawnKindForType: {pawnType.defName} is not a pawn type");
return null;
}
// 获取工作台的派系
Faction workTableFaction = this.Faction;
if (workTableFaction == null)
{
Log.Error($"[Airdrop] Work table has no faction");
WulaLog.Debug($"[Airdrop] Work table has no faction");
return null;
}
// 获取该种族的所有PawnKindDef
@@ -668,7 +668,7 @@ namespace WulaFallenEmpire
.ToList();
if (availableKinds.Count == 0)
{
Log.Error($"[Airdrop] No PawnKindDef found for race: {pawnType.defName}");
WulaLog.Debug($"[Airdrop] No PawnKindDef found for race: {pawnType.defName}");
return null;
}
// 最高优先级与工作台派系完全相同的PawnKind
@@ -702,12 +702,12 @@ namespace WulaFallenEmpire
if (noFactionKinds.Count > 0)
{
var selected = noFactionKinds.RandomElement();
Log.Message($"[Airdrop] Selected no-faction PawnKind: {selected.defName}");
WulaLog.Debug($"[Airdrop] Selected no-faction PawnKind: {selected.defName}");
return selected;
}
// 最后选择任何可用的PawnKind
var selectedKind = availableKinds.RandomElement();
Log.Message($"[Airdrop] Selected fallback PawnKind: {selectedKind.defName}");
WulaLog.Debug($"[Airdrop] Selected fallback PawnKind: {selectedKind.defName}");
return selectedKind;
}
@@ -729,14 +729,14 @@ namespace WulaFallenEmpire
{
if (contents == null || contents.Count == 0)
{
Log.Warning("[Airdrop] CreateDropPod: contents is null or empty");
WulaLog.Debug("[Airdrop] CreateDropPod: contents is null or empty");
return false;
}
Log.Message($"[Airdrop] Creating drop pod at {dropCell} with {contents.Count} items");
WulaLog.Debug($"[Airdrop] Creating drop pod at {dropCell} with {contents.Count} items");
// 检查目标单元格是否有效
if (!dropCell.IsValid || !dropCell.InBounds(Map))
{
Log.Error($"[Airdrop] Invalid drop cell: {dropCell}");
WulaLog.Debug($"[Airdrop] Invalid drop cell: {dropCell}");
return false;
}
// 创建空投舱信息 - 使用 DropPodInfo 而不是 ActiveTransporterInfo
@@ -752,29 +752,29 @@ namespace WulaFallenEmpire
{
if (!container.TryAdd(thing, true))
{
Log.Error($"[Airdrop] Failed to add {thing.Label} to drop pod");
WulaLog.Debug($"[Airdrop] Failed to add {thing.Label} to drop pod");
}
else
{
Log.Message($"[Airdrop] Added {thing.Label} to drop pod");
WulaLog.Debug($"[Airdrop] Added {thing.Label} to drop pod");
}
}
}
if (container.Count == 0)
{
Log.Warning("[Airdrop] No items were successfully added to drop pod");
WulaLog.Debug("[Airdrop] No items were successfully added to drop pod");
return false;
}
dropPodInfo.innerContainer = container;
// 生成空投舱
DropPodUtility.MakeDropPodAt(dropCell, Map, dropPodInfo, Faction.OfPlayer);
Log.Message($"[Airdrop] Successfully created drop pod at {dropCell}");
WulaLog.Debug($"[Airdrop] Successfully created drop pod at {dropCell}");
return true;
}
catch (System.Exception ex)
{
Log.Error($"[Airdrop] Failed to create drop pod at {dropCell}: {ex}");
WulaLog.Debug($"[Airdrop] Failed to create drop pod at {dropCell}: {ex}");
return false;
}
}

View File

@@ -1,4 +1,4 @@
// GlobalProductionOrder.cs (修复成本计算使用产物的costList)
// GlobalProductionOrder.cs (修复成本计算使用产物的costList)
using RimWorld;
using System.Collections.Generic;
using System.Linq;
@@ -37,7 +37,7 @@ namespace WulaFallenEmpire
_progress = Mathf.Clamp01(value);
if (value < 0f || value > 1f)
{
Log.Warning($"Progress clamped from {value} to {_progress} for {recipe?.defName ?? "unknown"}");
WulaLog.Debug($"Progress clamped from {value} to {_progress} for {recipe?.defName ?? "unknown"}");
}
}
}

View File

@@ -1,4 +1,4 @@
using RimWorld;
using RimWorld;
using System.Collections.Generic;
using Verse;
using UnityEngine;
@@ -94,7 +94,7 @@ namespace WulaFallenEmpire
// 防止除零错误
if (workAmount <= 0)
{
Log.Error($"Invalid workAmount ({workAmount}) for recipe {order.recipe.defName}");
WulaLog.Debug($"Invalid workAmount ({workAmount}) for recipe {order.recipe.defName}");
order.state = GlobalProductionOrder.ProductionState.Gathering;
order.progress = 0f;
return;
@@ -110,7 +110,7 @@ namespace WulaFallenEmpire
// 调试信息
if (Find.TickManager.TicksGame % 300 == 0) // 每5秒输出一次
{
Log.Message($"[DEBUG] Order {order.recipe.defName}: " +
WulaLog.Debug($"[DEBUG] Order {order.recipe.defName}: " +
$"progress={order.progress:P2}, " +
$"workAmount={workAmount}, " +
$"increment={progressIncrement:E4}, " +
@@ -153,7 +153,7 @@ namespace WulaFallenEmpire
}
// 最后的回退方案
Log.Warning($"Could not determine work amount for recipe {order.recipe.defName}, using default value");
WulaLog.Debug($"Could not determine work amount for recipe {order.recipe.defName}, using default value");
return 1000f; // 默认工作量
}
@@ -169,17 +169,17 @@ namespace WulaFallenEmpire
if (Find.TickManager.TicksGame % 600 == 0) // 每10秒记录一次
{
Log.Message($"[INFO] Order {order.recipe.defName} started producing");
WulaLog.Debug($"[INFO] Order {order.recipe.defName} started producing");
}
}
else
{
Log.Warning($"[WULA] Order {order.recipe.defName} had enough resources but failed to deduct them; staying in Gathering.");
WulaLog.Debug($"[WULA] Order {order.recipe.defName} had enough resources but failed to deduct them; staying in Gathering.");
}
}
else if (Find.TickManager.TicksGame % 1200 == 0) // 每20秒检查一次
{
Log.Message($"[DEBUG] Order {order.recipe.defName} is waiting. " +
WulaLog.Debug($"[DEBUG] Order {order.recipe.defName} is waiting. " +
$"HasEnoughResources: {order.HasEnoughResources()}");
}
}
@@ -189,7 +189,7 @@ namespace WulaFallenEmpire
// 生产完成(资源已经在开始生产时扣除)
order.Produce();
Log.Message($"[SUCCESS] Produced {order.recipe.products[0].thingDef.defName}, " +
WulaLog.Debug($"[SUCCESS] Produced {order.recipe.products[0].thingDef.defName}, " +
$"count: {order.currentCount}/{order.targetCount}");
// 重置进度
@@ -200,7 +200,7 @@ namespace WulaFallenEmpire
{
order.state = GlobalProductionOrder.ProductionState.Completed;
Delete(order); // 同步 GlobalStorageWorldComponent.productionOrders
Log.Message($"[COMPLETE] Order {order.recipe.defName} completed and removed");
WulaLog.Debug($"[COMPLETE] Order {order.recipe.defName} completed and removed");
}
else
{
@@ -222,23 +222,23 @@ namespace WulaFallenEmpire
if (float.IsNaN(order.progress) || float.IsInfinity(order.progress))
{
order.progress = 0f;
Log.Warning($"Fixed invalid progress for {order.recipe?.defName ?? "unknown"}");
WulaLog.Debug($"Fixed invalid progress for {order.recipe?.defName ?? "unknown"}");
}
else if (order.progress < 0f)
{
order.progress = 0f;
Log.Warning($"Fixed negative progress for {order.recipe?.defName ?? "unknown"}");
WulaLog.Debug($"Fixed negative progress for {order.recipe?.defName ?? "unknown"}");
}
else if (order.progress > 1f)
{
order.progress = 1f;
Log.Warning($"Fixed excessive progress for {order.recipe?.defName ?? "unknown"}");
WulaLog.Debug($"Fixed excessive progress for {order.recipe?.defName ?? "unknown"}");
}
// 修复状态
if (order.recipe == null)
{
Log.Warning($"Removing order with null recipe");
WulaLog.Debug($"Removing order with null recipe");
Delete(order); // 同步 GlobalStorageWorldComponent.productionOrders
continue;
}

View File

@@ -1,4 +1,4 @@
// GlobalStorageWorldComponent.cs (移除材质相关存储)
// GlobalStorageWorldComponent.cs (移除材质相关存储)
using LudeonTK;
using RimWorld;
using RimWorld.Planet;
@@ -247,7 +247,7 @@ namespace WulaFallenEmpire
{
globalStorage.AddToInputStorage(ThingDefOf.Steel, 200);
globalStorage.AddToInputStorage(ThingDefOf.ComponentIndustrial, 100);
Log.Message("Added test resources to global storage");
WulaLog.Debug("Added test resources to global storage");
}
}
@@ -271,7 +271,7 @@ namespace WulaFallenEmpire
globalStorage.outputContainer.Remove(thing);
GenPlace.TryPlaceThing(thing, workTable.Position, workTable.Map, ThingPlaceMode.Near);
}
Log.Message("Spawned all output products");
WulaLog.Debug("Spawned all output products");
}
}
}

View File

@@ -1,4 +1,4 @@
// ITab_GlobalBills.cs (移除材质选择功能)
// ITab_GlobalBills.cs (移除材质选择功能)
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -622,7 +622,7 @@ namespace WulaFallenEmpire
if (!resourcesConsumed)
{
Log.Message($"[GOD MODE] Could not consume resources for {order.recipe.defName}, completing without resource consumption");
WulaLog.Debug($"[GOD MODE] Could not consume resources for {order.recipe.defName}, completing without resource consumption");
}
// 添加产品到输出存储

View File

@@ -1,4 +1,4 @@
using RimWorld;
using RimWorld;
using System.Collections.Generic;
using UnityEngine;
using Verse;
@@ -45,14 +45,14 @@ namespace WulaFallenEmpire
{
if (!this.parent.Spawned)
{
Log.Error("Tried to launch " + this.parent + " but it's not spawned.");
WulaLog.Debug("Tried to launch " + this.parent + " but it's not spawned.");
return;
}
var globalStorage = Find.World.GetComponent<GlobalStorageWorldComponent>();
if (globalStorage == null)
{
Log.Error("Could not find GlobalStorageWorldComponent.");
WulaLog.Debug("Could not find GlobalStorageWorldComponent.");
return;
}

View File

@@ -1,4 +1,4 @@
using RimWorld;
using RimWorld;
using System.Collections.Generic;
using System.Text;
using UnityEngine;
@@ -96,7 +96,7 @@ namespace WulaFallenEmpire
}
else
{
Log.Error($"[CompGarbageShield] Could not find EventDef named '{Props.garbageShieldUIEventDefName}'.");
WulaLog.Debug($"[CompGarbageShield] Could not find EventDef named '{Props.garbageShieldUIEventDefName}'.");
}
}
}

View File

@@ -1,4 +1,4 @@
using RimWorld;
using RimWorld;
using System.Collections.Generic;
using System.Text;
using UnityEngine;
@@ -158,7 +158,7 @@ namespace WulaFallenEmpire
}
catch (System.Exception ex)
{
Log.Error($"[WULA ValueConverter] Error in GetConversionDescription: {ex}");
WulaLog.Debug($"[WULA ValueConverter] Error in GetConversionDescription: {ex}");
return "WULA_ConversionDescriptionError".Translate();
}
}
@@ -225,7 +225,7 @@ namespace WulaFallenEmpire
if (!this.parent.Spawned)
{
Log.Error("Tried to convert " + this.parent + " but it's not spawned.");
WulaLog.Debug("Tried to convert " + this.parent + " but it's not spawned.");
return;
}
@@ -253,7 +253,7 @@ namespace WulaFallenEmpire
}
else
{
Log.Error("Could not find GlobalStorageWorldComponent.");
WulaLog.Debug("Could not find GlobalStorageWorldComponent.");
return;
}
@@ -307,7 +307,7 @@ namespace WulaFallenEmpire
}
else
{
Log.Error($"[CompValueConverter] Could not find EventDef named '{uiEventDefName}'.");
WulaLog.Debug($"[CompValueConverter] Could not find EventDef named '{uiEventDefName}'.");
}
}
}
@@ -378,7 +378,7 @@ namespace WulaFallenEmpire
public new void TryLaunch(PlanetTile destinationTile, TransportersArrivalAction arrivalAction)
{
// 这个方法不应该被直接调用应该使用ConvertToCurrency
Log.Warning("CompValueConverter.TryLaunch should not be called directly. Use ConvertToCurrency instead.");
WulaLog.Debug("CompValueConverter.TryLaunch should not be called directly. Use ConvertToCurrency instead.");
ConvertToCurrency();
}
}

View File

@@ -1,4 +1,4 @@
using RimWorld;
using RimWorld;
using System.Collections.Generic;
using System.Linq;
using Verse;
@@ -15,13 +15,13 @@ namespace WulaFallenEmpire
{
if (!(t is Building_GlobalWorkTable table) || !table.Spawned || table.IsForbidden(pawn))
{
if (forced) Log.Message($"[WULA_DEBUG] HasJobOnThing: Target invalid or forbidden. {t}");
if (forced) WulaLog.Debug($"[WULA_DEBUG] HasJobOnThing: Target invalid or forbidden. {t}");
return false;
}
if (!pawn.CanReserve(table, 1, -1, null, forced))
{
if (forced) Log.Message($"[WULA_DEBUG] HasJobOnThing: Cannot reserve table.");
if (forced) WulaLog.Debug($"[WULA_DEBUG] HasJobOnThing: Cannot reserve table.");
return false;
}
@@ -31,10 +31,10 @@ namespace WulaFallenEmpire
{
if (forced)
{
Log.Message($"[WULA_DEBUG] HasJobOnThing: No gathering order found. Total orders: {table.globalOrderStack.orders.Count}");
WulaLog.Debug($"[WULA_DEBUG] HasJobOnThing: No gathering order found. Total orders: {table.globalOrderStack.orders.Count}");
foreach (var o in table.globalOrderStack.orders)
{
Log.Message($" - Order: {o.Label}, State: {o.state}, Paused: {o.paused}");
WulaLog.Debug($" - Order: {o.Label}, State: {o.state}, Paused: {o.paused}");
}
}
return false;
@@ -45,7 +45,7 @@ namespace WulaFallenEmpire
var neededMaterials = GetNeededMaterials(order, table, globalStorage);
if (neededMaterials.Count == 0)
{
if (forced) Log.Message($"[WULA_DEBUG] HasJobOnThing: Order has enough resources.");
if (forced) WulaLog.Debug($"[WULA_DEBUG] HasJobOnThing: Order has enough resources.");
return false;
}
@@ -53,7 +53,7 @@ namespace WulaFallenEmpire
var ingredients = FindBestIngredients(pawn, table, neededMaterials);
if (ingredients == null)
{
if (forced) Log.Message($"[WULA_DEBUG] HasJobOnThing: Could not find ingredients for {order.Label}.");
if (forced) WulaLog.Debug($"[WULA_DEBUG] HasJobOnThing: Could not find ingredients for {order.Label}.");
return false;
}
@@ -87,7 +87,7 @@ namespace WulaFallenEmpire
{
var result = new List<KeyValuePair<Thing, int>>();
Log.Message($"[WULA_DEBUG] Needed materials: {string.Join(", ", neededMaterials.Select(k => $"{k.Key.defName} x{k.Value}"))}");
WulaLog.Debug($"[WULA_DEBUG] Needed materials: {string.Join(", ", neededMaterials.Select(k => $"{k.Key.defName} x{k.Value}"))}");
foreach (var kvp in neededMaterials)
{
@@ -114,7 +114,7 @@ namespace WulaFallenEmpire
}
}
Log.Message($"[WULA_DEBUG] Found {currentCount}/{countNeeded} of {def.defName}");
WulaLog.Debug($"[WULA_DEBUG] Found {currentCount}/{countNeeded} of {def.defName}");
}
return result.Count > 0 ? result : null;

View File

@@ -1,4 +1,4 @@
using HarmonyLib;
using HarmonyLib;
using RimWorld.Planet;
using System.Linq;
using Verse;
@@ -27,7 +27,7 @@ namespace WulaFallenEmpire
if (isBeingObserved)
{
// 如果地图正在被监测,阻止地图被移除
Log.Message($"[MapObserver] 阻止地图移除: {__instance.Label} 正在被监测");
WulaLog.Debug($"[MapObserver] 阻止地图移除: {__instance.Label} 正在被监测");
return false;
}
@@ -36,14 +36,14 @@ namespace WulaFallenEmpire
{
if (shuttle != null && shuttle.PocketMapGenerated && shuttle.PocketMap != null && shuttle.PocketMap.mapPawns.AnyPawnBlockingMapRemoval)
{
Log.Message($"[WULA] 阻止地图移除: 穿梭机 '{shuttle.Label}' 的口袋维度中仍有生物");
WulaLog.Debug($"[WULA] 阻止地图移除: 穿梭机 '{shuttle.Label}' 的口袋维度中仍有生物");
return false;
}
}
}
catch (System.Exception ex)
{
Log.Error($"[MapObserver] MapParent_CheckRemoveMapNow_Patch 错误: {ex}");
WulaLog.Debug($"[MapObserver] MapParent_CheckRemoveMapNow_Patch 错误: {ex}");
}
// 如果没有找到需要保护的情况,允许原方法继续执行

View File

@@ -1,4 +1,4 @@
using HarmonyLib;
using HarmonyLib;
using RimWorld;
using RimWorld.Planet;
using Verse;
@@ -25,7 +25,7 @@ namespace WulaFallenEmpire.HarmonyPatches
{
if (item is Building_ArmedShuttle armedShuttle)
{
Log.Message($"[WULA] Harmony Patch: Found Building_ArmedShuttle ({armedShuttle.Label}) in caravan inventory. Setting as __result.");
WulaLog.Debug($"[WULA] Harmony Patch: Found Building_ArmedShuttle ({armedShuttle.Label}) in caravan inventory. Setting as __result.");
// We need to cast our Building_ArmedShuttle to Building_PassengerShuttle
// This is safe because Building_ArmedShuttle is designed to be compatible with Building_PassengerShuttle's interface for caravan purposes.
__result = (Building_PassengerShuttle)armedShuttle;

View File

@@ -1,4 +1,4 @@
using HarmonyLib;
using HarmonyLib;
using RimWorld;
using RimWorld.Planet;
using System.Collections.Generic;
@@ -26,7 +26,7 @@ namespace WulaFallenEmpire
if (autonomousMechs.Any())
{
widget.AddSection("WULA_AutonomousMechsSection".Translate(), autonomousMechs);
Log.Message($"[WULA] Postfix: Added 'Autonomous Mechs' section with {autonomousMechs.Count} mechs.");
WulaLog.Debug($"[WULA] Postfix: Added 'Autonomous Mechs' section with {autonomousMechs.Count} mechs.");
}
}
}

View File

@@ -1,4 +1,4 @@
using HarmonyLib;
using HarmonyLib;
using RimWorld;
using System;
using System.Collections.Generic;
@@ -46,7 +46,7 @@ namespace WulaFallenEmpire.HarmonyPatches
{
if (!occupiedCell.InBounds(map))
{
Log.Warning($"[WULA] Harmony Patch: SkyfallerCanLandAt - Occupied cell {occupiedCell} for WULA_ArmedShuttle (size: {size}) is out of map bounds. Preventing landing.");
WulaLog.Debug($"[WULA] Harmony Patch: SkyfallerCanLandAt - Occupied cell {occupiedCell} for WULA_ArmedShuttle (size: {size}) is out of map bounds. Preventing landing.");
__result = false;
return false; // 阻止原方法执行,并返回 false
}

View File

@@ -1,4 +1,4 @@
using HarmonyLib;
using HarmonyLib;
using RimWorld;
using Verse;
@@ -14,7 +14,7 @@ namespace WulaFallenEmpire
var interceptorComp = __instance.TryGetComp<CompDamageInterceptor>();
if (interceptorComp != null)
{
Log.Message($"[DamageInterceptor] {__instance.LabelShort} 即将受到 {dinfo.Amount} 点伤害,拦截组件激活");
WulaLog.Debug($"[DamageInterceptor] {__instance.LabelShort} 即将受到 {dinfo.Amount} 点伤害,拦截组件激活");
// 让拦截组件处理伤害
return interceptorComp.PreApplyDamage(ref dinfo);
@@ -34,7 +34,7 @@ namespace WulaFallenEmpire
var interceptorComp = __instance.TryGetComp<CompDamageInterceptor>();
if (interceptorComp != null && totalDamageDealt == 0f)
{
Log.Message($"[DamageInterceptor] {__instance.LabelShort} 成功拦截所有伤害实际承受0点伤害");
WulaLog.Debug($"[DamageInterceptor] {__instance.LabelShort} 成功拦截所有伤害实际承受0点伤害");
}
}
}

View File

@@ -1,4 +1,4 @@
using HarmonyLib;
using HarmonyLib;
using RimWorld;
using System;
using System.Collections.Generic;
@@ -51,7 +51,7 @@ namespace WulaFallenEmpire.HarmonyPatches
}
catch (Exception ex)
{
Log.Error($"Error in Projectile_Impact_Patch: {ex}");
WulaLog.Debug($"Error in Projectile_Impact_Patch: {ex}");
return true;
}
}
@@ -76,7 +76,7 @@ namespace WulaFallenEmpire.HarmonyPatches
}
catch (Exception ex)
{
Log.Error($"Error in GetInterceptorsOnPawn: {ex}");
WulaLog.Debug($"Error in GetInterceptorsOnPawn: {ex}");
}
return result;

View File

@@ -1,4 +1,4 @@
using HarmonyLib;
using HarmonyLib;
using RimWorld;
using System.Collections.Generic;
using System.Reflection;
@@ -74,18 +74,18 @@ namespace WulaFallenEmpire
false, // canTransfer
Faction.OfPlayer // faction
});
Log.Message("[WULA] Successfully called DropThingGroupsNear with faction parameter via reflection");
WulaLog.Debug("[WULA] Successfully called DropThingGroupsNear with faction parameter via reflection");
}
else
{
Log.Error("[WULA] Could not find 11-parameter DropThingGroupsNear method");
WulaLog.Debug("[WULA] Could not find 11-parameter DropThingGroupsNear method");
}
// 返回 false 来跳过原方法的执行
return false;
}
catch (System.Exception ex)
{
Log.Error($"[WULA] Error in DoDropPods prefix: {ex}");
WulaLog.Debug($"[WULA] Error in DoDropPods prefix: {ex}");
// 如果出错,让原方法继续执行
return true;
}

View File

@@ -1,4 +1,4 @@
using HarmonyLib;
using HarmonyLib;
using RimWorld;
using RimWorld.Planet; // 关键修复
using System.Collections.Generic;
@@ -17,7 +17,7 @@ namespace WulaFallenEmpire
return;
}
Log.Message("[WULA] Patch_CaravanFormingUtility_AllSendablePawns Postfix - Start checking for autonomous mechs...");
WulaLog.Debug("[WULA] Patch_CaravanFormingUtility_AllSendablePawns Postfix - Start checking for autonomous mechs...");
// 遍历地图上所有的Pawn
foreach (Pawn pawn in map.mapPawns.AllPawns)
@@ -29,17 +29,17 @@ namespace WulaFallenEmpire
var comp = pawn.GetComp<CompAutonomousMech>();
bool canBeAutonomous = comp != null && comp.CanBeAutonomous;
Log.Message($"[WULA] Checking Mech: {pawn.LabelCap}, Already in list: {alreadyInList}, Has CompAutonomousMech: {comp != null}, CanBeAutonomous: {canBeAutonomous}");
WulaLog.Debug($"[WULA] Checking Mech: {pawn.LabelCap}, Already in list: {alreadyInList}, Has CompAutonomousMech: {comp != null}, CanBeAutonomous: {canBeAutonomous}");
// 如果它是一个可以自主行动的机械体,但没有被原版方法包含,我们就添加它
if (!alreadyInList && canBeAutonomous)
{
__result.Add(pawn);
Log.Message($"[WULA] -> Added {pawn.LabelCap} to the list.");
WulaLog.Debug($"[WULA] -> Added {pawn.LabelCap} to the list.");
}
}
}
Log.Message("[WULA] Patch_CaravanFormingUtility_AllSendablePawns Postfix - Finished.");
WulaLog.Debug("[WULA] Patch_CaravanFormingUtility_AllSendablePawns Postfix - Finished.");
}
}
}

View File

@@ -1,4 +1,4 @@
using HarmonyLib;
using HarmonyLib;
using RimWorld;
using System.Collections.Generic;
using System.Linq;
@@ -30,7 +30,7 @@ namespace WulaFallenEmpire
{
if (corpseDef == null) return;
Log.Message($"[WulaSpecies] Starting corpse modification for WulaSpecies");
WulaLog.Debug($"[WulaSpecies] Starting corpse modification for WulaSpecies");
// 1. 移除腐烂组件(如果存在)
RemoveCompProperties(corpseDef, typeof(CompProperties_Rottable));
@@ -42,13 +42,13 @@ namespace WulaFallenEmpire
if (corpseDef.ingestible != null)
{
corpseDef.ingestible.preferability = FoodPreferability.NeverForNutrition;
Log.Message($"[WulaSpecies] Set ingestible preferability to NeverForNutrition");
WulaLog.Debug($"[WulaSpecies] Set ingestible preferability to NeverForNutrition");
}
// 4. 移除 HarbingerTreeConsumable 组件(如果存在)
RemoveCompProperties(corpseDef, typeof(CompProperties), "CompHarbingerTreeConsumable");
Log.Message($"[WulaSpecies] Completed corpse modification for WulaSpecies");
WulaLog.Debug($"[WulaSpecies] Completed corpse modification for WulaSpecies");
}
/// <summary>
@@ -65,19 +65,19 @@ namespace WulaFallenEmpire
if (comp.GetType() == compType)
{
compsToRemove.Add(comp);
Log.Message($"[WulaSpecies] Found and will remove component: {comp.GetType().Name}");
WulaLog.Debug($"[WulaSpecies] Found and will remove component: {comp.GetType().Name}");
}
else if (!string.IsNullOrEmpty(compClassName) && comp.compClass?.Name == compClassName)
{
compsToRemove.Add(comp);
Log.Message($"[WulaSpecies] Found and will remove component by class name: {compClassName}");
WulaLog.Debug($"[WulaSpecies] Found and will remove component by class name: {compClassName}");
}
}
foreach (var comp in compsToRemove)
{
thingDef.comps.Remove(comp);
Log.Message($"[WulaSpecies] Removed component: {comp.GetType().Name}");
WulaLog.Debug($"[WulaSpecies] Removed component: {comp.GetType().Name}");
}
}
}

View File

@@ -1,4 +1,4 @@
using RimWorld;
using RimWorld;
using Verse;
using Verse.Sound;
@@ -85,11 +85,11 @@ namespace WulaFallenEmpire
// 5. 暴力删除 pawn
DestroyPawn();
Log.Message($"[DisappearWithEffect] Pawn {Pawn.LabelCap} destroyed at {position}");
WulaLog.Debug($"[DisappearWithEffect] Pawn {Pawn.LabelCap} destroyed at {position}");
}
catch (System.Exception ex)
{
Log.Error($"[DisappearWithEffect] Error in TriggerDisappearEffect: {ex}");
WulaLog.Debug($"[DisappearWithEffect] Error in TriggerDisappearEffect: {ex}");
}
}
@@ -211,11 +211,11 @@ namespace WulaFallenEmpire
// 直接调用 Destroy绕过所有死亡逻辑
Pawn.Destroy(DestroyMode.Vanish);
Log.Message($"[DisappearWithEffect] Pawn {Pawn.LabelCap} destroyed");
WulaLog.Debug($"[DisappearWithEffect] Pawn {Pawn.LabelCap} destroyed");
}
catch (System.Exception ex)
{
Log.Error($"[DisappearWithEffect] Error destroying pawn: {ex}");
WulaLog.Debug($"[DisappearWithEffect] Error destroying pawn: {ex}");
}
}

View File

@@ -1,4 +1,4 @@
using RimWorld;
using RimWorld;
using Verse;
using System.Collections.Generic;
using UnityEngine;
@@ -400,7 +400,7 @@ namespace WulaFallenEmpire
}
catch (System.Exception ex)
{
Log.Error($"[NanoRepair] 修复部位 {part.def.defName} 时出错: {ex}");
WulaLog.Debug($"[NanoRepair] 修复部位 {part.def.defName} 时出错: {ex}");
return false;
}
}
@@ -470,7 +470,7 @@ namespace WulaFallenEmpire
HediffDef injuryDef = DefDatabase<HediffDef>.GetNamedSilentFail("Crush");
if (injuryDef == null)
{
Log.Error($"[NanoRepair] 找不到指定的hediff定义: Crush");
WulaLog.Debug($"[NanoRepair] 找不到指定的hediff定义: Crush");
return false;
}
@@ -484,7 +484,7 @@ namespace WulaFallenEmpire
}
catch (System.Exception ex)
{
Log.Error($"[NanoRepair] 转换缺失部件 {missingPart.Part.def.defName} 时出错: {ex}");
WulaLog.Debug($"[NanoRepair] 转换缺失部件 {missingPart.Part.def.defName} 时出错: {ex}");
return false;
}
}

View File

@@ -1,4 +1,4 @@
using RimWorld;
using RimWorld;
using System.Collections.Generic;
using UnityEngine;
using Verse;
@@ -51,7 +51,7 @@ namespace WulaFallenEmpire
HediffComp_Disappears hediffComp_Disappears = hediff.TryGetComp<HediffComp_Disappears>();
if (hediffComp_Disappears == null)
{
Log.Error("HediffComp_GiveHediffsInRangeToRace has a hediff in props which does not have a HediffComp_Disappears");
WulaLog.Debug("HediffComp_GiveHediffsInRangeToRace has a hediff in props which does not have a HediffComp_Disappears");
}
else
{

View File

@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using Verse;
using RimWorld;
@@ -36,7 +36,7 @@ namespace WulaFallenEmpire
Pawn pawn = this.parent.pawn;
if (pawn == null || pawn.story == null)
{
Log.Warning($"[WulaFallenEmpire] HediffComp_RegenerateBackstory: Pawn or Pawn.story is null for hediff {this.parent.def.defName}. Cannot regenerate backstory.");
WulaLog.Debug($"[WulaFallenEmpire] HediffComp_RegenerateBackstory: Pawn or Pawn.story is null for hediff {this.parent.def.defName}. Cannot regenerate backstory.");
return;
}
@@ -48,7 +48,7 @@ namespace WulaFallenEmpire
}
else
{
Log.Warning($"[WulaFallenEmpire] HediffComp_RegenerateBackstory: No spawnCategories specified for hediff {this.parent.def.defName}. Using all available categories.");
WulaLog.Debug($"[WulaFallenEmpire] HediffComp_RegenerateBackstory: No spawnCategories specified for hediff {this.parent.def.defName}. Using all available categories.");
categories = DefDatabase<BackstoryDef>.AllDefs.SelectMany(bs => bs.spawnCategories).Distinct().ToList(); // 如果没有指定类别,则使用所有类别
}
@@ -71,7 +71,7 @@ namespace WulaFallenEmpire
}
else
{
Log.Warning($"[WulaFallenEmpire] HediffComp_RegenerateBackstory: No childhood backstories found for categories: {string.Join(", ", Props.spawnCategories ?? new List<string>())}.");
WulaLog.Debug($"[WulaFallenEmpire] HediffComp_RegenerateBackstory: No childhood backstories found for categories: {string.Join(", ", Props.spawnCategories ?? new List<string>())}.");
}
} else
{
@@ -92,7 +92,7 @@ namespace WulaFallenEmpire
}
else
{
Log.Warning($"[WulaFallenEmpire] HediffComp_RegenerateBackstory: No adulthood backstories found for categories: {string.Join(", ", Props.spawnCategories ?? new List<string>())}.");
WulaLog.Debug($"[WulaFallenEmpire] HediffComp_RegenerateBackstory: No adulthood backstories found for categories: {string.Join(", ", Props.spawnCategories ?? new List<string>())}.");
}
// 应用新的背景故事
@@ -100,16 +100,16 @@ namespace WulaFallenEmpire
{
pawn.story.Childhood = newChildhood;
pawn.story.Adulthood = newAdulthood;
Log.Message($"[WulaFallenEmpire] Regenerated backstory for {pawn.NameShortColored}: Childhood='{newChildhood?.title ?? "None"}', Adulthood='{newAdulthood?.title ?? "None"}'.");
WulaLog.Debug($"[WulaFallenEmpire] Regenerated backstory for {pawn.NameShortColored}: Childhood='{newChildhood?.title ?? "None"}', Adulthood='{newAdulthood?.title ?? "None"}'.");
}
else
{
Log.Warning($"[WulaFallenEmpire] HediffComp_RegenerateBackstory: Failed to find any suitable backstories for {pawn.NameShortColored} with categories: {string.Join(", ", Props.spawnCategories ?? new List<string>())}.");
WulaLog.Debug($"[WulaFallenEmpire] HediffComp_RegenerateBackstory: Failed to find any suitable backstories for {pawn.NameShortColored} with categories: {string.Join(", ", Props.spawnCategories ?? new List<string>())}.");
}
// 删除当前的Hediff
pawn.health.RemoveHediff(this.parent);
Log.Message($"[WulaFallenEmpire] Removed hediff {this.parent.def.defName} from {pawn.NameShortColored} after backstory regeneration.");
WulaLog.Debug($"[WulaFallenEmpire] Removed hediff {this.parent.def.defName} from {pawn.NameShortColored} after backstory regeneration.");
}
}
}

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using UnityEngine;
using Verse;
@@ -315,7 +315,7 @@ namespace WulaFallenEmpire
{
if (this.gun == null)
{
Log.Error("CompTurrentGun had null gun after loading. Recreating.");
WulaLog.Debug("CompTurrentGun had null gun after loading. Recreating.");
this.MakeGun();
return;
}

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using RimWorld;
using UnityEngine;
@@ -12,7 +12,7 @@ namespace WulaFallenEmpire
{
if (parentHediff.pawn != null && parentHediff.def.defName != null && debug)
{
Log.Warning(parentHediff.pawn.Label + "'s Hediff: " + parentHediff.def.defName + " says goodbye.");
WulaLog.Debug(parentHediff.pawn.Label + "'s Hediff: " + parentHediff.def.defName + " says goodbye.");
}
parentHediff.Severity = 0f;
}
@@ -24,14 +24,14 @@ namespace WulaFallenEmpire
{
if (debug)
{
Log.Warning("GetPawnAgeOverlifeExpectancyRatio pawn NOT OK");
WulaLog.Debug("GetPawnAgeOverlifeExpectancyRatio pawn NOT OK");
}
return result;
}
result = pawn.ageTracker.AgeBiologicalYearsFloat / pawn.RaceProps.lifeExpectancy;
if (debug)
{
Log.Warning(string.Concat(new string[]
WulaLog.Debug(string.Concat(new string[]
{
pawn.Label,
" Age: ",
@@ -51,7 +51,7 @@ namespace WulaFallenEmpire
{
if (debug)
{
Log.Warning("pawn is null - wounded ");
WulaLog.Debug("pawn is null - wounded ");
}
return false;
}
@@ -66,7 +66,7 @@ namespace WulaFallenEmpire
}
if (debug && num > 0f)
{
Log.Warning(pawn.Label + " is wounded ");
WulaLog.Debug(pawn.Label + " is wounded ");
}
return num > 0f;
}
@@ -77,14 +77,14 @@ namespace WulaFallenEmpire
{
if (debug)
{
Log.Warning("pawn is null - IsHungry ");
WulaLog.Debug("pawn is null - IsHungry ");
}
return false;
}
bool flag = pawn.needs.food != null && pawn.needs.food.CurCategory == HungerCategory.Starving;
if (debug && flag)
{
Log.Warning(pawn.Label + " is hungry ");
WulaLog.Debug(pawn.Label + " is hungry ");
}
return flag;
}
@@ -98,7 +98,7 @@ namespace WulaFallenEmpire
{
if (debug)
{
Log.Warning(warning);
WulaLog.Debug(warning);
}
}

View File

@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using RimWorld;
using Verse;
using Verse.AI;
@@ -51,7 +51,7 @@ namespace WulaFallenEmpire
// 记录日志
if (Prefs.DevMode)
{
Log.Message($"[JobDriver_InspectBuilding] {pawn.Name} started inspecting {TargetThingA.Label} for {ticksLeft} ticks");
WulaLog.Debug($"[JobDriver_InspectBuilding] {pawn.Name} started inspecting {TargetThingA.Label} for {ticksLeft} ticks");
}
};
@@ -99,7 +99,7 @@ namespace WulaFallenEmpire
if (Prefs.DevMode)
{
Log.Message($"[JobDriver_InspectBuilding] {pawn.Name} completed inspection of {TargetThingA.Label}");
WulaLog.Debug($"[JobDriver_InspectBuilding] {pawn.Name} completed inspection of {TargetThingA.Label}");
}
}

View File

@@ -1,4 +1,4 @@
using RimWorld;
using RimWorld;
using RimWorld.Planet;
using System.Collections.Generic;
using System.Linq;
@@ -63,7 +63,7 @@ namespace WulaFallenEmpire
// 记录调试信息
if (Prefs.DevMode)
{
Log.Message($"[JobGiver_InspectBuilding] Assigned inspection job to {pawn.Name} at {inspectionTarget.Label}");
WulaLog.Debug($"[JobGiver_InspectBuilding] Assigned inspection job to {pawn.Name} at {inspectionTarget.Label}");
}
return job;
@@ -107,7 +107,7 @@ namespace WulaFallenEmpire
{
int remainingTicks = minIntervalTicks - elapsedTicks;
float remainingSeconds = remainingTicks / 60f;
Log.Message($"[JobGiver_InspectBuilding] {pawn.Name} must wait {remainingSeconds:F1} seconds before next inspection");
WulaLog.Debug($"[JobGiver_InspectBuilding] {pawn.Name} must wait {remainingSeconds:F1} seconds before next inspection");
}
return canInspect;
@@ -122,7 +122,7 @@ namespace WulaFallenEmpire
if (Prefs.DevMode)
{
Log.Message($"[JobGiver_InspectBuilding] Recorded inspection start for {pawn.Name} at tick {lastInspectionTicks[pawn]}");
WulaLog.Debug($"[JobGiver_InspectBuilding] Recorded inspection start for {pawn.Name} at tick {lastInspectionTicks[pawn]}");
}
}
@@ -158,7 +158,7 @@ namespace WulaFallenEmpire
{
if (Prefs.DevMode)
{
Log.Message($"[JobGiver_InspectBuilding] No valid inspection targets found for {pawn.Name}");
WulaLog.Debug($"[JobGiver_InspectBuilding] No valid inspection targets found for {pawn.Name}");
}
return null;
}
@@ -168,7 +168,7 @@ namespace WulaFallenEmpire
if (Prefs.DevMode)
{
Log.Message($"[JobGiver_InspectBuilding] Randomly selected {selectedBuilding.Label} from {validBuildings.Count} valid targets");
WulaLog.Debug($"[JobGiver_InspectBuilding] Randomly selected {selectedBuilding.Label} from {validBuildings.Count} valid targets");
}
return selectedBuilding;
@@ -228,7 +228,7 @@ namespace WulaFallenEmpire
{
if (Prefs.DevMode)
{
Log.Message($"[JobGiver_InspectBuilding] Excluding wall: {thing.Label}");
WulaLog.Debug($"[JobGiver_InspectBuilding] Excluding wall: {thing.Label}");
}
return true;
}
@@ -283,7 +283,7 @@ namespace WulaFallenEmpire
if (Prefs.DevMode && toRemove.Count > 0)
{
Log.Message($"[JobGiver_InspectBuilding] Cleaned up {toRemove.Count} inspection records");
WulaLog.Debug($"[JobGiver_InspectBuilding] Cleaned up {toRemove.Count} inspection records");
}
}

Some files were not shown because too many files have changed in this diff Show More