Merge pull request #8661 from penev92/bleed_renameCountry

Rename the Country trait to Faction
This commit is contained in:
Oliver Brakmann
2015-07-14 21:05:52 +02:00
59 changed files with 187 additions and 168 deletions

View File

@@ -114,11 +114,11 @@ namespace OpenRA
IsHuman = !runtimePlayer.IsBot,
IsBot = runtimePlayer.IsBot,
FactionName = runtimePlayer.Country.Name,
FactionId = runtimePlayer.Country.Race,
FactionId = runtimePlayer.Country.InternalName,
Color = runtimePlayer.Color,
Team = client.Team,
SpawnPoint = runtimePlayer.SpawnPoint,
IsRandomFaction = runtimePlayer.Country.Race != client.Race,
IsRandomFaction = runtimePlayer.Country.InternalName != client.Race,
IsRandomSpawnPoint = runtimePlayer.SpawnPoint != client.SpawnPoint
};

View File

@@ -29,7 +29,7 @@ namespace OpenRA
public MapPlayers(Ruleset rules, int playerCount)
{
var firstRace = rules.Actors["world"].Traits
.WithInterface<CountryInfo>().First(c => c.Selectable).Race;
.WithInterface<FactionInfo>().First(f => f.Selectable).InternalName;
Players = new Dictionary<string, PlayerReference>
{

View File

@@ -181,8 +181,8 @@
<Compile Include="Traits\TraitsInterfaces.cs" />
<Compile Include="Traits\Util.cs" />
<Compile Include="Traits\ValidateOrder.cs" />
<Compile Include="Traits\World\Country.cs" />
<Compile Include="Traits\World\MusicPlaylist.cs" />
<Compile Include="Traits\World\Faction.cs" />
<Compile Include="Traits\World\ResourceType.cs" />
<Compile Include="Traits\World\ScreenShaker.cs" />
<Compile Include="Traits\World\Shroud.cs" />

View File

@@ -31,14 +31,14 @@ namespace OpenRA
public readonly string PlayerName;
public readonly string InternalName;
public readonly CountryInfo Country;
public readonly FactionInfo Country;
public readonly bool NonCombatant = false;
public readonly bool Playable = true;
public readonly int ClientIndex;
public readonly PlayerReference PlayerReference;
// The country (including Random, etc) that was selected in the lobby
public readonly CountryInfo DisplayCountry;
public readonly FactionInfo DisplayCountry;
public WinState WinState = WinState.Undefined;
public bool IsBot;
@@ -51,20 +51,20 @@ namespace OpenRA
readonly IFogVisibilityModifier[] fogVisibilities;
CountryInfo ChooseCountry(World world, string name, bool requireSelectable = true)
FactionInfo ChooseCountry(World world, string name, bool requireSelectable = true)
{
var selectableCountries = world.Map.Rules.Actors["world"].Traits
.WithInterface<CountryInfo>().Where(c => !requireSelectable || c.Selectable)
.WithInterface<FactionInfo>().Where(f => !requireSelectable || f.Selectable)
.ToList();
var selected = selectableCountries.FirstOrDefault(c => c.Race == name)
var selected = selectableCountries.FirstOrDefault(f => f.InternalName == name)
?? selectableCountries.Random(world.SharedRandom);
// Don't loop infinite
for (var i = 0; i <= 10 && selected.RandomRaceMembers.Any(); i++)
for (var i = 0; i <= 10 && selected.RandomFactionMembers.Any(); i++)
{
var race = selected.RandomRaceMembers.Random(world.SharedRandom);
selected = selectableCountries.FirstOrDefault(c => c.Race == race);
var race = selected.RandomFactionMembers.Random(world.SharedRandom);
selected = selectableCountries.FirstOrDefault(f => f.InternalName == race);
if (selected == null)
throw new YamlException("Unknown race: {0}".F(race));
@@ -73,12 +73,12 @@ namespace OpenRA
return selected;
}
CountryInfo ChooseDisplayCountry(World world, string race)
FactionInfo ChooseDisplayCountry(World world, string race)
{
var countries = world.Map.Rules.Actors["world"].Traits
.WithInterface<CountryInfo>();
.WithInterface<FactionInfo>().ToArray();
return countries.FirstOrDefault(c => c.Race == race) ?? countries.First();
return countries.FirstOrDefault(f => f.InternalName == race) ?? countries.First();
}
public Player(World world, Session.Client client, Session.Slot slot, PlayerReference pr)

View File

@@ -54,7 +54,7 @@ namespace OpenRA.Traits
{
this.info = info;
var self = init.Self;
var race = init.Contains<RaceInit>() ? init.Get<RaceInit, string>() : self.Owner.Country.Race;
var race = init.Contains<RaceInit>() ? init.Get<RaceInit, string>() : self.Owner.Country.InternalName;
quantizedFacings = Exts.Lazy(() =>
{

View File

@@ -145,7 +145,7 @@ namespace OpenRA.Traits
{
if (Resources > 0.8 * ResourceCapacity)
{
Sound.PlayNotification(self.World.Map.Rules, owner, "Speech", "SilosNeeded", owner.Country.Race);
Sound.PlayNotification(self.World.Map.Rules, owner, "Speech", "SilosNeeded", owner.Country.InternalName);
AlertSilo = true;
}
else
@@ -187,14 +187,14 @@ namespace OpenRA.Traits
public void PlayCashTickUp(Actor self)
{
if (Game.Settings.Sound.CashTicks)
Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Sounds", "CashTickUp", self.Owner.Country.Race);
Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Sounds", "CashTickUp", self.Owner.Country.InternalName);
}
public void PlayCashTickDown(Actor self)
{
if (Game.Settings.Sound.CashTicks && nextCashTickTime == 0)
{
Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Sounds", "CashTickDown", self.Owner.Country.Race);
Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Sounds", "CashTickDown", self.Owner.Country.InternalName);
nextCashTickTime = 2;
}
}

View File

@@ -11,18 +11,18 @@
namespace OpenRA.Traits
{
[Desc("Attach this to the `World` actor.")]
public class CountryInfo : TraitInfo<Country>
public class FactionInfo : TraitInfo<Faction>
{
[Desc("This is the name exposed to the players.")]
public readonly string Name = null;
[Desc("This is the internal name for owner checks.")]
public readonly string Race = null;
public readonly string InternalName = null;
[Desc("Pick a random race as the player's race out of this list.")]
public readonly string[] RandomRaceMembers = { };
[Desc("Pick a random faction as the player's facton out of this list.")]
public readonly string[] RandomFactionMembers = { };
[Desc("The side that the country belongs to. For example, England belongs to the 'Allies' side.")]
[Desc("The side that the faction belongs to. For example, England belongs to the 'Allies' side.")]
public readonly string Side = null;
[Translate]
@@ -31,5 +31,5 @@ namespace OpenRA.Traits
public readonly bool Selectable = true;
}
public class Country { /* we're only interested in the Info */ }
public class Faction { /* we're only interested in the Info */ }
}

View File

@@ -27,7 +27,7 @@ namespace OpenRA
if (string.IsNullOrEmpty(voiced.VoiceSet))
return;
voiced.PlayVoice(self, phrase, self.Owner.Country.Race);
voiced.PlayVoice(self, phrase, self.Owner.Country.InternalName);
}
}
@@ -41,7 +41,7 @@ namespace OpenRA
if (string.IsNullOrEmpty(voiced.VoiceSet))
return;
voiced.PlayVoiceLocal(self, phrase, self.Owner.Country.Race, volume);
voiced.PlayVoiceLocal(self, phrase, self.Owner.Country.InternalName, volume);
}
}
@@ -66,7 +66,7 @@ namespace OpenRA
foreach (var v in orderSubject.TraitsImplementing<IOrderVoice>())
{
if (voice.PlayVoice(orderSubject, v.VoicePhraseForOrder(orderSubject, o),
orderSubject.Owner.Country.Race))
orderSubject.Owner.Country.InternalName))
return;
}
}

View File

@@ -19,7 +19,7 @@ namespace OpenRA.Widgets
{
public static Sprite GetChromeImage(World world, string name)
{
return ChromeProvider.GetImage("chrome-" + world.LocalPlayer.Country.Race, name);
return ChromeProvider.GetImage("chrome-" + world.LocalPlayer.Country.InternalName, name);
}
public static void DrawRGBA(Sprite s, float2 pos)