//When the character interact with this selectable, check all the actions and see if any should be triggered. public void Use(PlayerCharacter character, Vector3 pos) { if (enabled) { PlayerUI ui = PlayerUI.Get(character.player_id); ItemSlot slot = ui != null?ui.GetSelectedSlot() : null; MAction maction = slot != null && slot.GetItem() != null?slot.GetItem().FindMergeAction(this) : null; AAction aaction = FindAutoAction(character); if (maction != null && maction.CanDoAction(character, slot, this)) { maction.DoAction(character, slot, this); PlayerUI.Get(character.player_id)?.CancelSelection(); } else if (aaction != null && aaction.CanDoAction(character, this)) { aaction.DoAction(character, this); } else if (actions.Length > 0) { ActionSelector.Get(character.player_id)?.Show(character, this, pos); } if (onUse != null) { onUse.Invoke(character); } } }
private void DoMergeAction(MAction action, ItemSlot slot_action, ItemSlot slot_other) { if (slot_action == null || slot_other == null || current_player == null) { return; } action.DoAction(current_player, slot_action, slot_other); CancelPlayerSelection(); }