Allow picking of a random subfaction

This commit is contained in:
abcdefg30
2015-03-06 16:02:40 +01:00
parent 687403ab89
commit 63fe578ba8
19 changed files with 65 additions and 19 deletions

View File

@@ -118,7 +118,7 @@ namespace OpenRA
Color = runtimePlayer.Color, Color = runtimePlayer.Color,
Team = client.Team, Team = client.Team,
SpawnPoint = runtimePlayer.SpawnPoint, SpawnPoint = runtimePlayer.SpawnPoint,
IsRandomFaction = runtimePlayer.Country.Race != client.Country, IsRandomFaction = runtimePlayer.Country.Race != client.Race,
IsRandomSpawnPoint = runtimePlayer.SpawnPoint != client.SpawnPoint IsRandomSpawnPoint = runtimePlayer.SpawnPoint != client.SpawnPoint
}; };

View File

@@ -102,7 +102,7 @@ namespace OpenRA.Network
public int Index; public int Index;
public HSLColor PreferredColor; // Color that the client normally uses from settings.yaml. 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 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 int SpawnPoint;
public string Name; public string Name;
public string IpAddress; public string IpAddress;

View File

@@ -154,7 +154,7 @@ namespace OpenRA.Network
Name = Game.Settings.Player.Name, Name = Game.Settings.Player.Name,
PreferredColor = Game.Settings.Player.Color, PreferredColor = Game.Settings.Player.Color,
Color = Game.Settings.Player.Color, Color = Game.Settings.Player.Color,
Country = "random", Race = "Random",
SpawnPoint = 0, SpawnPoint = 0,
Team = 0, Team = 0,
State = Session.ClientState.Invalid State = Session.ClientState.Invalid

View File

@@ -52,8 +52,20 @@ namespace OpenRA
.WithInterface<CountryInfo>().Where(c => !requireSelectable || c.Selectable) .WithInterface<CountryInfo>().Where(c => !requireSelectable || c.Selectable)
.ToList(); .ToList();
return selectableCountries.FirstOrDefault(c => c.Race == name) var selected = selectableCountries.FirstOrDefault(c => c.Race == name)
?? selectableCountries.Random(world.SharedRandom); ?? 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) public Player(World world, Session.Client client, Session.Slot slot, PlayerReference pr)
@@ -70,7 +82,7 @@ namespace OpenRA
Color = client.Color; Color = client.Color;
PlayerName = client.Name; PlayerName = client.Name;
botType = client.Bot; botType = client.Bot;
Country = ChooseCountry(world, client.Country); Country = ChooseCountry(world, client.Race);
} }
else else
{ {

View File

@@ -64,7 +64,7 @@ namespace OpenRA.Server
else else
c.Color = c.PreferredColor; c.Color = c.PreferredColor;
if (pr.LockRace) if (pr.LockRace)
c.Country = pr.Race; c.Race = pr.Race;
if (pr.LockSpawn) if (pr.LockSpawn)
c.SpawnPoint = pr.Spawn; c.SpawnPoint = pr.Spawn;
if (pr.LockTeam) if (pr.LockTeam)
@@ -289,7 +289,7 @@ namespace OpenRA.Server
Slot = LobbyInfo.FirstEmptySlot(), Slot = LobbyInfo.FirstEmptySlot(),
PreferredColor = handshake.Client.Color, PreferredColor = handshake.Client.Color,
Color = handshake.Client.Color, Color = handshake.Client.Color,
Country = "random", Race = "Random",
SpawnPoint = 0, SpawnPoint = 0,
Team = 0, Team = 0,
State = Session.ClientState.Invalid, State = Session.ClientState.Invalid,

View File

@@ -18,6 +18,9 @@ namespace OpenRA.Traits
[Desc("This is the internal name for owner checks.")] [Desc("This is the internal name for owner checks.")]
public readonly string Race = null; 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.")] [Desc("The side that the country belongs to. For example, England belongs to the 'Allies' side.")]
public readonly string Side = null; public readonly string Side = null;

View File

@@ -32,7 +32,7 @@ namespace OpenRA.Widgets
ClientIndex = client.Index; ClientIndex = client.Index;
PlayerName = client.Name; PlayerName = client.Name;
Team = client.Team; Team = client.Team;
Country = client.Country; Country = client.Race;
SpawnPoint = client.SpawnPoint; SpawnPoint = client.SpawnPoint;
} }

