Don't call DetachCarryable every tick

This commit is contained in:
Gustas
2023-05-21 15:03:30 +03:00
committed by Pavel Penev
parent 1edf313090
commit c36609cc9f

View File

@@ -142,13 +142,13 @@ namespace OpenRA.Mods.Common.Traits
void ITick.Tick(Actor self) void ITick.Tick(Actor self)
{ {
// Cargo may be killed in the same tick as, but after they are attached // Cargo may be killed in the same tick as, but after they are attached.
if (Carryable != null && Carryable.IsDead) if (State == CarryallState.Carrying && (Carryable == null || Carryable.IsDead))
DetachCarryable(self); DetachCarryable(self);
// HACK: We don't have an efficient way to know when the preview // HACK: We don't have an efficient way to know when the preview
// bounds change, so assume that we need to update the screen map // bounds change, so assume that we need to update the screen map
// (only) when the facing changes // (only) when the facing changes.
if (facing.Facing != cachedFacing && carryablePreview != null) if (facing.Facing != cachedFacing && carryablePreview != null)
{ {
self.World.ScreenMap.AddOrUpdate(self); self.World.ScreenMap.AddOrUpdate(self);