Player has Country now, not Race

This commit is contained in:
Chris Forbes
2010-02-10 15:19:26 +13:00
parent e4b73b3924
commit ea3b674d9a
9 changed files with 34 additions and 23 deletions

View File

@@ -108,7 +108,7 @@ namespace OpenRA.Server
Index = newConn.PlayerIndex,
PaletteIndex = ChooseFreePalette(),
Name = "Player {0}".F(1 + newConn.PlayerIndex),
Race = "allies", /* hack */
Country = "allies", /* hack */
State = Session.ClientState.NotReady
});
@@ -249,7 +249,7 @@ namespace OpenRA.Server
return true;
}
GetClient(conn).Race = s;
GetClient(conn).Country = s;
SyncLobbyInfo();
return true;
}},

View File

@@ -21,7 +21,7 @@ namespace OpenRa.FileFormats
{
public int Index;
public int PaletteIndex;
public string Race;
public string Country;
public int SpawnPoint;
public string Name;
public ClientState State;

View File

@@ -153,10 +153,10 @@ namespace OpenRa
{
DrawDownloadBar();
chromeCollection = "chrome-" + world.LocalPlayer.Race;
radarCollection = "radar-" + world.LocalPlayer.Race;
paletteCollection = "palette-" + world.LocalPlayer.Race;
digitCollection = "digits-" + world.LocalPlayer.Race;
chromeCollection = "chrome-" + world.LocalPlayer.Country.Race;
radarCollection = "radar-" + world.LocalPlayer.Country.Race;
paletteCollection = "palette-" + world.LocalPlayer.Country.Race;
digitCollection = "digits-" + world.LocalPlayer.Country.Race;
buttons.Clear();
@@ -362,9 +362,13 @@ namespace OpenRa
void CycleRace(bool left)
{
// hack
var newRace = Game.world.LocalPlayer.Race == "allies" ? "soviet" : "allies";
Game.IssueOrder(Order.Chat("/race " + newRace));
var countries = Game.world.GetCountries();
var nextCountry = countries.Concat(countries)
.SkipWhile(c => c != Game.world.LocalPlayer.Country)
.Skip(1)
.First();
Game.IssueOrder(Order.Chat("/race " + nextCountry));
}
void CycleReady(bool left)
@@ -467,7 +471,7 @@ namespace OpenRa
paletteRect.Bottom+Game.viewport.Location.Y - 5),
Player.PlayerColors[client.PaletteIndex].c);
lineRenderer.Flush();
renderer.DrawText(client.Race, new int2(r.Left + 220, y), Color.White);
renderer.DrawText(client.Country, new int2(r.Left + 220, y), Color.White);
renderer.DrawText(client.State.ToString(), new int2(r.Left + 290, y), Color.White);
renderer.DrawText((client.SpawnPoint == 0)? "-" : client.SpawnPoint.ToString(), new int2(r.Left + 410, y), Color.White);
y += 30;
@@ -569,7 +573,7 @@ namespace OpenRa
string[] tabKeys = { "normal", "ready", "selected" };
var producing = queue.CurrentItem(groupName);
var index = q.Key == currentTab ? 2 : (producing != null && producing.Done) ? 1 : 0;
var race = world.LocalPlayer.Race;
var race = world.LocalPlayer.Country.Race;
rgbaRenderer.DrawSprite(ChromeProvider.GetImage(renderer,"tabs-"+tabKeys[index], race+"-"+q.Key), new float2(x, y), "chrome");
buttons.Add(Pair.New(new RectangleF(x, y, tabWidth, tabHeight),
@@ -850,7 +854,7 @@ namespace OpenRa
var allBuildables = Rules.TechTree.AllBuildables(world.LocalPlayer, queueName)
.Where(a => a.Traits.Contains<BuildableInfo>())
.Where(a => a.Traits.Get<BuildableInfo>().Owner.Contains(world.LocalPlayer.Race))
.Where(a => a.Traits.Get<BuildableInfo>().Owner.Contains(world.LocalPlayer.Country.Race))
.OrderBy(a => a.Traits.Get<BuildableInfo>().TechLevel);
var queue = world.LocalPlayer.PlayerActor.traits.Get<Traits.ProductionQueue>();

View File

@@ -39,7 +39,7 @@ namespace OpenRa.GameRules
var bi = info.Traits.GetOrDefault<BuildableInfo>();
if( bi == null ) return false;
if( !bi.Owner.Contains( player.Race ) )
if( !bi.Owner.Contains( player.Country.Race ) )
return false;
foreach( var p in bi.Prerequisites )

View File

@@ -16,7 +16,7 @@ namespace OpenRa
public int Kills;
public string PlayerName;
public string InternalName;
public string Race;
public CountryInfo Country;
public readonly int Index;
public int Cash = 10000;
public int Ore = 0;
@@ -62,7 +62,8 @@ namespace OpenRa
this.PaletteIndex = client != null ? client.PaletteIndex : index;
this.PlayerName = client != null ? client.Name : "Player {0}".F(index+1);
this.Race = client != null ? client.Race : "allies";
this.Country = world.GetCountries().FirstOrDefault( c => client != null && client.Country == c.Name )
?? world.GetCountries().First();
}
void UpdatePower()
@@ -177,10 +178,10 @@ namespace OpenRa
PlayerName = client.Name;
}
if (Race != client.Race)
if (Country.Name != client.Country)
{
Game.chat.AddLine(this, "is now playing {0}".F(client.Race));
Race = client.Race;
Game.chat.AddLine(this, "is now playing {0}".F(client.Country));
Country = PlayerActor.World.GetCountries().First(c => c.Name == client.Country);
}
if (PaletteIndex != client.PaletteIndex)

