Make flash prevent handheld light toggle (#9448)
Co-authored-by: Kara <lunarautomaton6@gmail.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using Content.Server.Flash.Components;
|
using Content.Server.Flash.Components;
|
||||||
|
using Content.Server.Light.EntitySystems;
|
||||||
using Content.Server.Stunnable;
|
using Content.Server.Stunnable;
|
||||||
using Content.Server.Weapon.Melee;
|
using Content.Server.Weapon.Melee;
|
||||||
using Content.Shared.Examine;
|
using Content.Shared.Examine;
|
||||||
@@ -31,6 +32,7 @@ namespace Content.Server.Flash
|
|||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
SubscribeLocalEvent<FlashComponent, MeleeHitEvent>(OnFlashMeleeHit);
|
SubscribeLocalEvent<FlashComponent, MeleeHitEvent>(OnFlashMeleeHit);
|
||||||
|
SubscribeLocalEvent<FlashComponent, UseInHandEvent>(OnFlashUseInHand, before: new []{ typeof(HandheldLightSystem) });
|
||||||
SubscribeLocalEvent<FlashComponent, ExaminedEvent>(OnFlashExamined);
|
SubscribeLocalEvent<FlashComponent, ExaminedEvent>(OnFlashExamined);
|
||||||
|
|
||||||
SubscribeLocalEvent<InventoryComponent, FlashAttemptEvent>(OnInventoryFlashAttempt);
|
SubscribeLocalEvent<InventoryComponent, FlashAttemptEvent>(OnInventoryFlashAttempt);
|
||||||
@@ -67,9 +69,7 @@ namespace Content.Server.Flash
|
|||||||
private void OnFlashMeleeHit(EntityUid uid, FlashComponent comp, MeleeHitEvent args)
|
private void OnFlashMeleeHit(EntityUid uid, FlashComponent comp, MeleeHitEvent args)
|
||||||
{
|
{
|
||||||
if (!UseFlash(comp, args.User))
|
if (!UseFlash(comp, args.User))
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
args.Handled = true;
|
args.Handled = true;
|
||||||
foreach (var e in args.HitEntities)
|
foreach (var e in args.HitEntities)
|
||||||
@@ -78,6 +78,15 @@ namespace Content.Server.Flash
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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)
|
private bool UseFlash(FlashComponent comp, EntityUid user)
|
||||||
{
|
{
|
||||||
if (comp.HasUses)
|
if (comp.HasUses)
|
||||||
|
|||||||
Reference in New Issue
Block a user