From 6c6c19adba95681b3d6347f1257eebbe3547cdef Mon Sep 17 00:00:00 2001 From: Charlese2 Date: Mon, 27 Dec 2021 09:51:12 -0700 Subject: [PATCH] Make handheld flash not flash thourgh walls. (#5916) Also make it so mobs don't block the flash. --- Content.Server/Flash/FlashSystem.cs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/Content.Server/Flash/FlashSystem.cs b/Content.Server/Flash/FlashSystem.cs index 6e20ae02d5..91750ea0c4 100644 --- a/Content.Server/Flash/FlashSystem.cs +++ b/Content.Server/Flash/FlashSystem.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using Content.Server.Flash.Components; using Content.Server.Inventory.Components; using Content.Server.Items; @@ -75,10 +76,7 @@ namespace Content.Server.Flash return; } - foreach (var entity in _entityLookup.GetEntitiesInRange(EntityManager.GetComponent(comp.Owner).Coordinates, comp.Range)) - { - Flash(entity, args.User, uid, comp.AoeFlashDuration, comp.SlowTo); - } + FlashArea(uid, args.User, comp.Range, comp.AoeFlashDuration, comp.SlowTo, true); } private bool UseFlash(FlashComponent comp, EntityUid user) @@ -142,15 +140,24 @@ namespace Content.Server.Flash public void FlashArea(EntityUid source, EntityUid? user, float range, float duration, float slowTo = 0f, bool displayPopup = false, SoundSpecifier? sound = null) { var transform = EntityManager.GetComponent(source); + var flashableEntities = new List(); foreach (var entity in _entityLookup.GetEntitiesInRange(transform.Coordinates, range)) { - if (!EntityManager.HasComponent(entity) || - !transform.InRangeUnobstructed(entity, range, CollisionGroup.Opaque)) continue; + if (!EntityManager.HasComponent(entity)) + continue; + + flashableEntities.Add(entity); + } + + foreach (var entity in flashableEntities) + { + // Check for unobstructed entities while ignoring the mobs with flashable components. + if (!transform.InRangeUnobstructed(entity, range, CollisionGroup.Opaque, (e) => flashableEntities.Contains(e))) + continue; Flash(entity, user, source, duration, slowTo, displayPopup); } - if (sound != null) { SoundSystem.Play(Filter.Pvs(transform), sound.GetSound(), transform.Coordinates);