* 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
26 lines
816 B
C#
26 lines
816 B
C#
using Content.Shared.Damage.Systems;
|
|
using Content.Shared.Weapons.Hitscan.Components;
|
|
using Content.Shared.Weapons.Hitscan.Events;
|
|
|
|
namespace Content.Shared.Weapons.Hitscan.Systems;
|
|
|
|
public sealed class HitscanStunSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly SharedStaminaSystem _stamina = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<HitscanStaminaDamageComponent, HitscanRaycastFiredEvent>(OnHitscanHit);
|
|
}
|
|
|
|
private void OnHitscanHit(Entity<HitscanStaminaDamageComponent> hitscan, ref HitscanRaycastFiredEvent args)
|
|
{
|
|
if (args.Data.HitEntity == null)
|
|
return;
|
|
|
|
_stamina.TakeStaminaDamage(args.Data.HitEntity.Value, hitscan.Comp.StaminaDamage, source: args.Data.Shooter ?? args.Data.Gun);
|
|
}
|
|
}
|