Make handheld flash not flash thourgh walls. (#5916)

Also make it so mobs don't block the flash.
This commit is contained in:
Charlese2
2021-12-27 09:51:12 -07:00
committed by GitHub
parent 8281bbb655
commit 6c6c19adba

View File

@@ -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<TransformComponent>(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<TransformComponent>(source);
var flashableEntities = new List<EntityUid>();
foreach (var entity in _entityLookup.GetEntitiesInRange(transform.Coordinates, range))
{
if (!EntityManager.HasComponent<FlashableComponent>(entity) ||
!transform.InRangeUnobstructed(entity, range, CollisionGroup.Opaque)) continue;
if (!EntityManager.HasComponent<FlashableComponent>(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);