✅ 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:
@@ -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}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user