diff --git a/OpenRA.Game/Graphics/Animation.cs b/OpenRA.Game/Graphics/Animation.cs index 10722e670c..135d2a4e29 100644 --- a/OpenRA.Game/Graphics/Animation.cs +++ b/OpenRA.Game/Graphics/Animation.cs @@ -79,6 +79,8 @@ namespace OpenRA.Graphics backwards = false; tickAlways = false; CurrentSequence = sequenceProvider.GetSequence(name, sequenceName); + timeUntilNextFrame = CurrentSequence != null ? CurrentSequence.Tick : defaultTick; + frame = 0; tickFunc = () => { @@ -94,6 +96,8 @@ namespace OpenRA.Graphics return false; CurrentSequence = sequenceProvider.GetSequence(name, sequenceName); + var tick = CurrentSequence != null ? CurrentSequence.Tick : defaultTick; + timeUntilNextFrame = Math.Min(tick, timeUntilNextFrame); frame %= CurrentSequence.Length; return true; } @@ -103,6 +107,8 @@ namespace OpenRA.Graphics backwards = false; tickAlways = false; CurrentSequence = sequenceProvider.GetSequence(name, sequenceName); + timeUntilNextFrame = CurrentSequence != null ? CurrentSequence.Tick : defaultTick; + frame = 0; tickFunc = () => { @@ -127,6 +133,8 @@ namespace OpenRA.Graphics backwards = false; tickAlways = true; CurrentSequence = sequenceProvider.GetSequence(name, sequenceName); + timeUntilNextFrame = CurrentSequence != null ? CurrentSequence.Tick : defaultTick; + frame = func(); tickFunc = () => frame = func(); } diff --git a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj index 9f94976bdb..0ca34282ae 100644 --- a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj +++ b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj @@ -246,7 +246,6 @@ - diff --git a/OpenRA.Mods.Common/Traits/Buildings/DeadBuildingState.cs b/OpenRA.Mods.Common/Traits/Buildings/DeadBuildingState.cs deleted file mode 100644 index 4f08db9c64..0000000000 --- a/OpenRA.Mods.Common/Traits/Buildings/DeadBuildingState.cs +++ /dev/null @@ -1,50 +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.Effects; -using OpenRA.Traits; - -namespace OpenRA.Mods.Common.Traits -{ - class DeadBuildingStateInfo : ITraitInfo, Requires, Requires - { - public readonly int LingerTime = 20; - - public object Create(ActorInitializer init) { return new DeadBuildingState(init.Self, this); } - } - - class DeadBuildingState : INotifyKilled - { - DeadBuildingStateInfo info; - RenderSimple rs; - - public DeadBuildingState(Actor self, DeadBuildingStateInfo info) - { - this.info = info; - rs = self.Trait(); - self.Trait().RemoveOnDeath = !rs.DefaultAnimation.HasSequence("dead"); - } - - public void Killed(Actor self, AttackInfo e) - { - if (!rs.DefaultAnimation.HasSequence("dead")) return; - - if (rs.DefaultAnimation.GetSequence("dead").Length > 1) - rs.DefaultAnimation.Play("dead"); - else - rs.DefaultAnimation.PlayRepeating("dead"); - - self.World.AddFrameEndTask( - w => w.Add( - new DelayedAction(info.LingerTime, - () => self.Destroy()))); - } - } -} diff --git a/OpenRA.Mods.Common/Traits/Render/WithBuildingExplosion.cs b/OpenRA.Mods.Common/Traits/Render/WithBuildingExplosion.cs index bdbca9a15c..262263375a 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithBuildingExplosion.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithBuildingExplosion.cs @@ -8,6 +8,8 @@ */ #endregion +using System.Collections.Generic; +using OpenRA.Effects; using OpenRA.Mods.Common.Effects; using OpenRA.Traits; @@ -19,6 +21,9 @@ namespace OpenRA.Mods.Common.Traits [Desc("Explosion sequence name to use")] public readonly string Sequence = "building"; + [Desc("Delay the explosions by this many ticks.")] + public readonly int Delay = 0; + [Desc("Custom palette name")] public readonly string Palette = "effect"; @@ -37,8 +42,18 @@ namespace OpenRA.Mods.Common.Traits public void Killed(Actor self, AttackInfo e) { var buildingInfo = self.Info.Traits.Get(); - FootprintUtils.UnpathableTiles(self.Info.Name, buildingInfo, self.Location).Do( - t => self.World.AddFrameEndTask(w => w.Add(new Explosion(w, w.Map.CenterOfCell(t), info.Sequence, info.Palette)))); + var cells = FootprintUtils.UnpathableTiles(self.Info.Name, buildingInfo, self.Location); + + if (info.Delay > 0) + self.World.AddFrameEndTask(w => w.Add(new DelayedAction(info.Delay, () => SpawnExplosions(self.World, cells)))); + else + SpawnExplosions(self.World, cells); + } + + void SpawnExplosions(World world, IEnumerable cells) + { + foreach (var c in cells) + world.AddFrameEndTask(w => w.Add(new Explosion(w, w.Map.CenterOfCell(c), info.Sequence, info.Palette))); } } } diff --git a/mods/cnc/rules/defaults.yaml b/mods/cnc/rules/defaults.yaml index bcfc3043fb..8d61389ed7 100644 --- a/mods/cnc/rules/defaults.yaml +++ b/mods/cnc/rules/defaults.yaml @@ -401,6 +401,7 @@ DestroyedSound: crumble.aud RenderBuilding: WithBuildingExplosion: + Delay: 1 EmitInfantryOnSell: ActorTypes: e6,e1 GivesExperience: @@ -432,7 +433,9 @@ RepairableBuilding: RepairPercent: 40 RepairStep: 14 - DeadBuildingState: + WithDeathAnimation: + DeathSequence: dead + UseDeathTypeSuffix: false GivesBuildableArea: EngineerRepairable: Sellable: @@ -560,7 +563,6 @@ RelativeToTopLeft: yes Health: HP: 500 - DeadBuildingState: Armor: Type: Wood AutoTargetIgnore: diff --git a/mods/cnc/rules/structures.yaml b/mods/cnc/rules/structures.yaml index 0c5ea55ece..7f9c6489f0 100644 --- a/mods/cnc/rules/structures.yaml +++ b/mods/cnc/rules/structures.yaml @@ -616,7 +616,7 @@ GUN: WithMuzzleFlash: AutoTarget: -RenderBuilding: - -DeadBuildingState: + -WithDeathAnimation: RenderRangeCircle: RenderDetectionCircle: DetectCloaked: diff --git a/mods/cnc/sequences/structures.yaml b/mods/cnc/sequences/structures.yaml index efcf107d9f..302a59a3d1 100644 --- a/mods/cnc/sequences/structures.yaml +++ b/mods/cnc/sequences/structures.yaml @@ -17,6 +17,7 @@ fact: Tick: 100 dead: Start: 48 + Tick: 800 make: factmake Start: 0 Length: * @@ -38,7 +39,7 @@ nuke: Tick: 1000 dead: Start: 8 - Tick: 1000 + Tick: 800 make: nukemake Start: 0 Length: * @@ -60,6 +61,7 @@ proc: Tick: 120 dead: Start: 60 + Tick: 800 make: procmake Start: 0 Length: * @@ -90,6 +92,7 @@ silo: dead: Start: 10 Offset: 0,-1 + Tick: 800 make: silomake Start: 0 Length: * @@ -109,6 +112,7 @@ hand: Start: 1 dead: Start: 2 + Tick: 800 make: handmake Start: 0 Length: * @@ -130,7 +134,7 @@ pyle: Tick: 100 dead: Start: 20 - Tick: 100 + Tick: 800 make: pylemake Start: 0 Length: * @@ -148,6 +152,7 @@ weap: Start: 1 dead: Start: 2 + Tick: 800 build-top: weap2 Start: 0 Length: 10 @@ -190,6 +195,7 @@ afld: dead: Start: 32 ZOffset: -1023 + Tick: 800 make: afldmake Start: 0 Length: * @@ -211,6 +217,7 @@ hq: Tick: 100 dead: Start: 32 + Tick: 800 make: hqmake Start: 0 Length: * @@ -232,6 +239,7 @@ nuk2: Tick: 1000 dead: Start: 8 + Tick: 800 make: nuk2make Start: 0 Length: * @@ -262,6 +270,7 @@ hpad: dead: Start: 14 ZOffset: -1023 + Tick: 800 make: hpadmake Start: 0 Length: * @@ -287,6 +296,7 @@ fix: dead: Start: 14 ZOffset: -1c511 + Tick: 800 make: fixmake Start: 0 Length: 14 @@ -309,6 +319,7 @@ eye: Tick: 100 dead: Start: 32 + Tick: 800 make: eyemake Start: 0 Length: * @@ -332,6 +343,7 @@ tmpl: Length: 5 dead: Start: 10 + Tick: 800 make: tmplmake Start: 0 Length: * @@ -357,6 +369,7 @@ obli: Tick: 680 dead: Start: 8 + Tick: 800 make: oblimake Start: 0 Length: 13 @@ -470,6 +483,7 @@ sam: Tick: 30 dead: Start: 128 + Tick: 800 make: sammake Start: 0 Length: 20 @@ -488,6 +502,7 @@ gtwr: Start: 1 dead: Start: 2 + Tick: 800 make: gtwrmake Start: 0 Length: * @@ -513,6 +528,7 @@ atwr: dead: Start: 2 Offset: 0,-1 + Tick: 800 make: atwrmake Start: 0 Length: * diff --git a/mods/ra/rules/civilian.yaml b/mods/ra/rules/civilian.yaml index 8f9fba2d45..5da465ba79 100644 --- a/mods/ra/rules/civilian.yaml +++ b/mods/ra/rules/civilian.yaml @@ -89,7 +89,11 @@ HOSP: Range: 3c0 Bib: HasMinibib: Yes - DeadBuildingState: + WithDeathAnimation: + DeathSequence: dead + UseDeathTypeSuffix: false + WithBuildingExplosion: + Delay: 1 V01: Inherits: ^CivBuilding @@ -291,7 +295,11 @@ MISS: Tooltip: Name: Technology Center Bib: - DeadBuildingState: + WithDeathAnimation: + DeathSequence: dead + UseDeathTypeSuffix: false + WithBuildingExplosion: + Delay: 1 BIO: Inherits: ^TechBuilding @@ -303,7 +311,11 @@ BIO: EngineerRepairable: Tooltip: Name: Biological Lab - DeadBuildingState: + WithDeathAnimation: + DeathSequence: dead + UseDeathTypeSuffix: false + WithBuildingExplosion: + Delay: 1 OILB: Inherits: ^TechBuilding diff --git a/mods/ra/rules/defaults.yaml b/mods/ra/rules/defaults.yaml index 2ded9840f8..ef99f6e77d 100644 --- a/mods/ra/rules/defaults.yaml +++ b/mods/ra/rules/defaults.yaml @@ -581,7 +581,6 @@ Types: Tree Health: HP: 500 - DeadBuildingState: Armor: Type: Wood AutoTargetIgnore: diff --git a/mods/ra/rules/structures.yaml b/mods/ra/rules/structures.yaml index 9b56d7f385..dd335f1ba6 100644 --- a/mods/ra/rules/structures.yaml +++ b/mods/ra/rules/structures.yaml @@ -903,12 +903,16 @@ FACT: ProductionBar@Defense: ProductionType: Defense Color: 138,138,138 - DeadBuildingState: BaseProvider: Range: 16 WithBuildingPlacedAnimation: Power: Amount: 0 + WithDeathAnimation: + DeathSequence: dead + UseDeathTypeSuffix: false + WithBuildingExplosion: + Delay: 1 PROC: Inherits: ^Building @@ -951,11 +955,15 @@ PROC: Percentage: 50 Minimum: 500 SoundToVictim: credit1.aud - DeadBuildingState: WithIdleOverlay@TOP: Sequence: idle-top Power: Amount: -30 + WithDeathAnimation: + DeathSequence: dead + UseDeathTypeSuffix: false + WithBuildingExplosion: + Delay: 1 SILO: Inherits: ^Building @@ -1191,7 +1199,6 @@ POWR: RevealsShroud: Range: 4c0 Bib: - DeadBuildingState: Power: Amount: 100 InfiltrateForPowerOutage: @@ -1200,6 +1207,11 @@ POWR: TargetTypes: Ground, C4, DetonateAttack, SpyInfiltrate ScalePowerWithHealth: DisabledOverlay: + WithDeathAnimation: + DeathSequence: dead + UseDeathTypeSuffix: false + WithBuildingExplosion: + Delay: 1 APWR: Inherits: ^Building @@ -1224,7 +1236,6 @@ APWR: RevealsShroud: Range: 4c0 Bib: - DeadBuildingState: Power: Amount: 200 InfiltrateForPowerOutage: @@ -1233,6 +1244,11 @@ APWR: TargetTypes: Ground, C4, DetonateAttack, SpyInfiltrate ScalePowerWithHealth: DisabledOverlay: + WithDeathAnimation: + DeathSequence: dead + UseDeathTypeSuffix: false + WithBuildingExplosion: + Delay: 1 STEK: Inherits: ^Building diff --git a/mods/ra/sequences/structures.yaml b/mods/ra/sequences/structures.yaml index 3428d2fdf8..e27f55c7b0 100644 --- a/mods/ra/sequences/structures.yaml +++ b/mods/ra/sequences/structures.yaml @@ -19,6 +19,7 @@ hosp: Length: 4 dead: Start: 8 + Tick: 800 make: hospmake Start: 0 Length: * @@ -36,6 +37,7 @@ bio: Start: 1 dead: Start: 2 + Tick: 800 make: biomake Start: 0 Length: * @@ -67,6 +69,7 @@ fact: Length: 25 dead: factdead Start: 0 + Tick: 800 bib: bib2 Start: 0 Length: * @@ -93,7 +96,7 @@ proc: Length: * dead: procdead Start: 0 - ZOffset: -1c511 + Tick: 800 bib: bib2 Start: 0 Length: * @@ -129,6 +132,7 @@ powr: Length: * dead: powrdead Start: 0 + Tick: 800 bib: bib3 Start: 0 Length: * @@ -145,6 +149,7 @@ apwr: Length: * dead: apwrdead Start: 0 + Tick: 800 bib: bib2 Start: 0 Length: * @@ -636,6 +641,7 @@ miss: Start: 1 dead: Start: 2 + Tick: 800 make: missmake Start: 0 Length: *