更新更新
This commit is contained in:
Binary file not shown.
@@ -2,6 +2,22 @@
|
||||
"Version": 1,
|
||||
"WorkspaceRootPath": "E:\\SteamLibrary\\steamapps\\common\\RimWorld\\Mods\\ArachnaeSwarm\\Source\\ArachnaeSwarm\\",
|
||||
"Documents": [
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{EAE0DB6B-E282-C812-7F5A-6D13E9D24581}|ArachnaeSwarm.csproj|e:\\steamlibrary\\steamapps\\common\\rimworld\\mods\\arachnaeswarm\\source\\arachnaeswarm\\hediffs\\ara_hivemind\\hediff_hivemindmaster.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{EAE0DB6B-E282-C812-7F5A-6D13E9D24581}|ArachnaeSwarm.csproj|solutionrelative:hediffs\\ara_hivemind\\hediff_hivemindmaster.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
},
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{EAE0DB6B-E282-C812-7F5A-6D13E9D24581}|ArachnaeSwarm.csproj|e:\\steamlibrary\\steamapps\\common\\rimworld\\mods\\arachnaeswarm\\source\\arachnaeswarm\\hediffs\\ara_hivemind\\hediff_hiveminddrone.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{EAE0DB6B-E282-C812-7F5A-6D13E9D24581}|ArachnaeSwarm.csproj|solutionrelative:hediffs\\ara_hivemind\\hediff_hiveminddrone.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
},
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{EAE0DB6B-E282-C812-7F5A-6D13E9D24581}|ArachnaeSwarm.csproj|e:\\steamlibrary\\steamapps\\common\\rimworld\\mods\\arachnaeswarm\\source\\arachnaeswarm\\hediffs\\ara_hivemind\\compabilityeffect_binddrone.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{EAE0DB6B-E282-C812-7F5A-6D13E9D24581}|ArachnaeSwarm.csproj|solutionrelative:hediffs\\ara_hivemind\\compabilityeffect_binddrone.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
},
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{EAE0DB6B-E282-C812-7F5A-6D13E9D24581}|ArachnaeSwarm.csproj|e:\\steamlibrary\\steamapps\\common\\rimworld\\mods\\arachnaeswarm\\source\\arachnaeswarm\\hediffs\\ara_hivemind\\compproperties_abilitybinddrone.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{EAE0DB6B-E282-C812-7F5A-6D13E9D24581}|ArachnaeSwarm.csproj|solutionrelative:hediffs\\ara_hivemind\\compproperties_abilitybinddrone.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
},
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{EAE0DB6B-E282-C812-7F5A-6D13E9D24581}|ArachnaeSwarm.csproj|e:\\steamlibrary\\steamapps\\common\\rimworld\\mods\\arachnaeswarm\\source\\arachnaeswarm\\verbs\\verb_shootarc.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{EAE0DB6B-E282-C812-7F5A-6D13E9D24581}|ArachnaeSwarm.csproj|solutionrelative:verbs\\verb_shootarc.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
@@ -14,21 +30,73 @@
|
||||
"DocumentGroups": [
|
||||
{
|
||||
"DockedWidth": 200,
|
||||
"SelectedChildIndex": 1,
|
||||
"SelectedChildIndex": 2,
|
||||
"Children": [
|
||||
{
|
||||
"$type": "Bookmark",
|
||||
"Name": "ST:0:0:{1c4feeaa-4718-4aa9-859d-94ce25d182ba}"
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 1,
|
||||
"Title": "Hediff_HiveMindDrone.cs",
|
||||
"DocumentMoniker": "E:\\SteamLibrary\\steamapps\\common\\RimWorld\\Mods\\ArachnaeSwarm\\Source\\ArachnaeSwarm\\Hediffs\\ARA_HiveMind\\Hediff_HiveMindDrone.cs",
|
||||
"RelativeDocumentMoniker": "Hediffs\\ARA_HiveMind\\Hediff_HiveMindDrone.cs",
|
||||
"ToolTip": "E:\\SteamLibrary\\steamapps\\common\\RimWorld\\Mods\\ArachnaeSwarm\\Source\\ArachnaeSwarm\\Hediffs\\ARA_HiveMind\\Hediff_HiveMindDrone.cs",
|
||||
"RelativeToolTip": "Hediffs\\ARA_HiveMind\\Hediff_HiveMindDrone.cs",
|
||||
"ViewState": "AgIAAAAAAAAAAAAAAADwvwAAAAAAAAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2025-10-20T17:26:14.842Z",
|
||||
"EditorCaption": ""
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 0,
|
||||
"Title": "Hediff_HiveMindMaster.cs",
|
||||
"DocumentMoniker": "E:\\SteamLibrary\\steamapps\\common\\RimWorld\\Mods\\ArachnaeSwarm\\Source\\ArachnaeSwarm\\Hediffs\\ARA_HiveMind\\Hediff_HiveMindMaster.cs",
|
||||
"RelativeDocumentMoniker": "Hediffs\\ARA_HiveMind\\Hediff_HiveMindMaster.cs",
|
||||
"ToolTip": "E:\\SteamLibrary\\steamapps\\common\\RimWorld\\Mods\\ArachnaeSwarm\\Source\\ArachnaeSwarm\\Hediffs\\ARA_HiveMind\\Hediff_HiveMindMaster.cs",
|
||||
"RelativeToolTip": "Hediffs\\ARA_HiveMind\\Hediff_HiveMindMaster.cs",
|
||||
"ViewState": "AgIAAHwAAAAAAAAAAAAkwJwAAAAQAAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2025-10-20T17:25:29.183Z",
|
||||
"EditorCaption": ""
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 2,
|
||||
"Title": "CompAbilityEffect_BindDrone.cs",
|
||||
"DocumentMoniker": "E:\\SteamLibrary\\steamapps\\common\\RimWorld\\Mods\\ArachnaeSwarm\\Source\\ArachnaeSwarm\\Hediffs\\ARA_HiveMind\\CompAbilityEffect_BindDrone.cs",
|
||||
"RelativeDocumentMoniker": "Hediffs\\ARA_HiveMind\\CompAbilityEffect_BindDrone.cs",
|
||||
"ToolTip": "E:\\SteamLibrary\\steamapps\\common\\RimWorld\\Mods\\ArachnaeSwarm\\Source\\ArachnaeSwarm\\Hediffs\\ARA_HiveMind\\CompAbilityEffect_BindDrone.cs",
|
||||
"RelativeToolTip": "Hediffs\\ARA_HiveMind\\CompAbilityEffect_BindDrone.cs",
|
||||
"ViewState": "AgIAADYAAAAAAAAAAAAAwE8AAAAtAAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2025-10-20T17:10:14.403Z",
|
||||
"EditorCaption": ""
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 3,
|
||||
"Title": "CompProperties_AbilityBindDrone.cs",
|
||||
"DocumentMoniker": "E:\\SteamLibrary\\steamapps\\common\\RimWorld\\Mods\\ArachnaeSwarm\\Source\\ArachnaeSwarm\\Hediffs\\ARA_HiveMind\\CompProperties_AbilityBindDrone.cs",
|
||||
"RelativeDocumentMoniker": "Hediffs\\ARA_HiveMind\\CompProperties_AbilityBindDrone.cs",
|
||||
"ToolTip": "E:\\SteamLibrary\\steamapps\\common\\RimWorld\\Mods\\ArachnaeSwarm\\Source\\ArachnaeSwarm\\Hediffs\\ARA_HiveMind\\CompProperties_AbilityBindDrone.cs",
|
||||
"RelativeToolTip": "Hediffs\\ARA_HiveMind\\CompProperties_AbilityBindDrone.cs",
|
||||
"ViewState": "AgIAAAAAAAAAAAAAAAAAAAkAAAA/AAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2025-10-20T17:10:09.072Z",
|
||||
"EditorCaption": ""
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 4,
|
||||
"Title": "Verb_ShootArc.cs",
|
||||
"DocumentMoniker": "E:\\SteamLibrary\\steamapps\\common\\RimWorld\\Mods\\ArachnaeSwarm\\Source\\ArachnaeSwarm\\Verbs\\Verb_ShootArc.cs",
|
||||
"RelativeDocumentMoniker": "Verbs\\Verb_ShootArc.cs",
|
||||
"ToolTip": "E:\\SteamLibrary\\steamapps\\common\\RimWorld\\Mods\\ArachnaeSwarm\\Source\\ArachnaeSwarm\\Verbs\\Verb_ShootArc.cs",
|
||||
"RelativeToolTip": "Verbs\\Verb_ShootArc.cs",
|
||||
"ViewState": "AgIAAAAAAAAAAAAAAADwvwAAAAAAAAAAAAAAAA==",
|
||||
"ViewState": "AgIAAAAAAAAAAAAAAADwvw4AAAAAAAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2025-10-19T13:10:19.942Z",
|
||||
"EditorCaption": ""
|
||||
|
||||
@@ -15,6 +15,17 @@ namespace ArachnaeSwarm
|
||||
|
||||
if (masterPawn != null && dronePawn != null)
|
||||
{
|
||||
// 检查目标是否有 ARA_NonPlayer_HiveMindDroneHediff
|
||||
Hediff nonPlayerDroneHediff = dronePawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("ARA_NonPlayer_HiveMindDroneHediff"));
|
||||
|
||||
if (nonPlayerDroneHediff != null)
|
||||
{
|
||||
// 处理非玩家派系的无人机
|
||||
HandleNonPlayerDroneConversion(dronePawn, masterPawn);
|
||||
return;
|
||||
}
|
||||
|
||||
// 原有的玩家派系无人机绑定逻辑
|
||||
Hediff_HiveMindMaster masterHediff = masterPawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("ARA_HiveMindMaster")) as Hediff_HiveMindMaster;
|
||||
if (masterHediff != null)
|
||||
{
|
||||
@@ -34,6 +45,56 @@ namespace ArachnaeSwarm
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理非玩家派系无人机的转换
|
||||
/// </summary>
|
||||
private void HandleNonPlayerDroneConversion(Pawn dronePawn, Pawn masterPawn)
|
||||
{
|
||||
// 1. 改变阵营
|
||||
if (dronePawn.Faction != masterPawn.Faction)
|
||||
{
|
||||
dronePawn.SetFaction(masterPawn.Faction, masterPawn);
|
||||
Log.Message($"Converted {dronePawn.LabelShort} from {dronePawn.Faction?.Name ?? "null"} to {masterPawn.Faction?.Name}");
|
||||
}
|
||||
|
||||
// 2. 移除 ARA_NonPlayer_HiveMindDroneHediff
|
||||
Hediff nonPlayerHediff = dronePawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("ARA_NonPlayer_HiveMindDroneHediff"));
|
||||
if (nonPlayerHediff != null)
|
||||
{
|
||||
dronePawn.health.RemoveHediff(nonPlayerHediff);
|
||||
Log.Message($"Removed ARA_NonPlayer_HiveMindDroneHediff from {dronePawn.LabelShort}");
|
||||
}
|
||||
|
||||
// 3. 添加 ARA_HiveMindDrone
|
||||
HediffDef hiveMindDroneDef = HediffDef.Named("ARA_HiveMindDrone");
|
||||
if (hiveMindDroneDef != null && !dronePawn.health.hediffSet.HasHediff(hiveMindDroneDef))
|
||||
{
|
||||
dronePawn.health.AddHediff(hiveMindDroneDef);
|
||||
Log.Message($"Added ARA_HiveMindDrone to {dronePawn.LabelShort}");
|
||||
}
|
||||
|
||||
// 4. 尝试绑定到主节点
|
||||
Hediff_HiveMindMaster masterHediff = masterPawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("ARA_HiveMindMaster")) as Hediff_HiveMindMaster;
|
||||
if (masterHediff != null)
|
||||
{
|
||||
if (masterHediff.TryBindDrone(dronePawn))
|
||||
{
|
||||
Messages.Message("ARA_BindDrone_ConversionSuccess".Translate(dronePawn.LabelShort, masterPawn.LabelShort), MessageTypeDefOf.PositiveEvent, historical: false);
|
||||
Log.Message($"Successfully bound converted drone {dronePawn.LabelShort} to master {masterPawn.LabelShort}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Messages.Message("ARA_BindDrone_ConversionFailure".Translate(dronePawn.LabelShort, masterPawn.LabelShort), MessageTypeDefOf.NegativeEvent, historical: false);
|
||||
Log.Warning($"Failed to bind converted drone {dronePawn.LabelShort} to master {masterPawn.LabelShort}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Messages.Message("ARA_BindDrone_NoMasterForConversion".Translate(masterPawn.LabelShort), MessageTypeDefOf.NegativeEvent, historical: false);
|
||||
Log.Error($"[ArachnaeSwarm] Master {masterPawn.LabelShort} tried to convert a non-player drone but does not have Hediff_HiveMindMaster.");
|
||||
}
|
||||
}
|
||||
|
||||
public override bool Valid(LocalTargetInfo target, bool throwMessages = false)
|
||||
{
|
||||
if (!base.Valid(target, throwMessages))
|
||||
@@ -64,7 +125,16 @@ namespace ArachnaeSwarm
|
||||
return false;
|
||||
}
|
||||
|
||||
// Target must have ARA_HiveMindDrone hediff
|
||||
// 检查目标是否有 ARA_NonPlayer_HiveMindDroneHediff(新增条件)
|
||||
Hediff nonPlayerDroneHediff = dronePawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("ARA_NonPlayer_HiveMindDroneHediff"));
|
||||
if (nonPlayerDroneHediff != null)
|
||||
{
|
||||
// 对于非玩家派系无人机,只需要基本检查,不需要绑定状态检查
|
||||
// 所有检查通过
|
||||
return true;
|
||||
}
|
||||
|
||||
// 原有的玩家派系无人机检查逻辑
|
||||
Hediff_HiveMindDrone droneHediff = dronePawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("ARA_HiveMindDrone")) as Hediff_HiveMindDrone;
|
||||
if (droneHediff == null)
|
||||
{
|
||||
@@ -105,4 +175,4 @@ namespace ArachnaeSwarm
|
||||
return Valid(target);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,6 +74,9 @@ namespace ArachnaeSwarm
|
||||
return false;
|
||||
}
|
||||
|
||||
// 新增:强制赋予主节点的文化给无人机
|
||||
ForceMasterCultureToDrone(drone);
|
||||
|
||||
droneHediff.target = this.pawn; // Set the drone's target to this master
|
||||
drones.Add(drone);
|
||||
UpdateSeverity();
|
||||
@@ -81,6 +84,84 @@ namespace ArachnaeSwarm
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 强制将主节点的文化赋予无人机
|
||||
/// </summary>
|
||||
private void ForceMasterCultureToDrone(Pawn drone)
|
||||
{
|
||||
// 检查是否有意识形态系统(Ideology DLC)
|
||||
if (ModsConfig.IdeologyActive)
|
||||
{
|
||||
// 获取主节点的意识形态
|
||||
Ideo masterIdeo = this.pawn.Ideo;
|
||||
|
||||
if (masterIdeo != null)
|
||||
{
|
||||
// 设置无人机的意识形态为主节点的意识形态
|
||||
if (drone.Ideo != masterIdeo)
|
||||
{
|
||||
drone.ideo.SetIdeo(masterIdeo);
|
||||
Log.Message($"[ArachnaeSwarm] Set drone {drone.LabelShort} ideology to master's ideology: {masterIdeo.name}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Warning($"[ArachnaeSwarm] Master {this.pawn.LabelShort} has no ideology to assign to drone {drone.LabelShort}");
|
||||
}
|
||||
|
||||
// 强制同步文化相关记忆和状态
|
||||
SyncCulturalMemories(drone);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Message($"[ArachnaeSwarm] Ideology DLC not active, skipping cultural assignment for drone {drone.LabelShort}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 同步文化相关记忆和状态
|
||||
/// </summary>
|
||||
private void SyncCulturalMemories(Pawn drone)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 清除可能存在的文化冲突记忆
|
||||
if (drone.needs?.mood != null)
|
||||
{
|
||||
// 移除与文化转换相关的负面想法
|
||||
var thoughtsToRemove = drone.needs.mood.thoughts.memories.Memories
|
||||
.Where(thought => thought.def.defName.Contains("Cultural") ||
|
||||
thought.def.defName.Contains("Ideo") ||
|
||||
thought.def.defName.Contains("Convert"))
|
||||
.ToList();
|
||||
|
||||
foreach (var thought in thoughtsToRemove)
|
||||
{
|
||||
drone.needs.mood.thoughts.memories.RemoveMemory(thought);
|
||||
}
|
||||
|
||||
if (thoughtsToRemove.Count > 0)
|
||||
{
|
||||
Log.Message($"[ArachnaeSwarm] Removed {thoughtsToRemove.Count} cultural conflict thoughts from drone {drone.LabelShort}");
|
||||
}
|
||||
|
||||
// 添加蜂群文化适应的正面想法
|
||||
ThoughtDef culturalHarmonyThought = DefDatabase<ThoughtDef>.GetNamedSilentFail("ARA_CulturalHarmony");
|
||||
if (culturalHarmonyThought != null)
|
||||
{
|
||||
drone.needs.mood.thoughts.memories.TryGainMemory(culturalHarmonyThought);
|
||||
}
|
||||
}
|
||||
|
||||
// 同步服装和文化偏好
|
||||
Log.Message($"[ArachnaeSwarm] Successfully synchronized cultural memories for drone {drone.LabelShort}");
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
Log.Error($"[ArachnaeSwarm] Error synchronizing cultural memories for drone {drone.LabelShort}: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
public void TryBindAllAvailableDrones()
|
||||
{
|
||||
if (this.pawn?.Map == null) return;
|
||||
@@ -102,6 +183,9 @@ namespace ArachnaeSwarm
|
||||
// Check if the drone is unlinked (target is null) and not already in our list
|
||||
if (droneHediff != null && droneHediff.target == null && !drones.Contains(drone))
|
||||
{
|
||||
// 新增:在自动绑定时也强制赋予文化
|
||||
ForceMasterCultureToDrone(drone);
|
||||
|
||||
droneHediff.target = this.pawn; // Set the drone's target to this master
|
||||
drones.Add(drone);
|
||||
Log.Message($"[ArachnaeSwarm] Master {this.pawn.LabelShort} automatically bound drone {drone.LabelShort}.");
|
||||
@@ -144,4 +228,4 @@ namespace ArachnaeSwarm
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,11 +37,24 @@ namespace ArachnaeSwarm
|
||||
// 添加:获取总天数
|
||||
public float TotalDays => Props.lifetimeDays;
|
||||
|
||||
// 新增:检查是否为玩家派系
|
||||
public bool IsPlayerFaction
|
||||
{
|
||||
get
|
||||
{
|
||||
Pawn pawn = parent as Pawn;
|
||||
return pawn != null && pawn.Faction == Faction.OfPlayer;
|
||||
}
|
||||
}
|
||||
|
||||
// 添加:检查是否有关闭系统的 Hediff
|
||||
public bool HasShutdownHediff
|
||||
{
|
||||
get
|
||||
{
|
||||
// 非玩家派系不检查 Hediff
|
||||
if (!IsPlayerFaction) return false;
|
||||
|
||||
// 每 300 tick 检查一次,避免性能问题
|
||||
if (hasShutdownHediffCached == null || Find.TickManager.TicksGame > lastHediffCheckTick + 300)
|
||||
{
|
||||
@@ -77,6 +90,9 @@ namespace ArachnaeSwarm
|
||||
// 新增:当hediff消失时执行的处理
|
||||
private void HandleMissingHediff()
|
||||
{
|
||||
// 非玩家派系不处理 Hediff 消失
|
||||
if (!IsPlayerFaction) return;
|
||||
|
||||
Pawn pawn = parent as Pawn;
|
||||
if (pawn == null) return;
|
||||
|
||||
@@ -109,6 +125,9 @@ namespace ArachnaeSwarm
|
||||
// 新增:获取或创建寿命Hediff
|
||||
private Hediff GetOrCreateLifespanHediff()
|
||||
{
|
||||
// 非玩家派系不创建 Hediff
|
||||
if (!IsPlayerFaction) return null;
|
||||
|
||||
Pawn pawn = parent as Pawn;
|
||||
if (pawn == null) return null;
|
||||
|
||||
@@ -150,6 +169,9 @@ namespace ArachnaeSwarm
|
||||
// 新增:同步组件和Hediff的寿命数据
|
||||
private void SyncLifespanWithHediff()
|
||||
{
|
||||
// 非玩家派系不进行同步
|
||||
if (!IsPlayerFaction) return;
|
||||
|
||||
Pawn pawn = parent as Pawn;
|
||||
if (pawn == null) return;
|
||||
|
||||
@@ -198,6 +220,9 @@ namespace ArachnaeSwarm
|
||||
// 新增:将Comp的数据写入Hediff(用于调试命令)
|
||||
private void WriteCompDataToHediff()
|
||||
{
|
||||
// 非玩家派系不写入 Hediff
|
||||
if (!IsPlayerFaction) return;
|
||||
|
||||
Pawn pawn = parent as Pawn;
|
||||
if (pawn == null) return;
|
||||
|
||||
@@ -223,6 +248,9 @@ namespace ArachnaeSwarm
|
||||
// 新增:定期校验Hediff状态
|
||||
private void ValidateHediffState()
|
||||
{
|
||||
// 非玩家派系不进行 Hediff 校验
|
||||
if (!IsPlayerFaction) return;
|
||||
|
||||
Pawn pawn = parent as Pawn;
|
||||
if (pawn == null) return;
|
||||
|
||||
@@ -259,6 +287,9 @@ namespace ArachnaeSwarm
|
||||
// 新增:检查是否需要创建寿命 Hediff
|
||||
private bool ShouldCreateLifespanHediff()
|
||||
{
|
||||
// 非玩家派系不创建 Hediff
|
||||
if (!IsPlayerFaction) return false;
|
||||
|
||||
// 如果有关闭 Hediff,不应该创建寿命 Hediff
|
||||
if (HasShutdownHediff)
|
||||
{
|
||||
@@ -290,33 +321,39 @@ namespace ArachnaeSwarm
|
||||
lastHediffSyncTick = Find.TickManager.TicksGame;
|
||||
lastHediffMissingCheckTick = Find.TickManager.TicksGame;
|
||||
|
||||
// 添加:检查是否需要创建寿命 Hediff
|
||||
if (ShouldCreateLifespanHediff())
|
||||
// 只有玩家派系才进行 Hediff 管理
|
||||
if (IsPlayerFaction)
|
||||
{
|
||||
// 确保寿命Hediff存在
|
||||
GetOrCreateLifespanHediff();
|
||||
|
||||
// 初始同步
|
||||
SyncLifespanWithHediff();
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Message($"Skipping lifespan hediff creation for {parent.Label} due to shutdown hediff");
|
||||
// 添加:检查是否需要创建寿命 Hediff
|
||||
if (ShouldCreateLifespanHediff())
|
||||
{
|
||||
// 确保寿命Hediff存在
|
||||
GetOrCreateLifespanHediff();
|
||||
|
||||
// 初始同步
|
||||
SyncLifespanWithHediff();
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Message($"Skipping lifespan hediff creation for {parent.Label} due to shutdown hediff");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override IEnumerable<Gizmo> CompGetGizmosExtra()
|
||||
{
|
||||
// 非玩家派系不显示 Gizmo(除非特别配置)
|
||||
if (!IsPlayerFaction && !Props.showGizmoOnNonPlayerControlled)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
|
||||
// 添加:如果有关闭 Hediff,不显示任何 Gizmo
|
||||
if (HasShutdownHediff)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
|
||||
if (parent.Faction != Faction.OfPlayer && !Props.showGizmoOnNonPlayerControlled)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
if (Find.Selector.SingleSelectedThing == parent)
|
||||
{
|
||||
if (gizmo == null)
|
||||
@@ -340,6 +377,7 @@ namespace ArachnaeSwarm
|
||||
if (pawn != null)
|
||||
{
|
||||
string message = $"关闭Hediff状态:\n" +
|
||||
$"玩家派系: {IsPlayerFaction}\n" +
|
||||
$"HasShutdownHediff: {HasShutdownHediff}\n" +
|
||||
$"Shutdown Hediff Def: {Props.immuteHediff?.defName ?? "None"}\n" +
|
||||
$"实际存在: {(Props.immuteHediff != null ? pawn.health.hediffSet.HasHediff(Props.immuteHediff).ToString() : "N/A")}";
|
||||
@@ -431,6 +469,7 @@ namespace ArachnaeSwarm
|
||||
if (hediff != null)
|
||||
{
|
||||
string message = $"寿命Hediff信息:\n" +
|
||||
$"玩家派系: {IsPlayerFaction}\n" +
|
||||
$"严重程度: {hediff.Severity:P4}\n" +
|
||||
$"剩余ticks: {powerTicksLeft}\n" +
|
||||
$"剩余天数: {DaysLeft:F4}\n" +
|
||||
@@ -444,6 +483,7 @@ namespace ArachnaeSwarm
|
||||
else
|
||||
{
|
||||
string message = $"未找到寿命hediff\n" +
|
||||
$"玩家派系: {IsPlayerFaction}\n" +
|
||||
$"关闭Hediff存在: {HasShutdownHediff}";
|
||||
Messages.Message(message, MessageTypeDefOf.SilentInput);
|
||||
}
|
||||
@@ -507,6 +547,9 @@ namespace ArachnaeSwarm
|
||||
{
|
||||
base.CompTick();
|
||||
|
||||
// 非玩家派系不进行任何 Tick 逻辑
|
||||
if (!IsPlayerFaction) return;
|
||||
|
||||
// 添加:如果有关闭 Hediff,停止所有 Tick 逻辑
|
||||
if (HasShutdownHediff)
|
||||
{
|
||||
@@ -605,19 +648,23 @@ namespace ArachnaeSwarm
|
||||
powerTicksLeft = (int)(Props.lifetimeDays * 60000);
|
||||
}
|
||||
|
||||
// 立即检查hediff是否存在
|
||||
ValidateHediffState();
|
||||
// 只有玩家派系才进行 Hediff 管理
|
||||
if (IsPlayerFaction)
|
||||
{
|
||||
// 立即检查hediff是否存在
|
||||
ValidateHediffState();
|
||||
|
||||
// 添加:检查是否需要创建寿命 Hediff
|
||||
if (ShouldCreateLifespanHediff())
|
||||
{
|
||||
// 确保寿命Hediff存在并同步
|
||||
GetOrCreateLifespanHediff();
|
||||
SyncLifespanWithHediff();
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Message($"Skipping lifespan hediff creation for {parent.Label} after load due to shutdown hediff");
|
||||
// 添加:检查是否需要创建寿命 Hediff
|
||||
if (ShouldCreateLifespanHediff())
|
||||
{
|
||||
// 确保寿命Hediff存在并同步
|
||||
GetOrCreateLifespanHediff();
|
||||
SyncLifespanWithHediff();
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Message($"Skipping lifespan hediff creation for {parent.Label} after load due to shutdown hediff");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user