存
This commit is contained in:
Binary file not shown.
@@ -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<CompRefuelableNutrition>();
|
||||
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
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user