Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com> Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com> Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com> Co-authored-by: ScarKy0 <scarky0@onet.eu>
48 lines
1.7 KiB
C#
48 lines
1.7 KiB
C#
using Content.Server.Stunnable.Components;
|
|
using Content.Shared.Standing;
|
|
using Content.Shared.StatusEffect;
|
|
using JetBrains.Annotations;
|
|
using Robust.Shared.Physics.Dynamics;
|
|
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 (!TryComp<StatusEffectsComponent>(target, out var status))
|
|
return;
|
|
|
|
_stunSystem.TryStun(target, component.StunAmount, component.Refresh, status);
|
|
|
|
_stunSystem.TryKnockdown(target, component.KnockdownAmount, component.Refresh, component.AutoStand);
|
|
|
|
_stunSystem.TrySlowdown(target, component.SlowdownAmount, component.Refresh, component.WalkSpeedModifier, component.SprintSpeedModifier, 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);
|
|
}
|
|
}
|
|
}
|