This commit is contained in:
2026-02-28 11:50:54 +08:00
parent 60cde0317d
commit bd4843bc89
19 changed files with 1212 additions and 367 deletions

View File

@@ -1,7 +1,7 @@
// File: Wulamechunit_Fixed.cs
using RimWorld;
using System.Collections.Generic;
using Verse;
using Verse.AI;
using Verse.AI.Group;
namespace WulaFallenEmpire
@@ -32,6 +32,16 @@ namespace WulaFallenEmpire
}
}
// 添加乘员相关的Gizmo
var crewComp = this.TryGetComp<CompMechCrewHolder>();
if (crewComp != null)
{
foreach (var gizmo in crewComp.CompGetGizmosExtra())
{
yield return gizmo;
}
}
// 原有的征兆Gizmo
if (drafter == null)
{
@@ -121,34 +131,66 @@ namespace WulaFallenEmpire
// 关键修复:重写死亡相关方法
public override void Kill(DamageInfo? dinfo = null, Hediff exactCulprit = null)
{
// 在死亡前弹出所有驾驶员
// 在死亡前弹出所有驾驶员和乘员
var pilotComp = this.TryGetComp<CompMechPilotHolder>();
if (pilotComp != null && pilotComp.HasPilots)
{
pilotComp.EjectAllPilotsOnDeath();
}
var crewComp = this.TryGetComp<CompMechCrewHolder>();
if (crewComp != null && crewComp.HasCrew)
{
crewComp.RemoveAllCrew();
}
base.Kill(dinfo, exactCulprit);
}
// 重写销毁方法
public override void Destroy(DestroyMode mode = DestroyMode.Vanish)
{
// 在销毁前弹出所有驾驶员
// 在销毁前弹出所有驾驶员和乘员
var pilotComp = this.TryGetComp<CompMechPilotHolder>();
if (pilotComp != null && pilotComp.HasPilots)
{
pilotComp.EjectAllPilotsOnDeath();
}
var crewComp = this.TryGetComp<CompMechCrewHolder>();
if (crewComp != null && crewComp.HasCrew)
{
crewComp.RemoveAllCrew();
}
base.Destroy(mode);
}
// IThingHolder 接口实现
public new ThingOwner GetDirectlyHeldThings()
{
// 合并驾驶员和乘员容器
var pilotComp = this.TryGetComp<CompMechPilotHolder>();
return pilotComp?.GetDirectlyHeldThings();
var crewComp = this.TryGetComp<CompMechCrewHolder>();
if (pilotComp != null && crewComp != null)
{
// 合并两个容器
var combined = new ThingOwner<Thing>(this);
combined.TryAddRangeOrTransfer(pilotComp.innerContainer);
combined.TryAddRangeOrTransfer(crewComp.innerContainer);
return combined;
}
else if (pilotComp != null)
{
return pilotComp.innerContainer;
}
else if (crewComp != null)
{
return crewComp.innerContainer;
}
return null;
}
public new void GetChildHolders(List<IThingHolder> outChildren)
@@ -159,8 +201,6 @@ namespace WulaFallenEmpire
public override void ExposeData()
{
base.ExposeData();
// 驾驶员容器的数据会在CompMechPilotHolder中自动保存
}
}
}