Shadow anomaly returns (#24629)
* content * add cat * ambient * I FORGOT HEARTS! * fix ambient * some fixes * canCollide: false * connect to damageable * pi * remove fx * some fixes * *sad bruh* * hazed * Update base_shadow.yml
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
using Content.Shared.Damage;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Server.Flash.Components;
|
||||
|
||||
// Also needed FlashableComponent on entity to work
|
||||
[RegisterComponent, Access(typeof(DamagedByFlashingSystem))]
|
||||
public sealed partial class DamagedByFlashingComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// damage from flashing
|
||||
/// </summary>
|
||||
[DataField(required: true), ViewVariables(VVAccess.ReadWrite)]
|
||||
public DamageSpecifier FlashDamage = new ();
|
||||
}
|
||||
22
Content.Server/Flash/DamagedByFlashingSystem.cs
Normal file
22
Content.Server/Flash/DamagedByFlashingSystem.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using Content.Server.Flash.Components;
|
||||
using Content.Shared.Damage;
|
||||
|
||||
namespace Content.Server.Flash;
|
||||
public sealed class DamagedByFlashingSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly DamageableSystem _damageable = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<DamagedByFlashingComponent, FlashAttemptEvent>(OnFlashAttempt);
|
||||
}
|
||||
private void OnFlashAttempt(Entity<DamagedByFlashingComponent> ent, ref FlashAttemptEvent args)
|
||||
{
|
||||
_damageable.TryChangeDamage(ent, ent.Comp.FlashDamage);
|
||||
|
||||
//To Do: It would be more logical if different flashes had different power,
|
||||
//and the damage would be inflicted depending on the strength of the flash.
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,7 @@ namespace Content.Server.Flash
|
||||
[Dependency] private readonly SharedChargesSystem _charges = default!;
|
||||
[Dependency] private readonly EntityLookupSystem _entityLookup = default!;
|
||||
[Dependency] private readonly IGameTiming _timing = default!;
|
||||
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
||||
[Dependency] private readonly SharedInteractionSystem _interaction = default!;
|
||||
[Dependency] private readonly InventorySystem _inventory = default!;
|
||||
[Dependency] private readonly PopupSystem _popup = default!;
|
||||
@@ -150,27 +151,23 @@ namespace Content.Server.Flash
|
||||
public void FlashArea(EntityUid source, EntityUid? user, float range, float duration, float slowTo = 0.8f, bool displayPopup = false, SoundSpecifier? sound = null)
|
||||
{
|
||||
var transform = EntityManager.GetComponent<TransformComponent>(source);
|
||||
var mapPosition = transform.MapPosition;
|
||||
var flashableEntities = new List<EntityUid>();
|
||||
var mapPosition = _transform.GetMapCoordinates(transform);
|
||||
var flashableQuery = GetEntityQuery<FlashableComponent>();
|
||||
|
||||
foreach (var entity in _entityLookup.GetEntitiesInRange(transform.Coordinates, range))
|
||||
{
|
||||
if (!flashableQuery.HasComponent(entity))
|
||||
if (!flashableQuery.TryGetComponent(entity, out var flashable))
|
||||
continue;
|
||||
|
||||
flashableEntities.Add(entity);
|
||||
}
|
||||
|
||||
foreach (var entity in flashableEntities)
|
||||
{
|
||||
// Check for unobstructed entities while ignoring the mobs with flashable components.
|
||||
if (!_interaction.InRangeUnobstructed(entity, mapPosition, range, CollisionGroup.Opaque, (e) => flashableEntities.Contains(e) || e == source))
|
||||
if (!_interaction.InRangeUnobstructed(entity, mapPosition, range, flashable.CollisionGroup, (e) => e == source))
|
||||
continue;
|
||||
|
||||
// They shouldn't have flash removed in between right?
|
||||
Flash(entity, user, source, duration, slowTo, displayPopup, flashableQuery.GetComponent(entity));
|
||||
}
|
||||
|
||||
if (sound != null)
|
||||
{
|
||||
_audio.PlayPvs(sound, source, AudioParams.Default.WithVolume(1f).WithMaxDistance(3f));
|
||||
|
||||
Reference in New Issue
Block a user