Merge branch 'main' of https://git.ra3battle.cn/Kalospacer/WulaFallenEmpireRW
This commit is contained in:
Binary file not shown.
@@ -69,6 +69,7 @@
|
||||
<!-- 隐藏事件:触发一次袭击 -->
|
||||
<WulaFallenEmpire.EventDef>
|
||||
<defName>Wula_HiddenEvent_TriggerRaid</defName>
|
||||
<hiddenWindow>true</hiddenWindow>
|
||||
<dismissEffects>
|
||||
<li>
|
||||
<effects>
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
<li Class="WulaFallenEmpire.Effect_ClearVariable">
|
||||
<name>Wula_FE_Spiritualist_Goodwill</name>
|
||||
</li>
|
||||
<li Class="WulaFallenEmpire.Effect_StoreFactionGoodwill">
|
||||
<li Class="WulaFallenEmpire.Effect_CheckFactionGoodwill">
|
||||
<factionDef>Wula_FE_Spiritualist_Faction</factionDef>
|
||||
<variableName>Wula_FE_Spiritualist_Goodwill</variableName>
|
||||
</li>
|
||||
|
||||
40
1.6/1.6/Defs/EventDefs/WULA_Effect_Examples.xml
Normal file
40
1.6/1.6/Defs/EventDefs/WULA_Effect_Examples.xml
Normal file
@@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<Defs>
|
||||
|
||||
<WulaFallenEmpire.EventDef>
|
||||
<defName>WULA_Debug_StoreAllStats</defName>
|
||||
<label>Debug: Store All Stats</label>
|
||||
<description>一个用于将各种游戏统计数据存储到变量中的调试事件。</description>
|
||||
<hiddenWindow>true</hiddenWindow>
|
||||
|
||||
<dismissEffects>
|
||||
<li>
|
||||
<effects>
|
||||
|
||||
<!-- 1. 存储派系好感度 (int) -->
|
||||
<li Class="WulaFallenEmpire.Effect_CheckFactionGoodwill">
|
||||
<factionDef>Mechanoid</factionDef>
|
||||
<variableName>Debug_MechanoidGoodwill</variableName>
|
||||
</li>
|
||||
|
||||
<!-- 2. 存储殖民地财富 (float) -->
|
||||
<li Class="WulaFallenEmpire.Effect_StoreColonyWealth">
|
||||
<variableName>Debug_ColonyWealth</variableName>
|
||||
</li>
|
||||
|
||||
<!-- 3. 存储真实游戏时间 (float, 秒) -->
|
||||
<li Class="WulaFallenEmpire.Effect_StoreRealPlayTime">
|
||||
<variableName>Debug_RealPlayTimeSeconds</variableName>
|
||||
</li>
|
||||
|
||||
<!-- 4. 存储已过去的游戏天数 (int) -->
|
||||
<li Class="WulaFallenEmpire.Effect_StoreDaysPassed">
|
||||
<variableName>Debug_DaysPassed</variableName>
|
||||
</li>
|
||||
|
||||
</effects>
|
||||
</li>
|
||||
</dismissEffects>
|
||||
</WulaFallenEmpire.EventDef>
|
||||
|
||||
</Defs>
|
||||
@@ -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));
|
||||
|
||||
@@ -506,93 +506,59 @@ 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<Pawn> 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<Pawn> 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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class Effect_CheckFactionGoodwill : Effect
|
||||
{
|
||||
public FactionDef factionDef;
|
||||
public string variableName;
|
||||
public List<Effect> successEffects;
|
||||
public List<Effect> failureEffects;
|
||||
|
||||
public override void Execute(Dialog_CustomDisplay dialog = null)
|
||||
{
|
||||
if (factionDef == null)
|
||||
{
|
||||
Log.Error("[WulaFallenEmpire] Effect_CheckFactionGoodwill has a null faction Def.");
|
||||
return;
|
||||
}
|
||||
|
||||
Faction targetFaction = Find.FactionManager.FirstFactionOfDef(factionDef);
|
||||
if (targetFaction == null)
|
||||
{
|
||||
Log.Warning($"[WulaFallenEmpire] Could not find an active faction for FactionDef '{factionDef.defName}'.");
|
||||
ExecuteEffects(failureEffects, dialog);
|
||||
return;
|
||||
}
|
||||
|
||||
int requiredGoodwill = Find.World.GetComponent<EventVariableManager>().GetVariable<int>(variableName);
|
||||
int currentGoodwill = Faction.OfPlayer.GoodwillWith(targetFaction);
|
||||
if (currentGoodwill >= requiredGoodwill)
|
||||
{
|
||||
ExecuteEffects(successEffects, dialog);
|
||||
}
|
||||
else
|
||||
{
|
||||
ExecuteEffects(failureEffects, dialog);
|
||||
}
|
||||
}
|
||||
|
||||
private void ExecuteEffects(List<Effect> effects, Dialog_CustomDisplay dialog)
|
||||
{
|
||||
if (effects.NullOrEmpty()) return;
|
||||
foreach (var effect in effects)
|
||||
{
|
||||
effect.Execute(dialog);
|
||||
}
|
||||
}
|
||||
}
|
||||
public class Effect_StoreFactionGoodwill : Effect
|
||||
{
|
||||
public FactionDef factionDef;
|
||||
public string variableName;
|
||||
@@ -601,7 +567,7 @@ public class Effect_StoreFactionGoodwill : Effect
|
||||
{
|
||||
if (factionDef == null || string.IsNullOrEmpty(variableName))
|
||||
{
|
||||
Log.Error("[WulaFallenEmpire] Effect_StoreFactionGoodwill is not configured correctly.");
|
||||
Log.Error("[WulaFallenEmpire] Effect_CheckFactionGoodwill is not configured correctly.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -616,9 +582,73 @@ public class Effect_StoreFactionGoodwill : Effect
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Warning($"[EventSystem] Effect_StoreFactionGoodwill: Faction '{factionDef.defName}' not found. Storing 0 in variable '{variableName}'.");
|
||||
Log.Warning($"[EventSystem] Effect_CheckFactionGoodwill: Faction '{factionDef.defName}' not found. Storing 0 in variable '{variableName}'.");
|
||||
eventVarManager.SetVariable(variableName, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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<EventVariableManager>();
|
||||
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<EventVariableManager>();
|
||||
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<EventVariableManager>();
|
||||
float wealth = currentMap.wealthWatcher.WealthTotal;
|
||||
Log.Message($"[EventSystem] Storing colony wealth ({wealth}) into variable '{variableName}'.");
|
||||
eventVarManager.SetVariable(variableName, wealth);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user