start cleaning up IWorldLoadHook vs IGameStarted -- IGameStarted dies.

This commit is contained in:
Chris Forbes
2010-08-25 21:53:54 +12:00
parent 50066ec238
commit f4da83e920
13 changed files with 23 additions and 26 deletions

View File

@@ -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();

View File

@@ -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();

View File

@@ -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); }

View File

@@ -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;

View File

@@ -17,7 +17,7 @@ namespace OpenRA.Traits
{
public class ResourceLayerInfo : TraitInfo<ResourceLayer> { }
public class ResourceLayer: IRenderOverlay, ILoadWorldHook
public class ResourceLayer: IRenderOverlay, IWorldLoaded
{
World world;

View File

@@ -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;

View File

@@ -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>())
@@ -101,10 +102,11 @@ namespace OpenRA
Timer.Time( "worldActor, players: {0}" );
foreach (var wlh in WorldActor.TraitsImplementing<ILoadWorldHook>())
PathFinder = new PathFinder(this);
foreach (var wlh in WorldActor.TraitsImplementing<IWorldLoaded>())
wlh.WorldLoaded(this);
PathFinder = new PathFinder(this);
Timer.Time( "hooks, pathing: {0}" );
Timer.Time( "----end World.ctor" );

View File

@@ -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;

View File

@@ -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;

View File

@@ -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)

View File

@@ -16,7 +16,7 @@ namespace OpenRA.Mods.RA
{
class DefaultShellmapScriptInfo : TraitInfo<DefaultShellmapScript> { }
class DefaultShellmapScript: ILoadWorldHook, ITick
class DefaultShellmapScript: IWorldLoaded, ITick
{
Dictionary<string, Actor> Actors;

View File

@@ -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);

View File

@@ -15,11 +15,11 @@ 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)
{