暂存选项隐藏派系检测

This commit is contained in:
2025-08-11 22:05:04 +08:00
parent 75561a846a
commit 126d539543
7 changed files with 143 additions and 1 deletions

View File

@@ -194,6 +194,10 @@ namespace WulaFallenEmpire
}
else
{
if (option.hideWhenDisabled)
{
continue; // Skip rendering this option entirely
}
Rect rect = listing.GetRect(30f);
Widgets.ButtonText(rect, option.label, false, true, false);
TooltipHandler.TipRegion(rect, GetDisabledReason(option, reason));

View File

@@ -565,6 +565,37 @@ namespace WulaFallenEmpire
}
}
public class Effect_CheckFactionGoodwill : Effect
{
public FactionDef factionDef;
public string variableName;
public override void Execute(Dialog_CustomDisplay dialog = null)
{
if (factionDef == null)
{
Log.Error("Effect_CheckFactionGoodwill requires a factionDef.");
return;
}
if (string.IsNullOrEmpty(variableName))
{
Log.Error("Effect_CheckFactionGoodwill requires a variableName.");
return;
}
Faction faction = Find.FactionManager.FirstFactionOfDef(factionDef);
if (faction == null)
{
// Faction doesn't exist, store a default value (e.g., 0 or a specific marker)
EventContext.SetVariable(variableName, 0);
Log.Warning($"Faction with def {factionDef.defName} not found. Setting '{variableName}' to 0.");
return;
}
int goodwill = faction.GoodwillWith(Faction.OfPlayer);
EventContext.SetVariable(variableName, goodwill);
}
}
}

View File

@@ -63,6 +63,7 @@ namespace WulaFallenEmpire
public List<ConditionalEffects> optionEffects;
public List<Condition> conditions;
public string disabledReason;
public bool hideWhenDisabled = false;
}
public class ConditionalEffects