示例#1
0
        private void TrySlip(SlipperyComponent component, EntityUid other)
        {
            if (HasComp <KnockedDownComponent>(other))
            {
                return;
            }

            var ev = new SlipAttemptEvent();

            RaiseLocalEvent(other, ev, false);
            if (ev.Cancelled)
            {
                return;
            }

            if (TryComp(other, out PhysicsComponent? physics))
            {
                physics.LinearVelocity *= component.LaunchForwardsMultiplier;
            }

            var playSound = !_statusEffectsSystem.HasStatusEffect(other, "KnockedDown");

            _stunSystem.TryParalyze(other, TimeSpan.FromSeconds(component.ParalyzeTime), true);

            // Preventing from playing the slip sound when you are already knocked down.
            if (playSound)
            {
                PlaySound(component);
            }

            _adminLogger.Add(LogType.Slip, LogImpact.Low,
                             $"{ToPrettyString(other):mob} slipped on collision with {ToPrettyString(component.Owner):entity}");
        }
示例#2
0
 private void HandleAttemptCollide(
     EntityUid uid,
     SlipperyComponent component,
     ref StepTriggerAttemptEvent args)
 {
     args.Continue |= CanSlip(uid, args.Tripper);
 }
示例#3
0
        // TODO: Now that we have StartCollide and EndCollide this should just use that to track bodies intersecting.
        private void Update(SlipperyComponent component)
        {
            if (!component.Slippery)
            {
                return;
            }

            if (!ComponentManager.TryGetComponent(component.Owner.Uid, out PhysicsComponent? body))
            {
                component.Colliding.Clear();
                return;
            }

            foreach (var uid in component.Colliding.ToArray())
            {
                if (!uid.IsValid() || !EntityManager.TryGetEntity(uid, out var entity))
                {
                    component.Colliding.Remove(uid);
                    component.Slipped.Remove(uid);
                    component.Dirty();
                    continue;
                }

                if (!entity.TryGetComponent(out PhysicsComponent? otherPhysics) ||
                    !body.GetWorldAABB().Intersects(otherPhysics.GetWorldAABB()))
                {
                    component.Colliding.Remove(uid);
                    component.Slipped.Remove(uid);
                    component.Dirty();
                    continue;
                }

                if (!component.Slipped.Contains(uid))
                {
                    TrySlip(component, body, otherPhysics);
                }
            }
        }
示例#4
0
        private bool TrySlip(SlipperyComponent component, IPhysBody ourBody, IPhysBody otherBody)
        {
            if (!component.Slippery ||
                component.Owner.IsInContainer() ||
                component.Slipped.Contains(otherBody.Owner.Uid) ||
                !otherBody.Owner.TryGetComponent(out SharedStunnableComponent? stun))
            {
                return(false);
            }

            if (otherBody.LinearVelocity.Length < component.RequiredSlipSpeed || stun.KnockedDown)
            {
                return(false);
            }

            var percentage = otherBody.GetWorldAABB().IntersectPercentage(ourBody.GetWorldAABB());

            if (percentage < component.IntersectPercentage)
            {
                return(false);
            }

            if (!EffectBlockerSystem.CanSlip(otherBody.Owner))
            {
                return(false);
            }

            otherBody.LinearVelocity *= component.LaunchForwardsMultiplier;

            stun.Paralyze(5);
            component.Slipped.Add(otherBody.Owner.Uid);
            component.Dirty();

            PlaySound(component);

            return(true);
        }
示例#5
0
 // Until we get predicted slip sounds TM?
 protected abstract void PlaySound(SlipperyComponent component);
示例#6
0
 private void HandleCollide(EntityUid uid, SlipperyComponent component, StartCollideEvent args)
 {
     component.Colliding.Add(args.OtherFixture.Body.Owner.Uid);
 }
示例#7
0
 private void HandleStepTrigger(EntityUid uid, SlipperyComponent component, ref StepTriggeredEvent args)
 {
     TrySlip(component, args.Tripper);
 }