protected virtual void TryInteract() { InteractDelegate interactDelegate = null; if (_input.space.Pressed) { interactDelegate = BeginInteract; } else if (_input.space.Released) { interactDelegate = EndInteract; } Collider2D[] facingColliders = Physics2D.OverlapCircleAll(_targetPosition + _interactOffset, 0.4f); if (interactDelegate != null) { foreach (Collider2D collider in facingColliders) { Interactable[] interactables = collider.GetComponents <Interactable>(); foreach (Interactable interactable in interactables) { interactDelegate(interactable); _onInteracted?.Invoke(new Interactable.InteractedEventInfo() { interactedWith = interactable }); } } } }
public WoWObject(uint pointer) { Pointer = pointer; if (IsValid) { _getObjectName = RegisterVirtualFunction <GetObjectNameDelegate>(Offsets.vTableOffsets.GetObjectName); _Interact = RegisterVirtualFunction <InteractDelegate>(Offsets.vTableOffsets.Interact); } }
//Author: Ben Stern /// <summary> /// Add an interaction to this objects list of interactions and responses /// </summary> /// <param name="action">The action type that is being added to this list</param> /// <param name="interactResponse">The DelegateResponse this action will Have</param> public void AddInteractionToList(string actionName, InteractDelegate interactResponse) { if (actionResponses.ContainsKey(actionName)) { Debug.Log("an action of the same name already exists in the list"); interactionsDirty = true; return; } actionResponses.Add(actionName, interactResponse); interactionsDirty = true; }
public WoWObject(IntPtr pointer) { Pointer = pointer; if (IsValid) { _getBag = RegisterVirtualFunction <GetBagDelegate>(Offsets.GetBag); _getObjectName = RegisterVirtualFunction <GetObjectNameDelegate>(Offsets.GetObjectName); _getObjectLocation = RegisterVirtualFunction <GetObjectLocationDelegate>(Offsets.GetObjectLocation); _interact = RegisterVirtualFunction <InteractDelegate>(Offsets.Interact); } }
public WoWObject(IntPtr pointer) { Pointer = pointer; if (IsValid) { _getObjectName = RegisterVirtualFunction <GetObjectNameDelegate>(Pointers.Object.GetObjectName); _getObjectLocation = RegisterVirtualFunction <GetObjectLocationDelegate>(Pointers.Object.GetObjectLocation); _getObjectFacing = RegisterVirtualFunction <GetObjectFacingDelegate>(Pointers.Object.GetObjectFacing); _interact = RegisterVirtualFunction <InteractDelegate>(Pointers.Object.Interact); } }
public void Open(Vector3 parentPosition, InspectDelegate Inspect, InteractDelegate Interact) { if (instMenu) { Debug.Log("Menu already instantiated for this object"); return; } instMenu = Instantiate(menu); instMenuPanel = instMenu.transform.Find("Panel").gameObject; instMenuInspect = instMenuPanel.transform.Find("TextBox").gameObject.transform.Find("InspectButton").GetComponent <Button>(); instMenuInteract = instMenuPanel.transform.Find("TextBox").gameObject.transform.Find("InteractButton").GetComponent <Button>(); instMenuClose = instMenuPanel.transform.Find("TextBox").gameObject.transform.Find("CloseButton").GetComponent <Button>(); instMenuInspect.onClick.AddListener(delegate { Inspect(); }); instMenuInteract.onClick.AddListener(delegate { Interact(); }); instMenuClose.onClick.AddListener(delegate { Close(); }); originPosition = parentPosition; }