Files
ss14-wega/Content.Shared/Weapons/Hitscan/Systems/HitscanBasicEffectsSystem.cs
beck-thompson 492a1aa9c3 Hitscans are now entities (#38035)
* Hitscans are now entities

* Cleanup

* Cleanup

* Silly mistakes but stop sign testing helps :)

* Address most of the review

* Reviews

* perry :(

* Final reviews

* Add comments

* Split event up

* better comment

* cleanup
2025-10-18 05:42:08 +00:00

37 lines
1.2 KiB
C#

using Content.Shared.Damage;
using Content.Shared.Effects;
using Content.Shared.Weapons.Hitscan.Components;
using Content.Shared.Weapons.Hitscan.Events;
using Content.Shared.Weapons.Ranged.Systems;
using Robust.Shared.Player;
namespace Content.Shared.Weapons.Hitscan.Systems;
public sealed class HitscanBasicEffectsSystem : EntitySystem
{
[Dependency] private readonly SharedColorFlashEffectSystem _color = default!;
[Dependency] private readonly SharedGunSystem _gun = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<HitscanBasicEffectsComponent, HitscanDamageDealtEvent>(OnHitscanDamageDealt);
}
private void OnHitscanDamageDealt(Entity<HitscanBasicEffectsComponent> ent, ref HitscanDamageDealtEvent args)
{
if (Deleted(args.Target))
return;
if (ent.Comp.HitColor != null && args.DamageDealt.GetTotal() != 0)
{
_color.RaiseEffect(ent.Comp.HitColor.Value,
new List<EntityUid> { args.Target },
Filter.Pvs(args.Target, entityManager: EntityManager));
}
_gun.PlayImpactSound(args.Target, args.DamageDealt, ent.Comp.Sound, ent.Comp.ForceSound);
}
}