From bc2b60be05ffd5f1b8832c14ffd0d80ce8a0fb7a Mon Sep 17 00:00:00 2001 From: reaperrr Date: Sat, 18 Jul 2015 22:27:21 +0200 Subject: [PATCH 01/11] Extend WithSpriteBody funtionality Move building placement range circle to PlaceBuilding, add PauseAnimationWhenDisabled. --- OpenRA.Mods.Common/Traits/Player/PlaceBuilding.cs | 14 +++++++++++++- .../Traits/Render/RenderBuilding.cs | 12 +----------- .../Traits/Render/WithSpriteBody.cs | 15 ++++++++++++++- 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/Player/PlaceBuilding.cs b/OpenRA.Mods.Common/Traits/Player/PlaceBuilding.cs index 7b5140d034..e3689bfdca 100644 --- a/OpenRA.Mods.Common/Traits/Player/PlaceBuilding.cs +++ b/OpenRA.Mods.Common/Traits/Player/PlaceBuilding.cs @@ -8,15 +8,17 @@ */ #endregion +using System.Collections.Generic; using System.Linq; using OpenRA.Effects; +using OpenRA.Graphics; using OpenRA.Primitives; using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { [Desc("Allows the player to execute build orders.", " Attach this to the player actor.")] - public class PlaceBuildingInfo : ITraitInfo + public class PlaceBuildingInfo : ITraitInfo, IPlaceBuildingDecoration { [Desc("Palette to use for rendering the placement sprite.")] [PaletteReference] public readonly string Palette = "terrain"; @@ -28,6 +30,16 @@ namespace OpenRA.Mods.Common.Traits public readonly string NewOptionsNotification = "NewOptions"; public object Create(ActorInitializer init) { return new PlaceBuilding(this); } + + public IEnumerable Render(WorldRenderer wr, World w, ActorInfo ai, WPos centerPosition) + { + if (!ai.Traits.Get().RequiresBaseProvider) + yield break; + + foreach (var a in w.ActorsWithTrait()) + foreach (var r in a.Trait.RenderAfterWorld(wr)) + yield return r; + } } public class PlaceBuilding : IResolveOrder diff --git a/OpenRA.Mods.Common/Traits/Render/RenderBuilding.cs b/OpenRA.Mods.Common/Traits/Render/RenderBuilding.cs index 15612e5588..c8333623b5 100644 --- a/OpenRA.Mods.Common/Traits/Render/RenderBuilding.cs +++ b/OpenRA.Mods.Common/Traits/Render/RenderBuilding.cs @@ -17,21 +17,11 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { [Desc("Render trait for stationary objects that can be placed from the build palette.")] - public class RenderBuildingInfo : RenderSimpleInfo, Requires, IPlaceBuildingDecoration + public class RenderBuildingInfo : RenderSimpleInfo, Requires { public readonly bool PauseOnLowPower = false; public override object Create(ActorInitializer init) { return new RenderBuilding(init, this); } - - public IEnumerable Render(WorldRenderer wr, World w, ActorInfo ai, WPos centerPosition) - { - if (!ai.Traits.Get().RequiresBaseProvider) - yield break; - - foreach (var a in w.ActorsWithTrait()) - foreach (var r in a.Trait.RenderAfterWorld(wr)) - yield return r; - } } public class RenderBuilding : RenderSimple, INotifyDamageStateChanged, INotifyBuildComplete diff --git a/OpenRA.Mods.Common/Traits/Render/WithSpriteBody.cs b/OpenRA.Mods.Common/Traits/Render/WithSpriteBody.cs index c4861111ce..dbb82faed1 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithSpriteBody.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithSpriteBody.cs @@ -25,6 +25,9 @@ namespace OpenRA.Mods.Common.Traits [Desc("Animation to play when the actor is idle.")] [SequenceReference] public readonly string Sequence = "idle"; + [Desc("Pause animation when actor is disabled.")] + public readonly bool PauseAnimationWhenDisabled = false; + public override object Create(ActorInitializer init) { return new WithSpriteBody(init, this); } public virtual IEnumerable RenderPreviewSprites(ActorPreviewInitializer init, RenderSpritesInfo rs, string image, int facings, PaletteReference p) @@ -36,7 +39,7 @@ namespace OpenRA.Mods.Common.Traits } } - public class WithSpriteBody : UpgradableTrait, ISpriteBody, INotifyDamageStateChanged + public class WithSpriteBody : UpgradableTrait, ISpriteBody, INotifyDamageStateChanged, INotifyBuildComplete { public readonly Animation DefaultAnimation; @@ -63,6 +66,16 @@ namespace OpenRA.Mods.Common.Traits return RenderSprites.NormalizeSequence(DefaultAnimation, self.GetDamageState(), sequence); } + // TODO: Get rid of INotifyBuildComplete in favor of using the upgrade system + public virtual void BuildingComplete(Actor self) + { + DefaultAnimation.PlayRepeating(NormalizeSequence(self, Info.Sequence)); + + if (Info.PauseAnimationWhenDisabled) + DefaultAnimation.Paused = () => + self.IsDisabled() && DefaultAnimation.CurrentSequence.Name == NormalizeSequence(self, Info.Sequence); + } + public void PlayCustomAnimation(Actor self, string name, Action after = null) { DefaultAnimation.PlayThen(NormalizeSequence(self, name), () => From 2df318cd3e36116fe7fa16ba058f2314b1bb3ace Mon Sep 17 00:00:00 2001 From: reaperrr Date: Wed, 15 Jul 2015 06:53:51 +0200 Subject: [PATCH 02/11] RenderBuildingCharge -> WithChargeAnimation --- OpenRA.Mods.Common/OpenRA.Mods.Common.csproj | 2 +- .../Traits/Render/RenderBuildingCharge.cs | 39 ------------------ .../Traits/Render/WithChargeAnimation.cs | 40 +++++++++++++++++++ .../UtilityCommands/UpgradeRules.cs | 33 +++++++++++++++ mods/cnc/rules/structures.yaml | 5 ++- mods/ra/rules/structures.yaml | 5 ++- 6 files changed, 82 insertions(+), 42 deletions(-) delete mode 100644 OpenRA.Mods.Common/Traits/Render/RenderBuildingCharge.cs create mode 100644 OpenRA.Mods.Common/Traits/Render/WithChargeAnimation.cs diff --git a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj index 374ce1713f..2c66eb7845 100644 --- a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj +++ b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj @@ -406,7 +406,6 @@ - @@ -427,6 +426,7 @@ + diff --git a/OpenRA.Mods.Common/Traits/Render/RenderBuildingCharge.cs b/OpenRA.Mods.Common/Traits/Render/RenderBuildingCharge.cs deleted file mode 100644 index f1f5104620..0000000000 --- a/OpenRA.Mods.Common/Traits/Render/RenderBuildingCharge.cs +++ /dev/null @@ -1,39 +0,0 @@ -#region Copyright & License Information -/* - * Copyright 2007-2015 The OpenRA Developers (see AUTHORS) - * This file is part of OpenRA, which is free software. It is made - * available to you under the terms of the GNU General Public License - * as published by the Free Software Foundation. For more information, - * see COPYING. - */ -#endregion - -using OpenRA.Traits; - -namespace OpenRA.Mods.Common.Traits -{ - [Desc("Used for tesla coil and obelisk.")] - public class RenderBuildingChargeInfo : RenderBuildingInfo - { - [Desc("Sequence to use for building charge animation.")] - [SequenceReference] public readonly string ChargeSequence = "active"; - - public override object Create(ActorInitializer init) { return new RenderBuildingCharge(init, this); } - } - - public class RenderBuildingCharge : RenderBuilding, INotifyCharging - { - RenderBuildingChargeInfo info; - - public RenderBuildingCharge(ActorInitializer init, RenderBuildingChargeInfo info) - : base(init, info) - { - this.info = info; - } - - public void Charging(Actor self, Target target) - { - PlayCustomAnim(self, info.ChargeSequence); - } - } -} diff --git a/OpenRA.Mods.Common/Traits/Render/WithChargeAnimation.cs b/OpenRA.Mods.Common/Traits/Render/WithChargeAnimation.cs new file mode 100644 index 0000000000..b48b9733d2 --- /dev/null +++ b/OpenRA.Mods.Common/Traits/Render/WithChargeAnimation.cs @@ -0,0 +1,40 @@ +#region Copyright & License Information +/* + * Copyright 2007-2015 The OpenRA Developers (see AUTHORS) + * This file is part of OpenRA, which is free software. It is made + * available to you under the terms of the GNU General Public License + * as published by the Free Software Foundation. For more information, + * see COPYING. + */ +#endregion + +using OpenRA.Traits; + +namespace OpenRA.Mods.Common.Traits +{ + [Desc("This actor displays a charge-up animation before firing.")] + public class WithChargeAnimationInfo : ITraitInfo, Requires, Requires + { + [Desc("Sequence to use for charge animation.")] + [SequenceReference] public readonly string ChargeSequence = "active"; + + public object Create(ActorInitializer init) { return new WithChargeAnimation(init, this); } + } + + public class WithChargeAnimation : INotifyCharging + { + readonly WithChargeAnimationInfo info; + readonly WithSpriteBody wsb; + + public WithChargeAnimation(ActorInitializer init, WithChargeAnimationInfo info) + { + this.info = info; + wsb = init.Self.Trait(); + } + + public void Charging(Actor self, Target target) + { + wsb.PlayCustomAnimation(self, info.ChargeSequence); + } + } +} diff --git a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs index 7ff22a81a2..c78ed091fd 100644 --- a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs +++ b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs @@ -1810,6 +1810,39 @@ namespace OpenRA.Mods.Common.UtilityCommands } } + if (engineVersion < 20150826) + { + // Replaced RenderBuildingCharge with RenderSprites + WithSpriteBody + WithChargeAnimation (+AutoSelectionSize) + if (depth == 0) + { + var childKeySequence = new[] { "ChargeSequence" }; + var childKeysExcludeFromRS = new[] { "Sequence", "ChargeSequence", "PauseOnLowPower" }; + + var rb = node.Value.Nodes.FirstOrDefault(n => n.Key.StartsWith("RenderBuildingCharge")); + if (rb != null) + { + rb.Key = "WithChargeAnimation"; + + var rsNodes = rb.Value.Nodes.Where(n => !childKeysExcludeFromRS.Contains(n.Key)).ToList(); + var wsbNodes = rb.Value.Nodes.Where(n => childKeySequence.Contains(n.Key)).ToList(); + + if (rsNodes.Any()) + node.Value.Nodes.Add(new MiniYamlNode("RenderSprites", new MiniYaml("", rsNodes))); + else + node.Value.Nodes.Add(new MiniYamlNode("RenderSprites", "")); + + node.Value.Nodes.Add(new MiniYamlNode("AutoSelectionSize", "")); + + rb.Value.Nodes.RemoveAll(n => rsNodes.Contains(n)); + rb.Value.Nodes.RemoveAll(n => wsbNodes.Contains(n)); + } + + var rrb = node.Value.Nodes.FirstOrDefault(n => n.Key.StartsWith("-RenderBuildingCharge")); + if (rrb != null) + rrb.Key = "-WithChargeAnimation"; + } + } + UpgradeActorRules(engineVersion, ref node.Value.Nodes, node, depth + 1); } } diff --git a/mods/cnc/rules/structures.yaml b/mods/cnc/rules/structures.yaml index ad7a68d28d..4f311e3596 100644 --- a/mods/cnc/rules/structures.yaml +++ b/mods/cnc/rules/structures.yaml @@ -730,7 +730,9 @@ OBLI: Range: 8c0 Bib: HasMinibib: Yes - RenderBuildingCharge: + RenderSprites: + WithSpriteBody: + WithChargeAnimation: Armament: Weapon: Laser LocalOffset: 0,0,725 @@ -745,6 +747,7 @@ OBLI: Range: 5 Power: Amount: -150 + -WithMakeAnimation: GTWR: Inherits: ^Defense diff --git a/mods/ra/rules/structures.yaml b/mods/ra/rules/structures.yaml index fb4105f562..2922c4f633 100644 --- a/mods/ra/rules/structures.yaml +++ b/mods/ra/rules/structures.yaml @@ -401,7 +401,9 @@ TSLA: Range: 8c0 Bib: HasMinibib: Yes - RenderBuildingCharge: + RenderSprites: + WithSpriteBody: + WithChargeAnimation: Armament: Weapon: TeslaZap LocalOffset: 0,0,427 @@ -415,6 +417,7 @@ TSLA: DetectCloaked: Range: 8 ProvidesPrerequisite@buildingname: + -WithMakeAnimation: AGUN: Inherits: ^Defense From 69d062495cd46fff35de1fe229e16cab53b797d2 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Wed, 15 Jul 2015 06:57:43 +0200 Subject: [PATCH 03/11] RenderBuildingSilo -> WithSiloAnimation --- OpenRA.Mods.Common/OpenRA.Mods.Common.csproj | 2 +- .../Traits/Render/RenderBuildingSilo.cs | 61 ------------------- .../Traits/Render/WithSiloAnimation.cs | 55 +++++++++++++++++ .../UtilityCommands/UpgradeRules.cs | 34 +++++++++++ mods/cnc/rules/structures.yaml | 6 +- mods/d2k/rules/structures.yaml | 5 +- mods/ra/rules/structures.yaml | 5 +- mods/ts/rules/shared-structures.yaml | 5 +- 8 files changed, 107 insertions(+), 66 deletions(-) delete mode 100644 OpenRA.Mods.Common/Traits/Render/RenderBuildingSilo.cs create mode 100644 OpenRA.Mods.Common/Traits/Render/WithSiloAnimation.cs diff --git a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj index 2c66eb7845..b18376aa1e 100644 --- a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj +++ b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj @@ -411,7 +411,6 @@ - @@ -424,6 +423,7 @@ + diff --git a/OpenRA.Mods.Common/Traits/Render/RenderBuildingSilo.cs b/OpenRA.Mods.Common/Traits/Render/RenderBuildingSilo.cs deleted file mode 100644 index 0652818378..0000000000 --- a/OpenRA.Mods.Common/Traits/Render/RenderBuildingSilo.cs +++ /dev/null @@ -1,61 +0,0 @@ -#region Copyright & License Information -/* - * Copyright 2007-2015 The OpenRA Developers (see AUTHORS) - * This file is part of OpenRA, which is free software. It is made - * available to you under the terms of the GNU General Public License - * as published by the Free Software Foundation. For more information, - * see COPYING. - */ -#endregion - -using System.Collections.Generic; -using OpenRA.Graphics; -using OpenRA.Mods.Common.Graphics; -using OpenRA.Traits; - -namespace OpenRA.Mods.Common.Traits -{ - [Desc("Render trait for buildings that change the sprite according to the remaining resource storage capacity across all depots.")] - class RenderBuildingSiloInfo : RenderBuildingInfo - { - public override object Create(ActorInitializer init) { return new RenderBuildingSilo(init, this); } - - public override IEnumerable RenderPreviewSprites(ActorPreviewInitializer init, RenderSpritesInfo rs, string image, int facings, PaletteReference p) - { - // Show a static frame instead of animating all of the fullness states - var anim = new Animation(init.World, image, () => 0); - anim.PlayFetchIndex(RenderSprites.NormalizeSequence(anim, init.GetDamageState(), Sequence), () => 0); - - yield return new SpriteActorPreview(anim, WVec.Zero, 0, p, rs.Scale); - } - } - - class RenderBuildingSilo : RenderBuilding, INotifyBuildComplete, INotifyOwnerChanged - { - readonly RenderBuildingSiloInfo info; - PlayerResources playerResources; - - public RenderBuildingSilo(ActorInitializer init, RenderBuildingSiloInfo info) - : base(init, info) - { - this.info = info; - playerResources = init.Self.Owner.PlayerActor.Trait(); - } - - public override void BuildingComplete(Actor self) - { - var animation = RenderSprites.NormalizeSequence(DefaultAnimation, self.GetDamageState(), info.Sequence); - - DefaultAnimation.PlayFetchIndex(animation, - () => playerResources.ResourceCapacity != 0 - ? ((10 * DefaultAnimation.CurrentSequence.Length - 1) * playerResources.Resources) / (10 * playerResources.ResourceCapacity) - : 0); - } - - public override void OnOwnerChanged(Actor self, Player oldOwner, Player newOwner) - { - playerResources = newOwner.PlayerActor.Trait(); - base.OnOwnerChanged(self, oldOwner, newOwner); - } - } -} diff --git a/OpenRA.Mods.Common/Traits/Render/WithSiloAnimation.cs b/OpenRA.Mods.Common/Traits/Render/WithSiloAnimation.cs new file mode 100644 index 0000000000..91eb2ea3aa --- /dev/null +++ b/OpenRA.Mods.Common/Traits/Render/WithSiloAnimation.cs @@ -0,0 +1,55 @@ +#region Copyright & License Information +/* + * Copyright 2007-2015 The OpenRA Developers (see AUTHORS) + * This file is part of OpenRA, which is free software. It is made + * available to you under the terms of the GNU General Public License + * as published by the Free Software Foundation. For more information, + * see COPYING. + */ +#endregion + +using System.Collections.Generic; +using OpenRA.Graphics; +using OpenRA.Mods.Common.Graphics; +using OpenRA.Traits; + +namespace OpenRA.Mods.Common.Traits +{ + [Desc("Render trait for buildings that change the sprite according to the remaining resource storage capacity across all depots.")] + class WithSiloAnimationInfo : ITraitInfo, Requires, Requires + { + public readonly int Stages = 10; + + public object Create(ActorInitializer init) { return new WithSiloAnimation(init, this); } + } + + class WithSiloAnimation : INotifyBuildComplete, INotifyOwnerChanged + { + readonly WithSiloAnimationInfo info; + readonly WithSpriteBody wsb; + PlayerResources playerResources; + + public WithSiloAnimation(ActorInitializer init, WithSiloAnimationInfo info) + { + this.info = info; + wsb = init.Self.Trait(); + playerResources = init.Self.Owner.PlayerActor.Trait(); + } + + public void BuildingComplete(Actor self) + { + var animation = wsb.NormalizeSequence(self, wsb.Info.Sequence); + + wsb.DefaultAnimation.PlayFetchIndex(animation, + () => playerResources.ResourceCapacity != 0 + ? ((info.Stages * wsb.DefaultAnimation.CurrentSequence.Length - 1) * playerResources.Resources) / (info.Stages * playerResources.ResourceCapacity) + : 0); + } + + public void OnOwnerChanged(Actor self, Player oldOwner, Player newOwner) + { + playerResources = newOwner.PlayerActor.Trait(); + OnOwnerChanged(self, oldOwner, newOwner); + } + } +} diff --git a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs index c78ed091fd..979287a349 100644 --- a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs +++ b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs @@ -1841,6 +1841,40 @@ namespace OpenRA.Mods.Common.UtilityCommands if (rrb != null) rrb.Key = "-WithChargeAnimation"; } + + // Replaced RenderBuildingSilo with RenderSprites + WithSpriteBody + WithSiloAnimation (+AutoSelectionSize) + if (depth == 0) + { + var childKeySequence = new[] { "Sequence", "PauseOnLowPower" }; + + var rb = node.Value.Nodes.FirstOrDefault(n => n.Key.StartsWith("RenderBuildingSilo")); + if (rb != null) + { + rb.Key = "WithSiloAnimation"; + + var rsNodes = rb.Value.Nodes.Where(n => !childKeySequence.Contains(n.Key)).ToList(); + var wsbNodes = rb.Value.Nodes.Where(n => childKeySequence.Contains(n.Key)).ToList(); + + if (rsNodes.Any()) + node.Value.Nodes.Add(new MiniYamlNode("RenderSprites", new MiniYaml("", rsNodes))); + else + node.Value.Nodes.Add(new MiniYamlNode("RenderSprites", "")); + + if (wsbNodes.Any()) + node.Value.Nodes.Add(new MiniYamlNode("WithSpriteBody", new MiniYaml("", wsbNodes))); + else + node.Value.Nodes.Add(new MiniYamlNode("WithSpriteBody", "")); + + node.Value.Nodes.Add(new MiniYamlNode("AutoSelectionSize", "")); + + rb.Value.Nodes.RemoveAll(n => rsNodes.Contains(n)); + rb.Value.Nodes.RemoveAll(n => wsbNodes.Contains(n)); + } + + var rrb = node.Value.Nodes.FirstOrDefault(n => n.Key.StartsWith("-RenderBuildingSilo")); + if (rrb != null) + rrb.Key = "-WithSiloAnimation"; + } } UpgradeActorRules(engineVersion, ref node.Value.Nodes, node, depth + 1); diff --git a/mods/cnc/rules/structures.yaml b/mods/cnc/rules/structures.yaml index 4f311e3596..b8ef1febf4 100644 --- a/mods/cnc/rules/structures.yaml +++ b/mods/cnc/rules/structures.yaml @@ -210,7 +210,10 @@ SILO: Range: 4c0 Bib: HasMinibib: Yes - RenderBuildingSilo: + RenderSprites: + WithSpriteBody: + AutoSelectionSize: + WithSiloAnimation: StoresResources: PipCount: 10 PipColor: Green @@ -223,6 +226,7 @@ SILO: RequiredForShortGame: false SelectionDecorations: VisualBounds: 49,30 + -WithMakeAnimation: PYLE: Inherits: ^BaseBuilding diff --git a/mods/d2k/rules/structures.yaml b/mods/d2k/rules/structures.yaml index ff1979c926..69de28c6ca 100644 --- a/mods/d2k/rules/structures.yaml +++ b/mods/d2k/rules/structures.yaml @@ -242,11 +242,13 @@ silo: RevealsShroud: Range: 4c0 -RenderBuilding: - RenderBuildingSilo: + RenderSprites: Image: silo.harkonnen FactionImages: atreides: silo.atreides ordos: silo.ordos + WithSpriteBody: + WithSiloAnimation: StoresResources: PipColor: green PipCount: 5 @@ -256,6 +258,7 @@ silo: Amount: -5 MustBeDestroyed: RequiredForShortGame: false + -WithMakeAnimation: light: Inherits: ^Building diff --git a/mods/ra/rules/structures.yaml b/mods/ra/rules/structures.yaml index 2922c4f633..46bdc3802c 100644 --- a/mods/ra/rules/structures.yaml +++ b/mods/ra/rules/structures.yaml @@ -982,7 +982,9 @@ SILO: Range: 4c0 Bib: HasMinibib: Yes - RenderBuildingSilo: + RenderSprites: + WithSpriteBody: + WithSiloAnimation: StoresResources: PipCount: 5 Capacity: 1500 @@ -990,6 +992,7 @@ SILO: -EmitInfantryOnSell: Power: Amount: -10 + -WithMakeAnimation: HPAD: Inherits: ^Building diff --git a/mods/ts/rules/shared-structures.yaml b/mods/ts/rules/shared-structures.yaml index ff6b9f2d33..e75941b725 100644 --- a/mods/ts/rules/shared-structures.yaml +++ b/mods/ts/rules/shared-structures.yaml @@ -127,11 +127,13 @@ GASILO: RevealsShroud: Range: 4c0 -RenderBuilding: - RenderBuildingSilo: + RenderSprites: Image: gasilo.gdi FactionImages: gdi: gasilo.gdi nod: gasilo.nod + WithSpriteBody: + WithSiloAnimation: WithIdleOverlay@UNDERLAY: Sequence: idle-underlay WithIdleOverlay@LIGHTS: @@ -143,6 +145,7 @@ GASILO: Amount: -10 SelectionDecorations: VisualBounds: 80, 48, -5, 0 + -WithMakeAnimation: ANYPOWER: AlwaysVisible: From 21186c10b6a37b72402229ca0ac03444eea27dd3 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Wed, 15 Jul 2015 07:02:02 +0200 Subject: [PATCH 04/11] RenderBuildingTurreted -> WithTurretedSpriteBody --- OpenRA.Mods.Cnc/Traits/AttackPopupTurreted.cs | 28 +++++++++++++------ OpenRA.Mods.Common/OpenRA.Mods.Common.csproj | 2 +- ...gTurreted.cs => WithTurretedSpriteBody.cs} | 15 +++++----- .../UtilityCommands/UpgradeRules.cs | 27 ++++++++++++++++++ mods/cnc/rules/structures.yaml | 9 ++++-- mods/ra/maps/allies-05a/map.yaml | 4 ++- mods/ra/rules/structures.yaml | 12 ++++++-- mods/ts/rules/gdi-support.yaml | 1 + 8 files changed, 75 insertions(+), 23 deletions(-) rename OpenRA.Mods.Common/Traits/Render/{RenderBuildingTurreted.cs => WithTurretedSpriteBody.cs} (75%) diff --git a/OpenRA.Mods.Cnc/Traits/AttackPopupTurreted.cs b/OpenRA.Mods.Cnc/Traits/AttackPopupTurreted.cs index 15db5c91ef..9299513e60 100644 --- a/OpenRA.Mods.Cnc/Traits/AttackPopupTurreted.cs +++ b/OpenRA.Mods.Cnc/Traits/AttackPopupTurreted.cs @@ -15,15 +15,25 @@ using OpenRA.Traits; namespace OpenRA.Mods.Cnc.Traits { [Desc("Actor's turret rises from the ground before attacking.")] - class AttackPopupTurretedInfo : AttackTurretedInfo, Requires, Requires + class AttackPopupTurretedInfo : AttackTurretedInfo, Requires, Requires { [Desc("How many game ticks should pass before closing the actor's turret.")] public int CloseDelay = 125; + public int DefaultFacing = 0; [Desc("The percentage of damage that is received while this actor is closed.")] public int ClosedDamageMultiplier = 50; + [Desc("Sequence to play when opening.")] + [SequenceReference] public string OpeningSequence = "opening"; + + [Desc("Sequence to play when closing.")] + [SequenceReference] public string ClosingSequence = "closing"; + + [Desc("Idle sequence to play when closed.")] + [SequenceReference] public string ClosedIdleSequence = "closed-idle"; + public override object Create(ActorInitializer init) { return new AttackPopupTurreted(init, this); } } @@ -32,11 +42,11 @@ namespace OpenRA.Mods.Cnc.Traits enum PopupState { Open, Rotating, Transitioning, Closed } readonly AttackPopupTurretedInfo info; - RenderBuilding rb; + readonly WithSpriteBody wsb; + readonly Turreted turret; int idleTicks = 0; PopupState state = PopupState.Open; - Turreted turret; bool skippedMakeAnimation; public AttackPopupTurreted(ActorInitializer init, AttackPopupTurretedInfo info) @@ -44,7 +54,7 @@ namespace OpenRA.Mods.Cnc.Traits { this.info = info; turret = turrets.FirstOrDefault(); - rb = init.Self.Trait(); + wsb = init.Self.Trait(); skippedMakeAnimation = init.Contains(); } @@ -60,10 +70,10 @@ namespace OpenRA.Mods.Cnc.Traits if (state == PopupState.Closed) { state = PopupState.Transitioning; - rb.PlayCustomAnimThen(self, "opening", () => + wsb.PlayCustomAnimation(self, info.OpeningSequence, () => { state = PopupState.Open; - rb.PlayCustomAnimRepeating(self, "idle"); + wsb.PlayCustomAnimationRepeating(self, wsb.Info.Sequence); }); return false; } @@ -81,10 +91,10 @@ namespace OpenRA.Mods.Cnc.Traits else if (state == PopupState.Rotating && turret.TurretFacing == info.DefaultFacing) { state = PopupState.Transitioning; - rb.PlayCustomAnimThen(self, "closing", () => + wsb.PlayCustomAnimation(self, info.ClosingSequence, () => { state = PopupState.Closed; - rb.PlayCustomAnimRepeating(self, "closed-idle"); + wsb.PlayCustomAnimationRepeating(self, info.ClosedIdleSequence); turret.DesiredFacing = null; }); } @@ -95,7 +105,7 @@ namespace OpenRA.Mods.Cnc.Traits if (skippedMakeAnimation) { state = PopupState.Closed; - rb.PlayCustomAnimRepeating(self, "closed-idle"); + wsb.PlayCustomAnimationRepeating(self, info.ClosedIdleSequence); turret.DesiredFacing = null; } } diff --git a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj index b18376aa1e..ec22d6a22d 100644 --- a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj +++ b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj @@ -406,8 +406,8 @@ - + diff --git a/OpenRA.Mods.Common/Traits/Render/RenderBuildingTurreted.cs b/OpenRA.Mods.Common/Traits/Render/WithTurretedSpriteBody.cs similarity index 75% rename from OpenRA.Mods.Common/Traits/Render/RenderBuildingTurreted.cs rename to OpenRA.Mods.Common/Traits/Render/WithTurretedSpriteBody.cs index 413ee3f180..36e7327f67 100644 --- a/OpenRA.Mods.Common/Traits/Render/RenderBuildingTurreted.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithTurretedSpriteBody.cs @@ -17,24 +17,25 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { - class RenderBuildingTurretedInfo : RenderBuildingInfo, Requires + [Desc("This actor has turret art with facings baked into the sprite.")] + public class WithTurretedSpriteBodyInfo : WithSpriteBodyInfo, Requires, Requires { - public override object Create(ActorInitializer init) { return new RenderBuildingTurreted(init, this); } + public override object Create(ActorInitializer init) { return new WithTurretedSpriteBody(init, this); } public override IEnumerable RenderPreviewSprites(ActorPreviewInitializer init, RenderSpritesInfo rs, string image, int facings, PaletteReference p) { - var t = init.Actor.Traits.WithInterface() - .FirstOrDefault(); + var t = init.Actor.Traits.WithInterface().FirstOrDefault(); + var wsb = init.Actor.Traits.WithInterface().FirstOrDefault(); // Show the correct turret facing var anim = new Animation(init.World, image, () => t.InitialFacing); - anim.PlayRepeating(RenderSprites.NormalizeSequence(anim, init.GetDamageState(), Sequence)); + anim.PlayRepeating(RenderSprites.NormalizeSequence(anim, init.GetDamageState(), wsb.Sequence)); yield return new SpriteActorPreview(anim, WVec.Zero, 0, p, rs.Scale); } } - class RenderBuildingTurreted : RenderBuilding + public class WithTurretedSpriteBody : WithSpriteBody { readonly Turreted turreted; @@ -45,7 +46,7 @@ namespace OpenRA.Mods.Common.Traits return () => turreted.TurretFacing; } - public RenderBuildingTurreted(ActorInitializer init, RenderBuildingInfo info) + public WithTurretedSpriteBody(ActorInitializer init, WithSpriteBodyInfo info) : base(init, info, MakeTurretFacingFunc(init.Self)) { turreted = init.Self.TraitsImplementing().FirstOrDefault(); diff --git a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs index 979287a349..7078102a48 100644 --- a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs +++ b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs @@ -1875,6 +1875,33 @@ namespace OpenRA.Mods.Common.UtilityCommands if (rrb != null) rrb.Key = "-WithSiloAnimation"; } + + // Replaced RenderBuildingTurreted with RenderSprites + WithTurretedSpriteBody (+AutoSelectionSize) + if (depth == 0) + { + var childKeysExcludeFromRS = new[] { "Sequence", "PauseOnLowPower" }; + + var rb = node.Value.Nodes.FirstOrDefault(n => n.Key.StartsWith("RenderBuildingTurreted")); + if (rb != null) + { + rb.Key = "WithTurretedSpriteBody"; + + var rsNodes = rb.Value.Nodes.Where(n => !childKeysExcludeFromRS.Contains(n.Key)).ToList(); + + if (rsNodes.Any()) + node.Value.Nodes.Add(new MiniYamlNode("RenderSprites", new MiniYaml("", rsNodes))); + else + node.Value.Nodes.Add(new MiniYamlNode("RenderSprites", "")); + + node.Value.Nodes.Add(new MiniYamlNode("AutoSelectionSize", "")); + + rb.Value.Nodes.RemoveAll(n => rsNodes.Contains(n)); + } + + var rrb = node.Value.Nodes.FirstOrDefault(n => n.Key.StartsWith("-RenderBuildingTurreted")); + if (rrb != null) + rrb.Key = "-WithTurretedSpriteBody"; + } } UpgradeActorRules(engineVersion, ref node.Value.Nodes, node, depth + 1); diff --git a/mods/cnc/rules/structures.yaml b/mods/cnc/rules/structures.yaml index b8ef1febf4..d0e53b1f1d 100644 --- a/mods/cnc/rules/structures.yaml +++ b/mods/cnc/rules/structures.yaml @@ -654,7 +654,8 @@ GUN: Turreted: ROT: 12 InitialFacing: 50 - RenderBuildingTurreted: + RenderSprites: + WithTurretedSpriteBody: Armament: Weapon: TurretGun LocalOffset: 512,0,112 @@ -667,6 +668,7 @@ GUN: Range: 3 Power: Amount: -20 + -WithMakeAnimation: SAM: Inherits: ^Defense @@ -695,7 +697,9 @@ SAM: Turreted: ROT: 10 InitialFacing: 0 - RenderBuildingTurreted: + RenderSprites: + WithTurretedSpriteBody: + AutoSelectionSize: Armament: Weapon: SAMMissile MuzzleSequence: muzzle @@ -705,6 +709,7 @@ SAM: -RenderDetectionCircle: Power: Amount: -20 + -WithMakeAnimation: OBLI: Inherits: ^Defense diff --git a/mods/ra/maps/allies-05a/map.yaml b/mods/ra/maps/allies-05a/map.yaml index de13891713..2510f069a5 100644 --- a/mods/ra/maps/allies-05a/map.yaml +++ b/mods/ra/maps/allies-05a/map.yaml @@ -1729,8 +1729,9 @@ Rules: Turreted: ROT: 15 InitialFacing: 224 - RenderBuildingTurreted: + RenderSprites: Image: AGUN + WithTurretedSpriteBody: Armament: Weapon: MissionColt LocalOffset: 432,150,-30, 432,-150,-30 @@ -1738,6 +1739,7 @@ Rules: AutoTarget: -RenderBuilding: -Selectable: + -WithMakeAnimation: E1.Autotarget: Inherits: E1 Buildable: diff --git a/mods/ra/rules/structures.yaml b/mods/ra/rules/structures.yaml index 46bdc3802c..e377c63bb3 100644 --- a/mods/ra/rules/structures.yaml +++ b/mods/ra/rules/structures.yaml @@ -451,7 +451,8 @@ AGUN: Turreted: ROT: 15 InitialFacing: 224 - RenderBuildingTurreted: + RenderSprites: + WithTurretedSpriteBody: Armament: Weapon: ZSU-23 LocalOffset: 432,150,-30, 432,-150,-30 @@ -465,6 +466,7 @@ AGUN: Amount: -50 DetectCloaked: Range: 6 + -WithMakeAnimation: DOME: Inherits: ^Building @@ -610,7 +612,8 @@ GUN: Turreted: ROT: 12 InitialFacing: 50 - RenderBuildingTurreted: + RenderSprites: + WithTurretedSpriteBody: Armament: Weapon: TurretGun LocalOffset: 512,0,112 @@ -622,6 +625,7 @@ GUN: Amount: -40 DetectCloaked: Range: 7 + -WithMakeAnimation: FTUR: Inherits: ^Defense @@ -686,7 +690,8 @@ SAM: Turreted: ROT: 30 InitialFacing: 0 - RenderBuildingTurreted: + RenderSprites: + WithTurretedSpriteBody: Armament: Weapon: Nike MuzzleSequence: muzzle @@ -699,6 +704,7 @@ SAM: Amount: -40 DetectCloaked: Range: 5 + -WithMakeAnimation: ATEK: Inherits: ^Building diff --git a/mods/ts/rules/gdi-support.yaml b/mods/ts/rules/gdi-support.yaml index 46e34401e5..188e373f2f 100644 --- a/mods/ts/rules/gdi-support.yaml +++ b/mods/ts/rules/gdi-support.yaml @@ -123,6 +123,7 @@ GACTWR: ProvidesPrerequisite@buildingname: SelectionDecorations: VisualBounds: 48, 48, 0, -12 + -WithMakeAnimation: GAVULC: Inherits: ^BuildingPlug From bf51e0600de15419cb2a5eb260ba703b9c7f17b8 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Wed, 15 Jul 2015 07:25:43 +0200 Subject: [PATCH 05/11] RenderBuildingWall -> WithWallSpriteBody --- OpenRA.Mods.Common/OpenRA.Mods.Common.csproj | 2 +- ...rBuildingWall.cs => WithWallSpriteBody.cs} | 36 ++++++++----------- .../UtilityCommands/UpgradeRules.cs | 27 ++++++++++++++ mods/cnc/rules/civilian.yaml | 4 +-- mods/cnc/rules/defaults.yaml | 4 ++- mods/cnc/rules/structures.yaml | 6 ++-- mods/d2k/rules/defaults.yaml | 4 ++- mods/d2k/rules/structures.yaml | 4 ++- mods/ra/rules/defaults.yaml | 3 +- mods/ra/rules/structures.yaml | 12 +++---- mods/ts/rules/civilian-structures.yaml | 2 +- mods/ts/rules/defaults.yaml | 4 ++- mods/ts/rules/gdi-support.yaml | 3 +- 13 files changed, 71 insertions(+), 40 deletions(-) rename OpenRA.Mods.Common/Traits/Render/{RenderBuildingWall.cs => WithWallSpriteBody.cs} (80%) diff --git a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj index ec22d6a22d..6020d044b3 100644 --- a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj +++ b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj @@ -411,7 +411,7 @@ - + diff --git a/OpenRA.Mods.Common/Traits/Render/RenderBuildingWall.cs b/OpenRA.Mods.Common/Traits/Render/WithWallSpriteBody.cs similarity index 80% rename from OpenRA.Mods.Common/Traits/Render/RenderBuildingWall.cs rename to OpenRA.Mods.Common/Traits/Render/WithWallSpriteBody.cs index 29160a0e85..8976ef6742 100644 --- a/OpenRA.Mods.Common/Traits/Render/RenderBuildingWall.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithWallSpriteBody.cs @@ -17,11 +17,11 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { [Desc("Render trait for actors that change sprites if neighbors with the same trait are present.")] - class RenderBuildingWallInfo : RenderBuildingInfo + class WithWallSpriteBodyInfo : WithSpriteBodyInfo { public readonly string Type = "wall"; - public override object Create(ActorInitializer init) { return new RenderBuildingWall(init, this); } + public override object Create(ActorInitializer init) { return new WithWallSpriteBody(init, this); } public override IEnumerable RenderPreviewSprites(ActorPreviewInitializer init, RenderSpritesInfo rs, string image, int facings, PaletteReference p) { @@ -39,7 +39,7 @@ namespace OpenRA.Mods.Common.Traits var haveNeighbour = false; foreach (var n in kv.Value) { - var rb = init.World.Map.Rules.Actors[n].Traits.GetOrDefault(); + var rb = init.World.Map.Rules.Actors[n].Traits.GetOrDefault(); if (rb != null && rb.Type == Type) { haveNeighbour = true; @@ -68,33 +68,26 @@ namespace OpenRA.Mods.Common.Traits } } - class RenderBuildingWall : RenderBuilding, INotifyAddedToWorld, INotifyRemovedFromWorld + class WithWallSpriteBody : WithSpriteBody, INotifyAddedToWorld, INotifyRemovedFromWorld, ITick { - readonly RenderBuildingWallInfo info; + readonly WithWallSpriteBodyInfo wallInfo; int adjacent = 0; bool dirty = true; - public RenderBuildingWall(ActorInitializer init, RenderBuildingWallInfo info) - : base(init, info) + public WithWallSpriteBody(ActorInitializer init, WithWallSpriteBodyInfo info) + : base(init, info, () => 0) { - this.info = info; - } - - public override void BuildingComplete(Actor self) - { - DefaultAnimation.PlayFetchIndex(info.Sequence, () => adjacent); - UpdateNeighbours(self); + wallInfo = info; + DefaultAnimation.PlayFetchIndex(NormalizeSequence(init.Self, Info.Sequence), () => adjacent); } public override void DamageStateChanged(Actor self, AttackInfo e) { - DefaultAnimation.PlayFetchIndex(NormalizeSequence(DefaultAnimation, e.DamageState, info.Sequence), () => adjacent); + DefaultAnimation.PlayFetchIndex(NormalizeSequence(self, Info.Sequence), () => adjacent); } - public override void Tick(Actor self) + public void Tick(Actor self) { - base.Tick(self); - if (!dirty) return; @@ -105,8 +98,8 @@ namespace OpenRA.Mods.Common.Traits adjacent = 0; foreach (var a in adjacentActors) { - var rb = a.TraitOrDefault(); - if (rb == null || rb.info.Type != info.Type) + var rb = a.TraitOrDefault(); + if (rb == null || rb.wallInfo.Type != wallInfo.Type) continue; var location = self.Location; @@ -129,7 +122,7 @@ namespace OpenRA.Mods.Common.Traits { var adjacentActors = CVec.Directions.SelectMany(dir => self.World.ActorMap.GetUnitsAt(self.Location + dir)) - .Select(a => a.TraitOrDefault()) + .Select(a => a.TraitOrDefault()) .Where(a => a != null); foreach (var rb in adjacentActors) @@ -138,6 +131,7 @@ namespace OpenRA.Mods.Common.Traits public void AddedToWorld(Actor self) { + DefaultAnimation.PlayFetchIndex(NormalizeSequence(self, Info.Sequence), () => adjacent); UpdateNeighbours(self); } diff --git a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs index 7078102a48..8968e854ba 100644 --- a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs +++ b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs @@ -1902,6 +1902,33 @@ namespace OpenRA.Mods.Common.UtilityCommands if (rrb != null) rrb.Key = "-WithTurretedSpriteBody"; } + + // Replaced RenderBuildingWall with RenderSprites + WithWallSpriteBody (+AutoSelectionSize) + if (depth == 0) + { + var childKeysExcludeFromRS = new[] { "Sequence", "Type" }; + + var rb = node.Value.Nodes.FirstOrDefault(n => n.Key.StartsWith("RenderBuildingWall")); + if (rb != null) + { + rb.Key = "WithWallSpriteBody"; + + var rsNodes = rb.Value.Nodes.Where(n => !childKeysExcludeFromRS.Contains(n.Key)).ToList(); + + if (rsNodes.Any()) + node.Value.Nodes.Add(new MiniYamlNode("RenderSprites", new MiniYaml("", rsNodes))); + else + node.Value.Nodes.Add(new MiniYamlNode("RenderSprites", "")); + + node.Value.Nodes.Add(new MiniYamlNode("AutoSelectionSize", "")); + + rb.Value.Nodes.RemoveAll(n => rsNodes.Contains(n)); + } + + var rrb = node.Value.Nodes.FirstOrDefault(n => n.Key.StartsWith("-RenderBuildingWall")); + if (rrb != null) + rrb.Key = "-WithWallSpriteBody"; + } } UpgradeActorRules(engineVersion, ref node.Value.Nodes, node, depth + 1); diff --git a/mods/cnc/rules/civilian.yaml b/mods/cnc/rules/civilian.yaml index fc02e60d23..ce160cf1bd 100644 --- a/mods/cnc/rules/civilian.yaml +++ b/mods/cnc/rules/civilian.yaml @@ -287,7 +287,7 @@ BARB: NodeTypes: barbwire LineBuildNode: Types: barbwire - RenderBuildingWall: + WithWallSpriteBody: Type: barbwire WOOD: @@ -303,7 +303,7 @@ WOOD: NodeTypes: woodfence LineBuildNode: Types: woodfence - RenderBuildingWall: + WithWallSpriteBody: Type: woodfence BRIDGE1: diff --git a/mods/cnc/rules/defaults.yaml b/mods/cnc/rules/defaults.yaml index 46d7572e6d..87e44b605a 100644 --- a/mods/cnc/rules/defaults.yaml +++ b/mods/cnc/rules/defaults.yaml @@ -560,8 +560,10 @@ Types: wall BodyOrientation: QuantizedFacings: 1 - RenderBuildingWall: + RenderSprites: Palette: staticterrain + WithWallSpriteBody: + AutoSelectionSize: GivesExperience: AutoTargetIgnore: Sellable: diff --git a/mods/cnc/rules/structures.yaml b/mods/cnc/rules/structures.yaml index d0e53b1f1d..611c7849dd 100644 --- a/mods/cnc/rules/structures.yaml +++ b/mods/cnc/rules/structures.yaml @@ -862,7 +862,7 @@ SBAG: NodeTypes: sandbag LineBuildNode: Types: sandbag - RenderBuildingWall: + WithWallSpriteBody: Type: sandbag CYCL: @@ -887,7 +887,7 @@ CYCL: NodeTypes: chain LineBuildNode: Types: chain - RenderBuildingWall: + WithWallSpriteBody: Type: chain BRIK: @@ -917,7 +917,7 @@ BRIK: NodeTypes: concrete LineBuildNode: Types: concrete - RenderBuildingWall: + WithWallSpriteBody: Type: concrete BARRACKS: diff --git a/mods/d2k/rules/defaults.yaml b/mods/d2k/rules/defaults.yaml index 00da36ee6f..c6491bdc77 100644 --- a/mods/d2k/rules/defaults.yaml +++ b/mods/d2k/rules/defaults.yaml @@ -312,7 +312,9 @@ -WithCrumbleOverlay: -WithMakeAnimation: -RenderBuilding: - RenderBuildingWall: + RenderSprites: + WithWallSpriteBody: + AutoSelectionSize: LineBuildNode: Types: turret MustBeDestroyed: diff --git a/mods/d2k/rules/structures.yaml b/mods/d2k/rules/structures.yaml index 69de28c6ca..cda6dc708d 100644 --- a/mods/d2k/rules/structures.yaml +++ b/mods/d2k/rules/structures.yaml @@ -513,7 +513,9 @@ wall: Types: wall TargetableBuilding: TargetTypes: Ground, Wall - RenderBuildingWall: + RenderSprites: + WithWallSpriteBody: + AutoSelectionSize: AutoTargetIgnore: Sellable: SellSounds: CHUNG.WAV diff --git a/mods/ra/rules/defaults.yaml b/mods/ra/rules/defaults.yaml index 14921451c6..5974b4df2b 100644 --- a/mods/ra/rules/defaults.yaml +++ b/mods/ra/rules/defaults.yaml @@ -462,8 +462,9 @@ Types: wall TargetableBuilding: TargetTypes: Ground, DetonateAttack, Wall - RenderBuildingWall: + RenderSprites: Palette: effect + WithWallSpriteBody: GivesExperience: AutoTargetIgnore: ProximityCaptor: diff --git a/mods/ra/rules/structures.yaml b/mods/ra/rules/structures.yaml index e377c63bb3..aa43ffe048 100644 --- a/mods/ra/rules/structures.yaml +++ b/mods/ra/rules/structures.yaml @@ -1514,7 +1514,7 @@ SBAG: NodeTypes: sandbag LineBuildNode: Types: sandbag - RenderBuildingWall: + WithWallSpriteBody: Type: sandbag FENC: @@ -1539,7 +1539,7 @@ FENC: NodeTypes: fence LineBuildNode: Types: fence - RenderBuildingWall: + WithWallSpriteBody: Type: fence BRIK: @@ -1569,7 +1569,7 @@ BRIK: NodeTypes: concrete LineBuildNode: Types: concrete - RenderBuildingWall: + WithWallSpriteBody: Type: concrete CYCL: @@ -1584,7 +1584,7 @@ CYCL: NodeTypes: chain LineBuildNode: Types: chain - RenderBuildingWall: + WithWallSpriteBody: Type: chain BARB: @@ -1599,7 +1599,7 @@ BARB: NodeTypes: barbwire LineBuildNode: Types: barbwire - RenderBuildingWall: + WithWallSpriteBody: Type: barbwire WOOD: @@ -1614,7 +1614,7 @@ WOOD: NodeTypes: woodfence LineBuildNode: Types: woodfence - RenderBuildingWall: + WithWallSpriteBody: Type: woodfence BARRACKS: diff --git a/mods/ts/rules/civilian-structures.yaml b/mods/ts/rules/civilian-structures.yaml index 1e6546d8c5..70695da9e8 100644 --- a/mods/ts/rules/civilian-structures.yaml +++ b/mods/ts/rules/civilian-structures.yaml @@ -1237,7 +1237,7 @@ GASAND: NodeTypes: sandbags LineBuildNode: Types: sandbags - RenderBuildingWall: + WithWallSpriteBody: Type: sandbags GASPOT: diff --git a/mods/ts/rules/defaults.yaml b/mods/ts/rules/defaults.yaml index a44a716de4..cfaf6d1532 100644 --- a/mods/ts/rules/defaults.yaml +++ b/mods/ts/rules/defaults.yaml @@ -166,7 +166,9 @@ Types: wall TargetableBuilding: TargetTypes: Ground, Wall, C4 - RenderBuildingWall: + RenderSprites: + AutoSelectionSize: + WithWallSpriteBody: Type: wall GivesExperience: AutoTargetIgnore: diff --git a/mods/ts/rules/gdi-support.yaml b/mods/ts/rules/gdi-support.yaml index 188e373f2f..3ec5e206a6 100644 --- a/mods/ts/rules/gdi-support.yaml +++ b/mods/ts/rules/gdi-support.yaml @@ -103,7 +103,8 @@ GACTWR: LineBuildNode: Types: turret -RenderBuilding: - RenderBuildingWall: + RenderSprites: + WithWallSpriteBody: Type: wall Power@base: Amount: -10 From 9da56f51e21064088f29e14d90839c27e10f240a Mon Sep 17 00:00:00 2001 From: reaperrr Date: Wed, 15 Jul 2015 07:29:45 +0200 Subject: [PATCH 06/11] Remove RenderBuilding --- .../Traits/Render/WithDeliveryAnimation.cs | 10 +-- OpenRA.Mods.Common/Activities/Rearm.cs | 4 +- OpenRA.Mods.Common/OpenRA.Mods.Common.csproj | 1 - .../Traits/Buildings/Refinery.cs | 3 +- .../Traits/Render/RenderBuilding.cs | 81 ------------------- .../Traits/Render/WithActiveAnimation.cs | 8 +- .../Render/WithBuildingPlacedAnimation.cs | 12 +-- .../Traits/Render/WithMakeAnimation.cs | 16 ++-- .../Traits/Render/WithRepairAnimation.cs | 8 +- .../Traits/Render/WithResources.cs | 10 ++- .../Traits/Render/WithSpriteBody.cs | 8 +- .../Traits/SupportPowers/GrantUpgradePower.cs | 5 +- .../Traits/SupportPowers/NukePower.cs | 8 +- .../UtilityCommands/UpgradeRules.cs | 34 ++++++++ OpenRA.Mods.RA/Activities/Teleport.cs | 4 +- mods/cnc/rules/defaults.yaml | 16 +++- mods/cnc/rules/misc.yaml | 2 +- mods/cnc/rules/structures.yaml | 26 ++---- mods/cnc/rules/tech.yaml | 2 - mods/cnc/rules/trees.yaml | 4 +- mods/d2k/rules/arrakis.yaml | 4 +- mods/d2k/rules/defaults.yaml | 6 +- mods/d2k/rules/structures.yaml | 32 ++++---- mods/ra/maps/allies-05a/map.yaml | 2 - mods/ra/maps/bomber-john/map.yaml | 7 +- .../maps/center-of-attention-redux-2/map.yaml | 4 +- mods/ra/maps/monster-tank-madness/map.yaml | 2 +- mods/ra/maps/soviet-05/map.yaml | 2 +- mods/ra/maps/survival01/map.yaml | 4 +- mods/ra/rules/civilian.yaml | 3 +- mods/ra/rules/defaults.yaml | 8 +- mods/ra/rules/fakes.yaml | 16 ++-- mods/ra/rules/misc.yaml | 2 +- mods/ra/rules/structures.yaml | 24 ++---- mods/ts/rules/civilian-structures.yaml | 32 ++++---- mods/ts/rules/defaults.yaml | 14 +++- mods/ts/rules/gdi-structures.yaml | 3 +- mods/ts/rules/gdi-support.yaml | 8 +- mods/ts/rules/nod-support.yaml | 1 - mods/ts/rules/shared-structures.yaml | 4 +- mods/ts/rules/shared-support.yaml | 2 +- mods/ts/rules/trees.yaml | 2 +- 42 files changed, 196 insertions(+), 248 deletions(-) delete mode 100644 OpenRA.Mods.Common/Traits/Render/RenderBuilding.cs diff --git a/OpenRA.Mods.Cnc/Traits/Render/WithDeliveryAnimation.cs b/OpenRA.Mods.Cnc/Traits/Render/WithDeliveryAnimation.cs index 5b6b3613e7..e043fb802f 100644 --- a/OpenRA.Mods.Cnc/Traits/Render/WithDeliveryAnimation.cs +++ b/OpenRA.Mods.Cnc/Traits/Render/WithDeliveryAnimation.cs @@ -14,7 +14,7 @@ using OpenRA.Traits; namespace OpenRA.Mods.Cnc.Traits { [Desc("Building animation to play when ProductionAirdrop is used to deliver units.")] - public class WithDeliveryAnimationInfo : ITraitInfo, Requires + public class WithDeliveryAnimationInfo : ITraitInfo, Requires { public readonly string ActiveSequence = "active"; @@ -26,23 +26,23 @@ namespace OpenRA.Mods.Cnc.Traits public class WithDeliveryAnimation : INotifyDelivery { readonly WithDeliveryAnimationInfo info; - readonly RenderBuilding building; + readonly WithSpriteBody wsb; public WithDeliveryAnimation(Actor self, WithDeliveryAnimationInfo info) { - building = self.Trait(); + wsb = self.Trait(); this.info = info; } public void IncomingDelivery(Actor self) { - building.PlayCustomAnimRepeating(self, info.ActiveSequence); + wsb.PlayCustomAnimationRepeating(self, info.ActiveSequence); } public void Delivered(Actor self) { - building.PlayCustomAnimRepeating(self, info.IdleSequence); + wsb.PlayCustomAnimationRepeating(self, info.IdleSequence); } } } \ No newline at end of file diff --git a/OpenRA.Mods.Common/Activities/Rearm.cs b/OpenRA.Mods.Common/Activities/Rearm.cs index 6c4bace567..f8b4c065af 100644 --- a/OpenRA.Mods.Common/Activities/Rearm.cs +++ b/OpenRA.Mods.Common/Activities/Rearm.cs @@ -48,7 +48,7 @@ namespace OpenRA.Mods.Common.Activities continue; // HACK to check if we are on the helipad/airfield/etc. - var hostBuilding = self.World.ActorMap.GetUnitsAt(self.Location).FirstOrDefault(a => a.HasTrait()); + var hostBuilding = self.World.ActorMap.GetUnitsAt(self.Location).FirstOrDefault(a => a.HasTrait()); if (hostBuilding == null || !hostBuilding.IsInWorld) return NextActivity; @@ -56,7 +56,7 @@ namespace OpenRA.Mods.Common.Activities if (!pool.GiveAmmo()) continue; - hostBuilding.Trait().PlayCustomAnim(hostBuilding, "active"); + hostBuilding.Trait().PlayCustomAnimation(hostBuilding, "active"); var sound = pool.Info.RearmSound; if (sound != null) diff --git a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj index 6020d044b3..39b3192914 100644 --- a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj +++ b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj @@ -405,7 +405,6 @@ - diff --git a/OpenRA.Mods.Common/Traits/Buildings/Refinery.cs b/OpenRA.Mods.Common/Traits/Buildings/Refinery.cs index f152a180c4..6a87c67a19 100644 --- a/OpenRA.Mods.Common/Traits/Buildings/Refinery.cs +++ b/OpenRA.Mods.Common/Traits/Buildings/Refinery.cs @@ -105,7 +105,8 @@ namespace OpenRA.Mods.Common.Traits // Harvester was killed while unloading if (dockedHarv != null && dockedHarv.IsDead) { - self.Trait().CancelCustomAnim(self); + var wsb = self.Trait(); + wsb.PlayCustomAnimation(self, wsb.Info.Sequence); dockedHarv = null; } diff --git a/OpenRA.Mods.Common/Traits/Render/RenderBuilding.cs b/OpenRA.Mods.Common/Traits/Render/RenderBuilding.cs deleted file mode 100644 index c8333623b5..0000000000 --- a/OpenRA.Mods.Common/Traits/Render/RenderBuilding.cs +++ /dev/null @@ -1,81 +0,0 @@ -#region Copyright & License Information -/* - * Copyright 2007-2015 The OpenRA Developers (see AUTHORS) - * This file is part of OpenRA, which is free software. It is made - * available to you under the terms of the GNU General Public License - * as published by the Free Software Foundation. For more information, - * see COPYING. - */ -#endregion - -using System; -using System.Collections.Generic; -using System.Linq; -using OpenRA.Graphics; -using OpenRA.Traits; - -namespace OpenRA.Mods.Common.Traits -{ - [Desc("Render trait for stationary objects that can be placed from the build palette.")] - public class RenderBuildingInfo : RenderSimpleInfo, Requires - { - public readonly bool PauseOnLowPower = false; - - public override object Create(ActorInitializer init) { return new RenderBuilding(init, this); } - } - - public class RenderBuilding : RenderSimple, INotifyDamageStateChanged, INotifyBuildComplete - { - RenderBuildingInfo info; - - public RenderBuilding(ActorInitializer init, RenderBuildingInfo info) - : this(init, info, () => 0) { } - - public RenderBuilding(ActorInitializer init, RenderBuildingInfo info, Func baseFacing) - : base(init, info, baseFacing) - { - var self = init.Self; - this.info = info; - - DefaultAnimation.PlayRepeating(NormalizeSequence(self, info.Sequence)); - } - - public virtual void BuildingComplete(Actor self) - { - DefaultAnimation.PlayRepeating(NormalizeSequence(self, info.Sequence)); - - if (info.PauseOnLowPower) - DefaultAnimation.Paused = () => - self.IsDisabled() && DefaultAnimation.CurrentSequence.Name == NormalizeSequence(self, info.Sequence); - } - - public void PlayCustomAnimThen(Actor self, string name, Action a) - { - DefaultAnimation.PlayThen(NormalizeSequence(self, name), - () => { DefaultAnimation.PlayRepeating(NormalizeSequence(self, info.Sequence)); a(); }); - } - - public void PlayCustomAnimRepeating(Actor self, string name) - { - DefaultAnimation.PlayThen(NormalizeSequence(self, name), - () => PlayCustomAnimRepeating(self, name)); - } - - public void PlayCustomAnimBackwards(Actor self, string name, Action a) - { - DefaultAnimation.PlayBackwardsThen(NormalizeSequence(self, name), - () => { DefaultAnimation.PlayRepeating(NormalizeSequence(self, info.Sequence)); a(); }); - } - - public void CancelCustomAnim(Actor self) - { - DefaultAnimation.PlayRepeating(NormalizeSequence(self, info.Sequence)); - } - - public virtual void DamageStateChanged(Actor self, AttackInfo e) - { - if (DefaultAnimation.CurrentSequence != null) - DefaultAnimation.ReplaceAnim(NormalizeSequence(self, DefaultAnimation.CurrentSequence.Name)); - } - } -} diff --git a/OpenRA.Mods.Common/Traits/Render/WithActiveAnimation.cs b/OpenRA.Mods.Common/Traits/Render/WithActiveAnimation.cs index da1c054ff8..2357568be9 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithActiveAnimation.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithActiveAnimation.cs @@ -16,7 +16,7 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { [Desc("Replaces the idle animation of a building.")] - public class WithActiveAnimationInfo : ITraitInfo, Requires + public class WithActiveAnimationInfo : ITraitInfo, Requires { [Desc("Sequence name to use")] [SequenceReference] public readonly string Sequence = "active"; @@ -31,11 +31,11 @@ namespace OpenRA.Mods.Common.Traits public class WithActiveAnimation : ITick, INotifyBuildComplete, INotifySold { readonly WithActiveAnimationInfo info; - readonly RenderBuilding renderBuilding; + readonly WithSpriteBody wsb; public WithActiveAnimation(Actor self, WithActiveAnimationInfo info) { - renderBuilding = self.Trait(); + wsb = self.Trait(); this.info = info; } @@ -48,7 +48,7 @@ namespace OpenRA.Mods.Common.Traits if (--ticks <= 0) { if (!(info.PauseOnLowPower && self.IsDisabled())) - renderBuilding.PlayCustomAnim(self, info.Sequence); + wsb.PlayCustomAnimation(self, info.Sequence); ticks = info.Interval; } } diff --git a/OpenRA.Mods.Common/Traits/Render/WithBuildingPlacedAnimation.cs b/OpenRA.Mods.Common/Traits/Render/WithBuildingPlacedAnimation.cs index 0e5b19bd93..5b6294fe0b 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithBuildingPlacedAnimation.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithBuildingPlacedAnimation.cs @@ -13,10 +13,10 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { [Desc("Changes the animation when the actor constructed a building.")] - public class WithBuildingPlacedAnimationInfo : ITraitInfo, Requires + public class WithBuildingPlacedAnimationInfo : ITraitInfo, Requires { - [Desc("Sequence name to use")] - [SequenceReference] public readonly string Sequence = "build"; + [Desc("Sequence name to use"), SequenceReference] + public readonly string Sequence = "build"; public object Create(ActorInitializer init) { return new WithBuildingPlacedAnimation(init.Self, this); } } @@ -24,13 +24,13 @@ namespace OpenRA.Mods.Common.Traits public class WithBuildingPlacedAnimation : INotifyBuildingPlaced, INotifyBuildComplete { readonly WithBuildingPlacedAnimationInfo info; - readonly RenderSimple renderSimple; + readonly WithSpriteBody wsb; bool buildComplete; public WithBuildingPlacedAnimation(Actor self, WithBuildingPlacedAnimationInfo info) { this.info = info; - renderSimple = self.Trait(); + wsb = self.Trait(); buildComplete = !self.HasTrait(); } @@ -42,7 +42,7 @@ namespace OpenRA.Mods.Common.Traits public void BuildingPlaced(Actor self) { if (buildComplete) - renderSimple.PlayCustomAnim(self, info.Sequence); + wsb.PlayCustomAnimation(self, info.Sequence, () => wsb.CancelCustomAnimation(self)); } } } \ No newline at end of file diff --git a/OpenRA.Mods.Common/Traits/Render/WithMakeAnimation.cs b/OpenRA.Mods.Common/Traits/Render/WithMakeAnimation.cs index e12da66ff4..b502c6584a 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithMakeAnimation.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithMakeAnimation.cs @@ -18,7 +18,7 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { [Desc("Replaces the sprite during construction.")] - public class WithMakeAnimationInfo : ITraitInfo, Requires, Requires + public class WithMakeAnimationInfo : ITraitInfo, Requires { [Desc("Sequence name to use")] [SequenceReference] public readonly string Sequence = "make"; @@ -29,18 +29,18 @@ namespace OpenRA.Mods.Common.Traits public class WithMakeAnimation { readonly WithMakeAnimationInfo info; - readonly RenderBuilding renderBuilding; + readonly WithSpriteBody wsb; public WithMakeAnimation(ActorInitializer init, WithMakeAnimationInfo info) { this.info = info; var self = init.Self; - renderBuilding = self.Trait(); + wsb = self.Trait(); - var building = self.Trait(); - if (!building.SkipMakeAnimation) + var building = self.TraitOrDefault(); + if (building != null && !building.SkipMakeAnimation) { - renderBuilding.PlayCustomAnimThen(self, info.Sequence, () => + wsb.PlayCustomAnimation(self, info.Sequence, () => { building.NotifyBuildingComplete(self); }); @@ -49,10 +49,10 @@ namespace OpenRA.Mods.Common.Traits public void Reverse(Actor self, Activity activity, bool queued = true) { - renderBuilding.PlayCustomAnimBackwards(self, info.Sequence, () => + wsb.PlayCustomAnimationBackwards(self, info.Sequence, () => { // avoids visual glitches as we wait for the actor to get destroyed - renderBuilding.DefaultAnimation.PlayFetchIndex(info.Sequence, () => 0); + wsb.DefaultAnimation.PlayFetchIndex(info.Sequence, () => 0); self.QueueActivity(queued, activity); }); } diff --git a/OpenRA.Mods.Common/Traits/Render/WithRepairAnimation.cs b/OpenRA.Mods.Common/Traits/Render/WithRepairAnimation.cs index d42abf1a1a..5aa6b86d39 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithRepairAnimation.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithRepairAnimation.cs @@ -15,7 +15,7 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { [Desc("Replaces the building animation when it repairs a unit.")] - public class WithRepairAnimationInfo : ITraitInfo, Requires + public class WithRepairAnimationInfo : ITraitInfo, Requires { [Desc("Sequence name to use")] [SequenceReference] public readonly string Sequence = "active"; @@ -36,9 +36,9 @@ namespace OpenRA.Mods.Common.Traits public void Repairing(Actor self, Actor host) { - var building = host.TraitOrDefault(); - if (building != null && !(info.PauseOnLowPower && self.IsDisabled())) - building.PlayCustomAnim(host, info.Sequence); + var spriteBody = host.TraitOrDefault(); + if (spriteBody != null && !(info.PauseOnLowPower && self.IsDisabled())) + spriteBody.PlayCustomAnimation(host, info.Sequence); } } } \ No newline at end of file diff --git a/OpenRA.Mods.Common/Traits/Render/WithResources.cs b/OpenRA.Mods.Common/Traits/Render/WithResources.cs index 8f5540b957..46bc33f62d 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithResources.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithResources.cs @@ -14,7 +14,7 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { [Desc("Displays the fill status of PlayerResources with an extra sprite overlay on the actor.")] - class WithResourcesInfo : ITraitInfo, Requires + class WithResourcesInfo : ITraitInfo, Requires, Requires { [Desc("Sequence name to use")] [SequenceReference] public readonly string Sequence = "resources"; @@ -26,7 +26,8 @@ namespace OpenRA.Mods.Common.Traits { readonly WithResourcesInfo info; readonly AnimationWithOffset anim; - readonly RenderSimple rs; + readonly RenderSprites rs; + readonly WithSpriteBody wsb; PlayerResources playerResources; bool buildComplete; @@ -34,7 +35,8 @@ namespace OpenRA.Mods.Common.Traits public WithResources(Actor self, WithResourcesInfo info) { this.info = info; - rs = self.Trait(); + rs = self.Trait(); + wsb = self.Trait(); playerResources = self.Owner.PlayerActor.Trait(); var a = new Animation(self.World, rs.GetImage(self)); @@ -55,7 +57,7 @@ namespace OpenRA.Mods.Common.Traits public void DamageStateChanged(Actor self, AttackInfo e) { if (anim.Animation.CurrentSequence != null) - anim.Animation.ReplaceAnim(rs.NormalizeSequence(self, info.Sequence)); + anim.Animation.ReplaceAnim(wsb.NormalizeSequence(self, info.Sequence)); } public void OnOwnerChanged(Actor self, Player oldOwner, Player newOwner) diff --git a/OpenRA.Mods.Common/Traits/Render/WithSpriteBody.cs b/OpenRA.Mods.Common/Traits/Render/WithSpriteBody.cs index dbb82faed1..dd57f52fda 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithSpriteBody.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithSpriteBody.cs @@ -19,11 +19,11 @@ namespace OpenRA.Mods.Common.Traits [Desc("Default trait for rendering sprite-based actors.")] public class WithSpriteBodyInfo : UpgradableTraitInfo, IRenderActorPreviewSpritesInfo, Requires { - [Desc("Animation to play when the actor is created.")] - [SequenceReference] public readonly string StartSequence = null; + [Desc("Animation to play when the actor is created."), SequenceReference] + public readonly string StartSequence = null; - [Desc("Animation to play when the actor is idle.")] - [SequenceReference] public readonly string Sequence = "idle"; + [Desc("Animation to play when the actor is idle."), SequenceReference] + public readonly string Sequence = "idle"; [Desc("Pause animation when actor is disabled.")] public readonly bool PauseAnimationWhenDisabled = false; diff --git a/OpenRA.Mods.Common/Traits/SupportPowers/GrantUpgradePower.cs b/OpenRA.Mods.Common/Traits/SupportPowers/GrantUpgradePower.cs index 1e7f7a1109..02961e2bb9 100644 --- a/OpenRA.Mods.Common/Traits/SupportPowers/GrantUpgradePower.cs +++ b/OpenRA.Mods.Common/Traits/SupportPowers/GrantUpgradePower.cs @@ -30,6 +30,9 @@ namespace OpenRA.Mods.Common.Traits public readonly int Range = 1; public readonly string GrantUpgradeSound = "ironcur9.aud"; + [Desc("Sequence to play for granting actor when activated."), SequenceReference] + public readonly string GrantUpgradeSequence = "active"; + public override object Create(ActorInitializer init) { return new GrantUpgradePower(init.Self, this); } } @@ -53,7 +56,7 @@ namespace OpenRA.Mods.Common.Traits { base.Activate(self, order, manager); - self.Trait().PlayCustomAnim(self, "active"); + self.Trait().PlayCustomAnimation(self, info.GrantUpgradeSequence); Sound.Play(info.GrantUpgradeSound, self.World.Map.CenterOfCell(order.TargetLocation)); diff --git a/OpenRA.Mods.Common/Traits/SupportPowers/NukePower.cs b/OpenRA.Mods.Common/Traits/SupportPowers/NukePower.cs index cf4d141ab7..eb747d3a35 100644 --- a/OpenRA.Mods.Common/Traits/SupportPowers/NukePower.cs +++ b/OpenRA.Mods.Common/Traits/SupportPowers/NukePower.cs @@ -47,6 +47,10 @@ namespace OpenRA.Mods.Common.Traits public readonly string FlashType = null; + [SequenceReference] + [Desc("Sequence the launching actor should play when activating this power.")] + public readonly string ActivationSequence = "active"; + public override object Create(ActorInitializer init) { return new NukePower(init.Self, this); } } @@ -71,8 +75,8 @@ namespace OpenRA.Mods.Common.Traits else Sound.Play(Info.IncomingSound); - var rb = self.Trait(); - rb.PlayCustomAnim(self, "active"); + var wsb = self.Trait(); + wsb.PlayCustomAnimation(self, info.ActivationSequence); var targetPosition = self.World.Map.CenterOfCell(order.TargetLocation); var missile = new NukeLaunch(self.Owner, info.MissileWeapon, diff --git a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs index 8968e854ba..6bc1f40c0a 100644 --- a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs +++ b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs @@ -1931,6 +1931,40 @@ namespace OpenRA.Mods.Common.UtilityCommands } } + if (engineVersion < 20150828) + { + // Replaced RenderBuilding with RenderSprites + WithSpriteBody (+AutoSelectionSize) + if (depth == 0) + { + var childKeysExcludeFromRS = new[] { "Sequence", "PauseOnLowPower" }; + + var rb = node.Value.Nodes.FirstOrDefault(n => n.Key.StartsWith("RenderBuilding")); + if (rb != null) + { + rb.Key = "WithSpriteBody"; + + var rsNodes = rb.Value.Nodes.Where(n => !childKeysExcludeFromRS.Contains(n.Key)).ToList(); + + if (rsNodes.Any()) + node.Value.Nodes.Add(new MiniYamlNode("RenderSprites", new MiniYaml("", rsNodes))); + else + node.Value.Nodes.Add(new MiniYamlNode("RenderSprites", "")); + + node.Value.Nodes.Add(new MiniYamlNode("AutoSelectionSize", "")); + + rb.Value.Nodes.RemoveAll(n => rsNodes.Contains(n)); + } + + var rrb = node.Value.Nodes.FirstOrDefault(n => n.Key.StartsWith("-RenderBuilding")); + if (rrb != null) + rrb.Key = "-WithSpriteBody"; + + if (depth == 2 && node.Key == "PauseOnLowPower" && (parentKey == "WithSpriteBody" + || parentKey == "WithTurretedSpriteBody" || parentKey == "WithWallSpriteBody")) + node.Key = "PauseAnimationWhenDisabled"; + } + } + UpgradeActorRules(engineVersion, ref node.Value.Nodes, node, depth + 1); } } diff --git a/OpenRA.Mods.RA/Activities/Teleport.cs b/OpenRA.Mods.RA/Activities/Teleport.cs index 958b791013..21384d8c0b 100644 --- a/OpenRA.Mods.RA/Activities/Teleport.cs +++ b/OpenRA.Mods.RA/Activities/Teleport.cs @@ -92,9 +92,9 @@ namespace OpenRA.Mods.RA.Activities if (teleporter != null && self != teleporter && !teleporter.Disposed) { - var building = teleporter.TraitOrDefault(); + var building = teleporter.TraitOrDefault(); if (building != null) - building.PlayCustomAnim(teleporter, "active"); + building.PlayCustomAnimation(teleporter, "active"); } return NextActivity; diff --git a/mods/cnc/rules/defaults.yaml b/mods/cnc/rules/defaults.yaml index 87e44b605a..4db7199592 100644 --- a/mods/cnc/rules/defaults.yaml +++ b/mods/cnc/rules/defaults.yaml @@ -432,7 +432,9 @@ DamagedSounds: xplos.aud DestroyedSounds: crumble.aud QuantizeFacingsFromSequence: - RenderBuilding: + RenderSprites: + WithSpriteBody: + AutoSelectionSize: WithBuildingExplosion: Delay: 1 CaptureNotification: @@ -489,7 +491,9 @@ Dimensions: 1,1 Footprint: x QuantizeFacingsFromSequence: - RenderBuilding: + RenderSprites: + WithSpriteBody: + AutoSelectionSize: Tooltip: Name: Civilian Building (Destroyed) GenericVisibility: None @@ -518,8 +522,10 @@ -WithBuildingExplosion: -TargetableBuilding: -Demolishable: - RenderBuilding: + RenderSprites: Palette: terrain + WithSpriteBody: + AutoSelectionSize: ^CivFieldHusk: AppearsOnRadar: @@ -601,8 +607,10 @@ Name: Blossom Tree BodyOrientation: QuantizedFacings: 1 - RenderBuilding: + RenderSprites: Palette: staticterrain + WithSpriteBody: + AutoSelectionSize: Building: Footprint: x Dimensions: 1,1 diff --git a/mods/cnc/rules/misc.yaml b/mods/cnc/rules/misc.yaml index bb064e94e9..c1c7bcc29d 100644 --- a/mods/cnc/rules/misc.yaml +++ b/mods/cnc/rules/misc.yaml @@ -47,7 +47,7 @@ waypoint: ^fact.colorpicker: Inherits: FACT - RenderBuilding: + RenderSprites: Image: fact Palette: colorpicker diff --git a/mods/cnc/rules/structures.yaml b/mods/cnc/rules/structures.yaml index 611c7849dd..91bd582fa2 100644 --- a/mods/cnc/rules/structures.yaml +++ b/mods/cnc/rules/structures.yaml @@ -72,7 +72,7 @@ FACT: FACT.GDI: Inherits: FACT - RenderBuilding: + RenderSprites: Image: fact Buildable: Queue: Building.GDI, Building.Nod @@ -84,7 +84,7 @@ FACT.GDI: FACT.NOD: Inherits: FACT - RenderBuilding: + RenderSprites: Image: fact Buildable: Queue: Building.GDI, Building.Nod @@ -218,7 +218,6 @@ SILO: PipCount: 10 PipColor: Green Capacity: 2000 - -RenderBuilding: -EmitInfantryOnSell: Power: Amount: -10 @@ -226,7 +225,6 @@ SILO: RequiredForShortGame: false SelectionDecorations: VisualBounds: 49,30 - -WithMakeAnimation: PYLE: Inherits: ^BaseBuilding @@ -463,8 +461,8 @@ HQ: RequiresPower: CanPowerDown: DisabledOverlay: - RenderBuilding: - PauseOnLowPower: yes + WithSpriteBody: + PauseAnimationWhenDisabled: true Health: HP: 700 RevealsShroud: @@ -549,8 +547,8 @@ EYE: RequiresPower: CanPowerDown: DisabledOverlay: - RenderBuilding: - PauseOnLowPower: yes + WithSpriteBody: + PauseAnimationWhenDisabled: true Health: HP: 1200 RevealsShroud: @@ -654,7 +652,7 @@ GUN: Turreted: ROT: 12 InitialFacing: 50 - RenderSprites: + -WithSpriteBody: WithTurretedSpriteBody: Armament: Weapon: TurretGun @@ -662,13 +660,11 @@ GUN: MuzzleSequence: muzzle AttackTurreted: WithMuzzleFlash: - -RenderBuilding: -WithDeathAnimation: DetectCloaked: Range: 3 Power: Amount: -20 - -WithMakeAnimation: SAM: Inherits: ^Defense @@ -697,7 +693,7 @@ SAM: Turreted: ROT: 10 InitialFacing: 0 - RenderSprites: + -WithSpriteBody: WithTurretedSpriteBody: AutoSelectionSize: Armament: @@ -705,11 +701,9 @@ SAM: MuzzleSequence: muzzle AttackPopupTurreted: WithMuzzleFlash: - -RenderBuilding: -RenderDetectionCircle: Power: Amount: -20 - -WithMakeAnimation: OBLI: Inherits: ^Defense @@ -739,8 +733,6 @@ OBLI: Range: 8c0 Bib: HasMinibib: Yes - RenderSprites: - WithSpriteBody: WithChargeAnimation: Armament: Weapon: Laser @@ -750,13 +742,11 @@ OBLI: ChargeAudio: obelpowr.aud ReloadTime: 40 InitialChargeDelay: 50 - -RenderBuilding: -EmitInfantryOnSell: DetectCloaked: Range: 5 Power: Amount: -150 - -WithMakeAnimation: GTWR: Inherits: ^Defense diff --git a/mods/cnc/rules/tech.yaml b/mods/cnc/rules/tech.yaml index dc99ad30da..e230c4711a 100644 --- a/mods/cnc/rules/tech.yaml +++ b/mods/cnc/rules/tech.yaml @@ -11,7 +11,6 @@ V19: V19.Husk: Inherits: ^CivBuildingHusk - -RenderBuilding: AutoSelectionSize: RenderSprites: BodyOrientation: @@ -88,7 +87,6 @@ BIO.Husk: MISS: Inherits: ^CivBuilding - RenderBuilding: Building: Footprint: xxx xxx Dimensions: 3,2 diff --git a/mods/cnc/rules/trees.yaml b/mods/cnc/rules/trees.yaml index 3d44a050cf..b31a0d9b9a 100644 --- a/mods/cnc/rules/trees.yaml +++ b/mods/cnc/rules/trees.yaml @@ -7,7 +7,7 @@ SPLIT2: SPLIT3: Inherits: ^TibTree - RenderBuilding: + RenderSprites: Image: split2 SeedsResource: ResourceType: Tiberium @@ -16,7 +16,7 @@ SPLIT3: SPLITBLUE: Inherits: ^TibTree - RenderBuilding: + RenderSprites: Image: split3 SeedsResource: ResourceType: BlueTiberium diff --git a/mods/d2k/rules/arrakis.yaml b/mods/d2k/rules/arrakis.yaml index 9f1c0d82d8..19d6060db8 100644 --- a/mods/d2k/rules/arrakis.yaml +++ b/mods/d2k/rules/arrakis.yaml @@ -1,6 +1,8 @@ spicebloom: HiddenUnderShroud: - RenderBuilding: + RenderSprites: + WithSpriteBody: + AutoSelectionSize: Building: Footprint: x Dimensions: 1,1 diff --git a/mods/d2k/rules/defaults.yaml b/mods/d2k/rules/defaults.yaml index c6491bdc77..a00606d90d 100644 --- a/mods/d2k/rules/defaults.yaml +++ b/mods/d2k/rules/defaults.yaml @@ -275,7 +275,9 @@ DamagedSounds: EXPLSML1.WAV DestroyedSounds: EXPLHG1.WAV QuantizeFacingsFromSequence: - RenderBuilding: + RenderSprites: + WithSpriteBody: + AutoSelectionSize: WithBuildingExplosion: RepairableBuilding: EmitInfantryOnSell: @@ -311,7 +313,7 @@ -GivesBuildableArea: -WithCrumbleOverlay: -WithMakeAnimation: - -RenderBuilding: + -WithSpriteBody: RenderSprites: WithWallSpriteBody: AutoSelectionSize: diff --git a/mods/d2k/rules/structures.yaml b/mods/d2k/rules/structures.yaml index cda6dc708d..d228a27037 100644 --- a/mods/d2k/rules/structures.yaml +++ b/mods/d2k/rules/structures.yaml @@ -67,7 +67,7 @@ conyard: ProductionBar: Power: Amount: 20 - RenderBuilding: + RenderSprites: Image: conyard.harkonnen FactionImages: atreides: conyard.atreides @@ -99,7 +99,7 @@ power: Type: Wood RevealsShroud: Range: 4c0 - RenderBuilding: + RenderSprites: Image: power.harkonnen FactionImages: atreides: power.atreides @@ -160,7 +160,7 @@ barracks: Factions: atreides, ordos Power: Amount: -20 - RenderBuilding: + RenderSprites: Image: barracks.harkonnen FactionImages: atreides: barracks.atreides @@ -205,7 +205,7 @@ refinery: DeliveryOffset: 2,2 DeliveringActor: carryall.reinforce Facing: 160 - RenderBuilding: + RenderSprites: Image: refinery.harkonnen FactionImages: atreides: refinery.atreides @@ -241,7 +241,6 @@ silo: Type: Wood RevealsShroud: Range: 4c0 - -RenderBuilding: RenderSprites: Image: silo.harkonnen FactionImages: @@ -258,7 +257,6 @@ silo: Amount: -5 MustBeDestroyed: RequiredForShortGame: false - -WithMakeAnimation: light: Inherits: ^Building @@ -283,7 +281,7 @@ light: Type: Wood RevealsShroud: Range: 4c0 - RenderBuilding: + RenderSprites: Image: light.harkonnen FactionImages: atreides: light.atreides @@ -361,7 +359,7 @@ heavy: ProvidesPrerequisite@missiletank: Prerequisite: heavy.missiletank Factions: atreides, harkonnen - RenderBuilding: + RenderSprites: Image: heavy.harkonnen FactionImages: atreides: heavy.atreides @@ -407,7 +405,7 @@ radar: DetectCloaked: Range: 6 RenderDetectionCircle: - RenderBuilding: + RenderSprites: Image: radar.harkonnen FactionImages: atreides: radar.atreides @@ -452,7 +450,7 @@ starport: ProductionAirdrop: Produces: Starport ActorType: frigate - RenderBuilding: + RenderSprites: Image: starport.harkonnen FactionImages: atreides: starport.atreides @@ -642,7 +640,7 @@ repair: FinishRepairingNotification: UnitRepaired RallyPoint: Offset: 1,3 - RenderBuilding: + RenderSprites: Image: repair.harkonnen FactionImages: atreides: repair.atreides @@ -681,7 +679,7 @@ hightech: Type: Wood RevealsShroud: Range: 4c0 - RenderBuilding: + RenderSprites: Image: hightech.harkonnen FactionImages: atreides: hightech.atreides @@ -742,7 +740,7 @@ research: Type: Wood RevealsShroud: Range: 4c0 - RenderBuilding: + RenderSprites: Image: research.harkonnen FactionImages: atreides: research.atreides @@ -779,7 +777,7 @@ palace: Type: Wood RevealsShroud: Range: 8c0 - RenderBuilding: + RenderSprites: Image: palace.harkonnen FactionImages: atreides: palace.atreides @@ -823,7 +821,7 @@ conyard.atreides: BuildPaletteOrder: 1000 Prerequisites: ~disabled ForceFaction: atreides - RenderBuilding: + RenderSprites: Image: conyard.atreides -FactionImages: @@ -834,7 +832,7 @@ conyard.harkonnen: BuildPaletteOrder: 1000 Prerequisites: ~disabled ForceFaction: harkonnen - RenderBuilding: + RenderSprites: Image: conyard.harkonnen -FactionImages: @@ -845,7 +843,7 @@ conyard.ordos: BuildPaletteOrder: 1000 Prerequisites: ~disabled ForceFaction: ordos - RenderBuilding: + RenderSprites: Image: conyard.ordos -FactionImages: diff --git a/mods/ra/maps/allies-05a/map.yaml b/mods/ra/maps/allies-05a/map.yaml index 2510f069a5..48e58ce393 100644 --- a/mods/ra/maps/allies-05a/map.yaml +++ b/mods/ra/maps/allies-05a/map.yaml @@ -1737,9 +1737,7 @@ Rules: LocalOffset: 432,150,-30, 432,-150,-30 AttackTurreted: AutoTarget: - -RenderBuilding: -Selectable: - -WithMakeAnimation: E1.Autotarget: Inherits: E1 Buildable: diff --git a/mods/ra/maps/bomber-john/map.yaml b/mods/ra/maps/bomber-john/map.yaml index 4a0036553f..50984054c2 100644 --- a/mods/ra/maps/bomber-john/map.yaml +++ b/mods/ra/maps/bomber-john/map.yaml @@ -877,6 +877,7 @@ Rules: EndChargeSound: ironrdy1.aud Range: 1 Upgrades: invulnerability + GrantUpgradeSequence: idle Power: Amount: 0 MINVV: @@ -893,9 +894,10 @@ Rules: Cost: 30 Health: HP: 200 - RenderBuilding: + RenderSprites: Image: miner - HasMakeAnimation: false + WithSpriteBody: + AutoSelectionSize: Tooltip: Name: Bomb Description: Bomb (Hotkey B) @@ -943,6 +945,7 @@ Rules: EndChargeSound: ironrdy1.aud Range: 1 Upgrades: invulnerability + GrantUpgradeSequence: idle Sequences: miner: diff --git a/mods/ra/maps/center-of-attention-redux-2/map.yaml b/mods/ra/maps/center-of-attention-redux-2/map.yaml index 6fc7d42db9..1218c71539 100644 --- a/mods/ra/maps/center-of-attention-redux-2/map.yaml +++ b/mods/ra/maps/center-of-attention-redux-2/map.yaml @@ -891,13 +891,13 @@ Rules: Inherits: OILB Health: HP: 6000 - RenderBuilding: + RenderSprites: Image: OILB OILB.Weak: Inherits: OILB Health: HP: 900 - RenderBuilding: + RenderSprites: Image: OILB Sequences: diff --git a/mods/ra/maps/monster-tank-madness/map.yaml b/mods/ra/maps/monster-tank-madness/map.yaml index f82be63892..011807840e 100644 --- a/mods/ra/maps/monster-tank-madness/map.yaml +++ b/mods/ra/maps/monster-tank-madness/map.yaml @@ -2238,7 +2238,7 @@ Rules: Inherits: DOME Buildable: Prerequisites: ~disabled - RenderBuilding: + RenderSprites: Image: DOME -InfiltrateForExploration: TargetableBuilding: diff --git a/mods/ra/maps/soviet-05/map.yaml b/mods/ra/maps/soviet-05/map.yaml index 35227cf143..296e656f0f 100644 --- a/mods/ra/maps/soviet-05/map.yaml +++ b/mods/ra/maps/soviet-05/map.yaml @@ -721,7 +721,7 @@ Rules: Prerequisites: ~disabled DOME.IGNORE: Inherits: DOME - RenderBuilding: + RenderSprites: Image: DOME AutoTargetIgnore: Buildable: diff --git a/mods/ra/maps/survival01/map.yaml b/mods/ra/maps/survival01/map.yaml index de9d7e1d10..9740347103 100644 --- a/mods/ra/maps/survival01/map.yaml +++ b/mods/ra/maps/survival01/map.yaml @@ -1273,7 +1273,7 @@ Rules: -ParatroopersPower@paratroopers: -AirstrikePower@parabombs: -SupportPowerChargeBar: - RenderBuilding: + RenderSprites: Image: AFLD ATEK.mission: Inherits: ATEK @@ -1285,7 +1285,7 @@ Rules: -TargetableBuilding: -GivesBuildableArea: -Huntable: - RenderBuilding: + RenderSprites: Image: ATEK GUN: Valued: diff --git a/mods/ra/rules/civilian.yaml b/mods/ra/rules/civilian.yaml index 07cecaec62..d9b74437af 100644 --- a/mods/ra/rules/civilian.yaml +++ b/mods/ra/rules/civilian.yaml @@ -232,7 +232,6 @@ V19.Husk: ExcludeTilesets: DESERT Tooltip: Name: Husk (Oil Pump) - -RenderBuilding: AutoSelectionSize: RenderSprites: BodyOrientation: @@ -628,7 +627,7 @@ SNOWHUT: Building: Footprint: x x Dimensions: 1,2 - RenderBuilding: + RenderSprites: Scale: 0.7 LHUS: diff --git a/mods/ra/rules/defaults.yaml b/mods/ra/rules/defaults.yaml index 5974b4df2b..fd76549b08 100644 --- a/mods/ra/rules/defaults.yaml +++ b/mods/ra/rules/defaults.yaml @@ -396,7 +396,9 @@ DamagedSounds: kaboom1.aud DestroyedSounds: kaboom22.aud QuantizeFacingsFromSequence: - RenderBuilding: + RenderSprites: + AutoSelectionSize: + WithSpriteBody: WithBuildingExplosion: CaptureNotification: ShakeOnDeath: @@ -521,7 +523,7 @@ ^CivBuilding: Inherits: ^TechBuilding - RenderBuilding: + RenderSprites: Palette: terrain EditorTilesetFilter: ExcludeTilesets: INTERIOR @@ -664,7 +666,7 @@ ^DesertCivBuilding: Inherits: ^CivBuilding - RenderBuilding: + RenderSprites: Palette: terrain EditorTilesetFilter: RequireTilesets: DESERT diff --git a/mods/ra/rules/fakes.yaml b/mods/ra/rules/fakes.yaml index 7be63993e0..ee8d3226a6 100644 --- a/mods/ra/rules/fakes.yaml +++ b/mods/ra/rules/fakes.yaml @@ -15,7 +15,7 @@ FACF: Footprint: xxx xxx xxx Dimensions: 3,3 Bib: - RenderBuilding: + RenderSprites: Image: FACT Valued: Cost: 250 @@ -37,7 +37,7 @@ WEAF: Footprint: xxx xxx Dimensions: 3,2 Bib: - RenderBuilding: + RenderSprites: Image: WEAP WithProductionDoorOverlay: Sequence: build-top @@ -64,7 +64,7 @@ SYRF: Dimensions: 3,3 Adjacent: 8 TerrainTypes: Water - RenderBuilding: + RenderSprites: Image: SYRD Valued: Cost: 100 @@ -91,7 +91,7 @@ SPEF: Dimensions: 3,3 Adjacent: 8 TerrainTypes: Water - RenderBuilding: + RenderSprites: Image: SPEN Valued: Cost: 100 @@ -115,7 +115,7 @@ DOMF: Footprint: xx xx Dimensions: 2,2 Bib: - RenderBuilding: + RenderSprites: Image: DOME Valued: Cost: 180 @@ -139,7 +139,7 @@ ATEF: Footprint: xx xx Dimensions: 2,2 Bib: - RenderBuilding: + RenderSprites: Image: ATEK Valued: Cost: 150 @@ -163,7 +163,7 @@ PDOF: Building: Footprint: xx xx Dimensions: 2,2 - RenderBuilding: + RenderSprites: Image: PDOX Bib: HasMinibib: Yes @@ -189,7 +189,7 @@ MSLF: Building: Footprint: xx Dimensions: 2,1 - RenderBuilding: + RenderSprites: Image: MSLO Valued: Cost: 250 diff --git a/mods/ra/rules/misc.yaml b/mods/ra/rules/misc.yaml index e0acacb67d..0118d072d7 100644 --- a/mods/ra/rules/misc.yaml +++ b/mods/ra/rules/misc.yaml @@ -414,7 +414,7 @@ waypoint: ^fact.colorpicker: Inherits: FACT - RenderBuilding: + RenderSprites: Image: fact Palette: colorpicker diff --git a/mods/ra/rules/structures.yaml b/mods/ra/rules/structures.yaml index aa43ffe048..851f536b3c 100644 --- a/mods/ra/rules/structures.yaml +++ b/mods/ra/rules/structures.yaml @@ -69,8 +69,8 @@ GAP: RequiresPower: CanPowerDown: DisabledOverlay: - RenderBuilding: - PauseOnLowPower: yes + WithSpriteBody: + PauseAnimationWhenDisabled: true Health: HP: 1000 Armor: @@ -401,8 +401,6 @@ TSLA: Range: 8c0 Bib: HasMinibib: Yes - RenderSprites: - WithSpriteBody: WithChargeAnimation: Armament: Weapon: TeslaZap @@ -411,13 +409,11 @@ TSLA: ChargeAudio: tslachg2.aud MaxCharges: 3 ReloadTime: 120 - -RenderBuilding: Power: Amount: -100 DetectCloaked: Range: 8 ProvidesPrerequisite@buildingname: - -WithMakeAnimation: AGUN: Inherits: ^Defense @@ -451,7 +447,7 @@ AGUN: Turreted: ROT: 15 InitialFacing: 224 - RenderSprites: + -WithSpriteBody: WithTurretedSpriteBody: Armament: Weapon: ZSU-23 @@ -459,14 +455,12 @@ AGUN: MuzzleSequence: muzzle AttackTurreted: WithMuzzleFlash: - -RenderBuilding: RenderRangeCircle: RangeCircleType: aa Power: Amount: -50 DetectCloaked: Range: 6 - -WithMakeAnimation: DOME: Inherits: ^Building @@ -612,7 +606,7 @@ GUN: Turreted: ROT: 12 InitialFacing: 50 - RenderSprites: + -WithSpriteBody: WithTurretedSpriteBody: Armament: Weapon: TurretGun @@ -620,12 +614,10 @@ GUN: MuzzleSequence: muzzle AttackTurreted: WithMuzzleFlash: - -RenderBuilding: Power: Amount: -40 DetectCloaked: Range: 7 - -WithMakeAnimation: FTUR: Inherits: ^Defense @@ -690,21 +682,19 @@ SAM: Turreted: ROT: 30 InitialFacing: 0 - RenderSprites: + -WithSpriteBody: WithTurretedSpriteBody: Armament: Weapon: Nike MuzzleSequence: muzzle AttackTurreted: WithMuzzleFlash: - -RenderBuilding: RenderRangeCircle: RangeCircleType: aa Power: Amount: -40 DetectCloaked: Range: 5 - -WithMakeAnimation: ATEK: Inherits: ^Building @@ -988,17 +978,13 @@ SILO: Range: 4c0 Bib: HasMinibib: Yes - RenderSprites: - WithSpriteBody: WithSiloAnimation: StoresResources: PipCount: 5 Capacity: 1500 - -RenderBuilding: -EmitInfantryOnSell: Power: Amount: -10 - -WithMakeAnimation: HPAD: Inherits: ^Building diff --git a/mods/ts/rules/civilian-structures.yaml b/mods/ts/rules/civilian-structures.yaml index 70695da9e8..3575e761ac 100644 --- a/mods/ts/rules/civilian-structures.yaml +++ b/mods/ts/rules/civilian-structures.yaml @@ -261,7 +261,7 @@ AMMOCRAT: Type: none Health: HP: 1 - RenderBuilding: + RenderSprites: Palette: player BBOARD01: @@ -625,7 +625,7 @@ CAARAY: Type: concrete Health: HP: 400 - RenderBuilding: + RenderSprites: Palette: player CAARMR: @@ -639,7 +639,7 @@ CAARMR: Type: concrete Health: HP: 800 - RenderBuilding: + RenderSprites: Palette: player ProvidesPrerequisite: Prerequisite: barracks.upgraded @@ -655,7 +655,7 @@ CABHUT: Dimensions: 1, 1 Health: HP: 2000 - RenderBuilding: + RenderSprites: Palette: player CACRSH01: @@ -729,7 +729,7 @@ CAHOSP: Type: concrete Health: HP: 800 - RenderBuilding: + RenderSprites: Palette: player CAPYR01: @@ -1126,7 +1126,7 @@ GAKODK: Type: heavy Health: HP: 1500 - RenderBuilding: + RenderSprites: Palette: player GAOLDCC1: @@ -1140,7 +1140,7 @@ GAOLDCC1: Type: heavy Health: HP: 400 - RenderBuilding: + RenderSprites: Palette: player GAOLDCC2: @@ -1154,7 +1154,7 @@ GAOLDCC2: Type: heavy Health: HP: 400 - RenderBuilding: + RenderSprites: Palette: player GAOLDCC3: @@ -1168,7 +1168,7 @@ GAOLDCC3: Type: heavy Health: HP: 400 - RenderBuilding: + RenderSprites: Palette: player GAOLDCC4: @@ -1182,7 +1182,7 @@ GAOLDCC4: Type: heavy Health: HP: 400 - RenderBuilding: + RenderSprites: Palette: player GAOLDCC5: @@ -1196,7 +1196,7 @@ GAOLDCC5: Type: heavy Health: HP: 400 - RenderBuilding: + RenderSprites: Palette: player GAOLDCC6: @@ -1210,7 +1210,7 @@ GAOLDCC6: Type: heavy Health: HP: 400 - RenderBuilding: + RenderSprites: Palette: player GASAND: @@ -1273,7 +1273,7 @@ GALITE: Cost: 200 Tooltip: Name: Light Post - RenderBuilding: + RenderSprites: Palette: terraindecoration -WithMakeAnimation: -WithDeathAnimation: @@ -1330,7 +1330,7 @@ NAMNTK: Type: heavy Health: HP: 1500 - RenderBuilding: + RenderSprites: Palette: player NTPYRA: @@ -1346,7 +1346,7 @@ NTPYRA: Type: heavy Health: HP: 1500 - RenderBuilding: + RenderSprites: Palette: player UFO: @@ -1354,7 +1354,7 @@ UFO: Building: Dimensions: 6, 4 Footprint: xxxxxx xxxxxx xxxxxx xxxxxx - RenderBuilding: + RenderSprites: Palette: terraindecoration Selectable: Bounds: 144, 72, 0, 0 diff --git a/mods/ts/rules/defaults.yaml b/mods/ts/rules/defaults.yaml index cfaf6d1532..a3b3419cf4 100644 --- a/mods/ts/rules/defaults.yaml +++ b/mods/ts/rules/defaults.yaml @@ -63,7 +63,9 @@ DamagedSounds: expnew01.aud DestroyedSounds: crmble2.aud QuantizeFacingsFromSequence: - RenderBuilding: + RenderSprites: + WithSpriteBody: + AutoSelectionSize: WithBuildingExplosion: Sequences: building, large_bang, large_brnl, verylarge_clsn, large_tumu EngineerRepairable: @@ -115,7 +117,7 @@ Range: 4c0 Tooltip: Description: Civilian Building - RenderBuilding: + RenderSprites: Palette: terraindecoration ^CivBillboard: @@ -530,8 +532,10 @@ ^BlossomTree: Tooltip: Name: Blossom Tree - RenderBuilding: + RenderSprites: Palette: player + WithSpriteBody: + AutoSelectionSize: Building: Footprint: x Dimensions: 1,1 @@ -636,7 +640,9 @@ Dimensions: 1,1 Footprint: x TerrainTypes: Clear, Road, DirtRoad, Rough - RenderBuilding: + RenderSprites: + WithSpriteBody: + AutoSelectionSize: WithMakeAnimation: SelectionDecorations: Palette: pips diff --git a/mods/ts/rules/gdi-structures.yaml b/mods/ts/rules/gdi-structures.yaml index 5be2744b0b..19c49c311a 100644 --- a/mods/ts/rules/gdi-structures.yaml +++ b/mods/ts/rules/gdi-structures.yaml @@ -247,7 +247,7 @@ GADEPT: ProvidesPrerequisite@buildingname: SelectionDecorations: VisualBounds: 98, 68, -6, -6 - RenderBuilding: + RenderSprites: Image: gadept.gdi FactionImages: gdi: gadept.gdi @@ -348,7 +348,6 @@ GAPLUG: CanPowerDown: IndicatorPalette: mouse DisabledOverlay: - RenderBuilding: WithIdleOverlay@DISH: Sequence: idle-dish WithIdleOverlay@LIGHTS: diff --git a/mods/ts/rules/gdi-support.yaml b/mods/ts/rules/gdi-support.yaml index 3ec5e206a6..a0e7342a6e 100644 --- a/mods/ts/rules/gdi-support.yaml +++ b/mods/ts/rules/gdi-support.yaml @@ -25,6 +25,9 @@ GAWALL: GACTWR: Inherits: ^Defense + -WithSpriteBody: + WithWallSpriteBody: + Type: wall Valued: Cost: 600 Tooltip: @@ -102,10 +105,6 @@ GACTWR: Sequence: idle-lights LineBuildNode: Types: turret - -RenderBuilding: - RenderSprites: - WithWallSpriteBody: - Type: wall Power@base: Amount: -10 Power@turrets: @@ -124,7 +123,6 @@ GACTWR: ProvidesPrerequisite@buildingname: SelectionDecorations: VisualBounds: 48, 48, 0, -12 - -WithMakeAnimation: GAVULC: Inherits: ^BuildingPlug diff --git a/mods/ts/rules/nod-support.yaml b/mods/ts/rules/nod-support.yaml index 9aa73c9b87..47b8a19d48 100644 --- a/mods/ts/rules/nod-support.yaml +++ b/mods/ts/rules/nod-support.yaml @@ -206,7 +206,6 @@ GAARTY: MuzzleSequence: muzzle BodyOrientation: QuantizedFacings: 32 - RenderBuilding: RenderVoxels: LightAmbientColor: 0.4, 0.4, 0.4 WithVoxelBarrel: diff --git a/mods/ts/rules/shared-structures.yaml b/mods/ts/rules/shared-structures.yaml index e75941b725..768bef216e 100644 --- a/mods/ts/rules/shared-structures.yaml +++ b/mods/ts/rules/shared-structures.yaml @@ -97,7 +97,7 @@ PROC: ProvidesPrerequisite@buildingname: SelectionDecorations: VisualBounds: 134, 122, 0, -18 - RenderBuilding: + RenderSprites: Image: proc.gdi FactionImages: gdi: proc.gdi @@ -126,7 +126,6 @@ GASILO: Type: Wood RevealsShroud: Range: 4c0 - -RenderBuilding: RenderSprites: Image: gasilo.gdi FactionImages: @@ -145,7 +144,6 @@ GASILO: Amount: -10 SelectionDecorations: VisualBounds: 80, 48, -5, 0 - -WithMakeAnimation: ANYPOWER: AlwaysVisible: diff --git a/mods/ts/rules/shared-support.yaml b/mods/ts/rules/shared-support.yaml index acdd128e52..58a58593bb 100644 --- a/mods/ts/rules/shared-support.yaml +++ b/mods/ts/rules/shared-support.yaml @@ -60,7 +60,7 @@ NAPULS: Amount: -150 SelectionDecorations: VisualBounds: 78, 54, 0, -12 - RenderBuilding: + RenderSprites: Image: napuls.gdi FactionImages: gdi: napuls.gdi diff --git a/mods/ts/rules/trees.yaml b/mods/ts/rules/trees.yaml index 2edbfcc809..4a229cdc0b 100644 --- a/mods/ts/rules/trees.yaml +++ b/mods/ts/rules/trees.yaml @@ -11,7 +11,7 @@ BIGBLUE: Inherits: ^BlossomTree Tooltip: Name: Large Blue Tiberium Crystal - RenderBuilding: + RenderSprites: Palette: bluetiberium RadarColorFromTerrain: Terrain: BlueTiberium From c39c7cdc4e56f7e88c6e0b9e108778d487077292 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Sun, 30 Aug 2015 13:44:25 +0200 Subject: [PATCH 07/11] Fix d2k NukePower sequence requirement --- OpenRA.Mods.Common/Traits/SupportPowers/NukePower.cs | 7 +++++-- mods/d2k/rules/structures.yaml | 1 + mods/ts/sequences/structures.yaml | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/SupportPowers/NukePower.cs b/OpenRA.Mods.Common/Traits/SupportPowers/NukePower.cs index eb747d3a35..bf7663fe86 100644 --- a/OpenRA.Mods.Common/Traits/SupportPowers/NukePower.cs +++ b/OpenRA.Mods.Common/Traits/SupportPowers/NukePower.cs @@ -75,8 +75,11 @@ namespace OpenRA.Mods.Common.Traits else Sound.Play(Info.IncomingSound); - var wsb = self.Trait(); - wsb.PlayCustomAnimation(self, info.ActivationSequence); + if (!string.IsNullOrEmpty(info.ActivationSequence)) + { + var wsb = self.Trait(); + wsb.PlayCustomAnimation(self, info.ActivationSequence); + } var targetPosition = self.World.Map.CenterOfCell(order.TargetLocation); var missile = new NukeLaunch(self.Owner, info.MissileWeapon, diff --git a/mods/d2k/rules/structures.yaml b/mods/d2k/rules/structures.yaml index d228a27037..d1fe88a150 100644 --- a/mods/d2k/rules/structures.yaml +++ b/mods/d2k/rules/structures.yaml @@ -808,6 +808,7 @@ palace: DisplayBeacon: True DisplayRadarPing: True CameraActor: camera + ActivationSequence: CanPowerDown: DisabledOverlay: RequiresPower: diff --git a/mods/ts/sequences/structures.yaml b/mods/ts/sequences/structures.yaml index 24681114f5..f754685c44 100644 --- a/mods/ts/sequences/structures.yaml +++ b/mods/ts/sequences/structures.yaml @@ -1163,7 +1163,7 @@ namisl: make: ntmislmk Length: 18 ShadowStart: 18 - active: ntmisl_a + active: ntmisl_a # TODO: This is an overlay Length: 10 Tick: 80 damaged-active: ntmisl_a From 10ab4cbe61d034755c6ac38fc076806f824c56cc Mon Sep 17 00:00:00 2001 From: reaperrr Date: Sun, 30 Aug 2015 02:25:23 +0200 Subject: [PATCH 08/11] Fixed production overlay ZOffsets --- mods/d2k/sequences/structures.yaml | 12 ++++++++++++ mods/ts/sequences/structures.yaml | 7 +++++++ 2 files changed, 19 insertions(+) diff --git a/mods/d2k/sequences/structures.yaml b/mods/d2k/sequences/structures.yaml index 3244787801..d310ff9724 100644 --- a/mods/d2k/sequences/structures.yaml +++ b/mods/d2k/sequences/structures.yaml @@ -82,11 +82,13 @@ conyard.atreides: Length: 14 Offset: -48,64 Tick: 80 + ZOffset: 1023 damaged-crane-overlay: DATA.R8 Start: 4436 Length: 14 Offset: -48,64 Tick: 80 + ZOffset: 1023 bib: BLOXBASE.R8 Frames: 611, 612, 613, 631, 632, 633 Length: 6 @@ -590,6 +592,7 @@ light.atreides: Offset: -48,64 Tick: 200 BlendMode: Additive + ZOffset: 1023 bib: BLOXBASE.R8 Frames: 611, 612, 613, 631, 632, 633 Length: 6 @@ -632,6 +635,7 @@ heavy.atreides: Offset: -48,80 Tick: 200 BlendMode: Additive + ZOffset: 511 bib: BLOXBASE.R8 Frames: 611, 612, 613, 631, 632, 633 Length: 6 @@ -665,11 +669,13 @@ conyard.harkonnen: Length: 14 Offset: -48,64 Tick: 80 + ZOffset: 1023 damaged-crane-overlay: DATA.R8 Start: 4450 Length: 14 Offset: -48,64 Tick: 80 + ZOffset: 1023 bib: BLOXBASE.R8 Frames: 611, 612, 613, 631, 632, 633 Length: 6 @@ -983,6 +989,7 @@ light.harkonnen: Offset: -48,64 Tick: 200 BlendMode: Additive + ZOffset: 1023 bib: BLOXBASE.R8 Frames: 611, 612, 613, 631, 632, 633 Length: 6 @@ -1025,6 +1032,7 @@ heavy.harkonnen: Offset: -48,80 Tick: 200 BlendMode: Additive + ZOffset: 511 bib: BLOXBASE.R8 Frames: 611, 612, 613, 631, 632, 633 Length: 6 @@ -1058,11 +1066,13 @@ conyard.ordos: Length: 14 Offset: -48,64 Tick: 80 + ZOffset: 1023 damaged-crane-overlay: DATA.R8 Start: 4464 Length: 14 Offset: -48,64 Tick: 80 + ZOffset: 1023 bib: BLOXBASE.R8 Frames: 611, 612, 613, 631, 632, 633 Length: 6 @@ -1368,6 +1378,7 @@ light.ordos: Offset: -48,64 Tick: 200 BlendMode: Additive + ZOffset: 1023 bib: BLOXBASE.R8 Frames: 611, 612, 613, 631, 632, 633 Length: 6 @@ -1410,6 +1421,7 @@ heavy.ordos: Offset: -48,80 Tick: 200 BlendMode: Additive + ZOffset: 511 bib: BLOXBASE.R8 Frames: 611, 612, 613, 631, 632, 633 Length: 6 diff --git a/mods/ts/sequences/structures.yaml b/mods/ts/sequences/structures.yaml index f754685c44..f3d5d569bb 100644 --- a/mods/ts/sequences/structures.yaml +++ b/mods/ts/sequences/structures.yaml @@ -16,11 +16,14 @@ gacnst: ShadowStart: 24 crane-overlay: gtcnst_d Length: 20 + ZOffset: 1023 damaged-crane-overlay: gtcnst_d Length: 20 + ZOffset: 1023 critical-crane-overlay: gtcnst_d Start: 20 Length: 20 + ZOffset: 1023 idle-top: gtcnst_c Length: 15 Tick: 200 @@ -109,10 +112,12 @@ gapile: production-lights: gtpile_a Length: 7 Tick: 200 + ZOffset: 1023 damaged-production-lights: gtpile_a Start:7 Length: 7 Tick: 200 + ZOffset: 1023 idle-light: gtpile_b Length: 7 Tick: 200 @@ -273,10 +278,12 @@ nahand: production-light: nthand_a Length: 5 Tick: 100 + ZOffset: 1023 damaged-production-light: nthand_a Start: 5 Length: 5 Tick: 100 + ZOffset: 1023 idle-lights: nthand_b Length: 8 Tick: 200 From 45e6c62ec9add9ab2b4a7bc17957c9af892549d7 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Wed, 2 Sep 2015 17:51:19 +0200 Subject: [PATCH 09/11] Cache WithSpriteBody in Refinery constructor --- OpenRA.Mods.Common/Traits/Buildings/Refinery.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/Buildings/Refinery.cs b/OpenRA.Mods.Common/Traits/Buildings/Refinery.cs index 6a87c67a19..6312b6395f 100644 --- a/OpenRA.Mods.Common/Traits/Buildings/Refinery.cs +++ b/OpenRA.Mods.Common/Traits/Buildings/Refinery.cs @@ -18,7 +18,7 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { - public class RefineryInfo : ITraitInfo + public class RefineryInfo : ITraitInfo, Requires { [Desc("Actual harvester facing when docking, 0-255 counter-clock-wise.")] public readonly int DockAngle = 0; @@ -47,6 +47,7 @@ namespace OpenRA.Mods.Common.Traits { readonly Actor self; readonly RefineryInfo info; + readonly WithSpriteBody wsb; PlayerResources playerResources; int currentDisplayTick = 0; @@ -69,6 +70,7 @@ namespace OpenRA.Mods.Common.Traits this.info = info; playerResources = self.Owner.PlayerActor.Trait(); currentDisplayTick = info.TickRate; + wsb = self.Trait(); } public virtual Activity DockSequence(Actor harv, Actor self) @@ -105,7 +107,6 @@ namespace OpenRA.Mods.Common.Traits // Harvester was killed while unloading if (dockedHarv != null && dockedHarv.IsDead) { - var wsb = self.Trait(); wsb.PlayCustomAnimation(self, wsb.Info.Sequence); dockedHarv = null; } From 2031df965c435af9db876d01b41a9e5518c4408c Mon Sep 17 00:00:00 2001 From: reaperrr Date: Wed, 2 Sep 2015 17:51:43 +0200 Subject: [PATCH 10/11] Clarify TODO on TS missile silo sequences --- mods/ts/sequences/structures.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mods/ts/sequences/structures.yaml b/mods/ts/sequences/structures.yaml index f3d5d569bb..716972384f 100644 --- a/mods/ts/sequences/structures.yaml +++ b/mods/ts/sequences/structures.yaml @@ -1170,10 +1170,10 @@ namisl: make: ntmislmk Length: 18 ShadowStart: 18 - active: ntmisl_a # TODO: This is an overlay + active: ntmisl_a # TODO: This is an overlay, but currently used as animation Length: 10 Tick: 80 - damaged-active: ntmisl_a + damaged-active: ntmisl_a # TODO: This is an overlay, but currently used as animation Start: 10 Length: 10 Tick: 80 From 0785bdbcf1d481813b3a1d12f18a7cf8619ef60e Mon Sep 17 00:00:00 2001 From: reaperrr Date: Wed, 2 Sep 2015 17:55:03 +0200 Subject: [PATCH 11/11] Move WithSpriteBody pause check to constructor --- OpenRA.Mods.Common/Traits/Render/WithSpriteBody.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/Render/WithSpriteBody.cs b/OpenRA.Mods.Common/Traits/Render/WithSpriteBody.cs index dd57f52fda..b7b5cdc42f 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithSpriteBody.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithSpriteBody.cs @@ -59,6 +59,10 @@ namespace OpenRA.Mods.Common.Traits () => PlayCustomAnimationRepeating(init.Self, info.Sequence)); else DefaultAnimation.PlayRepeating(NormalizeSequence(init.Self, info.Sequence)); + + if (info.PauseAnimationWhenDisabled) + DefaultAnimation.Paused = () => + init.Self.IsDisabled() && DefaultAnimation.CurrentSequence.Name == NormalizeSequence(init.Self, Info.Sequence); } public string NormalizeSequence(Actor self, string sequence) @@ -70,10 +74,6 @@ namespace OpenRA.Mods.Common.Traits public virtual void BuildingComplete(Actor self) { DefaultAnimation.PlayRepeating(NormalizeSequence(self, Info.Sequence)); - - if (Info.PauseAnimationWhenDisabled) - DefaultAnimation.Paused = () => - self.IsDisabled() && DefaultAnimation.CurrentSequence.Name == NormalizeSequence(self, Info.Sequence); } public void PlayCustomAnimation(Actor self, string name, Action after = null)