diff --git a/OpenRA.Mods.RA/Buildings/Building.cs b/OpenRA.Mods.RA/Buildings/Building.cs index c54729a961..9f17263dd5 100755 --- a/OpenRA.Mods.RA/Buildings/Building.cs +++ b/OpenRA.Mods.RA/Buildings/Building.cs @@ -29,10 +29,9 @@ namespace OpenRA.Mods.RA.Buildings public readonly string[] BuildSounds = {"placbldg.aud", "build5.aud"}; public readonly string[] SellSounds = {"cashturn.aud"}; - public readonly string DamagedSound = "kaboom1.aud"; - public readonly string DestroyedSound = "kaboom22.aud"; - public object Create(ActorInitializer init) { return new Building(init); } + + public object Create(ActorInitializer init) { return new Building(init, this); } public bool IsCloseEnoughToBase(World world, Player p, string buildingName, int2 topLeft) { @@ -73,11 +72,11 @@ namespace OpenRA.Mods.RA.Buildings public int2 PxPosition { get { return ( 2 * topLeft + Info.Dimensions ) * Game.CellSize / 2; } } - public Building(ActorInitializer init) + public Building(ActorInitializer init, BuildingInfo info) { this.self = init.self; this.topLeft = init.Get(); - this.Info = self.Info.Traits.Get(); + this.Info = info; this.PlayerPower = init.self.Owner.PlayerActor.Trait(); } @@ -95,12 +94,6 @@ namespace OpenRA.Mods.RA.Buildings // Power plants lose power with damage if (Info.Power > 0) PlayerPower.UpdateActor(self, GetPowerUsage()); - - if (e.DamageState == DamageState.Dead) - { - self.World.WorldActor.Trait().AddEffect(10, self.CenterLocation, 1); - Sound.Play(Info.DestroyedSound, self.CenterLocation); - } } public void ResolveOrder(Actor self, Order order) diff --git a/OpenRA.Mods.RA/Buildings/ShakeOnDeath.cs b/OpenRA.Mods.RA/Buildings/ShakeOnDeath.cs new file mode 100644 index 0000000000..64d3a14b63 --- /dev/null +++ b/OpenRA.Mods.RA/Buildings/ShakeOnDeath.cs @@ -0,0 +1,38 @@ +#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 System; +using System.Collections.Generic; +using System.Linq; +using OpenRA.Traits; + +namespace OpenRA.Mods.RA.Buildings +{ + public class ShakeOnDeathInfo : ITraitInfo + { + public readonly int Intensity = 10; + public object Create(ActorInitializer init) { return new ShakeOnDeath(this); } + } + + public class ShakeOnDeath : INotifyDamage + { + readonly ShakeOnDeathInfo Info; + public ShakeOnDeath(ShakeOnDeathInfo info) + { + this.Info = info; + } + + public void Damaged(Actor self, AttackInfo e) + { + if (e.DamageState == DamageState.Dead) + self.World.WorldActor.Trait().AddEffect(Info.Intensity, self.CenterLocation, 1); + } + } +} diff --git a/OpenRA.Mods.RA/Buildings/SoundOnDamageTransition.cs b/OpenRA.Mods.RA/Buildings/SoundOnDamageTransition.cs new file mode 100644 index 0000000000..8a18bf97f4 --- /dev/null +++ b/OpenRA.Mods.RA/Buildings/SoundOnDamageTransition.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 System; +using System.Collections.Generic; +using System.Linq; +using OpenRA.Graphics; +using OpenRA.Mods.RA.Buildings; +using OpenRA.Mods.RA.Effects; +using OpenRA.Traits; + +namespace OpenRA.Mods.RA.Render +{ + public class SoundOnDamageTransitionInfo : ITraitInfo + { + public readonly string DamagedSound; + public readonly string DestroyedSound; + + public object Create(ActorInitializer init) { return new SoundOnDamageTransition(this);} + } + + public class SoundOnDamageTransition : INotifyDamage + { + readonly SoundOnDamageTransitionInfo Info; + public SoundOnDamageTransition( SoundOnDamageTransitionInfo info ) + { + Info = info; + } + + public virtual void Damaged(Actor self, AttackInfo e) + { + if (!e.DamageStateChanged) + return; + + if (e.DamageState == DamageState.Dead) + Sound.Play(Info.DestroyedSound, self.CenterLocation); + else if (e.DamageState >= DamageState.Heavy && e.PreviousDamageState < DamageState.Heavy) + Sound.Play(Info.DamagedSound, self.CenterLocation); + } + } +} diff --git a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj index 9dabe345d1..c8c77b2507 100644 --- a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj +++ b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj @@ -1,4 +1,4 @@ - + Debug @@ -326,6 +326,8 @@ + + diff --git a/OpenRA.Mods.RA/Render/RenderBuilding.cs b/OpenRA.Mods.RA/Render/RenderBuilding.cs index 54177333ec..8867e46c55 100755 --- a/OpenRA.Mods.RA/Render/RenderBuilding.cs +++ b/OpenRA.Mods.RA/Render/RenderBuilding.cs @@ -107,10 +107,7 @@ namespace OpenRA.Mods.RA.Render self.World.AddFrameEndTask(w => w.Add(new Explosion(w, Traits.Util.CenterOfCell(cell), "building", false, 0))); } else if (e.DamageState >= DamageState.Heavy && e.PreviousDamageState < DamageState.Heavy) - { anim.ReplaceAnim("damaged-idle"); - Sound.Play(self.Info.Traits.Get().DamagedSound, self.CenterLocation); - } else if (e.DamageState < DamageState.Heavy) anim.ReplaceAnim("idle"); } diff --git a/OpenRA.Mods.RA/Render/RenderBuildingTurreted.cs b/OpenRA.Mods.RA/Render/RenderBuildingTurreted.cs index f6b35a935e..fc1ed8e561 100644 --- a/OpenRA.Mods.RA/Render/RenderBuildingTurreted.cs +++ b/OpenRA.Mods.RA/Render/RenderBuildingTurreted.cs @@ -35,10 +35,7 @@ namespace OpenRA.Mods.RA.Render if (!e.DamageStateChanged) return; if (e.DamageState >= DamageState.Heavy && e.PreviousDamageState < DamageState.Heavy) - { anim.ReplaceAnim("damaged-idle"); - Sound.Play(self.Info.Traits.Get().DamagedSound, self.CenterLocation); - } else if (e.DamageState < DamageState.Heavy) anim.ReplaceAnim("idle"); } diff --git a/OpenRA.Mods.RA/Render/RenderBuildingWall.cs b/OpenRA.Mods.RA/Render/RenderBuildingWall.cs index cd894bf1eb..602edb751c 100644 --- a/OpenRA.Mods.RA/Render/RenderBuildingWall.cs +++ b/OpenRA.Mods.RA/Render/RenderBuildingWall.cs @@ -35,24 +35,14 @@ namespace OpenRA.Mods.RA.Render { if (!e.DamageStateChanged) return; - 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")) - { 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/bits/sandbag2.aud b/mods/cnc/bits/sandbag2.aud new file mode 100644 index 0000000000..b3b602415a Binary files /dev/null and b/mods/cnc/bits/sandbag2.aud differ diff --git a/mods/cnc/rules/defaults.yaml b/mods/cnc/rules/defaults.yaml index 30c0332679..6a19c57836 100644 --- a/mods/cnc/rules/defaults.yaml +++ b/mods/cnc/rules/defaults.yaml @@ -187,6 +187,7 @@ Footprint: x BuildSounds: constru2.aud, hvydoor1.aud SellSounds: cashturn.aud + SoundOnDamageTransition: DamagedSound: xplos.aud DestroyedSound: xplobig4.aud Buildable: @@ -208,6 +209,7 @@ Notification: strclost.aud EditorAppearance: RelativeToTopLeft: yes + ShakeOnDeath: ^CivBuilding: Inherits: ^Building @@ -243,8 +245,6 @@ BuildSounds: hvydoor1.aud Capturable: false BaseNormal: no - DamagedSound: - DestroyedSound: Adjacent: 7 TargetableBuilding: TargetTypes: Ground @@ -311,8 +311,9 @@ BelowUnits: Health: HP: 1000 - Building: + SoundOnDamageTransition: DamagedSound: xplos.aud DestroyedSound: xplobig4.aud + Building: Footprint: ______ ______ ______ ______ Dimensions: 6,4 diff --git a/mods/cnc/rules/structures.yaml b/mods/cnc/rules/structures.yaml index bb56a325e2..679a0b8e6b 100644 --- a/mods/cnc/rules/structures.yaml +++ b/mods/cnc/rules/structures.yaml @@ -569,8 +569,8 @@ BRIK: Type: Heavy Wall: CrushClasses: heavywall - CrushSound: - Building: + -CrushSound: + SoundOnDamageTransition: DestroyedSound: crumble.aud GUN: diff --git a/mods/ra/rules/defaults.yaml b/mods/ra/rules/defaults.yaml index 7149b35a5e..e1117c37da 100644 --- a/mods/ra/rules/defaults.yaml +++ b/mods/ra/rules/defaults.yaml @@ -130,6 +130,9 @@ Building: Dimensions: 1,1 Footprint: x + SoundOnDamageTransition: + DamagedSound: kaboom1.aud + DestroyedSound: kaboom22.aud RenderBuilding: RepairableBuilding: EmitInfantryOnSell: @@ -141,6 +144,7 @@ Notification: strucap1.aud EditorAppearance: RelativeToTopLeft: yes + ShakeOnDeath: ^Wall: AppearsOnRadar: @@ -150,9 +154,10 @@ BuildSounds: placbldg.aud Capturable: false BaseNormal: no + Adjacent: 7 + SoundOnDamageTransition: DamagedSound: sandbag2.aud DestroyedSound: sandbag2.aud - Adjacent: 7 Wall: CrushClasses: wall LineBuild: diff --git a/mods/ra/rules/structures.yaml b/mods/ra/rules/structures.yaml index 1bf328adad..aa2a446900 100755 --- a/mods/ra/rules/structures.yaml +++ b/mods/ra/rules/structures.yaml @@ -1135,7 +1135,7 @@ BRIK: Tooltip: Name: Concrete Wall Description: Stop units and blocks enemy fire. - Building: + SoundOnDamageTransition: DamagedSound: crmble2.aud DestroyedSound: kaboom30.aud Health: