From d68bc48ba513dfccecf3b3efa031f595ca9ddb36 Mon Sep 17 00:00:00 2001 From: Andre Mohren Date: Fri, 28 Apr 2017 10:56:08 +0200 Subject: [PATCH] Added ReloadSound and ReloadSoundDelay to weapon declarations. --- OpenRA.Game/GameRules/WeaponInfo.cs | 6 ++++++ OpenRA.Mods.Common/Traits/Armament.cs | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/OpenRA.Game/GameRules/WeaponInfo.cs b/OpenRA.Game/GameRules/WeaponInfo.cs index c5a8fd46f3..575b753d6e 100644 --- a/OpenRA.Game/GameRules/WeaponInfo.cs +++ b/OpenRA.Game/GameRules/WeaponInfo.cs @@ -42,6 +42,12 @@ namespace OpenRA.GameRules [Desc("The sound played when the weapon is fired.")] public readonly string[] Report = null; + [Desc("The sound played when the weapon is reloaded.")] + public readonly string[] AfterFireSound = null; + + [Desc("Delay in ticks to play reloading sound.")] + public readonly int AfterFireSoundDelay = 0; + [Desc("Delay in ticks between reloading ammo magazines.")] public readonly int ReloadDelay = 1; diff --git a/OpenRA.Mods.Common/Traits/Armament.cs b/OpenRA.Mods.Common/Traits/Armament.cs index 6e9c55463f..373fc03d83 100644 --- a/OpenRA.Mods.Common/Traits/Armament.cs +++ b/OpenRA.Mods.Common/Traits/Armament.cs @@ -263,6 +263,14 @@ namespace OpenRA.Mods.Common.Traits FireDelay = Util.ApplyPercentageModifiers(Weapon.ReloadDelay, modifiers); Burst = Weapon.Burst; + if (args.Weapon.AfterFireSound != null && args.Weapon.AfterFireSound.Any()) + { + ScheduleDelayedAction(Weapon.AfterFireSoundDelay, () => + { + Game.Sound.Play(SoundType.World, Weapon.AfterFireSound.Random(self.World.SharedRandom), self.CenterPosition); + }); + } + foreach (var nbc in self.TraitsImplementing()) nbc.FiredBurst(self, target, this); }