2021-07-21 19:16:38 +10:00
|
|
|
using Content.Server.Stunnable.Components;
|
2021-10-15 14:45:04 -07:00
|
|
|
using Content.Shared.StatusEffect;
|
2021-07-21 19:16:38 +10:00
|
|
|
using JetBrains.Annotations;
|
2022-01-17 14:21:57 -05:00
|
|
|
using Content.Shared.Throwing;
|
2022-09-14 17:26:26 +10:00
|
|
|
using Robust.Shared.Physics.Events;
|
2021-07-21 19:16:38 +10:00
|
|
|
|
|
|
|
|
namespace Content.Server.Stunnable
|
|
|
|
|
{
|
|
|
|
|
[UsedImplicitly]
|
|
|
|
|
internal sealed class StunOnCollideSystem : EntitySystem
|
|
|
|
|
{
|
2021-10-10 12:47:26 +02:00
|
|
|
[Dependency] private readonly StunSystem _stunSystem = default!;
|
|
|
|
|
|
2021-07-21 19:16:38 +10:00
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
base.Initialize();
|
|
|
|
|
SubscribeLocalEvent<StunOnCollideComponent, StartCollideEvent>(HandleCollide);
|
2022-01-17 14:21:57 -05:00
|
|
|
SubscribeLocalEvent<StunOnCollideComponent, ThrowDoHitEvent>(HandleThrow);
|
2021-07-21 19:16:38 +10:00
|
|
|
}
|
|
|
|
|
|
2022-01-17 14:21:57 -05:00
|
|
|
private void TryDoCollideStun(EntityUid uid, StunOnCollideComponent component, EntityUid target)
|
2021-07-21 19:16:38 +10:00
|
|
|
{
|
2022-01-17 14:21:57 -05:00
|
|
|
if (EntityManager.TryGetComponent<StatusEffectsComponent>(target, out var status))
|
2021-07-21 19:16:38 +10:00
|
|
|
{
|
2024-04-06 21:30:40 +09:00
|
|
|
_stunSystem.TryStun(target, TimeSpan.FromSeconds(component.StunAmount), true, status);
|
2021-10-10 12:47:26 +02:00
|
|
|
|
2024-04-06 21:30:40 +09:00
|
|
|
_stunSystem.TryKnockdown(target, TimeSpan.FromSeconds(component.KnockdownAmount), true, status);
|
2024-03-30 21:02:10 +09:00
|
|
|
|
2022-01-17 14:21:57 -05:00
|
|
|
_stunSystem.TrySlowdown(target, TimeSpan.FromSeconds(component.SlowdownAmount), true,
|
2022-01-05 00:19:23 -08:00
|
|
|
component.WalkSpeedMultiplier, component.RunSpeedMultiplier, status);
|
2021-07-21 19:16:38 +10:00
|
|
|
}
|
|
|
|
|
}
|
2022-09-14 17:26:26 +10:00
|
|
|
private void HandleCollide(EntityUid uid, StunOnCollideComponent component, ref StartCollideEvent args)
|
2022-01-17 14:21:57 -05:00
|
|
|
{
|
2023-08-23 18:55:58 +10:00
|
|
|
if (args.OurFixtureId != component.FixtureID)
|
|
|
|
|
return;
|
2022-05-21 18:04:47 +10:00
|
|
|
|
2023-05-09 19:21:26 +12:00
|
|
|
TryDoCollideStun(uid, component, args.OtherEntity);
|
2022-01-17 14:21:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void HandleThrow(EntityUid uid, StunOnCollideComponent component, ThrowDoHitEvent args)
|
|
|
|
|
{
|
|
|
|
|
TryDoCollideStun(uid, component, args.Target);
|
|
|
|
|
}
|
2021-07-21 19:16:38 +10:00
|
|
|
}
|
|
|
|
|
}
|