public void TryRelease() { if (HeldGrabbable != null && HeldGrabbable.CanBeDropped) { GrabbableEventArgs args = new GrabbableEventArgs(HeldGrabbable.GetComponent <Grabbable>(), this); HeldGrabbable.DropItem(this); Drop?.Invoke(args); } // No longer try to bring flying grabbable to us resetFlyingGrabbable(); }
public virtual void OnNoLongerClosestGrabbable(object sender, GrabbableEventArgs e) { }
public virtual void OnBecomesClosestGrabbable(object sender, GrabbableEventArgs e) { }
void checkGrabbableEvents() { // Bail if nothing in our trigger area if (grabsInTrigger == null) { return; } // If last closest was this one let event know and remove validator if (previousClosest != grabsInTrigger.ClosestGrabbable) { if (previousClosest != null) { // Fire Off Events GrabbableEvents[] ge = previousClosest.GetComponents <GrabbableEvents>(); if (ge != null) { for (int x = 0; x < ge.Length; x++) { ge[x].OnNoLongerClosestGrabbable(HandSide); } } previousClosest.RemoveValidGrabber(this); } // Update closest Grabbable if (grabsInTrigger.ClosestGrabbable != null) { // Fire Off Events GrabbableEvents[] ge = grabsInTrigger.ClosestGrabbable.GetComponents <GrabbableEvents>(); if (ge != null) { for (int x = 0; x < ge.Length; x++) { ge[x].OnBecomesClosestGrabbable(HandSide); GrabbableEventArgs args = new GrabbableEventArgs(grabsInTrigger.ClosestGrabbable, this); ge[x].OnBecomesClosestGrabbable(this, args); } } grabsInTrigger.ClosestGrabbable.AddValidGrabber(this); } } if (grabsInTrigger.ClosestGrabbable != null && !HoldingItem) { grabsInTrigger.ClosestGrabbable.AddValidGrabber(this); } // Remote Grabbable Events // If last closest was this one, unhighlight object if (previousClosestRemote != grabsInTrigger.ClosestRemoteGrabbable) { if (previousClosestRemote != null) { // Fire Off Events GrabbableEvents[] ge = previousClosestRemote.GetComponents <GrabbableEvents>(); if (ge != null) { for (int x = 0; x < ge.Length; x++) { ge[x].OnNoLongerClosestRemoteGrabbable(HandSide); } } previousClosestRemote.RemoveValidGrabber(this); } // Update closest remote Grabbable if (grabsInTrigger.ClosestRemoteGrabbable != null && !HoldingItem) { // Fire Off Events GrabbableEvents[] ge = grabsInTrigger.ClosestRemoteGrabbable.GetComponents <GrabbableEvents>(); if (ge != null) { for (int x = 0; x < ge.Length; x++) { ge[x].OnBecomesClosestRemoteGrabbable(HandSide); } } grabsInTrigger.ClosestRemoteGrabbable.AddValidGrabber(this); } } // Set this as previous closest previousClosest = grabsInTrigger.ClosestGrabbable; previousClosestRemote = grabsInTrigger.ClosestRemoteGrabbable; }