//When the character interact with this selectable, check all the actions and see if any should be triggered. public void Use(PlayerCharacter character) { if (enabled) { ItemSlot islot = InventoryBar.Get().GetSelectedSlot(); ItemSlot eslot = EquipBar.Get().GetSelectedSlot(); ItemSlot slot = eslot != null ? eslot : islot; MAction maction = slot != null && slot.GetItem() != null?slot.GetItem().FindMergeAction(this) : null; AAction aaction = FindAutoAction(); if (maction != null && maction.CanDoAction(character, this)) { maction.DoAction(character, slot, this); TheUI.Get().CancelSelection(); } else if (aaction != null && aaction.CanDoAction(character, this)) { aaction.DoAction(character, this); } else if (actions.Length > 0) { ActionSelector.Get().Show(character, this); } if (onUse != null) { onUse.Invoke(character); } } }
private void OnInteractWithPlayer(PlayerCharacter character) { if (action == null) { Debug.Log($"Action doesn't set for {gameObject.name}"); } if (action.CanDoAction(character, this)) { Debug.Log($"Interacted with player {name}"); action.DoAction(character, this); } }