using Content.Shared.Movement.Events; using Content.Shared.Standing; using Content.Shared.Stunnable; using Robust.Shared.Physics.Events; namespace Content.Shared.Slippery; public sealed class SlidingSystem : EntitySystem { public override void Initialize() { base.Initialize(); SubscribeLocalEvent(OnSlideAttempt); SubscribeLocalEvent(OnStand); SubscribeLocalEvent(OnStartCollide); SubscribeLocalEvent(OnEndCollide); } /// /// Modify the friction by the frictionModifier stored on the component. /// private void OnSlideAttempt(EntityUid uid, SlidingComponent component, ref TileFrictionEvent args) { args.Modifier = component.FrictionModifier; } /// /// Remove the component when the entity stands up again. /// private void OnStand(EntityUid uid, SlidingComponent component, ref StoodEvent args) { RemComp(uid); } /// /// Sets friction to 0 if colliding with a SuperSlippery Entity. /// private void OnStartCollide(EntityUid uid, SlidingComponent component, ref StartCollideEvent args) { if (!TryComp(args.OtherEntity, out var slippery) || !slippery.SuperSlippery) return; component.CollidingEntities.Add(args.OtherEntity); component.FrictionModifier = 0; Dirty(uid, component); } /// /// Set friction to normal when ending collision with a SuperSlippery entity. /// private void OnEndCollide(EntityUid uid, SlidingComponent component, ref EndCollideEvent args) { if (!component.CollidingEntities.Remove(args.OtherEntity)) return; if (component.CollidingEntities.Count == 0) component.FrictionModifier = SharedStunSystem.KnockDownModifier; Dirty(uid, component); } }