Exemple #1
0
    public override void Eat()
    {
        if (this.m_Hallucination)
        {
            base.Disappear(true);
            return;
        }
        base.Eat();
        if (base.transform.parent != null)
        {
            DestroyIfNoChildren component = base.transform.parent.GetComponent <DestroyIfNoChildren>();
            if (component)
            {
                component.OnObjectDestroyed();
            }
        }
        Player.Get().GetComponent <EatingController>().Eat(this.m_FInfo);
        UnityEngine.Object.Destroy(base.gameObject);
        bool          flag = InventoryBackpack.Get().Contains(this);
        List <ItemID> eatingResultItems = ((FoodInfo)this.m_Info).m_EatingResultItems;

        for (int i = 0; i < eatingResultItems.Count; i++)
        {
            ItemID item_id = eatingResultItems[i];
            if (flag)
            {
                Item item = ItemsManager.Get().CreateItem(item_id, false, Vector3.zero, Quaternion.identity);
                InventoryBackpack.Get().InsertItem(item, null, null, true, true, true, true, false);
            }
            else if (this.m_Storage != null)
            {
                Item item2 = ItemsManager.Get().CreateItem(item_id, false, Vector3.zero, Quaternion.identity);
                InventoryCellsGroup inventoryCellsGroup = this.m_Info.m_InventoryCellsGroup;
                Storage             storage             = this.m_Storage;
                storage.RemoveItem(this, false);
                storage.InsertItem(item2, base.m_CurrentSlot, inventoryCellsGroup, true, true);
                item2.gameObject.SetActive(true);
            }
            else
            {
                GameObject prefab = GreenHellGame.Instance.GetPrefab(item_id.ToString());
                if (!prefab)
                {
                    DebugUtils.Assert("[Item:Harvest] Can't find prefab - " + item_id.ToString(), true, DebugUtils.AssertType.Info);
                }
                else
                {
                    UnityEngine.Object.Instantiate <GameObject>(prefab, base.transform.position, base.transform.rotation);
                }
            }
        }
        if (this.m_Acre)
        {
            this.m_Acre.OnEat(this);
        }
    }
Exemple #2
0
 protected override void OnDestroy()
 {
     base.OnDestroy();
     Trigger.s_AllTriggers.Remove(this);
     if (base.transform.parent != null)
     {
         DestroyIfNoChildren component = base.transform.parent.GetComponent <DestroyIfNoChildren>();
         if (component)
         {
             component.OnObjectDestroyed();
         }
     }
 }