diff --git a/OpenRA.Game/Actor.cs b/OpenRA.Game/Actor.cs index 31c77b87fd..99742496ed 100755 --- a/OpenRA.Game/Actor.cs +++ b/OpenRA.Game/Actor.cs @@ -25,9 +25,24 @@ namespace OpenRA public readonly World World; public readonly uint ActorID; + + IOccupySpace OccupiesSpace; + IHasLocation HasLocation; - public int2 Location { get { return Trait().TopLeft; } } - public int2 CenterLocation { get { return Trait().PxPosition; } } + public int2 Location + { get { + if (OccupiesSpace == null) + OccupiesSpace = Trait(); + return OccupiesSpace.TopLeft; + }} + + public int2 CenterLocation + { get { + if (HasLocation == null) + HasLocation = Trait(); + return HasLocation.PxPosition; + }} + [Sync] public Player Owner;