diff --git a/1.6/1.6/Assemblies/WulaFallenEmpire.dll b/1.6/1.6/Assemblies/WulaFallenEmpire.dll index f747b2de..5806a8ca 100644 Binary files a/1.6/1.6/Assemblies/WulaFallenEmpire.dll and b/1.6/1.6/Assemblies/WulaFallenEmpire.dll differ diff --git a/1.6/1.6/Defs/EventDefs/EventDef_Examples.xml b/1.6/1.6/Defs/EventDefs/EventDef_Examples.xml index 6ff878b3..78615cba 100644 --- a/1.6/1.6/Defs/EventDefs/EventDef_Examples.xml +++ b/1.6/1.6/Defs/EventDefs/EventDef_Examples.xml @@ -69,6 +69,7 @@ Wula_HiddenEvent_TriggerRaid + true
  • diff --git a/1.6/1.6/Defs/EventDefs/EventDef_Wula.xml b/1.6/1.6/Defs/EventDefs/EventDef_Wula.xml index aa4b79c4..351f745c 100644 --- a/1.6/1.6/Defs/EventDefs/EventDef_Wula.xml +++ b/1.6/1.6/Defs/EventDefs/EventDef_Wula.xml @@ -42,7 +42,7 @@
  • Wula_FE_Spiritualist_Goodwill
  • -
  • +
  • Wula_FE_Spiritualist_Faction Wula_FE_Spiritualist_Goodwill
  • diff --git a/1.6/1.6/Defs/EventDefs/WULA_Effect_Examples.xml b/1.6/1.6/Defs/EventDefs/WULA_Effect_Examples.xml new file mode 100644 index 00000000..f0e8c6e3 --- /dev/null +++ b/1.6/1.6/Defs/EventDefs/WULA_Effect_Examples.xml @@ -0,0 +1,40 @@ + + + + + WULA_Debug_StoreAllStats + + 一个用于将各种游戏统计数据存储到变量中的调试事件。 + true + + +
  • + + + +
  • + Mechanoid + Debug_MechanoidGoodwill +
  • + + +
  • + Debug_ColonyWealth +
  • + + +
  • + Debug_RealPlayTimeSeconds +
  • + + +
  • + Debug_DaysPassed +
  • + + + +
    +
    + +
    \ No newline at end of file diff --git a/Source/WulaFallenEmpire/EventSystem/DebugActions.cs b/Source/WulaFallenEmpire/EventSystem/DebugActions.cs index ed5e6e15..34de6b23 100644 --- a/Source/WulaFallenEmpire/EventSystem/DebugActions.cs +++ b/Source/WulaFallenEmpire/EventSystem/DebugActions.cs @@ -16,7 +16,37 @@ namespace WulaFallenEmpire EventDef currentDef = localDef; list.Add(new DebugMenuOption(currentDef.defName, DebugMenuOptionMode.Action, delegate { - Find.WindowStack.Add(new Dialog_CustomDisplay(currentDef)); + if (currentDef.hiddenWindow) + { + if (!currentDef.dismissEffects.NullOrEmpty()) + { + foreach (var conditionalEffect in currentDef.dismissEffects) + { + string reason; + bool conditionsMet = true; + if (!conditionalEffect.conditions.NullOrEmpty()) + { + foreach (var condition in conditionalEffect.conditions) + { + if (!condition.IsMet(out reason)) + { + conditionsMet = false; + break; + } + } + } + + if (conditionsMet) + { + conditionalEffect.Execute(null); + } + } + } + } + else + { + Find.WindowStack.Add(new Dialog_CustomDisplay(currentDef)); + } })); } Find.WindowStack.Add(new Dialog_DebugOptionListLister(list)); diff --git a/Source/WulaFallenEmpire/EventSystem/Effect.cs b/Source/WulaFallenEmpire/EventSystem/Effect.cs index bc705f1e..1d74a72f 100644 --- a/Source/WulaFallenEmpire/EventSystem/Effect.cs +++ b/Source/WulaFallenEmpire/EventSystem/Effect.cs @@ -506,43 +506,53 @@ namespace WulaFallenEmpire return; } + IncidentParms parms = new IncidentParms + { + target = map, + points = this.points, + faction = factionInst, + raidStrategy = this.raidStrategy, + raidArrivalMode = this.raidArrivalMode, + pawnGroupMakerSeed = Rand.Int, + forced = true + }; + + if (!RCellFinder.TryFindRandomPawnEntryCell(out parms.spawnCenter, map, CellFinder.EdgeRoadChance_Hostile)) + { + Log.Error("[WulaFallenEmpire] Effect_TriggerRaid could not find a valid spawn center."); + return; + } + + PawnGroupMakerParms groupMakerParms = new PawnGroupMakerParms + { + groupKind = this.groupKind ?? PawnGroupKindDefOf.Combat, + tile = map.Tile, + points = this.points, + faction = factionInst, + raidStrategy = this.raidStrategy, + seed = parms.pawnGroupMakerSeed + }; + + List pawns; if (!pawnGroupMakers.NullOrEmpty()) { - IncidentParms parms = new IncidentParms - { - target = map, - points = this.points, - faction = factionInst, - raidStrategy = this.raidStrategy, - raidArrivalMode = this.raidArrivalMode, - pawnGroupMakerSeed = Rand.Int, - forced = true - }; + var groupMaker = pawnGroupMakers.RandomElementByWeight(x => x.commonality); + pawns = groupMaker.GeneratePawns(groupMakerParms).ToList(); + } + else + { + pawns = PawnGroupMakerUtility.GeneratePawns(groupMakerParms).ToList(); + } - if (!RCellFinder.TryFindRandomPawnEntryCell(out parms.spawnCenter, map, CellFinder.EdgeRoadChance_Hostile)) - { - Log.Error("[WulaFallenEmpire] Effect_TriggerRaid could not find a valid spawn center."); - return; - } - - PawnGroupMakerParms groupMakerParms = new PawnGroupMakerParms - { - groupKind = this.groupKind ?? PawnGroupKindDefOf.Combat, - tile = map.Tile, - points = this.points, - faction = factionInst, - raidStrategy = this.raidStrategy, - seed = parms.pawnGroupMakerSeed - }; + if (pawns.Any()) + { + raidArrivalMode.Worker.Arrive(pawns, parms); + // Assign Lord and LordJob to make the pawns actually perform the raid. + raidStrategy.Worker.MakeLords(parms, pawns); - List pawns = PawnGroupMakerUtility.GeneratePawns(groupMakerParms).ToList(); - if (pawns.Any()) + if (!string.IsNullOrEmpty(letterLabel) && !string.IsNullOrEmpty(letterText)) { - raidArrivalMode.Worker.Arrive(pawns, parms); - if (!string.IsNullOrEmpty(letterLabel) && !string.IsNullOrEmpty(letterText)) - { - Find.LetterStack.ReceiveLetter(letterLabel, letterText, LetterDefOf.ThreatBig, pawns[0]); - } + Find.LetterStack.ReceiveLetter(letterLabel, letterText, LetterDefOf.ThreatBig, pawns[0]); } } } @@ -577,4 +587,68 @@ namespace WulaFallenEmpire } } } + + public class Effect_StoreRealPlayTime : Effect + { + public string variableName; + + public override void Execute(Dialog_CustomDisplay dialog = null) + { + if (string.IsNullOrEmpty(variableName)) + { + Log.Error("[WulaFallenEmpire] Effect_StoreRealPlayTime is not configured correctly (missing variableName)."); + return; + } + + var eventVarManager = Find.World.GetComponent(); + float realPlayTime = Find.GameInfo.RealPlayTimeInteracting; + Log.Message($"[EventSystem] Storing real play time ({realPlayTime}s) into variable '{variableName}'."); + eventVarManager.SetVariable(variableName, realPlayTime); + } + } + + public class Effect_StoreDaysPassed : Effect + { + public string variableName; + + public override void Execute(Dialog_CustomDisplay dialog = null) + { + if (string.IsNullOrEmpty(variableName)) + { + Log.Error("[WulaFallenEmpire] Effect_StoreDaysPassed is not configured correctly (missing variableName)."); + return; + } + + var eventVarManager = Find.World.GetComponent(); + int daysPassed = GenDate.DaysPassed; + Log.Message($"[EventSystem] Storing days passed ({daysPassed}) into variable '{variableName}'."); + eventVarManager.SetVariable(variableName, daysPassed); + } + } + + public class Effect_StoreColonyWealth : Effect + { + public string variableName; + + public override void Execute(Dialog_CustomDisplay dialog = null) + { + if (string.IsNullOrEmpty(variableName)) + { + Log.Error("[WulaFallenEmpire] Effect_StoreColonyWealth is not configured correctly (missing variableName)."); + return; + } + + Map currentMap = Find.CurrentMap; + if (currentMap == null) + { + Log.Error("[WulaFallenEmpire] Effect_StoreColonyWealth cannot execute without a current map."); + return; + } + + var eventVarManager = Find.World.GetComponent(); + float wealth = currentMap.wealthWatcher.WealthTotal; + Log.Message($"[EventSystem] Storing colony wealth ({wealth}) into variable '{variableName}'."); + eventVarManager.SetVariable(variableName, wealth); + } + } }