mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 18:31:17 +03:00
* No more permastuns * Throwing rocks at the problem * Update StunOnCollideSystem.cs * Update Content.Server/Stunnable/Systems/StunOnCollideSystem.cs Co-authored-by: SnappingOpossum <snappingopossum@outlook.com> --------- Co-authored-by: SnappingOpossum <snappingopossum@outlook.com>
69 lines
2.2 KiB
C#
69 lines
2.2 KiB
C#
using Content.Server.Stunnable.Components;
|
|
using Content.Shared.Movement.Systems;
|
|
using JetBrains.Annotations;
|
|
using Content.Shared.Throwing;
|
|
using Robust.Shared.Physics.Events;
|
|
using Content.Shared.Whitelist;
|
|
|
|
namespace Content.Server.Stunnable.Systems;
|
|
|
|
[UsedImplicitly]
|
|
internal sealed partial class StunOnCollideSystem : EntitySystem
|
|
{
|
|
[Dependency] private StunSystem _stunSystem = default!;
|
|
[Dependency] private MovementModStatusSystem _movementMod = default!;
|
|
[Dependency] private EntityWhitelistSystem _entityWhitelist = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<StunOnCollideComponent, StartCollideEvent>(HandleCollide);
|
|
SubscribeLocalEvent<StunOnCollideComponent, ThrowDoHitEvent>(HandleThrow);
|
|
}
|
|
|
|
private void TryDoCollideStun(Entity<StunOnCollideComponent> ent, EntityUid target)
|
|
{
|
|
if (_entityWhitelist.IsWhitelistPass(ent.Comp.Blacklist, target))
|
|
return;
|
|
|
|
_stunSystem.TryKnockdown(target, ent.Comp.KnockdownAmount, ent.Comp.Refresh, ent.Comp.AutoStand, ent.Comp.Drop, true);
|
|
|
|
if (ent.Comp.Refresh)
|
|
{
|
|
_stunSystem.TryUpdateStunDuration(target, ent.Comp.StunAmount);
|
|
|
|
_movementMod.TryUpdateMovementSpeedModDuration(
|
|
target,
|
|
MovementModStatusSystem.TaserSlowdown,
|
|
ent.Comp.SlowdownAmount,
|
|
ent.Comp.WalkSpeedModifier,
|
|
ent.Comp.SprintSpeedModifier
|
|
);
|
|
}
|
|
else
|
|
{
|
|
_stunSystem.TryAddStunDuration(target, ent.Comp.StunAmount);
|
|
_movementMod.TryAddMovementSpeedModDuration(
|
|
target,
|
|
MovementModStatusSystem.TaserSlowdown,
|
|
ent.Comp.SlowdownAmount,
|
|
ent.Comp.WalkSpeedModifier,
|
|
ent.Comp.SprintSpeedModifier
|
|
);
|
|
}
|
|
}
|
|
|
|
private void HandleCollide(Entity<StunOnCollideComponent> ent, ref StartCollideEvent args)
|
|
{
|
|
if (args.OurFixtureId != ent.Comp.FixtureID)
|
|
return;
|
|
|
|
TryDoCollideStun(ent, args.OtherEntity);
|
|
}
|
|
|
|
private void HandleThrow(Entity<StunOnCollideComponent> ent, ref ThrowDoHitEvent args)
|
|
{
|
|
TryDoCollideStun(ent, args.Target);
|
|
}
|
|
}
|