add CountryInfo.Selectable
This commit is contained in:
@@ -410,7 +410,7 @@ namespace OpenRA
|
||||
Players.Clear();
|
||||
|
||||
var firstRace = OpenRA.Rules.Info["world"].Traits
|
||||
.WithInterface<CountryInfo>().First().Race;
|
||||
.WithInterface<CountryInfo>().First(c => c.Selectable).Race;
|
||||
|
||||
Players.Add("Neutral", new PlayerReference
|
||||
{
|
||||
|
||||
@@ -39,6 +39,16 @@ namespace OpenRA
|
||||
public Shroud Shroud { get { return World.LocalShroud; }}
|
||||
public World World { get; private set; }
|
||||
|
||||
static CountryInfo ChooseCountry(World world, string name)
|
||||
{
|
||||
var selectableCountries = Rules.Info["world"].Traits
|
||||
.WithInterface<CountryInfo>().Where( c => c.Selectable )
|
||||
.ToArray();
|
||||
|
||||
return selectableCountries.FirstOrDefault(c => c.Race == name)
|
||||
?? selectableCountries.Random(world.SharedRandom);
|
||||
}
|
||||
|
||||
public Player(World world, Session.Client client, Session.Slot slot, PlayerReference pr)
|
||||
{
|
||||
World = world;
|
||||
@@ -53,10 +63,7 @@ namespace OpenRA
|
||||
ColorRamp = client.ColorRamp;
|
||||
PlayerName = client.Name;
|
||||
botType = client.Bot;
|
||||
|
||||
Country = world.GetCountries()
|
||||
.FirstOrDefault(c => client.Country == c.Race)
|
||||
?? world.GetCountries().Random(world.SharedRandom);
|
||||
Country = ChooseCountry(world, client.Country);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -66,10 +73,7 @@ namespace OpenRA
|
||||
PlayerName = pr.Name;
|
||||
NonCombatant = pr.NonCombatant;
|
||||
botType = pr.Bot;
|
||||
|
||||
Country = world.GetCountries()
|
||||
.FirstOrDefault(c => pr.Race == c.Race)
|
||||
?? world.GetCountries().Random(world.SharedRandom);
|
||||
Country = ChooseCountry(world, pr.Race);
|
||||
}
|
||||
PlayerActor = world.CreateActor("Player", new TypeDictionary { new OwnerInit(this) });
|
||||
|
||||
|
||||
@@ -14,8 +14,7 @@ namespace OpenRA.Traits
|
||||
{
|
||||
public readonly string Name = null;
|
||||
public readonly string Race = null;
|
||||
|
||||
/* todo: icon,... */
|
||||
public readonly bool Selectable = true;
|
||||
}
|
||||
|
||||
public class Country { /* we're only interested in the Info */ }
|
||||
|
||||
@@ -102,11 +102,6 @@ namespace OpenRA
|
||||
r.Next(w.Map.Bounds.Top, w.Map.Bounds.Bottom));
|
||||
}
|
||||
|
||||
public static IEnumerable<CountryInfo> GetCountries(this World w)
|
||||
{
|
||||
return w.WorldActor.Info.Traits.WithInterface<CountryInfo>();
|
||||
}
|
||||
|
||||
public static float Gauss1D(this Thirdparty.Random r, int samples)
|
||||
{
|
||||
return Graphics.Util.MakeArray(samples, _ => (float)r.NextDouble() * 2 - 1f)
|
||||
|
||||
@@ -153,6 +153,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
||||
};
|
||||
|
||||
CountryNames = Rules.Info["world"].Traits.WithInterface<CountryInfo>()
|
||||
.Where(c => c.Selectable)
|
||||
.ToDictionary(a => a.Race, a => a.Name);
|
||||
CountryNames.Add("random", "Any");
|
||||
|
||||
|
||||
@@ -104,6 +104,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
};
|
||||
|
||||
CountryNames = Rules.Info["world"].Traits.WithInterface<CountryInfo>()
|
||||
.Where(c => c.Selectable)
|
||||
.ToDictionary(a => a.Race, a => a.Name);
|
||||
CountryNames.Add("random", "Random");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user