private void OnRiderPull(EntityUid uid, RiderComponent component, PullAttemptEvent args)
 {
     if (component.Vehicle != null)
     {
         args.Cancelled = true;
     }
 }
Ejemplo n.º 2
0
 private void OnPullAttempt(EntityUid uid, AdminFrozenComponent component, PullAttemptEvent args)
 {
     args.Cancelled = true;
 }
Ejemplo n.º 3
0
        private static void HandlePullAttempt(EntityUid uid, HandsComponent component, PullAttemptEvent args)
        {
            if (args.Puller.Owner != uid)
            {
                return;
            }

            // Cancel pull if all hands full.
            if (!component.IsAnyHandFree())
            {
                args.Cancelled = true;
            }
        }
        // The main "start pulling" function.
        public bool TryStartPull(SharedPullerComponent puller, SharedPullableComponent pullable)
        {
            if (puller.Pulling == pullable.Owner)
            {
                return(true);
            }

            // Pulling a new object : Perform sanity checks.

            if (!CanPull(puller.Owner, pullable.Owner))
            {
                return(false);
            }

            if (!EntityManager.TryGetComponent <PhysicsComponent>(puller.Owner, out var pullerPhysics))
            {
                return(false);
            }

            if (!EntityManager.TryGetComponent <PhysicsComponent>(pullable.Owner, out var pullablePhysics))
            {
                return(false);
            }

            // Ensure that the puller is not currently pulling anything.
            // If this isn't done, then it happens too late, and the start/stop messages go out of order,
            //  and next thing you know it thinks it's not pulling anything even though it is!

            var oldPullable = puller.Pulling;

            if (oldPullable != null)
            {
                if (EntityManager.TryGetComponent <SharedPullableComponent?>(oldPullable.Value, out var oldPullableComp))
                {
                    if (!TryStopPull(oldPullableComp))
                    {
                        return(false);
                    }
                }
                else
                {
                    Logger.WarningS("c.go.c.pulling", "Well now you've done it, haven't you? Someone transferred pulling (onto {0}) while presently pulling something that has no Pullable component (on {1})!", pullable.Owner, oldPullable);
                    return(false);
                }
            }

            // Ensure that the pullable is not currently being pulled.
            // Same sort of reasons as before.

            var oldPuller = pullable.Puller;

            if (oldPuller != null)
            {
                if (!TryStopPull(pullable))
                {
                    return(false);
                }
            }

            // Continue with pulling process.

            var pullAttempt = new PullAttemptEvent(pullerPhysics, pullablePhysics);

            RaiseLocalEvent(puller.Owner, pullAttempt, broadcast: false);

            if (pullAttempt.Cancelled)
            {
                return(false);
            }

            RaiseLocalEvent(pullable.Owner, pullAttempt, true);

            if (pullAttempt.Cancelled)
            {
                return(false);
            }

            _pullSm.ForceRelationship(puller, pullable);
            pullable.PrevFixedRotation    = pullablePhysics.FixedRotation;
            pullablePhysics.FixedRotation = pullable.FixedRotationOnPull;
            return(true);
        }