From 9b051a662441454de43589a93dba09dcfb7bd4e4 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sat, 31 Jul 2010 01:08:22 +1200 Subject: [PATCH] Remove some bs from buildings with multiple damage states; cnc civilian structure rubble persists after death. --- OpenRA.Mods.Cnc/CriticalBuildingState.cs | 44 ------------- OpenRA.Mods.Cnc/DeadBuildingState.cs | 48 +++++++++++++++ OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj | 4 +- OpenRA.Mods.RA/Render/RenderBuildingWall.cs | 38 +++++------- mods/cnc/defaults.yaml | 7 ++- mods/cnc/sequences-map.xml | 68 ++++++++++----------- mods/cnc/sequences-structures.xml | 48 ++++++--------- mods/cnc/structures.yaml | 6 +- mods/ra/defaults.yaml | 1 - mods/ra/sequences.xml | 2 +- mods/ra/structures.yaml | 4 -- 11 files changed, 127 insertions(+), 143 deletions(-) delete mode 100644 OpenRA.Mods.Cnc/CriticalBuildingState.cs create mode 100644 OpenRA.Mods.Cnc/DeadBuildingState.cs diff --git a/OpenRA.Mods.Cnc/CriticalBuildingState.cs b/OpenRA.Mods.Cnc/CriticalBuildingState.cs deleted file mode 100644 index 7532912440..0000000000 --- a/OpenRA.Mods.Cnc/CriticalBuildingState.cs +++ /dev/null @@ -1,44 +0,0 @@ -#region Copyright & License Information -/* - * Copyright 2007-2010 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 LICENSE. - */ -#endregion - -using OpenRA.Effects; -using OpenRA.Traits; - -namespace OpenRA.Mods.Cnc -{ - class CriticalBuildingStateInfo : ITraitInfo, ITraitPrerequisite - { - public readonly int LingerTime = 20; - public object Create(ActorInitializer init) { return new CriticalBuildingState(init.self, this); } - } - - class CriticalBuildingState : INotifyDamage - { - CriticalBuildingStateInfo info; - - public CriticalBuildingState(Actor self, CriticalBuildingStateInfo info) - { - this.info = info; - self.traits.Get().RemoveOnDeath = false; - } - - public void Damaged(Actor self, AttackInfo e) - { - if (e.DamageStateChanged && e.DamageState == DamageState.Dead) - { - self.traits.Get().anim.PlayRepeating("critical-idle"); - self.World.AddFrameEndTask( - w => w.Add( - new DelayedAction(info.LingerTime, - () => w.Remove(self)))); - } - } - } -} diff --git a/OpenRA.Mods.Cnc/DeadBuildingState.cs b/OpenRA.Mods.Cnc/DeadBuildingState.cs new file mode 100644 index 0000000000..e42118565a --- /dev/null +++ b/OpenRA.Mods.Cnc/DeadBuildingState.cs @@ -0,0 +1,48 @@ +#region Copyright & License Information +/* + * Copyright 2007-2010 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 LICENSE. + */ +#endregion + +using OpenRA.Effects; +using OpenRA.Traits; + +namespace OpenRA.Mods.Cnc +{ + class DeadBuildingStateInfo : ITraitInfo, ITraitPrerequisite, ITraitPrerequisite + { + public readonly int LingerTime = 20; + public readonly bool Zombie = false; // Civilian structures stick around after death + public object Create(ActorInitializer init) { return new DeadBuildingState(init.self, this); } + } + + class DeadBuildingState : INotifyDamage + { + DeadBuildingStateInfo info; + RenderSimple rs; + public DeadBuildingState(Actor self, DeadBuildingStateInfo info) + { + this.info = info; + rs = self.traits.Get(); + self.traits.Get().RemoveOnDeath = !rs.anim.HasSequence("dead"); + } + + public void Damaged(Actor self, AttackInfo e) + { + if (e.DamageStateChanged && e.DamageState == DamageState.Dead) + { + if (!rs.anim.HasSequence("dead")) return; + rs.anim.PlayRepeating("dead"); + if (!info.Zombie) + self.World.AddFrameEndTask( + w => w.Add( + new DelayedAction(info.LingerTime, + () => w.Remove(self)))); + } + } + } +} diff --git a/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj b/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj index c4e71d6bb3..a6e49acf50 100644 --- a/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj +++ b/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj @@ -1,4 +1,4 @@ - + Debug @@ -52,7 +52,6 @@ - @@ -60,6 +59,7 @@ + diff --git a/OpenRA.Mods.RA/Render/RenderBuildingWall.cs b/OpenRA.Mods.RA/Render/RenderBuildingWall.cs index 6416452f67..57a6a73236 100644 --- a/OpenRA.Mods.RA/Render/RenderBuildingWall.cs +++ b/OpenRA.Mods.RA/Render/RenderBuildingWall.cs @@ -15,7 +15,6 @@ namespace OpenRA.Mods.RA.Render { class RenderBuildingWallInfo : RenderBuildingInfo { - public readonly int DamageStates = 2; public override object Create(ActorInitializer init) { return new RenderBuildingWall(init.self); } } @@ -33,30 +32,25 @@ namespace OpenRA.Mods.RA.Render public override void Damaged(Actor self, AttackInfo e) { - var numStates = self.Info.Traits.Get().DamageStates; - if (!e.DamageStateChanged) return; - switch (e.DamageState) + var bi = self.Info.Traits.Get(); + + if (e.DamageState == DamageState.Medium && anim.HasSequence("scratched-idle")) + seqName = "scratched-idle"; + else if (e.DamageState <= DamageState.Medium) + seqName = "idle"; + else if (e.DamageState == DamageState.Critical && anim.HasSequence("critical-idle")) { - case DamageState.Light: - seqName = "idle"; - break; - case DamageState.Medium: - if (numStates >= 4) - seqName = "minor-damaged-idle"; - break; - case DamageState.Heavy: - seqName = "damaged-idle"; - Sound.Play(self.Info.Traits.Get().DamagedSound, self.CenterLocation); - break; - case DamageState.Critical: - if (numStates >= 3) - { - seqName = "critical-idle"; - Sound.Play(self.Info.Traits.Get().DamagedSound, self.CenterLocation); - } - break; + seqName = "critical-idle"; + if (e.DamageState > e.PreviousDamageState) + Sound.Play(bi.DamagedSound, self.CenterLocation); + } + else if (e.DamageState <= DamageState.Critical) + { + seqName = "damaged-idle"; + if (e.DamageState > e.PreviousDamageState) + Sound.Play(bi.DamagedSound, self.CenterLocation); } anim.PlayFetchIndex(seqName, () => adjacentWalls); diff --git a/mods/cnc/defaults.yaml b/mods/cnc/defaults.yaml index 6d139bd7fc..5c44cf0fee 100644 --- a/mods/cnc/defaults.yaml +++ b/mods/cnc/defaults.yaml @@ -107,7 +107,7 @@ DamagedSound: xplos.aud DestroyedSound: xplobig4.aud RenderBuilding: - CriticalBuildingState: + DeadBuildingState: EmitInfantryOnSell: ActorTypes: c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,e1,e1,e1,e1,e1,e1,e1 MustBeDestroyed: @@ -121,6 +121,8 @@ ^CivBuilding: Inherits: ^Building + DeadBuildingState: + Zombie: true Health: HP: 400 Armor: wood @@ -132,6 +134,8 @@ ^CivField: Inherits: ^CivBuilding -Selectable: + DeadBuildingState: + Zombie: true Valued: Description: Field RenderBuilding: @@ -158,7 +162,6 @@ RenderBuildingWall: HasMakeAnimation: false Palette: terrain - DamageStates: 2 GivesExperience: ^Tree: diff --git a/mods/cnc/sequences-map.xml b/mods/cnc/sequences-map.xml index 303b29fc43..1d48c67c83 100644 --- a/mods/cnc/sequences-map.xml +++ b/mods/cnc/sequences-map.xml @@ -133,187 +133,187 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + \ No newline at end of file diff --git a/mods/cnc/sequences-structures.xml b/mods/cnc/sequences-structures.xml index acf23d2223..9ceb21733e 100644 --- a/mods/cnc/sequences-structures.xml +++ b/mods/cnc/sequences-structures.xml @@ -4,17 +4,16 @@ - - - + + - + @@ -26,116 +25,109 @@ - - + - + - + - + - + - - - + - + - + - - + - - + - + - - + - - + - + @@ -165,7 +157,6 @@ - @@ -173,21 +164,20 @@ - - + - + \ No newline at end of file diff --git a/mods/cnc/structures.yaml b/mods/cnc/structures.yaml index 61ed3cfe0b..b19712721a 100644 --- a/mods/cnc/structures.yaml +++ b/mods/cnc/structures.yaml @@ -442,8 +442,6 @@ CYCL: Health: HP: 300 Armor: none - RenderBuildingWall: - DamageStates: 3 SBAG: Category: Defense @@ -474,8 +472,6 @@ BRIK: Health: HP: 1000 Armor: heavy - RenderBuildingWall: - DamageStates: 4 Wall: CrushClasses: heavywall @@ -505,6 +501,7 @@ GUN: PrimaryWeapon: TurretGun AutoTarget: -RenderBuilding: + -DeadBuildingState: RenderRangeCircle: SAM: @@ -535,6 +532,7 @@ SAM: PrimaryWeapon: Nike AutoTarget: -RenderBuilding: + -DeadBuildingState: RenderRangeCircle: GTWR: diff --git a/mods/ra/defaults.yaml b/mods/ra/defaults.yaml index 5eeee6ec05..382b2922de 100644 --- a/mods/ra/defaults.yaml +++ b/mods/ra/defaults.yaml @@ -131,7 +131,6 @@ RenderBuildingWall: HasMakeAnimation: false Palette: terrain - DamageStates: 2 GivesExperience: ^CivBuilding: diff --git a/mods/ra/sequences.xml b/mods/ra/sequences.xml index 273e20a5aa..bd79a855c8 100644 --- a/mods/ra/sequences.xml +++ b/mods/ra/sequences.xml @@ -868,7 +868,7 @@ - + diff --git a/mods/ra/structures.yaml b/mods/ra/structures.yaml index ebbeaba08b..a723aecfa7 100644 --- a/mods/ra/structures.yaml +++ b/mods/ra/structures.yaml @@ -946,8 +946,6 @@ BRIK: Health: HP: 1500 Armor: none - RenderBuildingWall: - DamageStates: 4 Wall: CrushClasses: heavywall CYCL: @@ -955,8 +953,6 @@ CYCL: Health: HP: 100 Armor: none - RenderBuildingWall: - DamageStates: 3 BARB: Inherits: ^Wall