Allow picking of a random subfaction
This commit is contained in:
@@ -118,7 +118,7 @@ namespace OpenRA
|
||||
Color = runtimePlayer.Color,
|
||||
Team = client.Team,
|
||||
SpawnPoint = runtimePlayer.SpawnPoint,
|
||||
IsRandomFaction = runtimePlayer.Country.Race != client.Country,
|
||||
IsRandomFaction = runtimePlayer.Country.Race != client.Race,
|
||||
IsRandomSpawnPoint = runtimePlayer.SpawnPoint != client.SpawnPoint
|
||||
};
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ namespace OpenRA.Network
|
||||
public int Index;
|
||||
public HSLColor PreferredColor; // Color that the client normally uses from settings.yaml.
|
||||
public HSLColor Color; // Actual color that the client is using. Usually the same as PreferredColor but can be different on maps with locked colors.
|
||||
public string Country;
|
||||
public string Race;
|
||||
public int SpawnPoint;
|
||||
public string Name;
|
||||
public string IpAddress;
|
||||
|
||||
@@ -154,7 +154,7 @@ namespace OpenRA.Network
|
||||
Name = Game.Settings.Player.Name,
|
||||
PreferredColor = Game.Settings.Player.Color,
|
||||
Color = Game.Settings.Player.Color,
|
||||
Country = "random",
|
||||
Race = "Random",
|
||||
SpawnPoint = 0,
|
||||
Team = 0,
|
||||
State = Session.ClientState.Invalid
|
||||
|
||||
@@ -52,8 +52,20 @@ namespace OpenRA
|
||||
.WithInterface<CountryInfo>().Where(c => !requireSelectable || c.Selectable)
|
||||
.ToList();
|
||||
|
||||
return selectableCountries.FirstOrDefault(c => c.Race == name)
|
||||
var selected = selectableCountries.FirstOrDefault(c => c.Race == name)
|
||||
?? selectableCountries.Random(world.SharedRandom);
|
||||
|
||||
// Don't loop infinite
|
||||
for (var i = 0; i <= 10 && selected.RandomRaceMembers.Any(); i++)
|
||||
{
|
||||
var race = selected.RandomRaceMembers.Random(world.SharedRandom);
|
||||
selected = selectableCountries.FirstOrDefault(c => c.Race == race);
|
||||
|
||||
if (selected == null)
|
||||
throw new YamlException("Unknown race: {0}".F(race));
|
||||
}
|
||||
|
||||
return selected;
|
||||
}
|
||||
|
||||
public Player(World world, Session.Client client, Session.Slot slot, PlayerReference pr)
|
||||
@@ -70,7 +82,7 @@ namespace OpenRA
|
||||
Color = client.Color;
|
||||
PlayerName = client.Name;
|
||||
botType = client.Bot;
|
||||
Country = ChooseCountry(world, client.Country);
|
||||
Country = ChooseCountry(world, client.Race);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace OpenRA.Server
|
||||
else
|
||||
c.Color = c.PreferredColor;
|
||||
if (pr.LockRace)
|
||||
c.Country = pr.Race;
|
||||
c.Race = pr.Race;
|
||||
if (pr.LockSpawn)
|
||||
c.SpawnPoint = pr.Spawn;
|
||||
if (pr.LockTeam)
|
||||
@@ -289,7 +289,7 @@ namespace OpenRA.Server
|
||||
Slot = LobbyInfo.FirstEmptySlot(),
|
||||
PreferredColor = handshake.Client.Color,
|
||||
Color = handshake.Client.Color,
|
||||
Country = "random",
|
||||
Race = "Random",
|
||||
SpawnPoint = 0,
|
||||
Team = 0,
|
||||
State = Session.ClientState.Invalid,
|
||||
|
||||
@@ -18,6 +18,9 @@ namespace OpenRA.Traits
|
||||
[Desc("This is the internal name for owner checks.")]
|
||||
public readonly string Race = null;
|
||||
|
||||
[Desc("Pick a random race as the player's race out of this list.")]
|
||||
public readonly string[] RandomRaceMembers = { };
|
||||
|
||||
[Desc("The side that the country belongs to. For example, England belongs to the 'Allies' side.")]
|
||||
public readonly string Side = null;
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace OpenRA.Widgets
|
||||
ClientIndex = client.Index;
|
||||
PlayerName = client.Name;
|
||||
Team = client.Team;
|
||||
Country = client.Country;
|
||||
Country = client.Race;
|
||||
SpawnPoint = client.SpawnPoint;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user