From 9e18ec7314a42fda972c2cfef16d5b0a7c48511e Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sun, 3 Dec 2017 15:17:07 +0000 Subject: [PATCH] Simplify ScreenMap bounds checking. --- OpenRA.Game/Traits/World/ScreenMap.cs | 8 ++++++-- OpenRA.Game/World.cs | 12 +++--------- OpenRA.Mods.Common/Traits/Buildings/Building.cs | 8 ++------ OpenRA.Mods.Common/Traits/Immobile.cs | 8 ++------ 4 files changed, 13 insertions(+), 23 deletions(-) diff --git a/OpenRA.Game/Traits/World/ScreenMap.cs b/OpenRA.Game/Traits/World/ScreenMap.cs index 7b0f48e905..b7a019ef4a 100644 --- a/OpenRA.Game/Traits/World/ScreenMap.cs +++ b/OpenRA.Game/Traits/World/ScreenMap.cs @@ -78,12 +78,16 @@ namespace OpenRA.Traits public void Add(Actor a) { - partitionedActors.Add(a, ActorBounds(a)); + var bounds = ActorBounds(a); + if (!bounds.Size.IsEmpty) + partitionedActors.Add(a, ActorBounds(a)); } public void Update(Actor a) { - partitionedActors.Update(a, ActorBounds(a)); + var bounds = ActorBounds(a); + if (!bounds.Size.IsEmpty) + partitionedActors.Update(a, ActorBounds(a)); } public void Remove(Actor a) diff --git a/OpenRA.Game/World.cs b/OpenRA.Game/World.cs index 0c9013f5f6..112c266a3a 100644 --- a/OpenRA.Game/World.cs +++ b/OpenRA.Game/World.cs @@ -191,9 +191,7 @@ namespace OpenRA { ActorMap.AddInfluence(self, ios); ActorMap.AddPosition(self, ios); - - if (!self.RenderBounds.Size.IsEmpty) - ScreenMap.Add(self); + ScreenMap.Add(self); } public void UpdateMaps(Actor self, IOccupySpace ios) @@ -201,9 +199,7 @@ namespace OpenRA if (!self.IsInWorld) return; - if (!self.RenderBounds.Size.IsEmpty) - ScreenMap.Update(self); - + ScreenMap.Update(self); ActorMap.UpdatePosition(self, ios); } @@ -211,9 +207,7 @@ namespace OpenRA { ActorMap.RemoveInfluence(self, ios); ActorMap.RemovePosition(self, ios); - - if (!self.RenderBounds.Size.IsEmpty) - ScreenMap.Remove(self); + ScreenMap.Remove(self); } public void LoadComplete(WorldRenderer wr) diff --git a/OpenRA.Mods.Common/Traits/Buildings/Building.cs b/OpenRA.Mods.Common/Traits/Buildings/Building.cs index 37f2b552b7..b4422a3ab4 100644 --- a/OpenRA.Mods.Common/Traits/Buildings/Building.cs +++ b/OpenRA.Mods.Common/Traits/Buildings/Building.cs @@ -313,9 +313,7 @@ namespace OpenRA.Mods.Common.Traits self.World.ActorMap.AddInfluence(self, this); self.World.ActorMap.AddPosition(self, this); - - if (!self.RenderBounds.Size.IsEmpty) - self.World.ScreenMap.Add(self); + self.World.ScreenMap.Add(self); influence.AddInfluence(self, Info.Tiles(self.Location)); } @@ -324,9 +322,7 @@ namespace OpenRA.Mods.Common.Traits { self.World.ActorMap.RemoveInfluence(self, this); self.World.ActorMap.RemovePosition(self, this); - - if (!self.RenderBounds.Size.IsEmpty) - self.World.ScreenMap.Remove(self); + self.World.ScreenMap.Remove(self); influence.RemoveInfluence(self, Info.Tiles(self.Location)); } diff --git a/OpenRA.Mods.Common/Traits/Immobile.cs b/OpenRA.Mods.Common/Traits/Immobile.cs index 6dd84ff350..685648d044 100644 --- a/OpenRA.Mods.Common/Traits/Immobile.cs +++ b/OpenRA.Mods.Common/Traits/Immobile.cs @@ -56,18 +56,14 @@ namespace OpenRA.Mods.Common.Traits { self.World.ActorMap.AddInfluence(self, this); self.World.ActorMap.AddPosition(self, this); - - if (!self.RenderBounds.Size.IsEmpty) - self.World.ScreenMap.Add(self); + self.World.ScreenMap.Add(self); } void INotifyRemovedFromWorld.RemovedFromWorld(Actor self) { self.World.ActorMap.RemoveInfluence(self, this); self.World.ActorMap.RemovePosition(self, this); - - if (!self.RenderBounds.Size.IsEmpty) - self.World.ScreenMap.Remove(self); + self.World.ScreenMap.Remove(self); } } }