diff --git a/1.6/1.6/Assemblies/ArachnaeSwarm.dll b/1.6/1.6/Assemblies/ArachnaeSwarm.dll index 0ea2887..fa13e81 100644 Binary files a/1.6/1.6/Assemblies/ArachnaeSwarm.dll and b/1.6/1.6/Assemblies/ArachnaeSwarm.dll differ diff --git a/Source/ArachnaeSwarm/PowerArmor/ARA_PowerArmor.cs b/Source/ArachnaeSwarm/PowerArmor/ARA_PowerArmor.cs index 64a542e..646af0a 100644 --- a/Source/ArachnaeSwarm/PowerArmor/ARA_PowerArmor.cs +++ b/Source/ArachnaeSwarm/PowerArmor/ARA_PowerArmor.cs @@ -57,7 +57,14 @@ namespace ArachnaeSwarm protected override void Tick() { base.Tick(); - if (this.Wearer == null) return; + if (this.Wearer == null) + { + if (!this.Destroyed) + { + this.Destroy(); + } + return; + } var fuelComp = this.GetComp(); if (fuelComp != null) @@ -180,12 +187,8 @@ namespace ArachnaeSwarm GenPlace.TryPlaceThing(building, pawn.Position, pawn.Map, ThingPlaceMode.Near); Log.Message($"[PA_Debug] Notify_Unequipped: After spawning building (ID: {building.thingIDNumber}) - HitPoints: {building.HitPoints}, StackCount: {building.stackCount}"); - // To prevent the game from spawning a duplicate item, we must destroy the apparel. - // However, using DestroyMode.Vanish or Kill can cause "Spawning destroyed thing" errors - // if called directly within Notify_Unequipped. - // DestroyMode.QuestLogic is the correct way: it marks the thing as destroyed - // but defers the actual cleanup until the end of the current tick, avoiding race conditions. - this.Destroy(DestroyMode.QuestLogic); + // The destruction is now handled by the Tick() method when it detects Wearer is null. + // This is the safest way to implement delayed self-destruction. } #endregion diff --git a/Source/ArachnaeSwarm/PowerArmor/JobDriver_EnterPowerArmor.cs b/Source/ArachnaeSwarm/PowerArmor/JobDriver_EnterPowerArmor.cs index 35ff07c..29bc532 100644 --- a/Source/ArachnaeSwarm/PowerArmor/JobDriver_EnterPowerArmor.cs +++ b/Source/ArachnaeSwarm/PowerArmor/JobDriver_EnterPowerArmor.cs @@ -50,8 +50,10 @@ namespace ArachnaeSwarm apparelFuelComp.ReceiveFuel(buildingFuelComp.Fuel); } - // Wear the apparel, ensuring it's not locked. - actor.apparel.Wear(apparel, false, true); + // Wear the apparel. The second argument 'false' is lockWhileWorn. + // The third argument 'false' is playerForced, which is CRITICAL. + // If playerForced is true, the game automatically locks the apparel. + actor.apparel.Wear(apparel, false, false); // Despawn the building building.DeSpawn();