Files
OldThink/Content.Server/Stunnable/Systems/StunOnCollideSystem.cs
Aviu00 883623e448 Всякое (#271)
* - tweak: Something.

* - tweak: Tweaks.

* - tweak: Death to autoklickers.

* - tweak: Warop tweak.

* - tweak: Neuro tweaks.

* - add: Translate animal accents.

* - fix: Embeddable projectiles miss corpses.

* - tweak: More sniper ammo.

* - tweak: Free clothes in uplink.

* - tweak: Less speed up from stuff.

* - tweak: Ammo counter and toggleable clothing stuff.

* - add: More emag stuff.

* - tweak: No neuro blunt stamina damage.

* - fix: Fix name.

* - fix: Fix desc.
2024-04-06 15:30:40 +03:00

47 lines
1.7 KiB
C#

using Content.Server.Stunnable.Components;
using Content.Shared.StatusEffect;
using JetBrains.Annotations;
using Content.Shared.Throwing;
using Robust.Shared.Physics.Events;
namespace Content.Server.Stunnable
{
[UsedImplicitly]
internal sealed class StunOnCollideSystem : EntitySystem
{
[Dependency] private readonly StunSystem _stunSystem = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<StunOnCollideComponent, StartCollideEvent>(HandleCollide);
SubscribeLocalEvent<StunOnCollideComponent, ThrowDoHitEvent>(HandleThrow);
}
private void TryDoCollideStun(EntityUid uid, StunOnCollideComponent component, EntityUid target)
{
if (EntityManager.TryGetComponent<StatusEffectsComponent>(target, out var status))
{
_stunSystem.TryStun(target, TimeSpan.FromSeconds(component.StunAmount), true, status);
_stunSystem.TryKnockdown(target, TimeSpan.FromSeconds(component.KnockdownAmount), true, status);
_stunSystem.TrySlowdown(target, TimeSpan.FromSeconds(component.SlowdownAmount), true,
component.WalkSpeedMultiplier, component.RunSpeedMultiplier, status);
}
}
private void HandleCollide(EntityUid uid, StunOnCollideComponent component, ref StartCollideEvent args)
{
if (args.OurFixtureId != component.FixtureID)
return;
TryDoCollideStun(uid, component, args.OtherEntity);
}
private void HandleThrow(EntityUid uid, StunOnCollideComponent component, ThrowDoHitEvent args)
{
TryDoCollideStun(uid, component, args.Target);
}
}
}