View File

@@ -109,7 +109,8 @@ namespace OpenRa
return;
}
var variants = (voicedUnit.Owner.Race == "allies")
// todo: fix this
var variants = (voicedUnit.Owner.Country.Race == "allies")
? vi.AlliedVariants : vi.SovietVariants;
var variant = variants[voicedUnit.ActorID % variants.Length];

View File

@@ -48,7 +48,7 @@ namespace OpenRa.Traits
var buildings = Rules.TechTree.GatherBuildings(self.Owner);
var effectivePrereq = Info.Prerequisites
.Select(a => a.ToLowerInvariant())
.Where(a => Rules.Info[a].Traits.Get<BuildableInfo>().Owner.Contains(self.Owner.Race));
.Where(a => Rules.Info[a].Traits.Get<BuildableInfo>().Owner.Contains(self.Owner.Country.Race));
if (Info.GivenAuto)
{
@@ -80,7 +80,7 @@ namespace OpenRa.Traits
var buildings = Rules.TechTree.GatherBuildings(Owner);
var effectivePrereq = Info.Prerequisites
.Select(a => a.ToLowerInvariant())
.Where(a => Rules.Info[a].Traits.Get<BuildableInfo>().Owner.Contains(Owner.Race));
.Where(a => Rules.Info[a].Traits.Get<BuildableInfo>().Owner.Contains(Owner.Country.Race));
if (Info.Prerequisites.Count() == 0)
return Owner.GetPowerState() == PowerState.Normal;

View File

@@ -5,7 +5,7 @@ using System.Text;
namespace OpenRa.Traits
{
class CountryInfo : ITraitInfo
public class CountryInfo : ITraitInfo
{
public readonly string Name = null;
public readonly string Race = null;

View File

@@ -186,5 +186,10 @@ namespace OpenRa
!isX ? Game.SharedRandom.Next(w.Map.YOffset, w.Map.YOffset + w.Map.Height)
: (edge ? w.Map.YOffset : w.Map.YOffset + w.Map.Height));
}
public static IEnumerable<CountryInfo> GetCountries(this World w)
{
return w.WorldActor.Info.Traits.WithInterface<CountryInfo>();
}
}
}