readonly most of Player's state; setup for non-index player palettes (neutral)

This commit is contained in:
Chris Forbes
2010-03-17 22:49:55 +13:00
parent acf1a36e89
commit f9c70a2f65
2 changed files with 12 additions and 16 deletions

View File

@@ -32,12 +32,16 @@ namespace OpenRA
public class Player public class Player
{ {
public Actor PlayerActor; public Actor PlayerActor;
public int PaletteIndex;
public int Kills; public int Kills;
public string PlayerName;
public string InternalName; public readonly string Palette;
public CountryInfo Country; public readonly Color Color;
public readonly string PlayerName;
public readonly string InternalName;
public readonly CountryInfo Country;
public readonly int Index; public readonly int Index;
public int Cash = 10000; public int Cash = 10000;
public int Ore = 0; public int Ore = 0;
public int OreCapacity; public int OreCapacity;
@@ -60,16 +64,6 @@ namespace OpenRA
PlayerColors.Add(new Tuple<string, string, Color>(palette, name, c)); PlayerColors.Add(new Tuple<string, string, Color>(palette, name, c));
} }
public Color Color
{
get { return PlayerColors[PaletteIndex].c; }
}
public string Palette
{
get { return PlayerColors[PaletteIndex].a; }
}
public Shroud Shroud; public Shroud Shroud;
public Player( World world, int index, Session.Client client ) public Player( World world, int index, Session.Client client )
@@ -80,7 +74,9 @@ namespace OpenRA
this.Index = index; this.Index = index;
this.InternalName = "Multi{0}".F(index); this.InternalName = "Multi{0}".F(index);
this.PaletteIndex = client != null ? client.PaletteIndex : index; var paletteIndex = client != null ? client.PaletteIndex : index;
this.Palette = PlayerColors[paletteIndex].a;
this.Color = PlayerColors[paletteIndex].c;
this.PlayerName = client != null ? client.Name : "Player {0}".F(index+1); this.PlayerName = client != null ? client.Name : "Player {0}".F(index+1);
this.Country = world.GetCountries() this.Country = world.GetCountries()
.FirstOrDefault( c => client != null && client.Country == c.Name ) .FirstOrDefault( c => client != null && client.Country == c.Name )

View File

@@ -173,7 +173,7 @@ namespace OpenRA.Traits
if ( weapon.RenderAsLaser ) if ( weapon.RenderAsLaser )
{ {
// TODO: This is a hack; should probably use a particular palette index // TODO: This is a hack; should probably use a particular palette index
Color bc = (weapon.UsePlayerColor) ? Player.PlayerColors[self.Owner.PaletteIndex].c : Color.Red; Color bc = (weapon.UsePlayerColor) ? self.Owner.Color : Color.Red;
self.World.Add(new LaserZap(firePos, thisTarget.CenterLocation.ToInt2(), weapon.BeamRadius, bc)); self.World.Add(new LaserZap(firePos, thisTarget.CenterLocation.ToInt2(), weapon.BeamRadius, bc));
} }
if( weapon.RenderAsTesla ) if( weapon.RenderAsTesla )