Files
WulaFallenEmpireRW/Source/WulaFallenEmpire/EventSystem/Condition/Condition_FlagExists.cs
ProjectKoi-Kalo\Kalo 98a0400c78 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()
2025-12-15 13:05:50 +08:00

84 lines
2.4 KiB
C#

using Verse;
using RimWorld;
namespace WulaFallenEmpire
{
public abstract class Condition
{
public abstract bool IsMet(out string reason);
}
public class Condition_FlagExists : ConditionBase
{
public string flagName;
public override bool IsMet(out string reason)
{
if (string.IsNullOrEmpty(flagName))
{
reason = "Flag name is not specified.";
return false;
}
var eventVarManager = Find.World.GetComponent<EventVariableManager>();
bool flagExists = eventVarManager.HasFlag(flagName);
if (!flagExists)
{
reason = $"Flag '{flagName}' does not exist or has expired.";
}
else
{
int remainingTicks = eventVarManager.GetFlagRemainingTicks(flagName);
if (remainingTicks < 0)
{
reason = $"Flag '{flagName}' exists (permanent).";
}
else
{
reason = $"Flag '{flagName}' exists (expires in {remainingTicks} ticks).";
}
}
WulaLog.Debug($"[EventSystem] Condition_FlagExists check: Flag='{flagName}', Exists={flagExists}, Reason='{reason}'");
return flagExists;
}
}
public class Condition_FlagNotExists : ConditionBase
{
public string flagName;
public override bool IsMet(out string reason)
{
if (string.IsNullOrEmpty(flagName))
{
reason = "Flag name is not specified.";
return false;
}
var eventVarManager = Find.World.GetComponent<EventVariableManager>();
bool flagExists = eventVarManager.HasFlag(flagName);
if (flagExists)
{
int remainingTicks = eventVarManager.GetFlagRemainingTicks(flagName);
if (remainingTicks < 0)
{
reason = $"Flag '{flagName}' exists (permanent).";
}
else
{
reason = $"Flag '{flagName}' exists (expires in {remainingTicks} ticks).";
}
return false;
}
else
{
reason = $"Flag '{flagName}' does not exist.";
return true;
}
}
}
}