diff --git a/OpenRA.Game/Traits/Player/DeveloperMode.cs b/OpenRA.Game/Traits/Player/DeveloperMode.cs index ac628dc1cb..430b46d0a1 100644 --- a/OpenRA.Game/Traits/Player/DeveloperMode.cs +++ b/OpenRA.Game/Traits/Player/DeveloperMode.cs @@ -107,7 +107,7 @@ namespace OpenRA.Traits if (EnableAll) { - self.Owner.Shroud.ExploreAll(self.World); + self.Owner.Shroud.ExploreAll(); var amount = order.ExtraData != 0 ? (int)order.ExtraData : info.Cash; self.Trait().GiveCash(amount); @@ -177,7 +177,7 @@ namespace OpenRA.Traits case "DevGiveExploration": { - self.Owner.Shroud.ExploreAll(self.World); + self.Owner.Shroud.ExploreAll(); break; } diff --git a/OpenRA.Game/Traits/World/Shroud.cs b/OpenRA.Game/Traits/World/Shroud.cs index 7fbbc62c0c..b73b1a287d 100644 --- a/OpenRA.Game/Traits/World/Shroud.cs +++ b/OpenRA.Game/Traits/World/Shroud.cs @@ -33,7 +33,7 @@ namespace OpenRA.Traits public object Create(ActorInitializer init) { return new Shroud(init.Self); } } - public class Shroud : ISync + public class Shroud : ISync, INotifyCreated { public event Action> CellsChanged; @@ -79,6 +79,12 @@ namespace OpenRA.Traits explored = new CellLayer(map); } + void INotifyCreated.Created(Actor self) + { + if (!self.World.LobbyInfo.GlobalSettings.Shroud) + self.World.AddFrameEndTask(w => ExploreAll()); + } + void Invalidate(IEnumerable changed) { if (CellsChanged != null) @@ -241,7 +247,7 @@ namespace OpenRA.Traits Invalidate(changed); } - public void ExploreAll(World world) + public void ExploreAll() { var changed = new List(); foreach (var puv in map.ProjectedCellBounds) diff --git a/OpenRA.Game/World.cs b/OpenRA.Game/World.cs index f8075d122e..058f019a12 100644 --- a/OpenRA.Game/World.cs +++ b/OpenRA.Game/World.cs @@ -184,10 +184,6 @@ namespace OpenRA MapUid = Map.Uid, MapTitle = Map.Title }; - - if (!LobbyInfo.GlobalSettings.Shroud) - foreach (var player in Players) - player.Shroud.ExploreAll(this); } public void AddToMaps(Actor self, IOccupySpace ios) diff --git a/OpenRA.Mods.Common/Traits/Crates/RevealMapCrateAction.cs b/OpenRA.Mods.Common/Traits/Crates/RevealMapCrateAction.cs index 3b2c8bb5ab..69577b55c5 100644 --- a/OpenRA.Mods.Common/Traits/Crates/RevealMapCrateAction.cs +++ b/OpenRA.Mods.Common/Traits/Crates/RevealMapCrateAction.cs @@ -36,10 +36,10 @@ namespace OpenRA.Mods.Common.Traits { foreach (var player in collector.World.Players) if (collector.Owner.IsAlliedWith(player)) - player.Shroud.ExploreAll(player.World); + player.Shroud.ExploreAll(); } else - collector.Owner.Shroud.ExploreAll(collector.World); + collector.Owner.Shroud.ExploreAll(); base.Activate(collector); } diff --git a/OpenRA.Mods.RA/Traits/GpsWatcher.cs b/OpenRA.Mods.RA/Traits/GpsWatcher.cs index 9d5b287e25..9ff24f79bf 100644 --- a/OpenRA.Mods.RA/Traits/GpsWatcher.cs +++ b/OpenRA.Mods.RA/Traits/GpsWatcher.cs @@ -72,7 +72,7 @@ namespace OpenRA.Mods.RA.Traits i.Trait.RefreshGranted(); if ((Granted || GrantedAllies) && atek.Owner.IsAlliedWith(owner)) - atek.Owner.Shroud.ExploreAll(atek.World); + atek.Owner.Shroud.ExploreAll(); } void RefreshGranted() @@ -84,7 +84,7 @@ namespace OpenRA.Mods.RA.Traits GrantedAllies = owner.World.ActorsHavingTrait(g => g.Granted).Any(p => p.Owner.IsAlliedWith(owner)); if (Granted || GrantedAllies) - owner.Shroud.ExploreAll(owner.World); + owner.Shroud.ExploreAll(); if (wasGranted != Granted || wasGrantedAllies != GrantedAllies) foreach (var tp in notifyOnRefresh.ToList())