private void AttemptPull(PullAttemptMessage msg) { if (!ReadOnlyHands.Any(hand => hand.Enabled)) { msg.Cancelled = true; } }
private static void HandlePullAttempt(EntityUid uid, HandsComponent component, PullAttemptMessage 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 PullAttemptMessage(pullerPhysics, pullablePhysics); RaiseLocalEvent(puller.Owner, pullAttempt, broadcast: false); if (pullAttempt.Cancelled) { return(false); } RaiseLocalEvent(pullable.Owner, pullAttempt); if (pullAttempt.Cancelled) { return(false); } _pullSm.ForceRelationship(puller, pullable); return(true); }
private static void HandlePullAttempt(EntityUid uid, HandsComponent component, PullAttemptMessage args) { // Cancel pull if all hands full. if (component.Hands.All(hand => !hand.IsEmpty)) { args.Cancelled = true; } }
private static void HandlePullAttempt(EntityUid uid, HandsComponent component, PullAttemptMessage args) { if (args.Puller.Owner != uid) { return; } // Cancel pull if all hands full. if (component.Hands.All(hand => hand.HeldEntity != null)) { args.Cancelled = true; } }