start cleaning up IWorldLoadHook vs IGameStarted -- IGameStarted dies.
This commit is contained in:
@@ -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<IGameStarted>())
|
||||
gs.GameStarted(world);
|
||||
|
||||
orderManager.StartGame();
|
||||
viewport.RefreshPalette();
|
||||
AfterGameStart();
|
||||
|
||||
@@ -21,10 +21,11 @@ namespace OpenRA.Traits
|
||||
public readonly int InitialExploreRange = 5;
|
||||
}
|
||||
|
||||
public class MPStartLocations : IGameStarted
|
||||
public class MPStartLocations : IWorldLoaded
|
||||
{
|
||||
public Dictionary<Player, int2> Start = new Dictionary<Player, int2>();
|
||||
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();
|
||||
|
||||
@@ -159,8 +159,7 @@ namespace OpenRA.Traits
|
||||
public interface ITraitPrerequisite<T> 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); }
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace OpenRA.Traits
|
||||
{
|
||||
public class ResourceLayerInfo : TraitInfo<ResourceLayer> { }
|
||||
|
||||
public class ResourceLayer: IRenderOverlay, ILoadWorldHook
|
||||
public class ResourceLayer: IRenderOverlay, IWorldLoaded
|
||||
{
|
||||
World world;
|
||||
|
||||
|
||||
@@ -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<byte,byte>[,] tiles;
|
||||
|
||||
@@ -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<ICreatePlayers>())
|
||||
@@ -100,11 +101,12 @@ namespace OpenRA
|
||||
p.Stances[q] = Stance.Neutral;
|
||||
|
||||
Timer.Time( "worldActor, players: {0}" );
|
||||
|
||||
foreach (var wlh in WorldActor.TraitsImplementing<ILoadWorldHook>())
|
||||
wlh.WorldLoaded(this);
|
||||
|
||||
PathFinder = new PathFinder(this);
|
||||
|
||||
foreach (var wlh in WorldActor.TraitsImplementing<IWorldLoaded>())
|
||||
wlh.WorldLoaded(this);
|
||||
|
||||
Timer.Time( "hooks, pathing: {0}" );
|
||||
|
||||
Timer.Time( "----end World.ctor" );
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace OpenRA.Mods.RA
|
||||
{
|
||||
class Gdi01ScriptInfo : TraitInfo<Gdi01Script> { }
|
||||
|
||||
class Gdi01Script: ILoadWorldHook, ITick
|
||||
class Gdi01Script: IWorldLoaded, ITick
|
||||
{
|
||||
Dictionary<string, Actor> Actors;
|
||||
Dictionary<string, Player> Players;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace OpenRA.Mods.RA
|
||||
{
|
||||
class ColorPickerPaletteModifierInfo : TraitInfo<ColorPickerPaletteModifier> {}
|
||||
|
||||
class ColorPickerPaletteModifier : IPaletteModifier, ILoadWorldHook
|
||||
class ColorPickerPaletteModifier : IPaletteModifier, IWorldLoaded
|
||||
{
|
||||
bool SplitPlayerPalette;
|
||||
public void WorldLoaded(World w)
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace OpenRA.Mods.RA
|
||||
{
|
||||
class DefaultShellmapScriptInfo : TraitInfo<DefaultShellmapScript> { }
|
||||
|
||||
class DefaultShellmapScript: ILoadWorldHook, ITick
|
||||
class DefaultShellmapScript: IWorldLoaded, ITick
|
||||
{
|
||||
Dictionary<string, Actor> Actors;
|
||||
|
||||
|
||||
@@ -15,9 +15,9 @@ namespace OpenRA.Mods.RA
|
||||
{
|
||||
class SpawnMPUnitsInfo : TraitInfo<SpawnMPUnits>, ITraitPrerequisite<MPStartLocationsInfo> {}
|
||||
|
||||
class SpawnMPUnits : IGameStarted
|
||||
class SpawnMPUnits : IWorldLoaded
|
||||
{
|
||||
public void GameStarted(World world)
|
||||
public void WorldLoaded(World world)
|
||||
{
|
||||
foreach (var s in world.WorldActor.Trait<MPStartLocations>().Start)
|
||||
SpawnUnitsForPlayer(s.Key, s.Value);
|
||||
|
||||
@@ -15,17 +15,17 @@ namespace OpenRA.Mods.RA
|
||||
{
|
||||
public class SpawnMapActorsInfo : TraitInfo<SpawnMapActors> { }
|
||||
|
||||
public class SpawnMapActors : IGameStarted
|
||||
public class SpawnMapActors : IWorldLoaded
|
||||
{
|
||||
public Dictionary<string, Actor> Actors = new Dictionary<string, Actor>();
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user