public static void AddInteractable(Interactable interactable) { Instance.interactables.Add(interactable); interactable.OnSelected(); OnUpdated?.Invoke(); Collider collider = interactable.GetComponent <Collider>(); Instance.selectionMarker.transform.localScale = collider.bounds.size * 2f; //Instance.selectionMarker.transform.localPosition = collider.bounds.min + new Vector3(collider.bounds.extents.x, 0, collider.bounds.extents.z); Instance.selectionMarker.transform.SetParent(interactable.transform); Instance.selectionMarker.transform.localPosition = Vector3.zero; Instance.selectionMarker.SetActive(true); }
protected virtual void ActivateEnd() { if (VolumeActivateEnd != null) { VolumeActivateEnd.Invoke(InteractingGO); } }
protected virtual void Activating() { if (VolumeActivating != null) { VolumeActivating.Invoke(InteractingGO); } }
protected virtual void ActivateBegin() { if (VolumeActivateBegin != null) { VolumeActivateBegin.Invoke(InteractingGO); } }
protected virtual void HoverEnd() { if (VolumeHoverEnd != null) { VolumeHoverEnd.Invoke(InteractingGO); } }
protected virtual void Hovering() { if (VolumeHovering != null) { VolumeHovering.Invoke(InteractingGO); } }
/* ============== Virtual Event Functions ============== */ protected virtual void HoverBegin() { if (VolumeHoverBegin != null) { VolumeHoverBegin.Invoke(InteractingGO); } }
// This function tries to do the following things in order: // tries to use an item if inventory is open // tries to interact with terrain under player // tries to pick up Item private void HandleSpacePressed() { if (UI.InventoryOpen) { //Console.WriteLine("Space trigger item use!"); //Console.WriteLine("UsedItemEvent null? " + UsedItemEvent == null); UsedItemEvent?.Invoke(Util.PlayerID, EntityManager.GetComponent <InventoryComponent>(Util.PlayerID).Items[UI.InventoryCursorPosition - 1], ItemUsage.Consume); return; } var playerPos = EntityManager.GetComponent <TransformComponent>(Util.PlayerID).Position; int terrain = Util.CurrentFloor.GetTerrain(playerPos); if (terrain != 0) // is there special terrain? { var terrainInteraction = EntityManager.GetComponent <InteractableComponent>(terrain); if (terrainInteraction != null) // is it interactable? { InteractionEvent?.Invoke(Util.PlayerID, terrain); return; } } bool itemsOnFloor = Util.CurrentFloor.GetItems(playerPos).Count() > 0; // are there items here? if (!itemsOnFloor) { UISystem.Message("No items here to be picked up!"); return; } PickupItemEvent?.Invoke(Util.PlayerID); }
public void OnObjectCovid(VrController _controller) { if (isTouchable && (_controller.InputSource == allowedSource || allowedSource == SteamVrInputSource.Any)) { onCovid.Invoke(GenerateArgs(_controller)); } }
public void OnHoveredOut(VRInteractor interactor) { if (OnHoveredOutEvent != null) { OnHoveredOutEvent.Invoke(interactor); } }
/// <summary> /// Invokes the interact event. /// </summary> /// <param name="bypassIsInteractable">If true, it will ignore the Is Interactable property.</param> /// <param name="bypassLimit">If true, it will ignore the max limit property.</param> public void Interact(bool bypassIsInteractable, bool bypassLimit) { // If we can't interact and we're not bypassing the check, stop here. if (!isInteractable && !bypassIsInteractable) { return; } // If there's a limit on interactions, we've reached the max interactions, and we're not bypassing the check, stop here. if (limitedInteractions && interactions >= maxInteractions && !bypassLimit) { return; } // If limited interactions are enabled, add one to the interaction amount. if (limitedInteractions) { interactions++; } // Call the interact event. onInteract.Invoke(); // If the interactions has reached it's max, invoke the reached max interactions event. if (interactions == maxInteractions) { onReachedMaxInteractions.Invoke(); } }
public void OnInteractionFinished(VRInteractor interactor) { if (OnInteractionFinishedEvent != null) { OnInteractionFinishedEvent.Invoke(interactor); } }
//Debug private void Update() { if (Input.GetKeyDown(KeyCode.Escape)) { if (GameState != GameStates.Paused) { GameState = GameStates.Paused; } else { GameState = lastState; } } else if (Input.GetKeyDown(KeyCode.Tab)) { OnHighLightAll.Invoke(true); } else if (Input.GetKeyUp(KeyCode.Tab)) { OnHighLightAll.Invoke(false); } if (Input.GetKeyDown(KeyCode.E)) { OnInteractButtonPressed.Invoke(); } }
public void OnObjectUntouched(VrController _controller) { if (isTouchable && (_controller.InputSource == allowedSource || allowedSource == SteamVR_Input_Sources.Any)) { onUntouched.Invoke(GenerateArgs(_controller)); } }
public void OnObjectStopUsed(VrController _controller) { if (isUsable && (_controller.InputSource == allowedSource || allowedSource == SteamVRInputSource.Any)) { onStopUsed.Invoke(GenerateArgs(_controller)); } }
public void OnObjectStopUsing(VRController _controller) { if (isUsable && IsInputSourceAllowed(_controller)) { onStopUsing.Invoke(GenerateArgs(_controller)); } }
public void OnObjectReleased(VrController _controller) { if (isGrabbable && (_controller.InputSource == allowedSource || allowedSource == SteamVR_Input_Sources.Any)) { onReleased.Invoke(GenerateArgs(_controller)); } }
public void OnObjectReleased(VRController _controller) { if (isGrabbable && IsInputSourceAllowed(_controller)) { onReleased.Invoke(GenerateArgs(_controller)); } }
public void OnObjectTouched(VRController _controller) { if (isTouchable && IsInputSourceAllowed(_controller)) { onTouched.Invoke(GenerateArgs(_controller)); } }
public void OnInteractionStart(VRInteractor interactor) { if (OnInteractionStartEvent != null) { OnInteractionStartEvent.Invoke(interactor); } }
public void OnObjectReleased(VrCtrl _controller) { //If the object is grabbable or if it is any input source if (isGrabbable && (_controller.InputSource == allowedSource || allowedSource == SteamVR_Input_Sources.Any)) { onReleased.Invoke(GenerateArgs(_controller)); } }
public virtual void OnObjectReleased(VrController _controller) { if (_controller.InputSource == allowedSource || allowedSource == SteamVrInputSource.Any) { onReleased.Invoke(GenerateArgs(_controller)); Grabbed = null; } }
public void OnObjectUsed(VrCtrl _controller) { //If the object is being used or if it is any input source if (isUsable && (_controller.InputSource == allowedSource || allowedSource == SteamVR_Input_Sources.Any)) { onUsed.Invoke(GenerateArgs(_controller)); } }
public void OnObjectStopTouching(VrCtrl _controller) { //If the object is not being touched or if it is any input source if (isTouchable && (_controller.InputSource == allowedSource || allowedSource == SteamVR_Input_Sources.Any)) { onStopTouching.Invoke(GenerateArgs(_controller)); } }
public void OnObjectStopUsing(VrCtrl _controller) { //If the object has stopped being using or if it is any input source if (isUsable && (_controller.InputSource == allowedSource || allowedSource == SteamVR_Input_Sources.Any)) { onStopUsing.Invoke(GenerateArgs(_controller)); } }
public virtual void OnObjectGrabbed(VrController _controller) { if (isGrabbable && (_controller.InputSource == allowedSource || allowedSource == SteamVrInputSource.Any)) { onGrabbed.Invoke(GenerateArgs(_controller)); Grabbed = _controller.GetComponent <InteractGrab>(); } }
public void Damage(int amount) { ReduceHealth(amount); OnDamage.Invoke(); // Debug.Log("Damage amount " + amount); // if (!isItSchild) // ReduceHealth(amount); ShowEffects(); }
public virtual void OnInteract(PlayerHandler ph) { onInteract.Invoke(ph); EventJunction.Transmit(new InteractMessage(ph, this)); if (cooldown > 0) { coolingDown = Cooldown(cooldown); StartCoroutine(coolingDown); } }
private void ReleaseObject() { heldObject.Rigidbody.isKinematic = false; heldObject.transform.SetParent(heldOriginalParent); heldObject.Rigidbody.velocity = input.Controller.Velocity; heldObject.Rigidbody.angularVelocity = input.Controller.AngularVelocity; heldObject.OnObjectReleased(input.Controller); released.Invoke(new InteractEventArgs(input.Controller, heldObject.Rigidbody, heldObject.Collider)); heldObject = null; }
private void GrabObject() { heldObject = collidingObject; collidingObject = null; heldOriginalParent = heldObject.transform.parent; heldObject.Rigidbody.isKinematic = true; SnapObject(heldObject.transform, heldObject.AttachPoint); heldObject.OnObjectGrabbed(input.Controller); grabbed.Invoke(new InteractEventArgs(input.Controller, heldObject.Rigidbody, heldObject.Collider)); }