From 3bbbb59bb1959d50e5aafeb29a194fffc2f6c8fc Mon Sep 17 00:00:00 2001 From: Jacob Tong <10494922+ShadowCommander@users.noreply.github.com> Date: Thu, 14 Jul 2022 19:39:42 -0700 Subject: [PATCH] Make flash prevent handheld light toggle (#9448) Co-authored-by: Kara --- Content.Server/Flash/FlashSystem.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Content.Server/Flash/FlashSystem.cs b/Content.Server/Flash/FlashSystem.cs index 3f585b4403..80f669df9e 100644 --- a/Content.Server/Flash/FlashSystem.cs +++ b/Content.Server/Flash/FlashSystem.cs @@ -1,4 +1,5 @@ using Content.Server.Flash.Components; +using Content.Server.Light.EntitySystems; using Content.Server.Stunnable; using Content.Server.Weapon.Melee; using Content.Shared.Examine; @@ -31,6 +32,7 @@ namespace Content.Server.Flash { base.Initialize(); SubscribeLocalEvent(OnFlashMeleeHit); + SubscribeLocalEvent(OnFlashUseInHand, before: new []{ typeof(HandheldLightSystem) }); SubscribeLocalEvent(OnFlashExamined); SubscribeLocalEvent(OnInventoryFlashAttempt); @@ -67,9 +69,7 @@ namespace Content.Server.Flash private void OnFlashMeleeHit(EntityUid uid, FlashComponent comp, MeleeHitEvent args) { if (!UseFlash(comp, args.User)) - { return; - } args.Handled = true; foreach (var e in args.HitEntities) @@ -77,6 +77,15 @@ namespace Content.Server.Flash Flash(e, args.User, uid, comp.FlashDuration, comp.SlowTo); } } + + private void OnFlashUseInHand(EntityUid uid, FlashComponent comp, UseInHandEvent args) + { + if (args.Handled || !UseFlash(comp, args.User)) + return; + + args.Handled = true; + FlashArea(uid, args.User, comp.Range, comp.AoeFlashDuration, comp.SlowTo, true); + } private bool UseFlash(FlashComponent comp, EntityUid user) {