diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index 416d4e72b4..d9c7d9767b 100644 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -192,11 +192,6 @@ namespace OpenRA if (orderManager.GameStarted) return; Widget.SelectedWidget = null; - world.Queries = new World.AllQueries(world); - - foreach (var gs in world.WorldActor.TraitsImplementing()) - gs.GameStarted(world); - orderManager.StartGame(); viewport.RefreshPalette(); AfterGameStart(); diff --git a/OpenRA.Game/Traits/MPStartLocations.cs b/OpenRA.Game/Traits/MPStartLocations.cs index f6e7ab7a5e..18ff52179b 100644 --- a/OpenRA.Game/Traits/MPStartLocations.cs +++ b/OpenRA.Game/Traits/MPStartLocations.cs @@ -21,10 +21,11 @@ namespace OpenRA.Traits public readonly int InitialExploreRange = 5; } - public class MPStartLocations : IGameStarted + public class MPStartLocations : IWorldLoaded { public Dictionary Start = new Dictionary(); - public void GameStarted(World world) + + public void WorldLoaded(World world) { var taken = Game.LobbyInfo.Clients.Where(c => c.SpawnPoint != 0) .Select(c => world.Map.SpawnPoints.ElementAt(c.SpawnPoint - 1)).ToList(); diff --git a/OpenRA.Game/Traits/TraitsInterfaces.cs b/OpenRA.Game/Traits/TraitsInterfaces.cs index f355076672..4dac916619 100644 --- a/OpenRA.Game/Traits/TraitsInterfaces.cs +++ b/OpenRA.Game/Traits/TraitsInterfaces.cs @@ -159,8 +159,7 @@ namespace OpenRA.Traits public interface ITraitPrerequisite where T : ITraitInfo { } public interface INotifySelection { void SelectionChanged(); } - public interface ILoadWorldHook { void WorldLoaded(World w); } - public interface IGameStarted { void GameStarted(World w); } + public interface IWorldLoaded { void WorldLoaded(World w); } public interface ICreatePlayers { void CreatePlayers(World w); } public interface IBot { void Activate(Player p); } diff --git a/OpenRA.Game/Traits/World/BibLayer.cs b/OpenRA.Game/Traits/World/BibLayer.cs index 90789124d9..3b5513af01 100644 --- a/OpenRA.Game/Traits/World/BibLayer.cs +++ b/OpenRA.Game/Traits/World/BibLayer.cs @@ -23,7 +23,7 @@ namespace OpenRA.Traits public object Create(ActorInitializer init) { return new BibLayer(init.self, this); } } - class BibLayer: IRenderOverlay, ILoadWorldHook + class BibLayer: IRenderOverlay, IWorldLoaded { World world; BibLayerInfo info; diff --git a/OpenRA.Game/Traits/World/ResourceLayer.cs b/OpenRA.Game/Traits/World/ResourceLayer.cs index dd8f9e4e28..96ebef7f8a 100644 --- a/OpenRA.Game/Traits/World/ResourceLayer.cs +++ b/OpenRA.Game/Traits/World/ResourceLayer.cs @@ -17,7 +17,7 @@ namespace OpenRA.Traits { public class ResourceLayerInfo : TraitInfo { } - public class ResourceLayer: IRenderOverlay, ILoadWorldHook + public class ResourceLayer: IRenderOverlay, IWorldLoaded { World world; diff --git a/OpenRA.Game/Traits/World/SmudgeLayer.cs b/OpenRA.Game/Traits/World/SmudgeLayer.cs index 0f15213e04..2e33a2ec26 100644 --- a/OpenRA.Game/Traits/World/SmudgeLayer.cs +++ b/OpenRA.Game/Traits/World/SmudgeLayer.cs @@ -24,7 +24,7 @@ namespace OpenRA.Traits public object Create(ActorInitializer init) { return new SmudgeLayer(this); } } - public class SmudgeLayer: IRenderOverlay, ILoadWorldHook + public class SmudgeLayer: IRenderOverlay, IWorldLoaded { public SmudgeLayerInfo Info; TileReference[,] tiles; diff --git a/OpenRA.Game/World.cs b/OpenRA.Game/World.cs index 1fc79b6d8b..7a2ab9ff47 100644 --- a/OpenRA.Game/World.cs +++ b/OpenRA.Game/World.cs @@ -88,6 +88,7 @@ namespace OpenRA Timer.Time("renderer: {0}"); WorldActor = CreateActor( "World", new TypeDictionary() ); + Queries = new AllQueries(this); // Add players foreach (var cmp in WorldActor.TraitsImplementing()) @@ -100,11 +101,12 @@ namespace OpenRA p.Stances[q] = Stance.Neutral; Timer.Time( "worldActor, players: {0}" ); - - foreach (var wlh in WorldActor.TraitsImplementing()) - wlh.WorldLoaded(this); PathFinder = new PathFinder(this); + + foreach (var wlh in WorldActor.TraitsImplementing()) + wlh.WorldLoaded(this); + Timer.Time( "hooks, pathing: {0}" ); Timer.Time( "----end World.ctor" ); diff --git a/OpenRA.Mods.Cnc/Missions/Gdi01Script.cs b/OpenRA.Mods.Cnc/Missions/Gdi01Script.cs index cbd2f6af85..bcd151f89c 100644 --- a/OpenRA.Mods.Cnc/Missions/Gdi01Script.cs +++ b/OpenRA.Mods.Cnc/Missions/Gdi01Script.cs @@ -21,7 +21,7 @@ namespace OpenRA.Mods.RA { class Gdi01ScriptInfo : TraitInfo { } - class Gdi01Script: ILoadWorldHook, ITick + class Gdi01Script: IWorldLoaded, ITick { Dictionary Actors; Dictionary Players; diff --git a/OpenRA.Mods.RA/BridgeLayer.cs b/OpenRA.Mods.RA/BridgeLayer.cs index 79322dcc99..b44f220fff 100644 --- a/OpenRA.Mods.RA/BridgeLayer.cs +++ b/OpenRA.Mods.RA/BridgeLayer.cs @@ -23,7 +23,7 @@ namespace OpenRA.Mods.RA public object Create(ActorInitializer init) { return new BridgeLayer(init.self, this); } } - class BridgeLayer : ILoadWorldHook + class BridgeLayer : IWorldLoaded { readonly BridgeLayerInfo Info; readonly World world; diff --git a/OpenRA.Mods.RA/ColorPickerPaletteModifier.cs b/OpenRA.Mods.RA/ColorPickerPaletteModifier.cs index 5fbfa82404..3cfa544df1 100644 --- a/OpenRA.Mods.RA/ColorPickerPaletteModifier.cs +++ b/OpenRA.Mods.RA/ColorPickerPaletteModifier.cs @@ -17,7 +17,7 @@ namespace OpenRA.Mods.RA { class ColorPickerPaletteModifierInfo : TraitInfo {} - class ColorPickerPaletteModifier : IPaletteModifier, ILoadWorldHook + class ColorPickerPaletteModifier : IPaletteModifier, IWorldLoaded { bool SplitPlayerPalette; public void WorldLoaded(World w) diff --git a/OpenRA.Mods.RA/DefaultShellmapScript.cs b/OpenRA.Mods.RA/DefaultShellmapScript.cs index e2cb4ee891..5bd8f04b9d 100644 --- a/OpenRA.Mods.RA/DefaultShellmapScript.cs +++ b/OpenRA.Mods.RA/DefaultShellmapScript.cs @@ -16,7 +16,7 @@ namespace OpenRA.Mods.RA { class DefaultShellmapScriptInfo : TraitInfo { } - class DefaultShellmapScript: ILoadWorldHook, ITick + class DefaultShellmapScript: IWorldLoaded, ITick { Dictionary Actors; diff --git a/OpenRA.Mods.RA/SpawnMPUnits.cs b/OpenRA.Mods.RA/SpawnMPUnits.cs index c915a4be2b..294994fc00 100644 --- a/OpenRA.Mods.RA/SpawnMPUnits.cs +++ b/OpenRA.Mods.RA/SpawnMPUnits.cs @@ -15,9 +15,9 @@ namespace OpenRA.Mods.RA { class SpawnMPUnitsInfo : TraitInfo, ITraitPrerequisite {} - class SpawnMPUnits : IGameStarted + class SpawnMPUnits : IWorldLoaded { - public void GameStarted(World world) + public void WorldLoaded(World world) { foreach (var s in world.WorldActor.Trait().Start) SpawnUnitsForPlayer(s.Key, s.Value); diff --git a/OpenRA.Mods.RA/SpawnMapActors.cs b/OpenRA.Mods.RA/SpawnMapActors.cs index 8a59f1a50d..4eaf36f67d 100644 --- a/OpenRA.Mods.RA/SpawnMapActors.cs +++ b/OpenRA.Mods.RA/SpawnMapActors.cs @@ -15,17 +15,17 @@ namespace OpenRA.Mods.RA { public class SpawnMapActorsInfo : TraitInfo { } - public class SpawnMapActors : IGameStarted + public class SpawnMapActors : IWorldLoaded { public Dictionary Actors = new Dictionary(); - public void GameStarted(World world) + public void WorldLoaded(World world) { - foreach( var actorReference in world.Map.Actors ) + foreach (var actorReference in world.Map.Actors) { var initDict = actorReference.Value.InitDict; - initDict.Add( new SkipMakeAnimsInit() ); - Actors[ actorReference.Key ] = world.CreateActor( actorReference.Value.Type, initDict ); + initDict.Add(new SkipMakeAnimsInit()); + Actors[actorReference.Key] = world.CreateActor(actorReference.Value.Type, initDict); } } }