暂存4
This commit is contained in:
Binary file not shown.
@@ -2,10 +2,6 @@
|
||||
"Version": 1,
|
||||
"WorkspaceRootPath": "C:\\Steam\\steamapps\\common\\RimWorld\\Mods\\3516260226\\Source\\WulaFallenEmpire\\",
|
||||
"Documents": [
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{F5AE8C3B-0221-4C16-A128-9A62D521A8FF}|WulaFallenEmpire.csproj|c:\\steam\\steamapps\\common\\rimworld\\mods\\3516260226\\source\\wulafallenempire\\debugactions.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{F5AE8C3B-0221-4C16-A128-9A62D521A8FF}|WulaFallenEmpire.csproj|solutionrelative:debugactions.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
},
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{F5AE8C3B-0221-4C16-A128-9A62D521A8FF}|WulaFallenEmpire.csproj|C:\\Steam\\steamapps\\common\\RimWorld\\Mods\\3516260226\\Source\\WulaFallenEmpire\\mentalstate_brokenpersonality.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{F5AE8C3B-0221-4C16-A128-9A62D521A8FF}|WulaFallenEmpire.csproj|solutionrelative:mentalstate_brokenpersonality.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
@@ -71,19 +67,6 @@
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 0,
|
||||
"Title": "DebugActions.cs",
|
||||
"DocumentMoniker": "C:\\Steam\\steamapps\\common\\RimWorld\\Mods\\3516260226\\Source\\WulaFallenEmpire\\DebugActions.cs",
|
||||
"RelativeDocumentMoniker": "DebugActions.cs",
|
||||
"ToolTip": "C:\\Steam\\steamapps\\common\\RimWorld\\Mods\\3516260226\\Source\\WulaFallenEmpire\\DebugActions.cs",
|
||||
"RelativeToolTip": "DebugActions.cs",
|
||||
"ViewState": "AQIAAAAAAAAAAAAAAAAAAAkAAAAAAAAA",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2025-07-27T07:57:05.014Z",
|
||||
"EditorCaption": ""
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 1,
|
||||
"Title": "MentalState_BrokenPersonality.cs",
|
||||
"DocumentMoniker": "C:\\Steam\\steamapps\\common\\RimWorld\\Mods\\3516260226\\Source\\WulaFallenEmpire\\MentalState_BrokenPersonality.cs",
|
||||
"RelativeDocumentMoniker": "MentalState_BrokenPersonality.cs",
|
||||
@@ -91,11 +74,12 @@
|
||||
"RelativeToolTip": "MentalState_BrokenPersonality.cs",
|
||||
"ViewState": "AQIAABMAAAAAAAAAAAAAwEsAAAAjAAAA",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2025-07-25T13:51:03.13Z"
|
||||
"WhenOpened": "2025-07-25T13:51:03.13Z",
|
||||
"EditorCaption": ""
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 2,
|
||||
"DocumentIndex": 1,
|
||||
"Title": "Recipe_AdministerWulaMechRepairKit.cs",
|
||||
"DocumentMoniker": "C:\\Steam\\steamapps\\common\\RimWorld\\Mods\\3516260226\\Source\\WulaFallenEmpire\\Recipe_AdministerWulaMechRepairKit.cs",
|
||||
"RelativeDocumentMoniker": "Recipe_AdministerWulaMechRepairKit.cs",
|
||||
@@ -107,7 +91,7 @@
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 3,
|
||||
"DocumentIndex": 2,
|
||||
"Title": "WorkGiver_Warden_DeliverEnergy.cs",
|
||||
"DocumentMoniker": "C:\\Steam\\steamapps\\common\\RimWorld\\Mods\\3516260226\\Source\\WulaFallenEmpire\\WorkGiver_Warden_DeliverEnergy.cs",
|
||||
"RelativeDocumentMoniker": "WorkGiver_Warden_DeliverEnergy.cs",
|
||||
@@ -119,7 +103,7 @@
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 4,
|
||||
"DocumentIndex": 3,
|
||||
"Title": "WorkGiverDefExtension_FeedWula.cs",
|
||||
"DocumentMoniker": "C:\\Steam\\steamapps\\common\\RimWorld\\Mods\\3516260226\\Source\\WulaFallenEmpire\\WorkGiverDefExtension_FeedWula.cs",
|
||||
"RelativeDocumentMoniker": "WorkGiverDefExtension_FeedWula.cs",
|
||||
@@ -131,7 +115,7 @@
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 5,
|
||||
"DocumentIndex": 4,
|
||||
"Title": "CompApparelInterceptor.cs",
|
||||
"DocumentMoniker": "C:\\Steam\\steamapps\\common\\RimWorld\\Mods\\3516260226\\Source\\WulaFallenEmpire\\CompApparelInterceptor.cs",
|
||||
"RelativeDocumentMoniker": "CompApparelInterceptor.cs",
|
||||
@@ -143,7 +127,7 @@
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 6,
|
||||
"DocumentIndex": 5,
|
||||
"Title": "Projectile_Launch_Patch.cs",
|
||||
"DocumentMoniker": "C:\\Steam\\steamapps\\common\\RimWorld\\Mods\\3516260226\\Source\\WulaFallenEmpire\\HarmonyPatches\\Projectile_Launch_Patch.cs",
|
||||
"RelativeDocumentMoniker": "HarmonyPatches\\Projectile_Launch_Patch.cs",
|
||||
@@ -155,7 +139,7 @@
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 8,
|
||||
"DocumentIndex": 7,
|
||||
"Title": "IngestPatch.cs",
|
||||
"DocumentMoniker": "C:\\Steam\\steamapps\\common\\RimWorld\\Mods\\3516260226\\Source\\WulaFallenEmpire\\IngestPatch.cs",
|
||||
"RelativeDocumentMoniker": "IngestPatch.cs",
|
||||
@@ -167,7 +151,7 @@
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 7,
|
||||
"DocumentIndex": 6,
|
||||
"Title": "CompUseEffect_WulaSkillTrainer.cs",
|
||||
"DocumentMoniker": "C:\\Steam\\steamapps\\common\\RimWorld\\Mods\\3516260226\\Source\\WulaFallenEmpire\\CompUseEffect_WulaSkillTrainer.cs",
|
||||
"RelativeDocumentMoniker": "CompUseEffect_WulaSkillTrainer.cs",
|
||||
@@ -179,7 +163,7 @@
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 9,
|
||||
"DocumentIndex": 8,
|
||||
"Title": "Building_Wula_DarkEnergy_Engine.cs",
|
||||
"DocumentMoniker": "C:\\Steam\\steamapps\\common\\RimWorld\\Mods\\3516260226\\Source\\WulaFallenEmpire\\Building_Wula_DarkEnergy_Engine.cs",
|
||||
"RelativeDocumentMoniker": "Building_Wula_DarkEnergy_Engine.cs",
|
||||
@@ -191,7 +175,7 @@
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 10,
|
||||
"DocumentIndex": 9,
|
||||
"Title": "HediffComp_RegenerateBackstory.cs",
|
||||
"DocumentMoniker": "C:\\Steam\\steamapps\\common\\RimWorld\\Mods\\3516260226\\Source\\WulaFallenEmpire\\HediffComp_RegenerateBackstory.cs",
|
||||
"RelativeDocumentMoniker": "HediffComp_RegenerateBackstory.cs",
|
||||
@@ -203,7 +187,7 @@
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 11,
|
||||
"DocumentIndex": 10,
|
||||
"Title": "WulaFallenEmpireMod.cs",
|
||||
"DocumentMoniker": "C:\\Steam\\steamapps\\common\\RimWorld\\Mods\\3516260226\\Source\\WulaFallenEmpire\\WulaFallenEmpireMod.cs",
|
||||
"RelativeDocumentMoniker": "WulaFallenEmpireMod.cs",
|
||||
@@ -215,7 +199,7 @@
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 12,
|
||||
"DocumentIndex": 11,
|
||||
"Title": "MechanitorPatch.cs",
|
||||
"DocumentMoniker": "C:\\Steam\\steamapps\\common\\RimWorld\\Mods\\3516260226\\Source\\WulaFallenEmpire\\MechanitorPatch.cs",
|
||||
"RelativeDocumentMoniker": "MechanitorPatch.cs",
|
||||
@@ -224,10 +208,6 @@
|
||||
"ViewState": "AQIAAAAAAAAAAAAAAAAAACEAAAAJAAAA",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2025-07-18T10:20:31.368Z"
|
||||
},
|
||||
{
|
||||
"$type": "Bookmark",
|
||||
"Name": "ST:0:0:{269a02dc-6af8-11d3-bdc4-00c04f688e50}"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ namespace WulaFallenEmpire
|
||||
{
|
||||
public string name;
|
||||
public string value;
|
||||
public string valueVariableName;
|
||||
|
||||
public override bool IsMet(out string reason)
|
||||
{
|
||||
@@ -22,11 +23,21 @@ namespace WulaFallenEmpire
|
||||
return false;
|
||||
}
|
||||
|
||||
// Simple string comparison for now. Can be expanded.
|
||||
bool met = variable.ToString() == value;
|
||||
string compareValue = value;
|
||||
if (!string.IsNullOrEmpty(valueVariableName))
|
||||
{
|
||||
compareValue = EventContext.GetVariable<object>(valueVariableName)?.ToString();
|
||||
if (compareValue == null)
|
||||
{
|
||||
reason = $"Comparison variable '{valueVariableName}' not set.";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool met = variable.ToString() == compareValue;
|
||||
if (!met)
|
||||
{
|
||||
reason = $"Requires {name} = {value} (Current: {variable})";
|
||||
reason = $"Requires {name} = {compareValue} (Current: {variable})";
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -35,25 +46,40 @@ namespace WulaFallenEmpire
|
||||
return met;
|
||||
}
|
||||
}
|
||||
|
||||
public class Condition_VariableGreaterThan : Condition
|
||||
|
||||
public abstract class Condition_CompareVariable : Condition
|
||||
{
|
||||
public string name;
|
||||
public float value;
|
||||
public string valueVariableName;
|
||||
|
||||
protected abstract bool Compare(float var1, float var2);
|
||||
protected abstract string GetOperatorString();
|
||||
|
||||
public override bool IsMet(out string reason)
|
||||
{
|
||||
float variable = EventContext.GetVariable<float>(name, float.MinValue);
|
||||
if (variable == float.MinValue)
|
||||
float variable = EventContext.GetVariable<float>(name, float.NaN);
|
||||
if (float.IsNaN(variable))
|
||||
{
|
||||
reason = $"Variable '{name}' not set.";
|
||||
reason = $"Variable '{name}' not set or not a number.";
|
||||
return false;
|
||||
}
|
||||
|
||||
bool met = variable > value;
|
||||
float compareValue = value;
|
||||
if (!string.IsNullOrEmpty(valueVariableName))
|
||||
{
|
||||
compareValue = EventContext.GetVariable<float>(valueVariableName, float.NaN);
|
||||
if (float.IsNaN(compareValue))
|
||||
{
|
||||
reason = $"Comparison variable '{valueVariableName}' not set or not a number.";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool met = Compare(variable, compareValue);
|
||||
if (!met)
|
||||
{
|
||||
reason = $"Requires {name} > {value} (Current: {variable})";
|
||||
reason = $"Requires {name} {GetOperatorString()} {compareValue} (Current: {variable})";
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -63,4 +89,27 @@ namespace WulaFallenEmpire
|
||||
}
|
||||
}
|
||||
|
||||
public class Condition_VariableGreaterThan : Condition_CompareVariable
|
||||
{
|
||||
protected override bool Compare(float var1, float var2) => var1 > var2;
|
||||
protected override string GetOperatorString() => ">";
|
||||
}
|
||||
|
||||
public class Condition_VariableLessThan : Condition_CompareVariable
|
||||
{
|
||||
protected override bool Compare(float var1, float var2) => var1 < var2;
|
||||
protected override string GetOperatorString() => "<";
|
||||
}
|
||||
|
||||
public class Condition_VariableGreaterThanOrEqual : Condition_CompareVariable
|
||||
{
|
||||
protected override bool Compare(float var1, float var2) => var1 >= var2;
|
||||
protected override string GetOperatorString() => ">=";
|
||||
}
|
||||
|
||||
public class Condition_VariableLessThanOrEqual : Condition_CompareVariable
|
||||
{
|
||||
protected override bool Compare(float var1, float var2) => var1 <= var2;
|
||||
protected override string GetOperatorString() => "<=";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -264,8 +264,109 @@ namespace WulaFallenEmpire
|
||||
TaggedString finalText = letterText.Formatted(pawn.Named("PAWN")).AdjustedFor(pawn);
|
||||
PawnRelationUtility.TryAppendRelationsWithColonistsInfo(ref finalText, ref finalLabel, pawn);
|
||||
Find.LetterStack.ReceiveLetter(finalLabel, finalText, letterDef ?? LetterDefOf.PositiveEvent, pawn);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum VariableOperation
|
||||
{
|
||||
Add,
|
||||
Subtract,
|
||||
Multiply,
|
||||
Divide
|
||||
}
|
||||
|
||||
public class Effect_ModifyVariable : Effect
|
||||
{
|
||||
public string name;
|
||||
public float value;
|
||||
public VariableOperation operation;
|
||||
|
||||
public override void Execute(Dialog_CustomDisplay dialog)
|
||||
{
|
||||
if (string.IsNullOrEmpty(name))
|
||||
{
|
||||
Log.Error("[WulaFallenEmpire] Effect_ModifyVariable has a null or empty name.");
|
||||
return;
|
||||
}
|
||||
|
||||
float currentValue = EventContext.GetVariable<float>(name, 0f);
|
||||
|
||||
switch (operation)
|
||||
{
|
||||
case VariableOperation.Add:
|
||||
currentValue += value;
|
||||
break;
|
||||
case VariableOperation.Subtract:
|
||||
currentValue -= value;
|
||||
break;
|
||||
case VariableOperation.Multiply:
|
||||
currentValue *= value;
|
||||
break;
|
||||
case VariableOperation.Divide:
|
||||
if (value != 0)
|
||||
{
|
||||
currentValue /= value;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Error($"[WulaFallenEmpire] Effect_ModifyVariable tried to divide by zero for variable '{name}'.");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
EventContext.SetVariable(name, currentValue);
|
||||
}
|
||||
}
|
||||
|
||||
public class Effect_ClearVariable : Effect
|
||||
{
|
||||
public string name;
|
||||
|
||||
public override void Execute(Dialog_CustomDisplay dialog)
|
||||
{
|
||||
if (string.IsNullOrEmpty(name))
|
||||
{
|
||||
Log.Error("[WulaFallenEmpire] Effect_ClearVariable has a null or empty name.");
|
||||
return;
|
||||
}
|
||||
EventContext.ClearVariable(name);
|
||||
}
|
||||
}
|
||||
|
||||
public class Effect_AddQuest : Effect
|
||||
{
|
||||
public QuestScriptDef quest;
|
||||
|
||||
public override void Execute(Dialog_CustomDisplay dialog)
|
||||
{
|
||||
if (quest == null)
|
||||
{
|
||||
Log.Error("[WulaFallenEmpire] Effect_AddQuest has a null quest Def.");
|
||||
return;
|
||||
}
|
||||
|
||||
Quest newQuest = Quest.MakeRaw();
|
||||
newQuest.root = quest;
|
||||
newQuest.id = Find.UniqueIDsManager.GetNextQuestID();
|
||||
Find.QuestManager.Add(newQuest);
|
||||
}
|
||||
}
|
||||
|
||||
public class Effect_FinishResearch : Effect
|
||||
{
|
||||
public ResearchProjectDef research;
|
||||
|
||||
public override void Execute(Dialog_CustomDisplay dialog)
|
||||
{
|
||||
if (research == null)
|
||||
{
|
||||
Log.Error("[WulaFallenEmpire] Effect_FinishResearch has a null research Def.");
|
||||
return;
|
||||
}
|
||||
|
||||
Find.ResearchManager.FinishProject(research);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,5 +48,17 @@ namespace WulaFallenEmpire
|
||||
variables.Clear();
|
||||
Log.Message("[EventContext] All variables cleared.");
|
||||
}
|
||||
|
||||
public static void ClearVariable(string name)
|
||||
{
|
||||
if (variables.Remove(name))
|
||||
{
|
||||
Log.Message($"[EventContext] Cleared variable '{name}'.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Warning($"[EventContext] Tried to clear variable '{name}' but it was not found.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@
|
||||
<Compile Include="MentalState_BrokenPersonality.cs" />
|
||||
<Compile Include="MentalStateDefExtension_BrokenPersonality.cs" />
|
||||
<Compile Include="MentalBreakWorker_BrokenPersonality.cs" />
|
||||
<Compile Include="DebugActions.cs" />
|
||||
<Compile Include="EventSystem\DebugActions.cs" />
|
||||
<Compile Include="EventSystem\Condition.cs" />
|
||||
<Compile Include="EventSystem\CustomUIDef.cs" />
|
||||
<Compile Include="EventSystem\Dialog_CustomDisplay.cs" />
|
||||
|
||||
Reference in New Issue
Block a user