public static void GrabNeedleWhenAttachedItemIsGrabbed(ItemConnector connector, Transform target, Interactable addTo) { Needle needle = addTo as Needle; if (needle == null) { throw new System.Exception("Needle is null"); } Interactable otherItem = needle.Connector.AttachedInteractable; Hand otherHand = Hand.GrabbingHand(otherItem); otherHand.Connector.Connection.Remove(); HandSmoother smooth = target.GetComponent <Hand>().Smooth; Transform handOffset = smooth?.transform; target = handOffset ?? target; connector.Connection = ItemConnection.AddJointConnection(connector, target, addTo); smooth?.DisableInitMode(); otherHand.InteractWith(otherItem, false); }
// Verify for Luerlock/Needle public static void GrabLuerlockWhenAttachedItemsAreGrabbed(ItemConnector connector, Transform target, Interactable addTo) { LuerlockAdapter luerlock = addTo as LuerlockAdapter; if (luerlock == null) { throw new System.Exception("Luerlock is null"); } Interactable otherItem; if (luerlock.LeftConnector.HasAttachedObject && luerlock.LeftConnector.AttachedInteractable.State == InteractState.Grabbed) { otherItem = luerlock.LeftConnector.AttachedInteractable; } else if (luerlock.RightConnector.HasAttachedObject && luerlock.RightConnector.AttachedInteractable.State == InteractState.Grabbed) { otherItem = luerlock.RightConnector.AttachedInteractable; } else { Logger.Error("Could not find the other grabbed item"); return; } Hand otherHand = Hand.GrabbingHand(otherItem); otherHand.Connector.Connection.Remove(); HandSmoother smooth = target.GetComponent <Hand>().Smooth; Transform handOffset = smooth.transform; target = handOffset ?? target; connector.Connection = ItemConnection.AddJointConnection(connector, target, addTo); smooth?.DisableInitMode(); otherHand.InteractWith(otherItem, false); }