Make handheld flash not flash thourgh walls. (#5916)
Also make it so mobs don't block the flash.
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using Content.Server.Flash.Components;
|
using Content.Server.Flash.Components;
|
||||||
using Content.Server.Inventory.Components;
|
using Content.Server.Inventory.Components;
|
||||||
using Content.Server.Items;
|
using Content.Server.Items;
|
||||||
@@ -75,10 +76,7 @@ namespace Content.Server.Flash
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var entity in _entityLookup.GetEntitiesInRange(EntityManager.GetComponent<TransformComponent>(comp.Owner).Coordinates, comp.Range))
|
FlashArea(uid, args.User, comp.Range, comp.AoeFlashDuration, comp.SlowTo, true);
|
||||||
{
|
|
||||||
Flash(entity, args.User, uid, comp.AoeFlashDuration, comp.SlowTo);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool UseFlash(FlashComponent comp, EntityUid user)
|
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)
|
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 transform = EntityManager.GetComponent<TransformComponent>(source);
|
||||||
|
var flashableEntities = new List<EntityUid>();
|
||||||
|
|
||||||
foreach (var entity in _entityLookup.GetEntitiesInRange(transform.Coordinates, range))
|
foreach (var entity in _entityLookup.GetEntitiesInRange(transform.Coordinates, range))
|
||||||
{
|
{
|
||||||
if (!EntityManager.HasComponent<FlashableComponent>(entity) ||
|
if (!EntityManager.HasComponent<FlashableComponent>(entity))
|
||||||
!transform.InRangeUnobstructed(entity, range, CollisionGroup.Opaque)) continue;
|
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);
|
Flash(entity, user, source, duration, slowTo, displayPopup);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sound != null)
|
if (sound != null)
|
||||||
{
|
{
|
||||||
SoundSystem.Play(Filter.Pvs(transform), sound.GetSound(), transform.Coordinates);
|
SoundSystem.Play(Filter.Pvs(transform), sound.GetSound(), transform.Coordinates);
|
||||||
|
|||||||
Reference in New Issue
Block a user