修event袭击
This commit is contained in:
Binary file not shown.
@@ -4,9 +4,11 @@
|
||||
<WulaFallenEmpire.EventDef>
|
||||
<defName>Wula_Test_Raid_Event</defName>
|
||||
<label>测试袭击事件</label>
|
||||
<Description>这是一个测试,用于触发一个带有自定义 pawn 组的袭击。</Description>
|
||||
<description>这是一个测试,用于触发一个带有自定义 pawn 组的袭击。</description>
|
||||
<dismissEffects>
|
||||
<li Class="WulaFallenEmpire.Effect_TriggerRaid">
|
||||
<letterLabel>侦测到失控乌拉!</letterLabel>
|
||||
<letterText>我们的传感器侦测到一伙来自 {FACTION_name} 的袭击者!他们看起来充满敌意,正朝着我们的殖民地前进。</letterText>
|
||||
<points>10000</points>
|
||||
<faction>Wula_Broken_Personality_Faction</faction>
|
||||
<raidStrategy>ImmediateAttack</raidStrategy>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<!-- General Style -->
|
||||
<labelFont>Small</labelFont>
|
||||
<drawBorders>false</drawBorders>
|
||||
<showDefName>true</showDefName>
|
||||
<showDefName>false</showDefName>
|
||||
<showLabel>true</showLabel>
|
||||
<defaultBackgroundImagePath></defaultBackgroundImagePath>
|
||||
|
||||
|
||||
@@ -262,6 +262,8 @@
|
||||
- **raidArrivalMode**: (PawnsArrivalModeDef) 袭击者到达方式的 `defName` (例如 `EdgeWalkIn`)。
|
||||
- **groupKind**: (PawnGroupKindDef) (高级模式) 定义队伍类型,例如 `Combat` 或 `Trader`。默认为 `Combat`。
|
||||
- **pawnGroupMakers**: (List<PawnGroupMaker>) (高级模式) 一个 `PawnGroupMaker` 列表,用于动态定义袭击队伍的构成。
|
||||
- **letterLabel**: (string) (可选) 自定义袭击信件的标题。如果提供,将覆盖默认的 "Raid" 标题。
|
||||
- **letterText**: (string) (可选) 自定义袭击信件的内容。如果提供,将覆盖默认的袭击描述文本。
|
||||
|
||||
**简单模式示例:**
|
||||
```xml
|
||||
@@ -270,6 +272,8 @@
|
||||
<faction>Pirate</faction>
|
||||
<raidStrategy>ImmediateAttack</raidStrategy>
|
||||
<raidArrivalMode>EdgeWalkIn</raidArrivalMode>
|
||||
<letterLabel>侦测到威胁!</letterLabel>
|
||||
<letterText>我们的传感器侦测到一伙来自 {FACTION_name} 的袭击者!他们看起来充满敌意,正朝着我们的殖民地前进。</letterText>
|
||||
</li>
|
||||
```
|
||||
|
||||
|
||||
Binary file not shown.
@@ -385,6 +385,8 @@ public class Effect_TriggerRaid : Effect
|
||||
public PawnsArrivalModeDef raidArrivalMode;
|
||||
public PawnGroupKindDef groupKind;
|
||||
public List<PawnGroupMaker> 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
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
27
work_log.txt
27
work_log.txt
@@ -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` 来编译项目,并根据新的编译错误逐步调试和修复问题,直到最终编译成功。
|
||||
Reference in New Issue
Block a user