From a8d8764b8101c4c8c4a7f6e3793170ca17a93299 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sun, 11 Oct 2015 19:18:04 +0200 Subject: [PATCH] unhardcode and self-document the notification --- .../Traits/Power/CanPowerDown.cs | 28 +++++++++++++++++-- mods/cnc/rules/structures.yaml | 6 ++++ mods/d2k/rules/structures.yaml | 8 ++++++ mods/ra/rules/structures.yaml | 12 ++++++++ 4 files changed, 52 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/Power/CanPowerDown.cs b/OpenRA.Mods.Common/Traits/Power/CanPowerDown.cs index 196d3ae2cb..fee4ef87a1 100644 --- a/OpenRA.Mods.Common/Traits/Power/CanPowerDown.cs +++ b/OpenRA.Mods.Common/Traits/Power/CanPowerDown.cs @@ -24,6 +24,12 @@ namespace OpenRA.Mods.Common.Traits [PaletteReference] public readonly string IndicatorPalette = "chrome"; + public readonly string PowerupSound = null; + public readonly string PowerdownSound = null; + + public readonly string PowerupSpeech = null; + public readonly string PowerdownSpeech = null; + public override object Create(ActorInitializer init) { return new CanPowerDown(init.Self, this); } } @@ -45,7 +51,19 @@ namespace OpenRA.Mods.Common.Traits if (!IsTraitDisabled && order.OrderString == "PowerDown") { disabled = !disabled; - Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Sounds", disabled ? "EnablePower" : "DisablePower", self.Owner.Faction.InternalName); + + if (Info.PowerupSound != null && disabled) + Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Sounds", Info.PowerupSound, self.Owner.Faction.InternalName); + + if (Info.PowerdownSound != null && !disabled) + Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Sounds", Info.PowerdownSound, self.Owner.Faction.InternalName); + + if (Info.PowerupSpeech != null && disabled) + Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", Info.PowerupSpeech, self.Owner.Faction.InternalName); + + if (Info.PowerdownSpeech != null && !disabled) + Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", Info.PowerdownSpeech, self.Owner.Faction.InternalName); + power.UpdateActor(self); if (disabled) @@ -68,7 +86,13 @@ namespace OpenRA.Mods.Common.Traits if (!disabled || !Info.CancelWhenDisabled) return; disabled = false; - Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Sounds", "EnablePower", self.Owner.Faction.InternalName); + + if (Info.PowerupSound != null) + Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Sound", Info.PowerupSound, self.Owner.Faction.InternalName); + + if (Info.PowerupSpeech != null) + Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", Info.PowerupSpeech, self.Owner.Faction.InternalName); + power.UpdateActor(self); } } diff --git a/mods/cnc/rules/structures.yaml b/mods/cnc/rules/structures.yaml index f4f17ad671..9bed45effe 100644 --- a/mods/cnc/rules/structures.yaml +++ b/mods/cnc/rules/structures.yaml @@ -460,6 +460,8 @@ HQ: Bounds: 48,36,0,12 RequiresPower: CanPowerDown: + PowerupSound: EnablePower + PowerdownSound: DisablePower DisabledOverlay: WithSpriteBody: PauseAnimationWhenDisabled: true @@ -547,6 +549,8 @@ EYE: Bounds: 48,36,0,12 RequiresPower: CanPowerDown: + PowerupSound: EnablePower + PowerdownSound: DisablePower DisabledOverlay: WithSpriteBody: PauseAnimationWhenDisabled: true @@ -598,6 +602,8 @@ TMPL: Bounds: 72,48,0,16 RequiresPower: CanPowerDown: + PowerupSound: EnablePower + PowerdownSound: DisablePower DisabledOverlay: Health: HP: 2000 diff --git a/mods/d2k/rules/structures.yaml b/mods/d2k/rules/structures.yaml index 6ffa3bae67..7d6462e4fa 100644 --- a/mods/d2k/rules/structures.yaml +++ b/mods/d2k/rules/structures.yaml @@ -444,6 +444,8 @@ outpost: Inherits: ^Building RequiresPower: CanPowerDown: + PowerupSound: EnablePower + PowerdownSound: DisablePower DisabledOverlay: Buildable: Prerequisites: construction_yard, barracks, ~techlevel.medium @@ -528,6 +530,8 @@ starport: PrimaryBuilding: RequiresPower: CanPowerDown: + PowerupSound: EnablePower + PowerdownSound: DisablePower DisabledOverlay: ProvidesPrerequisite@atreides: Prerequisite: starport.atreides @@ -672,6 +676,8 @@ large_gun_turret: InitialFacing: 128 RequiresPower: CanPowerDown: + PowerupSound: EnablePower + PowerdownSound: DisablePower DisabledOverlay: Power: Amount: -60 @@ -923,6 +929,8 @@ palace: Production: Produces: Palace CanPowerDown: + PowerupSound: EnablePower + PowerdownSound: DisablePower DisabledOverlay: RequiresPower: SupportPowerChargeBar: diff --git a/mods/ra/rules/structures.yaml b/mods/ra/rules/structures.yaml index 39563ed088..bcef4b5ce3 100644 --- a/mods/ra/rules/structures.yaml +++ b/mods/ra/rules/structures.yaml @@ -40,6 +40,8 @@ MSLO: CameraActor: camera FlashType: Nuke CanPowerDown: + PowerupSound: EnablePower + PowerdownSound: DisablePower RequiresPower: DisabledOverlay: SupportPowerChargeBar: @@ -274,6 +276,8 @@ IRON: Dimensions: 2,1 RequiresPower: CanPowerDown: + PowerupSound: EnablePower + PowerdownSound: DisablePower DisabledOverlay: Selectable: Bounds: 48,28,0,2 @@ -322,6 +326,8 @@ PDOX: Dimensions: 2,2 RequiresPower: CanPowerDown: + PowerupSound: EnablePower + PowerdownSound: DisablePower DisabledOverlay: Health: HP: 1000 @@ -394,6 +400,8 @@ TSLA: SelectionDecorations: VisualBounds: 24,36,0,4 CanPowerDown: + PowerupSound: EnablePower + PowerdownSound: DisablePower DisabledOverlay: Health: HP: 400 @@ -439,6 +447,8 @@ AGUN: VisualBounds: 24,36,0,12 RequiresPower: CanPowerDown: + PowerupSound: EnablePower + PowerdownSound: DisablePower DisabledOverlay: Health: HP: 400 @@ -486,6 +496,8 @@ DOME: TargetTypes: Ground, Structure, C4, DetonateAttack, SpyInfiltrate RequiresPower: CanPowerDown: + PowerupSound: EnablePower + PowerdownSound: DisablePower DisabledOverlay: Health: HP: 1000