From 5d4ad5f1507f2ba7b8b7da16690e8c8faa6517cd Mon Sep 17 00:00:00 2001 From: RemberBL Date: Sun, 4 Oct 2020 18:10:33 +0200 Subject: [PATCH] Fixed flashlights staying enabled after taking the battery out of them (#2158) * Fixed flashlights staying enabled after taking the battery out of them * Refactored code for flashlights shutting off after the battery is removed * Fixed casing in makeNoise --- .../Components/Interactable/HandheldLightComponent.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Content.Server/GameObjects/Components/Interactable/HandheldLightComponent.cs b/Content.Server/GameObjects/Components/Interactable/HandheldLightComponent.cs index ae3e86e268..e29cdd8d2d 100644 --- a/Content.Server/GameObjects/Components/Interactable/HandheldLightComponent.cs +++ b/Content.Server/GameObjects/Components/Interactable/HandheldLightComponent.cs @@ -124,7 +124,7 @@ namespace Content.Server.GameObjects.Components.Interactable return true; } - private void TurnOff() + private void TurnOff(bool makeNoise = true) { if (!Activated) { @@ -134,7 +134,10 @@ namespace Content.Server.GameObjects.Components.Interactable SetState(false); Activated = false; - EntitySystem.Get().PlayFromEntity("/Audio/Items/flashlight_toggle.ogg", Owner); + if (makeNoise) + { + EntitySystem.Get().PlayFromEntity("/Audio/Items/flashlight_toggle.ogg", Owner); + } } private void TurnOn(IEntity user) @@ -237,6 +240,9 @@ namespace Content.Server.GameObjects.Components.Interactable cell.Owner.Transform.Coordinates = user.Transform.Coordinates; } + // Assuming the battery has just been taken out of the flashlight, make sure it's getting disabled + TurnOff(false); + EntitySystem.Get().PlayFromEntity("/Audio/Items/pistol_magout.ogg", Owner); }