View File

@@ -270,7 +270,7 @@ namespace OpenRA.Mods.Common.Server
Name = botType, Name = botType,
Bot = botType, Bot = botType,
Slot = parts[0], Slot = parts[0],
Country = "random", Race = "Random",
SpawnPoint = 0, SpawnPoint = 0,
Team = 0, Team = 0,
State = Session.ClientState.NotReady, State = Session.ClientState.NotReady,
@@ -738,7 +738,7 @@ namespace OpenRA.Mods.Common.Server
if (server.LobbyInfo.Slots[targetClient.Slot].LockRace) if (server.LobbyInfo.Slots[targetClient.Slot].LockRace)
return true; return true;
targetClient.Country = parts[1]; targetClient.Race = parts[1];
server.SyncLobbyClients(); server.SyncLobbyClients();
return true; return true;
} }

View File

@@ -144,7 +144,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic
colorPreview = lobby.Get<ColorPreviewManagerWidget>("COLOR_MANAGER"); colorPreview = lobby.Get<ColorPreviewManagerWidget>("COLOR_MANAGER");
colorPreview.Color = Game.Settings.Player.Color; colorPreview.Color = Game.Settings.Player.Color;
countries.Add("random", new LobbyCountry { Name = "Any" });
foreach (var c in modRules.Actors["world"].Traits.WithInterface<CountryInfo>().Where(c => c.Selectable)) foreach (var c in modRules.Actors["world"].Traits.WithInterface<CountryInfo>().Where(c => c.Selectable))
countries.Add(c.Race, new LobbyCountry { Name = c.Name, Side = c.Side, Description = c.Description }); countries.Add(c.Race, new LobbyCountry { Name = c.Name, Side = c.Side, Description = c.Description });

View File

@@ -110,7 +110,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
Func<string, ScrollItemWidget, ScrollItemWidget> setupItem = (race, itemTemplate) => Func<string, ScrollItemWidget, ScrollItemWidget> setupItem = (race, itemTemplate) =>
{ {
var item = ScrollItemWidget.Setup(itemTemplate, var item = ScrollItemWidget.Setup(itemTemplate,
() => client.Country == race, () => client.Race == race,
() => orderManager.IssueOrder(Order.Command("race {0} {1}".F(client.Index, race)))); () => orderManager.IssueOrder(Order.Command("race {0} {1}".F(client.Index, race))));
var country = countries[race]; var country = countries[race];
item.Get<LabelWidget>("LABEL").GetText = () => country.Name; item.Get<LabelWidget>("LABEL").GetText = () => country.Name;
@@ -398,7 +398,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
var dropdown = parent.Get<DropDownButtonWidget>("FACTION"); var dropdown = parent.Get<DropDownButtonWidget>("FACTION");
dropdown.IsDisabled = () => s.LockRace || orderManager.LocalClient.IsReady; dropdown.IsDisabled = () => s.LockRace || orderManager.LocalClient.IsReady;
dropdown.OnMouseDown = _ => ShowRaceDropDown(dropdown, c, orderManager, countries); dropdown.OnMouseDown = _ => ShowRaceDropDown(dropdown, c, orderManager, countries);
var factionDescription = countries[c.Country].Description; var factionDescription = countries[c.Race].Description;
dropdown.GetTooltipText = () => factionDescription; dropdown.GetTooltipText = () => factionDescription;
SetupFactionWidget(dropdown, s, c, countries); SetupFactionWidget(dropdown, s, c, countries);
} }
@@ -407,9 +407,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
Dictionary<string, LobbyCountry> countries) Dictionary<string, LobbyCountry> countries)
{ {
var factionName = parent.Get<LabelWidget>("FACTIONNAME"); var factionName = parent.Get<LabelWidget>("FACTIONNAME");
factionName.GetText = () => countries[c.Country].Name; factionName.GetText = () => countries[c.Race].Name;
var factionFlag = parent.Get<ImageWidget>("FACTIONFLAG"); var factionFlag = parent.Get<ImageWidget>("FACTIONFLAG");
factionFlag.GetImageName = () => c.Country; factionFlag.GetImageName = () => c.Race;
factionFlag.GetImageCollection = () => "flags"; factionFlag.GetImageCollection = () => "flags";
} }

