Beispiel #1
0
    public static bool ConsumeProduct(int EntityID, ItemValue item)
    {
        bool result = false;

        EntityAliveSDX myEntity = GameManager.Instance.World.GetEntity(EntityID) as EntityAliveSDX;

        if (!myEntity)
        {
            return(false);
        }

        // No Item, no consumption
        if (item == null)
        {
            return(false);
        }


        DisplayLog(" ConsumeProduct() " + item.ItemClass.GetItemName());
        ItemClass original = myEntity.inventory.holdingItem;

        myEntity.inventory.SetBareHandItem(item);
        ItemAction itemAction = myEntity.inventory.holdingItem.Actions[0];

        if (itemAction != null)
        {
            myEntity.Attack(true);
            DisplayLog("ConsumeProduct(): Hold Item has Action0. Executing..");
            itemAction.ExecuteAction(myEntity.inventory.holdingItemData.actionData[0], true);

            //// We want to consume the food, but the consumption of food isn't supported on the non-players, so just fire off the buff
            ///
            DisplayLog("ConsumeProduct(): Trigger Events");
            myEntity.FireEvent(MinEventTypes.onSelfPrimaryActionEnd);
            myEntity.FireEvent(MinEventTypes.onSelfHealedSelf);


            myEntity.SetInvestigatePosition(Vector3.zero, 0);
        }

        DisplayLog(" ConsumeProduct(): Restoring hand item");
        myEntity.inventory.SetBareHandItem(ItemClass.GetItem(original.Name, false));

        return(result);
    }