From 7c1ef2231da3c11cc26d8a977cbe68900284bcfc Mon Sep 17 00:00:00 2001 From: penev92 Date: Wed, 15 Jul 2015 05:59:02 +0300 Subject: [PATCH] Rename RaceInit to FactionInit --- OpenRA.Game/Map/ActorInitializer.cs | 12 ++++++------ OpenRA.Game/Traits/BodyOrientation.cs | 2 +- OpenRA.Mods.Common/Activities/Transform.cs | 2 +- OpenRA.Mods.Common/EditorBrushes/EditorActorBrush.cs | 2 +- .../Orders/PlaceBuildingOrderGenerator.cs | 2 +- OpenRA.Mods.Common/Traits/Player/PlaceBuilding.cs | 4 ++-- OpenRA.Mods.Common/Traits/Player/ProductionQueue.cs | 2 +- .../Traits/Player/ProvidesPrerequisite.cs | 2 +- OpenRA.Mods.Common/Traits/Production.cs | 4 ++-- OpenRA.Mods.Common/Traits/Render/RenderSprites.cs | 4 ++-- OpenRA.Mods.Common/Traits/Render/RenderVoxels.cs | 2 +- OpenRA.Mods.Common/Traits/Transforms.cs | 2 +- .../Traits/World/EditorActorPreview.cs | 8 ++++---- OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs | 6 ++++++ OpenRA.Mods.Common/Widgets/Logic/ColorPickerLogic.cs | 2 +- .../Widgets/Logic/Editor/ActorSelectorLogic.cs | 2 +- .../Traits/Buildings/ProductionFromMapEdge.cs | 2 +- .../Traits/Buildings/ClonesProducedUnits.cs | 2 +- OpenRA.Mods.RA/Traits/LeavesHusk.cs | 4 ++-- 19 files changed, 36 insertions(+), 30 deletions(-) diff --git a/OpenRA.Game/Map/ActorInitializer.cs b/OpenRA.Game/Map/ActorInitializer.cs index 3e68491065..1cb9eb938b 100755 --- a/OpenRA.Game/Map/ActorInitializer.cs +++ b/OpenRA.Game/Map/ActorInitializer.cs @@ -103,13 +103,13 @@ namespace OpenRA } } - // Allows maps / transformations to specify the race variant of an actor. - public class RaceInit : IActorInit + // Allows maps / transformations to specify the faction variant of an actor. + public class FactionInit : IActorInit { - [FieldFromYamlKey] public readonly string Race; + [FieldFromYamlKey] public readonly string Faction; - public RaceInit() { } - public RaceInit(string race) { Race = race; } - public string Value(World world) { return Race; } + public FactionInit() { } + public FactionInit(string faction) { Faction = faction; } + public string Value(World world) { return Faction; } } } diff --git a/OpenRA.Game/Traits/BodyOrientation.cs b/OpenRA.Game/Traits/BodyOrientation.cs index 617e330322..4b5d4ad714 100644 --- a/OpenRA.Game/Traits/BodyOrientation.cs +++ b/OpenRA.Game/Traits/BodyOrientation.cs @@ -54,7 +54,7 @@ namespace OpenRA.Traits { this.info = info; var self = init.Self; - var race = init.Contains() ? init.Get() : self.Owner.Faction.InternalName; + var race = init.Contains() ? init.Get() : self.Owner.Faction.InternalName; quantizedFacings = Exts.Lazy(() => { diff --git a/OpenRA.Mods.Common/Activities/Transform.cs b/OpenRA.Mods.Common/Activities/Transform.cs index 565c4eb77f..3542d6b47a 100644 --- a/OpenRA.Mods.Common/Activities/Transform.cs +++ b/OpenRA.Mods.Common/Activities/Transform.cs @@ -65,7 +65,7 @@ namespace OpenRA.Mods.Common.Activities init.Add(new SkipMakeAnimsInit()); if (Race != null) - init.Add(new RaceInit(Race)); + init.Add(new FactionInit(Race)); var health = self.TraitOrDefault(); if (health != null) diff --git a/OpenRA.Mods.Common/EditorBrushes/EditorActorBrush.cs b/OpenRA.Mods.Common/EditorBrushes/EditorActorBrush.cs index e8a1d720a7..af121d73e9 100644 --- a/OpenRA.Mods.Common/EditorBrushes/EditorActorBrush.cs +++ b/OpenRA.Mods.Common/EditorBrushes/EditorActorBrush.cs @@ -65,7 +65,7 @@ namespace OpenRA.Mods.Common.Widgets td.Add(new FacingInit(facing)); td.Add(new TurretFacingInit(facing)); td.Add(new OwnerInit(owner.Name)); - td.Add(new RaceInit(owner.Faction)); + td.Add(new FactionInit(owner.Faction)); preview.SetPreview(actor, td); var ios = actor.Traits.GetOrDefault(); diff --git a/OpenRA.Mods.Common/Orders/PlaceBuildingOrderGenerator.cs b/OpenRA.Mods.Common/Orders/PlaceBuildingOrderGenerator.cs index 60413907dd..be7d2a6ac7 100644 --- a/OpenRA.Mods.Common/Orders/PlaceBuildingOrderGenerator.cs +++ b/OpenRA.Mods.Common/Orders/PlaceBuildingOrderGenerator.cs @@ -170,7 +170,7 @@ namespace OpenRA.Mods.Common.Orders { var td = new TypeDictionary() { - new RaceInit(race), + new FactionInit(race), new OwnerInit(producer.Owner), new HideBibPreviewInit() }; diff --git a/OpenRA.Mods.Common/Traits/Player/PlaceBuilding.cs b/OpenRA.Mods.Common/Traits/Player/PlaceBuilding.cs index bb92fc5c6a..5bc22c9b97 100644 --- a/OpenRA.Mods.Common/Traits/Player/PlaceBuilding.cs +++ b/OpenRA.Mods.Common/Traits/Player/PlaceBuilding.cs @@ -78,7 +78,7 @@ namespace OpenRA.Mods.Common.Traits { new LocationInit(t), new OwnerInit(order.Player), - new RaceInit(race) + new FactionInit(race) }); if (playSounds) @@ -119,7 +119,7 @@ namespace OpenRA.Mods.Common.Traits { new LocationInit(order.TargetLocation), new OwnerInit(order.Player), - new RaceInit(race), + new FactionInit(race), }); foreach (var s in buildingInfo.BuildSounds) diff --git a/OpenRA.Mods.Common/Traits/Player/ProductionQueue.cs b/OpenRA.Mods.Common/Traits/Player/ProductionQueue.cs index 3654d7b632..b688cabee2 100644 --- a/OpenRA.Mods.Common/Traits/Player/ProductionQueue.cs +++ b/OpenRA.Mods.Common/Traits/Player/ProductionQueue.cs @@ -97,7 +97,7 @@ namespace OpenRA.Mods.Common.Traits playerPower = playerActor.Trait(); developerMode = playerActor.Trait(); - Race = init.Contains() ? init.Get() : self.Owner.Faction.InternalName; + Race = init.Contains() ? init.Get() : self.Owner.Faction.InternalName; Enabled = !info.Race.Any() || info.Race.Contains(Race); CacheProduceables(playerActor); diff --git a/OpenRA.Mods.Common/Traits/Player/ProvidesPrerequisite.cs b/OpenRA.Mods.Common/Traits/Player/ProvidesPrerequisite.cs index 0b792ca835..3928c7f164 100644 --- a/OpenRA.Mods.Common/Traits/Player/ProvidesPrerequisite.cs +++ b/OpenRA.Mods.Common/Traits/Player/ProvidesPrerequisite.cs @@ -45,7 +45,7 @@ namespace OpenRA.Mods.Common.Traits if (string.IsNullOrEmpty(prerequisite)) prerequisite = init.Self.Info.Name; - var race = init.Contains() ? init.Get() : init.Self.Owner.Faction.InternalName; + var race = init.Contains() ? init.Get() : init.Self.Owner.Faction.InternalName; Update(init.Self.Owner, race); } diff --git a/OpenRA.Mods.Common/Traits/Production.cs b/OpenRA.Mods.Common/Traits/Production.cs index 0d0abe1a72..09920c678e 100644 --- a/OpenRA.Mods.Common/Traits/Production.cs +++ b/OpenRA.Mods.Common/Traits/Production.cs @@ -39,7 +39,7 @@ namespace OpenRA.Mods.Common.Traits { Info = info; rp = Exts.Lazy(() => init.Self.IsDead ? null : init.Self.TraitOrDefault()); - Race = init.Contains() ? init.Get() : init.Self.Owner.Faction.InternalName; + Race = init.Contains() ? init.Get() : init.Self.Owner.Faction.InternalName; } public void DoProduction(Actor self, ActorInfo producee, ExitInfo exitinfo, string raceVariant) @@ -69,7 +69,7 @@ namespace OpenRA.Mods.Common.Traits }; if (raceVariant != null) - td.Add(new RaceInit(raceVariant)); + td.Add(new FactionInit(raceVariant)); var newUnit = self.World.CreateActor(producee.Name, td); diff --git a/OpenRA.Mods.Common/Traits/Render/RenderSprites.cs b/OpenRA.Mods.Common/Traits/Render/RenderSprites.cs index f039c3d9db..7eceef2ecb 100644 --- a/OpenRA.Mods.Common/Traits/Render/RenderSprites.cs +++ b/OpenRA.Mods.Common/Traits/Render/RenderSprites.cs @@ -57,7 +57,7 @@ namespace OpenRA.Mods.Common.Traits public IEnumerable RenderPreview(ActorPreviewInitializer init) { var sequenceProvider = init.World.Map.SequenceProvider; - var race = init.Get(); + var race = init.Get(); var ownerName = init.Get().PlayerName; var image = GetImage(init.Actor, sequenceProvider, race); var palette = init.WorldRenderer.Palette(Palette ?? PlayerPalette + ownerName); @@ -145,7 +145,7 @@ namespace OpenRA.Mods.Common.Traits public RenderSprites(ActorInitializer init, RenderSpritesInfo info) { this.info = info; - race = init.Contains() ? init.Get() : init.Self.Owner.Faction.InternalName; + race = init.Contains() ? init.Get() : init.Self.Owner.Faction.InternalName; } public string GetImage(Actor self) diff --git a/OpenRA.Mods.Common/Traits/Render/RenderVoxels.cs b/OpenRA.Mods.Common/Traits/Render/RenderVoxels.cs index 9afa73a249..0895f1654f 100644 --- a/OpenRA.Mods.Common/Traits/Render/RenderVoxels.cs +++ b/OpenRA.Mods.Common/Traits/Render/RenderVoxels.cs @@ -48,7 +48,7 @@ namespace OpenRA.Mods.Common.Traits public virtual IEnumerable RenderPreview(ActorPreviewInitializer init) { var body = init.Actor.Traits.Get(); - var race = init.Get(); + var race = init.Get(); var ownerName = init.Get().PlayerName; var sequenceProvider = init.World.Map.SequenceProvider; var image = Image ?? init.Actor.Name; diff --git a/OpenRA.Mods.Common/Traits/Transforms.cs b/OpenRA.Mods.Common/Traits/Transforms.cs index 5934e05034..13d2b9b2bc 100644 --- a/OpenRA.Mods.Common/Traits/Transforms.cs +++ b/OpenRA.Mods.Common/Traits/Transforms.cs @@ -62,7 +62,7 @@ namespace OpenRA.Mods.Common.Traits self = init.Self; this.info = info; buildingInfo = self.World.Map.Rules.Actors[info.IntoActor].Traits.GetOrDefault(); - race = init.Contains() ? init.Get() : self.Owner.Faction.InternalName; + race = init.Contains() ? init.Get() : self.Owner.Faction.InternalName; } public string VoicePhraseForOrder(Actor self, Order order) diff --git a/OpenRA.Mods.Common/Traits/World/EditorActorPreview.cs b/OpenRA.Mods.Common/Traits/World/EditorActorPreview.cs index b101940746..578ffa5298 100644 --- a/OpenRA.Mods.Common/Traits/World/EditorActorPreview.cs +++ b/OpenRA.Mods.Common/Traits/World/EditorActorPreview.cs @@ -43,8 +43,8 @@ namespace OpenRA.Mods.Common.Traits this.Owner = owner; this.worldRenderer = worldRenderer; - if (!actor.InitDict.Contains()) - actor.InitDict.Add(new RaceInit(owner.Faction)); + if (!actor.InitDict.Contains()) + actor.InitDict.Add(new FactionInit(owner.Faction)); if (!actor.InitDict.Contains()) actor.InitDict.Add(new OwnerInit(owner.Name)); @@ -118,8 +118,8 @@ namespace OpenRA.Mods.Common.Traits { Func saveInit = init => { - var race = init as RaceInit; - if (race != null && race.Race == Owner.Faction) + var factionInit = init as FactionInit; + if (factionInit != null && factionInit.Faction == Owner.Faction) return false; // TODO: Other default values will need to be filtered diff --git a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs index e23f86f98e..4d87407d32 100644 --- a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs +++ b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs @@ -2172,6 +2172,12 @@ namespace OpenRA.Mods.Common.UtilityCommands ConvertFloatToIntPercentage(ref node.Value.Value); } + if (engineVersion < 20150715) + { + if (node.Key == "Race") + node.Key = "Faction"; + } + UpgradeActors(engineVersion, ref node.Value.Nodes, node, depth + 1); } } diff --git a/OpenRA.Mods.Common/Widgets/Logic/ColorPickerLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/ColorPickerLogic.cs index 0724e535d8..ca36d2b443 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/ColorPickerLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/ColorPickerLogic.cs @@ -31,7 +31,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic var td = new TypeDictionary(); td.Add(new HideBibPreviewInit()); td.Add(new OwnerInit(world.WorldActor.Owner)); - td.Add(new RaceInit(world.WorldActor.Owner.PlayerReference.Faction)); + td.Add(new FactionInit(world.WorldActor.Owner.PlayerReference.Faction)); if (preview != null) preview.SetPreview(actor, td); diff --git a/OpenRA.Mods.Common/Widgets/Logic/Editor/ActorSelectorLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Editor/ActorSelectorLogic.cs index 74772978ab..8b2330c5ef 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Editor/ActorSelectorLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Editor/ActorSelectorLogic.cs @@ -112,7 +112,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic td.Add(new TurretFacingInit(92)); td.Add(new HideBibPreviewInit()); td.Add(new OwnerInit(selectedOwner.Name)); - td.Add(new RaceInit(selectedOwner.Faction)); + td.Add(new FactionInit(selectedOwner.Faction)); try { diff --git a/OpenRA.Mods.D2k/Traits/Buildings/ProductionFromMapEdge.cs b/OpenRA.Mods.D2k/Traits/Buildings/ProductionFromMapEdge.cs index 63b7b7d3c3..b2a9852571 100644 --- a/OpenRA.Mods.D2k/Traits/Buildings/ProductionFromMapEdge.cs +++ b/OpenRA.Mods.D2k/Traits/Buildings/ProductionFromMapEdge.cs @@ -50,7 +50,7 @@ namespace OpenRA.Mods.D2k.Traits }; if (raceVariant != null) - td.Add(new RaceInit(raceVariant)); + td.Add(new FactionInit(raceVariant)); var newUnit = self.World.CreateActor(producee.Name, td); diff --git a/OpenRA.Mods.RA/Traits/Buildings/ClonesProducedUnits.cs b/OpenRA.Mods.RA/Traits/Buildings/ClonesProducedUnits.cs index 434d145947..f507e97f10 100644 --- a/OpenRA.Mods.RA/Traits/Buildings/ClonesProducedUnits.cs +++ b/OpenRA.Mods.RA/Traits/Buildings/ClonesProducedUnits.cs @@ -34,7 +34,7 @@ namespace OpenRA.Mods.RA.Traits { this.info = info; production = init.Self.Trait(); - race = init.Contains() ? init.Get() : init.Self.Owner.Faction.InternalName; + race = init.Contains() ? init.Get() : init.Self.Owner.Faction.InternalName; } public void UnitProducedByOther(Actor self, Actor producer, Actor produced) diff --git a/OpenRA.Mods.RA/Traits/LeavesHusk.cs b/OpenRA.Mods.RA/Traits/LeavesHusk.cs index 736a81d2ba..50d0568b4c 100644 --- a/OpenRA.Mods.RA/Traits/LeavesHusk.cs +++ b/OpenRA.Mods.RA/Traits/LeavesHusk.cs @@ -33,7 +33,7 @@ namespace OpenRA.Mods.RA.Traits { this.info = info; - race = init.Contains() ? init.Get() : init.Self.Owner.Faction.InternalName; + race = init.Contains() ? init.Get() : init.Self.Owner.Faction.InternalName; } public void Killed(Actor self, AttackInfo e) @@ -49,7 +49,7 @@ namespace OpenRA.Mods.RA.Traits new LocationInit(self.Location), new CenterPositionInit(self.CenterPosition), new OwnerInit(self.Owner), - new RaceInit(race), + new FactionInit(race), new SkipMakeAnimsInit() };