Make flash prevent handheld light toggle (#9448)

Co-authored-by: Kara <lunarautomaton6@gmail.com>
This commit is contained in:
Jacob Tong
2022-07-14 19:39:42 -07:00
committed by GitHub
parent a7ac81635c
commit 3bbbb59bb1

View File

@@ -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<FlashComponent, MeleeHitEvent>(OnFlashMeleeHit);
SubscribeLocalEvent<FlashComponent, UseInHandEvent>(OnFlashUseInHand, before: new []{ typeof(HandheldLightSystem) });
SubscribeLocalEvent<FlashComponent, ExaminedEvent>(OnFlashExamined);
SubscribeLocalEvent<InventoryComponent, FlashAttemptEvent>(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)
{