From 5274776d5507c3ed2714f359e4f6c209d3013958 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Tue, 20 May 2014 10:52:04 +0200 Subject: [PATCH 1/2] add the Dune 2000 repair depot active overlay --- OpenRA.Game/Traits/TraitsInterfaces.cs | 1 + OpenRA.Mods.RA/Activities/Repair.cs | 5 +- OpenRA.Mods.RA/OpenRA.Mods.RA.csproj | 2 + OpenRA.Mods.RA/Render/WithRepairAnimation.cs | 49 +++++++++++++ OpenRA.Mods.RA/Render/WithRepairOverlay.cs | 77 ++++++++++++++++++++ mods/cnc/rules/structures.yaml | 2 + mods/d2k/rules/structures.yaml | 1 + mods/d2k/sequences/structures.yaml | 66 ++++++++--------- mods/ra/rules/structures.yaml | 1 + 9 files changed, 168 insertions(+), 36 deletions(-) create mode 100644 OpenRA.Mods.RA/Render/WithRepairAnimation.cs create mode 100644 OpenRA.Mods.RA/Render/WithRepairOverlay.cs diff --git a/OpenRA.Game/Traits/TraitsInterfaces.cs b/OpenRA.Game/Traits/TraitsInterfaces.cs index df81e3eb88..577b1c972c 100755 --- a/OpenRA.Game/Traits/TraitsInterfaces.cs +++ b/OpenRA.Game/Traits/TraitsInterfaces.cs @@ -69,6 +69,7 @@ namespace OpenRA.Traits public interface INotifySold { void Selling(Actor self); void Sold(Actor self); } public interface INotifyDamage { void Damaged(Actor self, AttackInfo e); } public interface INotifyDamageStateChanged { void DamageStateChanged(Actor self, AttackInfo e); } + public interface INotifyRepair { void Repairing(Actor self, Actor host); } public interface INotifyKilled { void Killed(Actor self, AttackInfo e); } public interface INotifyAppliedDamage { void AppliedDamage(Actor self, Actor damaged, AttackInfo e); } public interface INotifyBuildComplete { void BuildingComplete(Actor self); } diff --git a/OpenRA.Mods.RA/Activities/Repair.cs b/OpenRA.Mods.RA/Activities/Repair.cs index d1d87caad7..5941b23ab5 100644 --- a/OpenRA.Mods.RA/Activities/Repair.cs +++ b/OpenRA.Mods.RA/Activities/Repair.cs @@ -63,9 +63,8 @@ namespace OpenRA.Mods.RA.Activities self.InflictDamage(self, -hpToRepair, null); - if (host != null) - host.Trait() - .PlayCustomAnim(host, "active"); + foreach (var depot in host.TraitsImplementing()) + depot.Repairing(self, host); remainingTicks = repairsUnits.Interval; } diff --git a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj index 61f49fe7cf..ec9d881bfa 100644 --- a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj +++ b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj @@ -526,6 +526,8 @@ + + diff --git a/OpenRA.Mods.RA/Render/WithRepairAnimation.cs b/OpenRA.Mods.RA/Render/WithRepairAnimation.cs new file mode 100644 index 0000000000..b5946f01e9 --- /dev/null +++ b/OpenRA.Mods.RA/Render/WithRepairAnimation.cs @@ -0,0 +1,49 @@ +#region Copyright & License Information +/* + * Copyright 2007-2014 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 System.Linq; +using OpenRA.FileFormats; +using OpenRA.Graphics; +using OpenRA.Traits; +using OpenRA.Mods.RA.Buildings; +using OpenRA.Effects; + +namespace OpenRA.Mods.RA.Render +{ + public class WithRepairAnimationInfo : ITraitInfo, Requires + { + [Desc("Sequence name to use")] + public readonly string Sequence = "active"; + + public readonly bool PauseOnLowPower = false; + + public object Create(ActorInitializer init) { return new WithRepairAnimation(init.self, this); } + } + + public class WithRepairAnimation : INotifyRepair + { + IEnumerable disabled; + WithRepairAnimationInfo info; + + public WithRepairAnimation(Actor self, WithRepairAnimationInfo info) + { + disabled = self.TraitsImplementing(); + this.info = info; + } + + public void Repairing(Actor self, Actor host) + { + var building = host.TraitOrDefault(); + if (building != null && !(info.PauseOnLowPower && disabled.Any(d => d.Disabled))) + building.PlayCustomAnim(host, info.Sequence); + } + } +} \ No newline at end of file diff --git a/OpenRA.Mods.RA/Render/WithRepairOverlay.cs b/OpenRA.Mods.RA/Render/WithRepairOverlay.cs new file mode 100644 index 0000000000..094c35b7ad --- /dev/null +++ b/OpenRA.Mods.RA/Render/WithRepairOverlay.cs @@ -0,0 +1,77 @@ +#region Copyright & License Information +/* + * Copyright 2007-2014 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.Linq; +using OpenRA.FileFormats; +using OpenRA.Graphics; +using OpenRA.Traits; +using OpenRA.Mods.RA.Buildings; +using OpenRA.Effects; + +namespace OpenRA.Mods.RA.Render +{ + public class WithRepairOverlayInfo : ITraitInfo, Requires, Requires + { + [Desc("Sequence name to use")] + public readonly string Sequence = "active"; + + [Desc("Position relative to body")] + public readonly WVec Offset = WVec.Zero; + + public readonly bool PauseOnLowPower = false; + + public object Create(ActorInitializer init) { return new WithRepairOverlay(init.self, this); } + } + + public class WithRepairOverlay : INotifyDamageStateChanged, INotifyBuildComplete, INotifySold, INotifyRepair + { + Animation overlay; + bool buildComplete; + + public WithRepairOverlay(Actor self, WithRepairOverlayInfo info) + { + var rs = self.Trait(); + var body = self.Trait(); + var disabled = self.TraitsImplementing(); + + buildComplete = !self.HasTrait(); // always render instantly for units + overlay = new Animation(self.World, rs.GetImage(self)); + overlay.Play(info.Sequence); + rs.anims.Add("repair_{0}".F(info.Sequence), + new AnimationWithOffset(overlay, + () => body.LocalToWorld(info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation))), + () => !buildComplete, + () => info.PauseOnLowPower && disabled.Any(d => d.Disabled), + p => WithTurret.ZOffsetFromCenter(self, p, 1))); + } + + public void BuildingComplete(Actor self) + { + self.World.AddFrameEndTask(w => w.Add(new DelayedAction(120, () => + buildComplete = true))); + } + + public void Sold(Actor self) { } + public void Selling(Actor self) + { + buildComplete = false; + } + + public void DamageStateChanged(Actor self, AttackInfo e) + { + overlay.ReplaceAnim(RenderSprites.NormalizeSequence(overlay, e.DamageState, overlay.CurrentSequence.Name)); + } + + public void Repairing(Actor self, Actor host) + { + overlay.Play(overlay.CurrentSequence.Name); + } + } +} \ No newline at end of file diff --git a/mods/cnc/rules/structures.yaml b/mods/cnc/rules/structures.yaml index 5fcf9e9ffe..8e798c145d 100644 --- a/mods/cnc/rules/structures.yaml +++ b/mods/cnc/rules/structures.yaml @@ -340,6 +340,7 @@ HPAD: Produces: Aircraft Reservable: RepairsUnits: + WithRepairAnimation: RallyPoint: ProductionQueue: Type: Aircraft @@ -422,6 +423,7 @@ FIX: Reservable: RepairsUnits: RallyPoint: + WithRepairAnimation: EYE: Inherits: ^BaseBuilding diff --git a/mods/d2k/rules/structures.yaml b/mods/d2k/rules/structures.yaml index 2655ddabdc..da3e69fc6f 100644 --- a/mods/d2k/rules/structures.yaml +++ b/mods/d2k/rules/structures.yaml @@ -577,6 +577,7 @@ WALL: RallyPoint: 1,3 ProvidesCustomPrerequisite: Prerequisite: Repair + WithRepairOverlay: ^HIGHTECH: Inherits: ^Building diff --git a/mods/d2k/sequences/structures.yaml b/mods/d2k/sequences/structures.yaml index 5ee32b28ef..5f54f14f27 100644 --- a/mods/d2k/sequences/structures.yaml +++ b/mods/d2k/sequences/structures.yaml @@ -219,17 +219,17 @@ repaira: Start: 2571 Offset: -48,48 ZOffset: -1c511 -# active: DATA # TODO: overlay -# Start: 4746 -# Length: 14 -# Offset: -48,48 -# ZOffset: -1c511 -# damaged-active: DATA # TODO: overlay -# Start: 4746 -# Length: 14 -# Tick: 60 -# Offset: -48,48 -# ZOffset: -1c511 + active: DATA + Start: 4746 + Length: 14 + Offset: -48,48 + ZOffset: -1c511 + damaged-active: DATA + Start: 4746 + Length: 14 + Tick: 60 + Offset: -48,48 + ZOffset: -1c511 damaged-idle: DATA Start: 2572 Offset: -48,48 @@ -252,17 +252,17 @@ repairh: Start: 2731 Offset: -48,48 ZOffset: -1c511 -# active: DATA # TODO: overlay -# Start: 4746 -# Length: 14 -# Offset: -48,48 -# ZOffset: -1c511 -# damaged-active: DATA # TODO: overlay -# Start: 4746 -# Length: 14 -# Tick: 60 -# Offset: -48,48 -# ZOffset: -1c511 + active: DATA + Start: 4746 + Length: 14 + Offset: -48,48 + ZOffset: -1c511 + damaged-active: DATA + Start: 4746 + Length: 14 + Tick: 60 + Offset: -48,48 + ZOffset: -1c511 damaged-idle: DATA Start: 2732 Offset: -48,48 @@ -285,17 +285,17 @@ repairo: Start: 2891 Offset: -48,48 ZOffset: -1c511 -# active: DATA # TODO: overlay -# Start: 4746 -# Length: 14 -# Offset: -48,48 -# ZOffset: -1c511 -# damaged-active: DATA # TODO: overlay -# Start: 4746 -# Length: 14 -# Tick: 60 -# Offset: -48,48 -# ZOffset: -1c511 + active: DATA + Start: 4746 + Length: 14 + Offset: -48,48 + ZOffset: -1c511 + damaged-active: DATA + Start: 4746 + Length: 14 + Tick: 60 + Offset: -48,48 + ZOffset: -1c511 damaged-idle: DATA Start: 2892 Offset: -48,48 diff --git a/mods/ra/rules/structures.yaml b/mods/ra/rules/structures.yaml index df80c23d6d..16d004a516 100644 --- a/mods/ra/rules/structures.yaml +++ b/mods/ra/rules/structures.yaml @@ -1197,6 +1197,7 @@ FIX: IronCurtainable: RepairsUnits: Interval: 10 + WithRepairAnimation: FACF: Inherits: ^Building From d80edcd4e86dae2fdffe2a90b5c821112e0a7a10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Tue, 20 May 2014 20:52:47 +0200 Subject: [PATCH 2/2] add Tiberian Sun repair depot --- mods/ts/rules/defaults.yaml | 1 + mods/ts/rules/structures.yaml | 34 ++++++++++++++++++ mods/ts/sequences/structures.yaml | 57 +++++++++++++++++++++++++++++++ 3 files changed, 92 insertions(+) diff --git a/mods/ts/rules/defaults.yaml b/mods/ts/rules/defaults.yaml index 4ede213a5a..389c6f9c59 100644 --- a/mods/ts/rules/defaults.yaml +++ b/mods/ts/rules/defaults.yaml @@ -189,6 +189,7 @@ TargetableUnit: TargetTypes: Ground Repairable: + RepairBuildings: gadept Passenger: CargoType: Vehicle AttackMove: diff --git a/mods/ts/rules/structures.yaml b/mods/ts/rules/structures.yaml index 0aa7a1113e..78cdd18af5 100644 --- a/mods/ts/rules/structures.yaml +++ b/mods/ts/rules/structures.yaml @@ -709,6 +709,40 @@ NAHPAD: WithIdleOverlay@LIGHTS: Sequence: idle-lights +GADEPT: + Inherits: ^Building + Valued: + Cost: 1200 + Tooltip: + Name: Service Depot + Description: Repairs vehicles + Buildable: + BuildPaletteOrder: 80 + Prerequisites: factory + Owner: gdi + Queue: Building + Building: + Power: -30 + Footprint: _x_ xxx _x_ + Dimensions: 3,3 + Health: + HP: 1100 + RevealsShroud: + Range: 5c0 + Reservable: + RepairsUnits: + RallyPoint: + WithIdleOverlay@LIGHT: + Sequence: idle-light + WithIdleOverlay@GROUND: + Sequence: ground + WithRepairOverlay@CIRCUITS: + Sequence: circuits + WithRepairOverlay@CRANE: + Sequence: crane + WithRepairOverlay@PLATFORM: + Sequence: platform + ANYPOWER: Tooltip: Name: Power Plant diff --git a/mods/ts/sequences/structures.yaml b/mods/ts/sequences/structures.yaml index 9f21d10f8b..1a529881de 100644 --- a/mods/ts/sequences/structures.yaml +++ b/mods/ts/sequences/structures.yaml @@ -645,4 +645,61 @@ proc: # TODO: unused narefn_a, narefn_b # Start: 0 # Length: * icon: reficon + Start: 0 + +gadept: + idle: + Start: 0 + ShadowStart: 3 + damaged-idle: + Start: 1 + ShadowStart: 4 + critical-idle: + Start: 2 + ShadowStart: 5 + ground: gadeptbb + Start: 0 + ShadowStart: 3 + ZOffset: -1c611 + damaged-ground: gadeptbb + Start: 1 + ShadowStart: 4 + ZOffset: -1c611 + critical-ground: gadeptbb + Start: 2 + ShadowStart: 5 + ZOffset: -1c611 + idle-light: gadept_b + Start: 0 + Length: 7 + Tick: 120 + damaged-idle-light: gadept_b + Start: 7 + Length: 7 + Tick: 120 + circuits: gadept_a + Start: 0 + Length: 5 + ZOffset: -1c511 + damaged-circuits: gadept_a + Start: 5 + Length: 5 + ZOffset: -1c511 + crane: gadept_c + Start: 0 + Length: 16 + platform: gadept_d + Start: 0 + Length: 7 + ZOffset: -1c511 + damaged-platform: gadept_d + Start: 7 + Length: 7 + ZOffset: -1c511 + make: gadeptmk + Start: 0 + Length: 10 + Tick: 60 + ShadowStart: 10 + icon: fixicon Start: 0 \ No newline at end of file