View File

@@ -461,7 +461,7 @@ scrollbar: chrome.png
flags: chrome.png flags: chrome.png
nod: 352,0,32,16 nod: 352,0,32,16
gdi: 352,16,32,16 gdi: 352,16,32,16
random: 352,32,32,16 Random: 352,32,32,16
strategic: strategic.png strategic: strategic.png
unowned: 0,0,32,32 unowned: 0,0,32,32

View File

@@ -81,6 +81,10 @@ World:
FogVariants: typea, typeb, typec, typed FogVariants: typea, typeb, typec, typed
OverrideFullShroud: full OverrideFullShroud: full
OverrideFullFog: full OverrideFullFog: full
Country@Random:
Name: Any
Race: Random
RandomRaceMembers: gdi, nod
Country@gdi: Country@gdi:
Name: GDI Name: GDI
Race: gdi Race: gdi

View File

@@ -91,7 +91,7 @@ flags: buttons.png
atreides: 0,114,22,21 atreides: 0,114,22,21
harkonnen: 22,114,23,21 harkonnen: 22,114,23,21
ordos: 45,114,22,21 ordos: 45,114,22,21
random: 67,114,23,21 Random: 67,114,23,21
spectator: 67,114,23,21 spectator: 67,114,23,21
# Used for the menu # Used for the menu

View File

@@ -94,6 +94,10 @@ World:
OverrideFullShroud: full OverrideFullShroud: full
OverrideFullFog: full OverrideFullFog: full
ShroudBlend: Multiply ShroudBlend: Multiply
Country@Random:
Name: Any
Race: Random
RandomRaceMembers: atreides, harkonnen, ordos
Country@Atreides: Country@Atreides:
Name: Atreides Name: Atreides
Race: atreides Race: atreides

View File

@@ -471,7 +471,9 @@ strategic: strategic.png
flags: buttons.png flags: buttons.png
soviet: 0,112,30,15 soviet: 0,112,30,15
allies: 30,112,30,15 allies: 30,112,30,15
random: 60,112,30,15 Random: 60,112,30,15
RandomAllies: 30,172,30,15
RandomSoviet: 0,172,30,15
spectator: 60,112,30,15 spectator: 60,112,30,15
russia: 0,127,30,15 russia: 0,127,30,15

View File

@@ -126,6 +126,24 @@ World:
Race: ukraine Race: ukraine
Side: Soviet Side: Soviet
Description: Ukraine: Demolitions\nSpecial Ability: Parabombs\nSpecial Unit: Demolition Truck Description: Ukraine: Demolitions\nSpecial Ability: Parabombs\nSpecial Unit: Demolition Truck
Country@random:
Name: Any
Race: Random
RandomRaceMembers: RandomAllies, RandomSoviet
Side: Random
Description: A random country.
Country@randomallies:
Name: Allied
Race: RandomAllies
RandomRaceMembers: allies, england, france, germany
Side: Random
Description: A random Allied country.
Country@randomsoviet:
Name: Soviet
Race: RandomSoviet
RandomRaceMembers: soviet, russia, ukraine
Side: Random
Description: A random Soviet country.
DomainIndex: DomainIndex:
SmudgeLayer@SCORCH: SmudgeLayer@SCORCH:
Type: Scorch Type: Scorch

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 257 KiB

View File

@@ -453,7 +453,7 @@ strategic: strategic.png
flags: buttons.png flags: buttons.png
gdi: 30,112,30,15 gdi: 30,112,30,15
nod: 0,112,30,15 nod: 0,112,30,15
random: 60,112,30,15 Random: 60,112,30,15
spectator: 60,112,30,15 spectator: 60,112,30,15
music: musicplayer.png music: musicplayer.png

View File

@@ -79,6 +79,10 @@ World:
VoxelNormalsPalette@normals: VoxelNormalsPalette@normals:
Name: normals Name: normals
Type: TiberianSun Type: TiberianSun
Country@Random:
Name: Any
Race: Random
RandomRaceMembers: gdi, nod
Country@0: Country@0:
Name: GDI Name: GDI
Race: gdi Race: gdi