Пример #1
0
        private static void PullerHandlePullStopped(
            EntityUid uid,
            SharedPullerComponent component,
            PullStoppedMessage args)
        {
            if (args.Puller.Owner.Uid != uid)
            {
                return;
            }

            if (component.Owner.TryGetComponent(out SharedAlertsComponent? alerts))
            {
                alerts.ClearAlert(AlertType.Pulling);
            }
        }
Пример #2
0
        private void PullerHandlePullStopped(
            EntityUid uid,
            SharedPullerComponent component,
            PullStoppedMessage args)
        {
            if (args.Puller.Owner != uid)
            {
                return;
            }

            var euid = component.Owner;

            _alertsSystem.ClearAlert(euid, AlertType.Pulling);

            RefreshMovementSpeed(component);
        }
Пример #3
0
        private void HandlePullStopped(EntityUid uid, HandsComponent component, PullStoppedMessage args)
        {
            // Try find hand that is doing this pull.
            // and clear it.
            foreach (var hand in component.Hands)
            {
                if (hand.HeldEntity == default ||
                    !EntityManager.TryGetComponent(hand.HeldEntity, out HandVirtualItemComponent? virtualItem) ||
                    virtualItem.BlockingEntity != args.Pulled.Owner)
                {
                    continue;
                }

                EntityManager.DeleteEntity(hand.HeldEntity);
                break;
            }
        }
Пример #4
0
        private void HandlePullStopped(EntityUid uid, HandsComponent component, PullStoppedMessage args)
        {
            // Try find hand that is doing this pull.
            // and clear it.
            foreach (var hand in component.Hands)
            {
                if (hand.HeldEntity == null ||
                    !hand.HeldEntity.TryGetComponent(out HandVirtualPullComponent? virtualPull) ||
                    virtualPull.PulledEntity != args.Pulled.Owner.Uid)
                {
                    continue;
                }

                hand.HeldEntity.Delete();
                break;
            }
        }
Пример #5
0
        private void PullerHandlePullStopped(
            EntityUid uid,
            SharedPullerComponent component,
            PullStoppedMessage args)
        {
            if (args.Puller.Owner != uid)
            {
                return;
            }

            if (EntityManager.TryGetComponent(component.Owner, out SharedAlertsComponent? alerts))
            {
                alerts.ClearAlert(AlertType.Pulling);
            }

            RefreshMovementSpeed(component);
        }
Пример #6
0
        private void HandlePullStopped(EntityUid uid, HandsComponent component, PullStoppedMessage args)
        {
            if (args.Puller.Owner != uid)
            {
                return;
            }

            // Try find hand that is doing this pull.
            // and clear it.
            foreach (var hand in component.Hands.Values)
            {
                if (hand.HeldEntity == null ||
                    !TryComp(hand.HeldEntity, out HandVirtualItemComponent? virtualItem) ||
                    virtualItem.BlockingEntity != args.Pulled.Owner)
                {
                    continue;
                }

                QueueDel(hand.HeldEntity.Value);
                break;
            }
        }
        // A WARNING:
        // The following 2 functions are the most internal part of the pulling system's relationship management.
        // They do not expect to be cancellable.
        private void ForceDisconnect(SharedPullerComponent puller, SharedPullableComponent pullable)
        {
            var pullerPhysics   = puller.Owner.GetComponent <PhysicsComponent>();
            var pullablePhysics = pullable.Owner.GetComponent <PhysicsComponent>();

            // MovingTo shutdown
            ForceSetMovingTo(pullable, null);

            // Joint shutdown
            if (puller.Owner.TryGetComponent <JointComponent>(out var jointComp))
            {
                if (jointComp.GetJoints.Contains(pullable.PullJoint !))
                {
                    _jointSystem.RemoveJoint(pullable.PullJoint !);
                }
            }
            pullable.PullJoint = null;

            // State shutdown
            puller.Pulling  = null;
            pullable.Puller = null;

            // Messaging
            var message = new PullStoppedMessage(pullerPhysics, pullablePhysics);

            RaiseLocalEvent(puller.Owner.Uid, message, broadcast: false);

            if (pullable.Owner.LifeStage <= EntityLifeStage.MapInitialized)
            {
                RaiseLocalEvent(pullable.Owner.Uid, message);
            }

            // Networking
            puller.Dirty();
            pullable.Dirty();
        }
 private void OnPullStopped(PullStoppedMessage message)
 {
     RemovePuller(message.Puller.Owner);
 }