added ISpawnStartingUnits trait; default impl just spawns an MCV

This commit is contained in:
Chris Forbes
2010-02-13 21:14:15 +13:00
parent 641c21107e
commit 3462607e9a
6 changed files with 23 additions and 8 deletions

View File

@@ -233,14 +233,12 @@ namespace OpenRa
foreach (var client in LobbyInfo.Clients)
{
int2 sp;
if (client.SpawnPoint == 0)
sp = ChooseSpawnPoint(available, taken);
else
sp = world.Map.SpawnPoints.ElementAt(client.SpawnPoint - 1);
// todo: spawn more than one unit, in most cases!
world.CreateActor("mcv", sp, world.players[client.Index]);
var sp = (client.SpawnPoint == 0)
? ChooseSpawnPoint(available, taken)
: world.Map.SpawnPoints.ElementAt(client.SpawnPoint - 1);
foreach (var ssu in world.players[client.Index].PlayerActor.traits.WithInterface<ISpawnStartingUnits>())
ssu.SpawnStartingUnits(world.players[client.Index], sp);
}
Game.viewport.GoToStartLocation( Game.world.LocalPlayer );

View File

@@ -119,6 +119,7 @@
<Compile Include="Sync.cs" />
<Compile Include="Traits\Attack\AttackOmni.cs" />
<Compile Include="Traits\CustomSellValue.cs" />
<Compile Include="Traits\Player\SpawnDefaultUnits.cs" />
<Compile Include="Traits\World\BridgeLoadHook.cs" />
<Compile Include="Traits\World\ChoosePaletteOnSelect.cs" />
<Compile Include="Traits\World\Country.cs" />

View File

@@ -0,0 +1,13 @@
namespace OpenRa.Traits
{
class SpawnDefaultUnitsInfo : StatelessTraitInfo<SpawnDefaultUnits> { }
class SpawnDefaultUnits : ISpawnStartingUnits
{
public void SpawnStartingUnits(Player p, int2 sp)
{
p.PlayerActor.World.CreateActor("mcv", sp, p);
}
}
}

View File

@@ -104,4 +104,5 @@ namespace OpenRa.Traits
public interface INotifySelection { void SelectionChanged(); }
public interface ILoadWorldHook { void WorldLoaded(World w); }
public interface ISpawnStartingUnits { void SpawnStartingUnits(Player p, int2 sp); }
}

View File

@@ -9,6 +9,7 @@ Player:
CancelledAudio: cancel1.aud
ClickAudio: button.aud
PlaceBuilding:
SpawnDefaultUnits:
World:
WaterPaletteRotation:

View File

@@ -57,6 +57,7 @@ Player:
TechLevel: 5
GivenAuto: no
OneShot: yes
SpawnDefaultUnits:
World:
WaterPaletteRotation: