protected override void StartDelayed(InteractionEvent interactionEvent) { GameObject source = interactionEvent.Source?.GetComponentInTree <Creature>().gameObject; GameObject target = interactionEvent.Target.GetComponent <Transform>().gameObject; Consumable itemInHand = source?.GetComponentInChildren <Hands>().GetItemInHand()?.GetComponent <Consumable>(); //Debug.Log("source: " + source.name + " target: " + target?.name + " item: " + itemInHand?.gameObject.name); // Item in hand and interacting with origin if (target == null) { itemInHand.ConsumeAction(source); } // Item not in hand Consumable targetedItem = target.GetComponent <Consumable>(); if (targetedItem) { targetedItem.ConsumeAction(source); } // Item in hand and interacting with other player if (target.GetComponent <Creature>()) { itemInHand.ConsumeAction(source, target); } }
protected override void StartDelayed(InteractionEvent interactionEvent) { GameObject source = interactionEvent.Source?.GetComponentInTree <Entity>().gameObject; GameObject target = interactionEvent.Target.GetComponent <Transform>().gameObject; Consumable itemInHand = source.GetComponent <Consumable>(); // Item in hand and interacting with origin if (target == null) { itemInHand.ConsumeAction(source); } // Item not in hand Consumable targetedItem = target.GetComponent <Consumable>(); if (targetedItem) { targetedItem.ConsumeAction(source); } // Item in hand and interacting with other player if (target.GetComponent <Entity>()) { itemInHand.ConsumeAction(source, target); } }