Fix inconsistent FrozenActor state on capture/destruction.

This commit is contained in:
Paul Chote
2019-02-02 17:55:33 +00:00
committed by Oliver Brakmann
parent 08e3e429db
commit 2b6ebcd09c

View File

@@ -28,7 +28,7 @@ namespace OpenRA.Mods.Common.Traits
public object Create(ActorInitializer init) { return new FrozenUnderFog(init, this); }
}
public class FrozenUnderFog : ICreatesFrozenActors, IRenderModifier, IDefaultVisibility, ITick, ITickRender, ISync, INotifyCreated
public class FrozenUnderFog : ICreatesFrozenActors, IRenderModifier, IDefaultVisibility, ITick, ITickRender, ISync, INotifyCreated, INotifyOwnerChanged, INotifyActorDisposing
{
[Sync] public int VisibilityHash;
@@ -173,6 +173,20 @@ namespace OpenRA.Mods.Common.Traits
{
return bounds;
}
void INotifyOwnerChanged.OnOwnerChanged(Actor self, Player oldOwner, Player newOwner)
{
// Force a state update for the old owner so the tooltip etc doesn't show them as the owner
var oldOwnerIndex = self.World.Players.IndexOf(oldOwner);
UpdateFrozenActor(self, frozenStates[oldOwnerIndex].FrozenActor, oldOwnerIndex);
}
void INotifyActorDisposing.Disposing(Actor self)
{
// Invalidate the frozen actor (which exists if this actor was captured from an enemy)
// for the current owner
frozenStates[self.Owner].FrozenActor.Invalidate();
}
}
public class HiddenUnderFogInit : IActorInit { }