This commit is contained in:
alzeih
2011-03-13 10:42:23 +13:00
committed by Chris Forbes
parent 22aa1308ce
commit b5efc97996
2 changed files with 24 additions and 31 deletions

View File

@@ -42,43 +42,36 @@ namespace OpenRA
public Shroud Shroud { get { return World.LocalShroud; }}
public World World { get; private set; }
public Player(World world, PlayerReference pr, int index)
{
World = world;
Index = index;
Palette = "player" + index;
ColorRamp = pr.ColorRamp;
ClientIndex = 0; /* it's a map player, "owned" by host */
PlayerName = InternalName = pr.Name;
NonCombatant = pr.NonCombatant;
Country = world.GetCountries()
.FirstOrDefault(c => pr.Race == c.Race)
?? world.GetCountries().Random(world.SharedRandom);
PlayerRef = pr;
PlayerActor = world.CreateActor("Player", new TypeDictionary { new OwnerInit(this) });
}
public Player(World world, Session.Client client, PlayerReference pr, int index)
{
World = world;
Index = index;
Palette = "player" + index;
ColorRamp = client.ColorRamp;
PlayerName = client.Name;
InternalName = pr.Name;
Country = world.GetCountries()
.FirstOrDefault(c => client != null && client.Country == c.Race)
?? world.GetCountries().Random(world.SharedRandom);
ClientIndex = client.Index;
PlayerRef = pr;
if (client != null)
{
ClientIndex = client.Index;
ColorRamp = client.ColorRamp;
PlayerName = client.Name;
Country = world.GetCountries()
.FirstOrDefault(c => client.Country == c.Race)
?? world.GetCountries().Random(world.SharedRandom);
}
else
{
ClientIndex = 0; /* it's a map player, "owned" by host */
ColorRamp = pr.ColorRamp;
PlayerName = pr.Name;
NonCombatant = pr.NonCombatant;
Country = world.GetCountries()
.FirstOrDefault(c => pr.Race == c.Race)
?? world.GetCountries().Random(world.SharedRandom);
}
PlayerActor = world.CreateActor("Player", new TypeDictionary { new OwnerInit(this) });
}

View File

@@ -27,7 +27,7 @@ namespace OpenRA.Mods.RA
// create the unplayable map players -- neutral, shellmap, scripted, etc.
foreach (var kv in w.Map.Players.Where(p => !p.Value.Playable))
{
var player = new Player(w, kv.Value, mapPlayerIndex--);
var player = new Player(w, null, kv.Value, mapPlayerIndex--);
w.AddPlayer(player);
if (kv.Value.OwnsWorld)
w.WorldActor.Owner = player;
@@ -55,7 +55,7 @@ namespace OpenRA.Mods.RA
/* todo: pick a random name from the pool */
var player = new Player(w, w.Map.Players[slot.MapPlayer], playerIndex++);
var player = new Player(w, null, w.Map.Players[slot.MapPlayer], playerIndex++);
w.AddPlayer(player);
/* activate the bot option that's selected! */