public LuerlockConnector(LuerlockAdapter.Side side, LuerlockAdapter luerlock, GameObject collider) : base(luerlock.transform) { GeneralItem = luerlock; attached = new AttachedObject(); this.side = side; this.Collider = collider; }
public void SetLuerlockPair(LuerlockAdapter.Side side, LuerlockAdapter luerlock) { if (luerlock == null) { // Luerlock pair.Value can only be null when removing the syringe from luerlock, therefore Warning instead of Error Logger.Error("Luerlock pair value was null. Problem with SetInteractors cast?"); } LuerlockPair = new KeyValuePair <LuerlockAdapter.Side, LuerlockAdapter>(side, luerlock); }
protected override void SnapObjectPosition() { Transform obj = attached.GameObject.transform; Transform coll = Collider.transform; Transform luerlockPos = LuerlockAdapter.LuerlockPosition(obj); Vector3 pivot = Vector3.Cross(coll.up, obj.up); obj.Rotate(pivot, -Vector3.SignedAngle(coll.up, obj.up, pivot), Space.World); Vector3 offset = coll.position - luerlockPos.position; obj.position += offset; }
// Verify for Luerlock/Needle public static void ReleaseLuerlockWhenLuerlockAttachedItemIsGrabbed(LuerlockAdapter luerlock) { Interactable otherInteractable = null; foreach (Interactable other in luerlock.AttachedInteractables) { if (other.State == InteractState.Grabbed) { otherInteractable = other; } } Hand otherHand = Hand.GrabbingHand(otherInteractable); otherHand.Connector.Connection.Remove(); otherHand.InteractWith(otherInteractable, 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); }
public static void ReleaseLuerlockAttachedItemWhenOtherLuerlockAttachedItemIsGrabbed(Interactable grabbedInteractable, LuerlockAdapter luerlock) { Interactable otherInteractable = luerlock.GetOtherInteractable(grabbedInteractable); Hand otherHand = Hand.GrabbingHand(otherInteractable); otherHand.Connector.Connection.Remove(); otherHand.InteractWith(otherInteractable); }
private IEnumerator PlayCoroutine(AutoPlayStrength autoPlay) { yield return(null); yield return(null); yield return(null); // Create objects GameObject g_syringeCapBag = Instantiate(p_syringeCapBag, SpawnPos, Quaternion.Euler(Vector3.zero)); GameObject g_luerlock = Instantiate(p_luerlock, SpawnPos, Quaternion.Euler(Vector3.zero)); GameObject g_needle = Instantiate(p_needle, SpawnPos, Quaternion.Euler(Vector3.zero)); GameObject g_bigSyringe = Instantiate(p_bigSyringe, SpawnPos, Quaternion.Euler(Vector3.zero)); GameObject g_bottle = Instantiate(p_bottle, SpawnPos, Quaternion.Euler(Vector3.zero)); GameObject[] g_smallSyringes = new GameObject[6]; Transform[] all = new Transform[11]; all[0] = g_syringeCapBag.transform; all[1] = g_luerlock.transform; all[2] = g_needle.transform; all[3] = g_bigSyringe.transform; all[4] = g_bottle.transform; for (int i = 0; i < 6; i++) { g_smallSyringes[i] = Instantiate(p_smallSyringe, SpawnPos, Quaternion.Euler(Vector3.zero)); all[5 + i] = g_smallSyringes[i].transform; } IgnoreCollisions(all, true); yield return(null); yield return(null); yield return(null); Interactable capBag = ToIntr(g_syringeCapBag); LuerlockAdapter luerlock = ToIntr(g_luerlock) as LuerlockAdapter; Needle needle = ToIntr(g_needle) as Needle; Syringe bigSyringe = ToIntr(g_bigSyringe) as Syringe; MedicineBottle bottle = ToIntr(g_bottle) as MedicineBottle; Syringe[] smallSyringes = new Syringe[6]; for (int i = 0; i < 6; i++) { smallSyringes[i] = ToIntr(g_smallSyringes[i]) as Syringe; NullCheck.Check(smallSyringes[i]); } NullCheck.Check(capBag, luerlock, needle, bigSyringe, bottle); // Select tools task Hand hand = VRInput.Hands[0].Hand; yield return(null); hand.InteractWith(capBag); yield return(null); hand.Uninteract(); yield return(null); hand.InteractWith(luerlock); yield return(null); hand.Uninteract(); yield return(null); hand.InteractWith(needle); yield return(null); hand.Uninteract(); yield return(null); hand.InteractWith(bigSyringe); yield return(null); hand.Uninteract(); yield return(null); hand.InteractWith(smallSyringes[0]); yield return(null); hand.Uninteract(); yield return(null); // Select bottle task hand.InteractWith(bottle); yield return(null); hand.Uninteract(); yield return(null); // Correct items in throughput task yield return(null); capBag.transform.position = correctPositions.GetChild(0).position; capBag.transform.up = correctPositions.right; capBag.Rigidbody.velocity = Vector3.zero; yield return(null); luerlock.transform.position = correctPositions.GetChild(1).position; luerlock.transform.up = correctPositions.right; luerlock.Rigidbody.velocity = Vector3.zero; yield return(null); needle.transform.position = correctPositions.GetChild(2).position; needle.transform.up = correctPositions.right; needle.Rigidbody.velocity = Vector3.zero; yield return(null); bigSyringe.transform.position = correctPositions.GetChild(3).position; bigSyringe.transform.up = correctPositions.right; bigSyringe.Rigidbody.velocity = Vector3.zero; yield return(null); bottle.transform.position = correctPositions.GetChild(4).position; bottle.transform.up = correctPositions.right; bottle.Rigidbody.velocity = Vector3.zero; for (int i = 0; i < 6; i++) { smallSyringes[i].transform.position = correctPositions.GetChild(5 + i).position; smallSyringes[i].transform.up = correctPositions.right; smallSyringes[i].Rigidbody.velocity = Vector3.zero; yield return(null); } if (autoPlay == AutoPlayStrength.ItemsToPassThrough) { IgnoreCollisions(all, false); yield break; } yield return(Wait); hand.InteractWith(teleportDoorKnob); yield return(null); IgnoreCollisions(all, false); yield return(null); IsAutoPlaying = false; if (autoPlay == AutoPlayStrength.WorkspaceRoom) { yield break; } yield return(new WaitForSeconds(1)); capBag.transform.position = correctPositionLaminarCabinet.GetChild(0).position; capBag.transform.up = correctPositions.right; capBag.Rigidbody.velocity = Vector3.zero; yield return(null); luerlock.transform.position = correctPositionLaminarCabinet.GetChild(1).position; luerlock.transform.up = correctPositions.right; luerlock.Rigidbody.velocity = Vector3.zero; yield return(null); needle.transform.position = correctPositionLaminarCabinet.GetChild(2).position; needle.transform.up = correctPositions.right; needle.Rigidbody.velocity = Vector3.zero; yield return(null); bigSyringe.transform.position = correctPositionLaminarCabinet.GetChild(3).position; bigSyringe.transform.up = correctPositions.right; bigSyringe.Rigidbody.velocity = Vector3.zero; yield return(null); bottle.transform.position = correctPositionLaminarCabinet.GetChild(4).position; bottle.transform.up = correctPositions.right; bottle.Rigidbody.velocity = Vector3.zero; for (int i = 0; i < 6; i++) { smallSyringes[i].transform.position = correctPositionLaminarCabinet.GetChild(5 + i).position; smallSyringes[i].transform.up = correctPositions.right; smallSyringes[i].Rigidbody.velocity = Vector3.zero; yield return(null); } if (autoPlay == AutoPlayStrength.ItemsToLaminarCabinet) { yield break; } yield return(Wait); hand.InteractWith(laminarCabinetCheckButton); if (autoPlay == AutoPlayStrength.CheckCabinetItems) { yield break; } yield return(Wait); GameObject g_sterileCloth = Instantiate(p_sterileCloth); g_sterileCloth.transform.position = new Vector3(100, 100, 100); g_sterileCloth.name = "STERILE CLOTH AUTOPLAY"; yield return(null); Interactable sterileCloth = Interactable.GetInteractable(g_sterileCloth.transform); sterileCloth.transform.position = bottle.transform.position; yield return(Wait); sterileCloth.transform.position = regularTrash.transform.position; yield return(null); yield return(null); if (autoPlay == AutoPlayStrength.DisinfectBottle) { yield break; } needle.Connector.ConnectItem(bigSyringe); yield return(null); yield return(null); needle.transform.position = bottle.transform.position; bottle.Container.TransferTo(bigSyringe.Container, 900); yield return(null); yield return(null); needle.transform.position = bottle.transform.position + new Vector3(0, 0.25f, 0); yield return(null); yield return(null); needle.Connector.Connection.Remove(); bigSyringe.transform.position = needle.transform.position + new Vector3(0.05f, 0, 0); yield return(null); yield return(null); if (autoPlay == AutoPlayStrength.TakeMedicine) { yield break; } luerlock.LeftConnector.ConnectItem(bigSyringe); Events.FireEvent(EventType.AttachLuerlock, CallbackData.Object(bigSyringe.gameObject)); Events.FireEvent(EventType.SyringeToLuerlock, CallbackData.Object(bigSyringe.gameObject)); yield return(null); yield return(null); if (autoPlay == AutoPlayStrength.BigSyringeToLuerlock) { yield break; } foreach (Syringe smallSyringe in smallSyringes) { luerlock.RightConnector.ConnectItem(smallSyringe); Events.FireEvent(EventType.AttachLuerlock, CallbackData.Object(smallSyringe.gameObject)); Events.FireEvent(EventType.SyringeToLuerlock, CallbackData.Object(smallSyringe.gameObject)); yield return(null); yield return(null); bigSyringe.Container.TransferTo(smallSyringe.Container, 150); yield return(null); yield return(null); luerlock.RightConnector.Connection.Remove(); smallSyringe.transform.position = luerlock.transform.position + new Vector3(0.05f, 0, 0); yield return(null); yield return(null); } luerlock.LeftConnector.Connection.Remove(); bigSyringe.transform.position = luerlock.transform.position + new Vector3(-0.05f, 0, 0); yield return(null); yield return(null); if (autoPlay == AutoPlayStrength.MedicineToSmallSyringes) { yield break; } foreach (Syringe smallSyringe in smallSyringes) { SyringeCap.AddSyringeCap(smallSyringe); } yield return(null); yield return(null); if (autoPlay == AutoPlayStrength.AddSyringeCaps) { yield break; } foreach (Syringe smallSyringe in smallSyringes) { smallSyringe.transform.position = sterileBag.transform.position; yield return(null); yield return(null); } if (autoPlay == AutoPlayStrength.SyringesToSterileBag) { yield break; } sterileBag.CloseSterileBagFinal(); yield return(null); yield return(null); if (autoPlay == AutoPlayStrength.CloseSterileBag) { yield break; } needle.transform.position = sharpTrash.transform.position; yield return(null); yield return(null); luerlock.transform.position = regularTrash.transform.position; yield return(null); yield return(null); bigSyringe.transform.position = regularTrash.transform.position; yield return(null); yield return(null); if (autoPlay == AutoPlayStrength.Cleanup) { yield break; } }