✅ 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:
@@ -57,7 +57,7 @@ namespace WulaFallenEmpire
|
||||
{
|
||||
if (gun == null)
|
||||
{
|
||||
Log.Error("CompTurrentGun had null gun after loading. Recreating.");
|
||||
WulaLog.Debug("CompTurrentGun had null gun after loading. Recreating.");
|
||||
MakeGun();
|
||||
}
|
||||
else
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using RimWorld;
|
||||
using UnityEngine;
|
||||
using Verse;
|
||||
@@ -251,14 +251,14 @@ namespace WulaFallenEmpire
|
||||
// 确保Command不为null
|
||||
if (switchWeaponCommand == null)
|
||||
{
|
||||
Log.Error($"Failed to create weapon switch gizmo for {MechPawn?.LabelCap}");
|
||||
WulaLog.Debug($"Failed to create weapon switch gizmo for {MechPawn?.LabelCap}");
|
||||
return null;
|
||||
}
|
||||
return switchWeaponCommand;
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
Log.Error($"Error creating weapon switch gizmo: {ex}");
|
||||
WulaLog.Debug($"Error creating weapon switch gizmo: {ex}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -282,7 +282,7 @@ namespace WulaFallenEmpire
|
||||
|
||||
if (Prefs.DevMode)
|
||||
{
|
||||
Log.Message($"[CompAutonomousMech] {MechPawn.LabelCap} dropped weapon: {currentWeapon.LabelCap}");
|
||||
WulaLog.Debug($"[CompAutonomousMech] {MechPawn.LabelCap} dropped weapon: {currentWeapon.LabelCap}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -302,7 +302,7 @@ namespace WulaFallenEmpire
|
||||
|
||||
if (Prefs.DevMode)
|
||||
{
|
||||
Log.Message($"[CompAutonomousMech] {MechPawn.LabelCap} equipped new weapon: {newWeaponDef.LabelCap}");
|
||||
WulaLog.Debug($"[CompAutonomousMech] {MechPawn.LabelCap} equipped new weapon: {newWeaponDef.LabelCap}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -314,7 +314,7 @@ namespace WulaFallenEmpire
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
Log.Error($"[CompAutonomousMech] Error switching weapon for {MechPawn?.LabelCap}: {ex}");
|
||||
WulaLog.Debug($"[CompAutonomousMech] Error switching weapon for {MechPawn?.LabelCap}: {ex}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using RimWorld;
|
||||
using RimWorld;
|
||||
using Verse;
|
||||
using Verse.AI;
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace WulaFallenEmpire
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
Log.Error($"[WULA] Exception in ThinkNode_ConditionalAutonomousWorkMode.Satisfied for pawn {pawn?.LabelShort}: {ex}");
|
||||
WulaLog.Debug($"[WULA] Exception in ThinkNode_ConditionalAutonomousWorkMode.Satisfied for pawn {pawn?.LabelShort}: {ex}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using RimWorld;
|
||||
using UnityEngine;
|
||||
using Verse;
|
||||
@@ -255,7 +255,7 @@ namespace WulaFallenEmpire
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
Log.Error($"CompFighterInvisible: Error sending letter for {Sightstealer?.LabelCap}: {ex}");
|
||||
WulaLog.Debug($"CompFighterInvisible: Error sending letter for {Sightstealer?.LabelCap}: {ex}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Verse;
|
||||
using RimWorld;
|
||||
@@ -63,7 +63,7 @@ namespace WulaFallenEmpire
|
||||
{
|
||||
AddHediffsToPawn(pawn);
|
||||
hediffsApplied = true;
|
||||
Log.Message($"Debug: Applied hediffs to {pawn.Label}");
|
||||
WulaLog.Debug($"Debug: Applied hediffs to {pawn.Label}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// JobDriver_HaulToMaintenancePod.cs (修复版)
|
||||
// JobDriver_HaulToMaintenancePod.cs (修复版)
|
||||
using System.Collections.Generic;
|
||||
using RimWorld;
|
||||
using Verse;
|
||||
@@ -41,14 +41,14 @@ namespace WulaFallenEmpire
|
||||
{
|
||||
if (Takee == null || Takee.Destroyed)
|
||||
{
|
||||
Log.Error("试图搬运不存在的Pawn");
|
||||
WulaLog.Debug("试图搬运不存在的Pawn");
|
||||
return;
|
||||
}
|
||||
|
||||
// 使用TryStartCarryThing并明确指定数量
|
||||
if (pawn.carryTracker.TryStartCarry(Takee, 1) <= 0)
|
||||
{
|
||||
Log.Error($"无法搬运Pawn: {Takee.Label}");
|
||||
WulaLog.Debug($"无法搬运Pawn: {Takee.Label}");
|
||||
EndJobWith(JobCondition.Incompletable);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Need_Maintenance.cs
|
||||
// Need_Maintenance.cs
|
||||
using RimWorld;
|
||||
using Verse;
|
||||
using System.Linq;
|
||||
@@ -120,7 +120,7 @@ namespace WulaFallenEmpire
|
||||
// 情况1:没有 Hediff,但应该有
|
||||
if (expectedStatus != MaintenanceStatus.Operational && actualHediffs.Count == 0)
|
||||
{
|
||||
Log.Warning($"[Maintenance] Validation: {pawn.Label} should have {expectedStatus} hediff but has none. Reapplying.");
|
||||
WulaLog.Debug($"[Maintenance] Validation: {pawn.Label} should have {expectedStatus} hediff but has none. Reapplying.");
|
||||
UpdateHediffForStatus(expectedStatus);
|
||||
return;
|
||||
}
|
||||
@@ -128,7 +128,7 @@ namespace WulaFallenEmpire
|
||||
// 情况2:有 Hediff,但不应该有
|
||||
if (expectedStatus == MaintenanceStatus.Operational && actualHediffs.Count > 0)
|
||||
{
|
||||
Log.Warning($"[Maintenance] Validation: {pawn.Label} is operational but has maintenance hediffs. Removing all.");
|
||||
WulaLog.Debug($"[Maintenance] Validation: {pawn.Label} is operational but has maintenance hediffs. Removing all.");
|
||||
RemoveAllMaintenanceHediffs();
|
||||
currentAppliedStatus = MaintenanceStatus.Operational;
|
||||
currentAppliedHediff = null;
|
||||
@@ -138,7 +138,7 @@ namespace WulaFallenEmpire
|
||||
// 情况3:有多个 Hediff
|
||||
if (actualHediffs.Count > 1)
|
||||
{
|
||||
Log.Warning($"[Maintenance] Validation: {pawn.Label} has multiple maintenance hediffs ({actualHediffs.Count}). Cleaning up.");
|
||||
WulaLog.Debug($"[Maintenance] Validation: {pawn.Label} has multiple maintenance hediffs ({actualHediffs.Count}). Cleaning up.");
|
||||
CleanupMultipleHediffs(expectedStatus);
|
||||
return;
|
||||
}
|
||||
@@ -151,7 +151,7 @@ namespace WulaFallenEmpire
|
||||
|
||||
if (currentHediff.def != expectedHediffDef)
|
||||
{
|
||||
Log.Warning($"[Maintenance] Validation: {pawn.Label} has wrong hediff type. Expected {expectedHediffDef?.defName}, got {currentHediff.def.defName}. Correcting.");
|
||||
WulaLog.Debug($"[Maintenance] Validation: {pawn.Label} has wrong hediff type. Expected {expectedHediffDef?.defName}, got {currentHediff.def.defName}. Correcting.");
|
||||
UpdateHediffForStatus(expectedStatus);
|
||||
return;
|
||||
}
|
||||
@@ -160,14 +160,14 @@ namespace WulaFallenEmpire
|
||||
if (currentAppliedHediff != currentHediff)
|
||||
{
|
||||
currentAppliedHediff = currentHediff;
|
||||
Log.Message($"[Maintenance] Validation: Updated currentAppliedHediff reference for {pawn.Label}");
|
||||
WulaLog.Debug($"[Maintenance] Validation: Updated currentAppliedHediff reference for {pawn.Label}");
|
||||
}
|
||||
}
|
||||
|
||||
// 情况5:状态记录不一致
|
||||
if (currentAppliedStatus != expectedStatus)
|
||||
{
|
||||
Log.Warning($"[Maintenance] Validation: {pawn.Label} status mismatch. Recorded: {currentAppliedStatus}, Actual: {expectedStatus}. Synchronizing.");
|
||||
WulaLog.Debug($"[Maintenance] Validation: {pawn.Label} status mismatch. Recorded: {currentAppliedStatus}, Actual: {expectedStatus}. Synchronizing.");
|
||||
currentAppliedStatus = expectedStatus;
|
||||
}
|
||||
}
|
||||
@@ -248,7 +248,7 @@ namespace WulaFallenEmpire
|
||||
{
|
||||
if (Prefs.DevMode)
|
||||
{
|
||||
Log.Message($"[Maintenance] Status changed for {pawn.Label}: {currentAppliedStatus} -> {newStatus}");
|
||||
WulaLog.Debug($"[Maintenance] Status changed for {pawn.Label}: {currentAppliedStatus} -> {newStatus}");
|
||||
}
|
||||
|
||||
UpdateHediffForStatus(newStatus);
|
||||
@@ -273,7 +273,7 @@ namespace WulaFallenEmpire
|
||||
// 调试日志
|
||||
if (Prefs.DevMode)
|
||||
{
|
||||
Log.Message($"[Maintenance] Applied {hediffDefToAdd.defName} for status {status} to {pawn.Label}");
|
||||
WulaLog.Debug($"[Maintenance] Applied {hediffDefToAdd.defName} for status {status} to {pawn.Label}");
|
||||
}
|
||||
}
|
||||
else if (status == MaintenanceStatus.Operational)
|
||||
@@ -281,7 +281,7 @@ namespace WulaFallenEmpire
|
||||
// 操作状态,不需要 Hediff
|
||||
if (Prefs.DevMode)
|
||||
{
|
||||
Log.Message($"[Maintenance] {pawn.Label} is operational, no hediff needed");
|
||||
WulaLog.Debug($"[Maintenance] {pawn.Label} is operational, no hediff needed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user