✅ WulaLog.cs - 修改了DebugEnabled属性,仅检查enableDebugLogs设置(不检查DevMode) ✅ WulaFallenEmpireMod.cs - 在DoSettingsWindowContents中添加了UI复选框,显示"Enable Debug Logs"选项 ✅ 替换了所有848个Log.Message/Error/Warning调用为WulaLog.Debug()
106 lines
2.2 KiB
C#
106 lines
2.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using RimWorld;
|
|
using UnityEngine;
|
|
using Verse;
|
|
|
|
namespace WulaFallenEmpire
|
|
{
|
|
public static class Tools
|
|
{
|
|
public static void DestroyParentHediff(Hediff parentHediff, bool debug = false)
|
|
{
|
|
if (parentHediff.pawn != null && parentHediff.def.defName != null && debug)
|
|
{
|
|
WulaLog.Debug(parentHediff.pawn.Label + "'s Hediff: " + parentHediff.def.defName + " says goodbye.");
|
|
}
|
|
parentHediff.Severity = 0f;
|
|
}
|
|
|
|
public static float GetPawnAgeOverlifeExpectancyRatio(Pawn pawn, bool debug = false)
|
|
{
|
|
float result = 1f;
|
|
if (pawn == null)
|
|
{
|
|
if (debug)
|
|
{
|
|
WulaLog.Debug("GetPawnAgeOverlifeExpectancyRatio pawn NOT OK");
|
|
}
|
|
return result;
|
|
}
|
|
result = pawn.ageTracker.AgeBiologicalYearsFloat / pawn.RaceProps.lifeExpectancy;
|
|
if (debug)
|
|
{
|
|
WulaLog.Debug(string.Concat(new string[]
|
|
{
|
|
pawn.Label,
|
|
" Age: ",
|
|
pawn.ageTracker.AgeBiologicalYearsFloat.ToString(),
|
|
"; lifeExpectancy: ",
|
|
pawn.RaceProps.lifeExpectancy.ToString(),
|
|
"; ratio:",
|
|
result.ToString()
|
|
}));
|
|
}
|
|
return result;
|
|
}
|
|
|
|
public static bool IsInjured(this Pawn pawn, bool debug = false)
|
|
{
|
|
if (pawn == null)
|
|
{
|
|
if (debug)
|
|
{
|
|
WulaLog.Debug("pawn is null - wounded ");
|
|
}
|
|
return false;
|
|
}
|
|
float num = 0f;
|
|
List<Hediff> hediffs = pawn.health.hediffSet.hediffs;
|
|
for (int i = 0; i < hediffs.Count; i++)
|
|
{
|
|
if (hediffs[i] is Hediff_Injury && !hediffs[i].IsPermanent())
|
|
{
|
|
num += hediffs[i].Severity;
|
|
}
|
|
}
|
|
if (debug && num > 0f)
|
|
{
|
|
WulaLog.Debug(pawn.Label + " is wounded ");
|
|
}
|
|
return num > 0f;
|
|
}
|
|
|
|
public static bool IsHungry(this Pawn pawn, bool debug = false)
|
|
{
|
|
if (pawn == null)
|
|
{
|
|
if (debug)
|
|
{
|
|
WulaLog.Debug("pawn is null - IsHungry ");
|
|
}
|
|
return false;
|
|
}
|
|
bool flag = pawn.needs.food != null && pawn.needs.food.CurCategory == HungerCategory.Starving;
|
|
if (debug && flag)
|
|
{
|
|
WulaLog.Debug(pawn.Label + " is hungry ");
|
|
}
|
|
return flag;
|
|
}
|
|
|
|
public static bool OkPawn(Pawn pawn)
|
|
{
|
|
return pawn != null && pawn.Map != null;
|
|
}
|
|
|
|
public static void Warn(string warning, bool debug = false)
|
|
{
|
|
if (debug)
|
|
{
|
|
WulaLog.Debug(warning);
|
|
}
|
|
}
|
|
|
|
}
|
|
} |