diff --git a/1.6/Assemblies/WulaFallenEmpire.dll b/1.6/Assemblies/WulaFallenEmpire.dll index 74336113..8d1d9af2 100644 Binary files a/1.6/Assemblies/WulaFallenEmpire.dll and b/1.6/Assemblies/WulaFallenEmpire.dll differ diff --git a/1.6/Defs/EventDefs/EventDef_Examples.xml b/1.6/Defs/EventDefs/EventDef_Examples.xml index cb92a8b0..2faa2674 100644 --- a/1.6/Defs/EventDefs/EventDef_Examples.xml +++ b/1.6/Defs/EventDefs/EventDef_Examples.xml @@ -4,9 +4,11 @@ Wula_Test_Raid_Event - 这是一个测试,用于触发一个带有自定义 pawn 组的袭击。 + 这是一个测试,用于触发一个带有自定义 pawn 组的袭击。
  • + 侦测到失控乌拉! + 我们的传感器侦测到一伙来自 {FACTION_name} 的袭击者!他们看起来充满敌意,正朝着我们的殖民地前进。 10000 Wula_Broken_Personality_Faction ImmediateAttack diff --git a/1.6/Defs/WulaMiscSettingDefs/EventUIConfig.xml b/1.6/Defs/WulaMiscSettingDefs/EventUIConfig.xml index 789a7274..275c587b 100644 --- a/1.6/Defs/WulaMiscSettingDefs/EventUIConfig.xml +++ b/1.6/Defs/WulaMiscSettingDefs/EventUIConfig.xml @@ -7,7 +7,7 @@ Small false - true + false true diff --git a/Documentation/EventSystem_Documentation.md b/Documentation/EventSystem_Documentation.md index 59fa83d4..32500a69 100644 --- a/Documentation/EventSystem_Documentation.md +++ b/Documentation/EventSystem_Documentation.md @@ -262,6 +262,8 @@ - **raidArrivalMode**: (PawnsArrivalModeDef) 袭击者到达方式的 `defName` (例如 `EdgeWalkIn`)。 - **groupKind**: (PawnGroupKindDef) (高级模式) 定义队伍类型,例如 `Combat` 或 `Trader`。默认为 `Combat`。 - **pawnGroupMakers**: (List) (高级模式) 一个 `PawnGroupMaker` 列表,用于动态定义袭击队伍的构成。 +- **letterLabel**: (string) (可选) 自定义袭击信件的标题。如果提供,将覆盖默认的 "Raid" 标题。 +- **letterText**: (string) (可选) 自定义袭击信件的内容。如果提供,将覆盖默认的袭击描述文本。 **简单模式示例:** ```xml @@ -270,6 +272,8 @@ Pirate ImmediateAttack EdgeWalkIn + 侦测到威胁! + 我们的传感器侦测到一伙来自 {FACTION_name} 的袭击者!他们看起来充满敌意,正朝着我们的殖民地前进。
  • ``` diff --git a/Source/WulaFallenEmpire/.vs/WulaFallenEmpire/v17/.suo b/Source/WulaFallenEmpire/.vs/WulaFallenEmpire/v17/.suo index c7f2d06e..f845370d 100644 Binary files a/Source/WulaFallenEmpire/.vs/WulaFallenEmpire/v17/.suo and b/Source/WulaFallenEmpire/.vs/WulaFallenEmpire/v17/.suo differ diff --git a/Source/WulaFallenEmpire/EventSystem/Effect.cs b/Source/WulaFallenEmpire/EventSystem/Effect.cs index c7e548a4..095b207f 100644 --- a/Source/WulaFallenEmpire/EventSystem/Effect.cs +++ b/Source/WulaFallenEmpire/EventSystem/Effect.cs @@ -385,6 +385,8 @@ public class Effect_TriggerRaid : Effect public PawnsArrivalModeDef raidArrivalMode; public PawnGroupKindDef groupKind; public List pawnGroupMakers; + public string letterLabel; + public string letterText; public override void Execute(Dialog_CustomDisplay dialog = null) { @@ -416,6 +418,12 @@ public class Effect_TriggerRaid : Effect 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, @@ -440,17 +448,36 @@ public class Effect_TriggerRaid : Effect parms.raidArrivalMode.Worker.Arrive(pawns, parms); - TaggedString letterLabel = "LetterLabelRaid".Translate(factionInst.def.label).CapitalizeFirst(); - TaggedString letterText = "LetterRaid".Translate( - factionInst.Name, - factionInst.def.pawnsPlural, - parms.raidStrategy.arrivalTextEnemy - ).CapitalizeFirst(); + parms.raidStrategy.Worker.MakeLords(parms, pawns); + + TaggedString finalLabel; + if (!string.IsNullOrEmpty(this.letterLabel)) + { + finalLabel = this.letterLabel; + } + else + { + finalLabel = "LetterLabelRaid".Translate(factionInst.def.label).CapitalizeFirst(); + } + + TaggedString finalText; + if (!string.IsNullOrEmpty(this.letterText)) + { + finalText = this.letterText; + } + else + { + finalText = "LetterRaid".Translate( + factionInst.Name, + factionInst.def.pawnsPlural, + parms.raidStrategy.arrivalTextEnemy + ).CapitalizeFirst(); + } Pawn mostImportantPawn = pawns.FirstOrDefault(); TargetInfo target = mostImportantPawn != null ? new TargetInfo(mostImportantPawn) : new TargetInfo(parms.spawnCenter, map); - Find.LetterStack.ReceiveLetter(letterLabel, letterText, LetterDefOf.ThreatBig, target, factionInst); + Find.LetterStack.ReceiveLetter(finalLabel, finalText, LetterDefOf.ThreatBig, target, factionInst); } else // Fallback to default raid incident worker { diff --git a/Source/WulaFallenEmpire/EventSystem/EventDef.cs b/Source/WulaFallenEmpire/EventSystem/EventDef.cs index 40affb94..8814c6b4 100644 --- a/Source/WulaFallenEmpire/EventSystem/EventDef.cs +++ b/Source/WulaFallenEmpire/EventSystem/EventDef.cs @@ -20,7 +20,6 @@ namespace WulaFallenEmpire public DescriptionSelectionMode descriptionMode = DescriptionSelectionMode.Random; // Backwards compatibility: old single description field - [System.Obsolete("Use 'descriptions' list instead. This field is for backwards compatibility only.")] public new string description = null; public Vector2 windowSize = Vector2.zero; diff --git a/Source/WulaFallenEmpire/EventSystem/Letter_EventChoice.cs b/Source/WulaFallenEmpire/EventSystem/Letter_EventChoice.cs index 72ffed00..d6a16b96 100644 --- a/Source/WulaFallenEmpire/EventSystem/Letter_EventChoice.cs +++ b/Source/WulaFallenEmpire/EventSystem/Letter_EventChoice.cs @@ -62,7 +62,10 @@ namespace WulaFallenEmpire // Scribe_Values.Look(ref letterTitle, "letterTitle"); // Now uses base.title // Scribe_Values.Look(ref letterText, "letterText"); // Now uses base.text Scribe_Collections.Look(ref options, "options", LookMode.Deep); - Scribe_References.Look(ref quest, "quest"); + if (Scribe.mode != LoadSaveMode.Saving || quest != null) + { + Scribe_References.Look(ref quest, "quest"); + } } } } \ No newline at end of file diff --git a/work_log.txt b/work_log.txt deleted file mode 100644 index ed3808b2..00000000 --- a/work_log.txt +++ /dev/null @@ -1,27 +0,0 @@ -任务:修复 RimWorld mod 中的编译错误和功能问题。 - -已执行的操作: - -1. **分析并修复初始编译错误 (CS1620, CS1615):** - * 错误发生在 `Effect_TriggerRaid` 类中,与 `PawnGroupMakerUtility.TryGetRandomPawnGroupMaker` 的调用有关。 - * 通过查阅 RimWorld 反编译代码,确定了正确的方法签名。 - * 发现代码逻辑应该是从效果定义中提供的 `pawnGroupMakers` 列表中选择,而不是调用 `PawnGroupMakerUtility`。 - * 将 `PawnGroupMakerUtility.TryGetRandomPawnGroupMaker(...)` 修正为 `pawnGroupMakers.TryRandomElement(out var chosenGroupMaker)`。 - * 进一步修复了后续对 `PawnGroupMakerUtility.GeneratePawns` 的错误调用,将其更改为对 `chosenGroupMaker` 实例的 `GeneratePawns` 方法的调用。 - -2. **重构 `CustomUIDef` 为 `EventDef`:** - * 根据用户要求,执行了大规模重构。 - * 重命名文件 `CustomUIDef.cs` 为 `EventDef.cs`。 - * 在 `EventDef.cs` 中,重命名类 `CustomUIDef` 为 `EventDef`,`CustomUIOption` 为 `EventOption`。 - * 更新了所有 C# 文件 (`Dialog_CustomDisplay.cs`, `Effect.cs`, `CompOpenCustomUI.cs`, `DebugActions.cs`) 中对旧类名的引用。 - * 更新了项目文件 `WulaFallenEmpire.csproj` 以反映文件重命名。 - * 更新了示例 XML 文件 `EventDef_Examples.xml` 中的节点名称。 - * 更新了文档 `EventSystem_Documentation.md` 中的所有相关术语和示例代码。 - -3. **修复 `QuestNode_Root_EventLetter` 的显示问题:** - * 用户报告信件标题和文本不显示。 - * 经调查,发现 `Letter_EventChoice` 类没有正确地将其内容赋值给基类 `ChoiceLetter` 的相应字段/属性。 - * 修改了 `QuestNode_Root_EventLetter.cs`,将值赋给 `letter.Label` (属性), `letter.title` (字段), 和 `letter.Text` (属性),而不是自定义的、无效的字段。 - -4. **持续编译和验证:** - * 在每个主要步骤之后,都执行了 `dotnet build` 来编译项目,并根据新的编译错误逐步调试和修复问题,直到最终编译成功。 \ No newline at end of file