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(HandleCollide); SubscribeLocalEvent(HandleThrow); } private void TryDoCollideStun(EntityUid uid, StunOnCollideComponent component, EntityUid target) { if (!TryComp(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); } } }