From 99c7989ebcb46b1ac12849128aa9d7a124615683 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sun, 24 Apr 2016 19:48:41 +0200 Subject: [PATCH] Rename WithSmoke into a more generic WithDamageOverlay trait. Rename Sequence parameter to Image to avoid confusion. --- OpenRA.Mods.Common/OpenRA.Mods.Common.csproj | 2 +- .../{WithSmoke.cs => WithDamageOverlay.cs} | 20 +++++++++---------- .../UtilityCommands/UpgradeRules.cs | 16 +++++++++++++++ mods/cnc/rules/defaults.yaml | 16 +++++++-------- mods/ra/rules/defaults.yaml | 4 ++-- 5 files changed, 37 insertions(+), 21 deletions(-) rename OpenRA.Mods.Common/Traits/Render/{WithSmoke.cs => WithDamageOverlay.cs} (73%) diff --git a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj index e817174245..c9edc3b685 100644 --- a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj +++ b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj @@ -431,6 +431,7 @@ + @@ -447,7 +448,6 @@ - diff --git a/OpenRA.Mods.Common/Traits/Render/WithSmoke.cs b/OpenRA.Mods.Common/Traits/Render/WithDamageOverlay.cs similarity index 73% rename from OpenRA.Mods.Common/Traits/Render/WithSmoke.cs rename to OpenRA.Mods.Common/Traits/Render/WithDamageOverlay.cs index 3ad2cfd0a6..19f24b3c7f 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithSmoke.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithDamageOverlay.cs @@ -17,13 +17,13 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits.Render { [Desc("Renders an overlay when the actor is taking heavy damage.")] - public class WithSmokeInfo : ITraitInfo, Requires // TODO: rename to WithDamageOverlay + public class WithDamageOverlayInfo : ITraitInfo, Requires { - public readonly string Sequence = "smoke_m"; // TODO: rename to image + public readonly string Image = "smoke_m"; - [SequenceReference("Sequence")] public readonly string IdleSequence = "idle"; - [SequenceReference("Sequence")] public readonly string LoopSequence = "loop"; - [SequenceReference("Sequence")] public readonly string EndSequence = "end"; + [SequenceReference("Image")] public readonly string IdleSequence = "idle"; + [SequenceReference("Image")] public readonly string LoopSequence = "loop"; + [SequenceReference("Image")] public readonly string EndSequence = "end"; [Desc("Damage types that this should be used for (defined on the warheads).", "Leave empty to disable all filtering.")] @@ -33,23 +33,23 @@ namespace OpenRA.Mods.Common.Traits.Render public readonly DamageState MinimumDamageState = DamageState.Heavy; public readonly DamageState MaximumDamageState = DamageState.Dead; - public object Create(ActorInitializer init) { return new WithSmoke(init.Self, this); } + public object Create(ActorInitializer init) { return new WithDamageOverlay(init.Self, this); } } - public class WithSmoke : INotifyDamage + public class WithDamageOverlay : INotifyDamage { - readonly WithSmokeInfo info; + readonly WithDamageOverlayInfo info; readonly Animation anim; bool isSmoking; - public WithSmoke(Actor self, WithSmokeInfo info) + public WithDamageOverlay(Actor self, WithDamageOverlayInfo info) { this.info = info; var rs = self.Trait(); - anim = new Animation(self.World, info.Sequence); + anim = new Animation(self.World, info.Image); rs.Add(new AnimationWithOffset(anim, null, () => !isSmoking)); } diff --git a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs index 4fa6ad33ba..2222cf84a7 100644 --- a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs +++ b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs @@ -788,6 +788,22 @@ namespace OpenRA.Mods.Common.UtilityCommands n.Key = "DetonationDelay"; } + // WithSmoke was refactored to become more generic and Sequence/Image notation has been unified. + if (engineVersion < 20160528) + { + if (depth == 1 && node.Key.StartsWith("WithSmoke")) + { + var s = node.Value.Nodes.FirstOrDefault(n => n.Key == "Sequence"); + if (s != null) + s.Key = "Image"; + + var parts = node.Key.Split('@'); + node.Key = "WithDamageOverlay"; + if (parts.Length > 1) + node.Key += "@" + parts[1]; + } + } + UpgradeActorRules(engineVersion, ref node.Value.Nodes, node, depth + 1); } } diff --git a/mods/cnc/rules/defaults.yaml b/mods/cnc/rules/defaults.yaml index 458b62d1f9..572863ffd2 100644 --- a/mods/cnc/rules/defaults.yaml +++ b/mods/cnc/rules/defaults.yaml @@ -79,7 +79,7 @@ HiddenUnderFog: AttackMove: DrawLineToTarget: - WithSmoke: + WithDamageOverlay: WithFacingSpriteBody: Explodes: Weapon: UnitExplodeSmall @@ -446,7 +446,7 @@ ActorLostNotification: AttackMove: DrawLineToTarget: - WithSmoke: + WithDamageOverlay: Explodes: Weapon: UnitExplodeShip EmptyWeapon: UnitExplodeShip @@ -636,19 +636,19 @@ Type: Wood Targetable: TargetTypes: Trees - WithSmoke@SmallBurn: + WithDamageOverlay@SmallBurn: DamageType: Incendiary - Sequence: burn-s + Image: burn-s MinimumDamageState: Light MaximumDamageState: Medium - WithSmoke@MediumBurn: + WithDamageOverlay@MediumBurn: DamageType: Incendiary - Sequence: burn-m + Image: burn-m MinimumDamageState: Medium MaximumDamageState: Heavy - WithSmoke@LargeBurn: + WithDamageOverlay@LargeBurn: DamageType: Incendiary - Sequence: burn-l + Image: burn-l MinimumDamageState: Heavy MaximumDamageState: Dead AutoTargetIgnore: diff --git a/mods/ra/rules/defaults.yaml b/mods/ra/rules/defaults.yaml index 3fa6559fa0..74bc12c931 100644 --- a/mods/ra/rules/defaults.yaml +++ b/mods/ra/rules/defaults.yaml @@ -99,7 +99,7 @@ GivesBounty: GpsDot: String: Vehicle - WithSmoke: + WithDamageOverlay: Guard: Guardable: Tooltip: @@ -325,7 +325,7 @@ RepairableNear: GpsDot: String: Ship - WithSmoke: + WithDamageOverlay: Explodes: Weapon: UnitExplodeShip EmptyWeapon: UnitExplodeShip