Merge pull request #9038 from penev92/bleed_rename

Some more renaming from "race" to "faction"
This commit is contained in:
Matthias Mailänder
2015-08-13 21:13:31 +02:00
11 changed files with 79 additions and 55 deletions

View File

@@ -24,9 +24,9 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Be sure to use lowercase. Default value is \"e1\".")]
public readonly string[] ActorTypes = { "e1" };
[Desc("Spawns actors only if the selling player's race is in this list." +
"Leave empty to allow all races by default.")]
public readonly string[] Races = { };
[Desc("Spawns actors only if the selling player's faction is in this list." +
"Leave empty to allow all factions by default.")]
public readonly string[] Factions = { };
public object Create(ActorInitializer init) { return new EmitInfantryOnSell(init.Self, this); }
}
@@ -34,20 +34,20 @@ namespace OpenRA.Mods.Common.Traits
public class EmitInfantryOnSell : INotifySold
{
readonly EmitInfantryOnSellInfo info;
readonly bool correctRace = false;
readonly bool correctFaction;
public EmitInfantryOnSell(Actor self, EmitInfantryOnSellInfo info)
{
this.info = info;
var raceList = info.Races;
correctRace = raceList.Length == 0 || raceList.Contains(self.Owner.Faction.InternalName);
var factionsList = info.Factions;
correctFaction = factionsList.Length == 0 || factionsList.Contains(self.Owner.Faction.InternalName);
}
public void Selling(Actor self) { }
void Emit(Actor self)
{
if (!correctRace)
if (!correctFaction)
return;
var csv = self.Info.Traits.GetOrDefault<CustomSellValueInfo>();

View File

@@ -27,8 +27,8 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Group queues from separate buildings together into the same tab.")]
public readonly string Group = null;
[Desc("Only enable this queue for certain factions")]
public readonly string[] Race = { };
[Desc("Only enable this queue for certain factions.")]
public readonly string[] Factions = { };
[Desc("Should the prerequisite remain enabled if the owner changes?")]
public readonly bool Sticky = true;
@@ -87,7 +87,7 @@ namespace OpenRA.Mods.Common.Traits
[Sync] public bool CurrentDone { get { return QueueLength != 0 && queue[0].Done; } }
[Sync] public bool Enabled { get; private set; }
public string Race { get; private set; }
public string Faction { get; private set; }
public ProductionQueue(ActorInitializer init, Actor playerActor, ProductionQueueInfo info)
{
@@ -97,8 +97,8 @@ namespace OpenRA.Mods.Common.Traits
playerPower = playerActor.Trait<PowerManager>();
developerMode = playerActor.Trait<DeveloperMode>();
Race = init.Contains<FactionInit>() ? init.Get<FactionInit, string>() : self.Owner.Faction.InternalName;
Enabled = !info.Race.Any() || info.Race.Contains(Race);
Faction = init.Contains<FactionInit>() ? init.Get<FactionInit, string>() : self.Owner.Faction.InternalName;
Enabled = !info.Factions.Any() || info.Factions.Contains(Faction);
CacheProduceables(playerActor);
}
@@ -123,8 +123,8 @@ namespace OpenRA.Mods.Common.Traits
if (!Info.Sticky)
{
Race = self.Owner.Faction.InternalName;
Enabled = !Info.Race.Any() || Info.Race.Contains(Race);
Faction = self.Owner.Faction.InternalName;
Enabled = !Info.Factions.Any() || Info.Factions.Contains(Faction);
}
// Regenerate the produceables and tech tree state
@@ -371,7 +371,7 @@ namespace OpenRA.Mods.Common.Traits
}
var sp = self.TraitsImplementing<Production>().FirstOrDefault(p => p.Info.Produces.Contains(Info.Type));
if (sp != null && !self.IsDisabled() && sp.Produce(self, self.World.Map.Rules.Actors[name], Race))
if (sp != null && !self.IsDisabled() && sp.Produce(self, self.World.Map.Rules.Actors[name], Faction))
{
FinishProduction();
return true;

View File

@@ -21,8 +21,8 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Exposed via the UI to the player.")]
public readonly string ClassName = "Unlabeled";
[Desc("Only available when selecting this faction.", "Leave empty for no restrictions.")]
public readonly string[] Races = { };
[Desc("Only available when selecting one of these factions.", "Leave empty for no restrictions.")]
public readonly string[] Factions = { };
[Desc("The mobile construction vehicle.")]
public readonly string BaseActor = null;

View File

@@ -31,7 +31,7 @@ namespace OpenRA.Mods.Common.Traits
{
var spawnClass = p.PlayerReference.StartingUnitsClass ?? w.LobbyInfo.GlobalSettings.StartingUnitsClass;
var unitGroup = w.Map.Rules.Actors["world"].Traits.WithInterface<MPStartUnitsInfo>()
.Where(g => g.Class == spawnClass && g.Races != null && g.Races.Contains(p.Faction.InternalName))
.Where(g => g.Class == spawnClass && g.Factions != null && g.Factions.Contains(p.Faction.InternalName))
.RandomOrDefault(w.SharedRandom);
if (unitGroup == null)

View File

@@ -1736,6 +1736,30 @@ namespace OpenRA.Mods.Common.UtilityCommands
node.Key = "Offset";
}
if (engineVersion < 20150811)
{
if (node.Key.StartsWith("ProductionQueue"))
{
var race = node.Value.Nodes.FirstOrDefault(x => x.Key == "Race");
if (race != null)
race.Key = "Factions";
}
if (node.Key.StartsWith("EmitInfantryOnSell"))
{
var race = node.Value.Nodes.FirstOrDefault(x => x.Key == "Races");
if (race != null)
race.Key = "Factions";
}
if (node.Key.StartsWith("MPStartUnits"))
{
var race = node.Value.Nodes.FirstOrDefault(x => x.Key == "Races");
if (race != null)
race.Key = "Factions";
}
}
UpgradeActorRules(engineVersion, ref node.Value.Nodes, node, depth + 1);
}
}