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); } }
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(); } } }
private void ItemDestroyed(string group, GameObject go) { int i = 0; while (i < this.m_ObjectsInArea[group].Count) { BalanceSystemObject balanceSystemObject = this.m_ObjectsInArea[group][i]; GameObject gameObject = balanceSystemObject.m_GameObject; if (gameObject == go) { if (balanceSystemObject.m_BalanceSpawner != null) { BalanceSpawner component = balanceSystemObject.m_BalanceSpawner.GetComponent <BalanceSpawner>(); bool flag = component.IsAttachmentSpawner(); if (flag) { DestroyIfNoChildren component2 = gameObject.GetComponent <DestroyIfNoChildren>(); if (component2 == null) { DebugUtils.Assert(DebugUtils.AssertType.Info); } if (component2.CheckNoChildren()) { balanceSystemObject.m_ActiveChildrenMask = -1; } else { this.SetupActiveChildrenMask(gameObject, out balanceSystemObject.m_ActiveChildrenMask); } this.m_ObjectsInArea[group].Remove(balanceSystemObject); } else { Item item = null; this.m_TempItemList.Clear(); go.GetComponents <Item>(this.m_TempItemList); if (this.m_TempList.Count > 0) { item = this.m_TempItemList[0]; } if (item && item.m_DestroyingOnlyScript) { i++; } else { this.m_QuadTree.RemoveObject(balanceSystemObject); this.m_ObjectsInArea[group].Remove(balanceSystemObject); } } } else { i++; } } else { i++; } } }
private bool ItemDestroyed(string group, GameObject go, bool main_obj_destroyed) { int i = 0; while (i < this.m_ObjectsInArea[group].Count) { BalanceSystemObject balanceSystemObject = this.m_ObjectsInArea[group][i]; GameObject gameObject = balanceSystemObject.m_GameObject; if (gameObject == go) { if (balanceSystemObject.m_BalanceSpawner != null) { BalanceSpawner component = balanceSystemObject.m_BalanceSpawner.GetComponent <BalanceSpawner>(); int activeChildrenMask = balanceSystemObject.m_ActiveChildrenMask; if (component.IsAttachmentSpawner()) { DestroyIfNoChildren component2 = gameObject.GetComponent <DestroyIfNoChildren>(); if (component2 == null) { Debug.Log("obj_in_area name: " + gameObject.name); DebugUtils.Assert(DebugUtils.AssertType.Info); continue; } if (component2.m_NumChildren == 0) { balanceSystemObject.m_AllChildrenDestroyed = true; } if (component2.CheckNoChildren()) { balanceSystemObject.m_ActiveChildrenMask = 0; } else { this.SetupActiveChildrenMask(gameObject, ref balanceSystemObject.m_ActiveChildrenMask); } if (main_obj_destroyed) { this.m_ObjectsInArea[group].Remove(balanceSystemObject); } else { i++; } } else { Item item = null; this.m_TempItemList.Clear(); go.GetComponents <Item>(this.m_TempItemList); if (this.m_TempItemList.Count > 0) { item = this.m_TempItemList[0]; } if (item && item.m_DestroyingOnlyScript) { i++; } else { if (main_obj_destroyed) { this.m_QuadTree.RemoveObject(balanceSystemObject); this.m_ObjectsInArea[group].Remove(balanceSystemObject); } else { i++; } if (go.GetComponent <DestroyablePlant>()) { balanceSystemObject.m_ActiveChildrenMask = 0; } else { this.SetupActiveChildrenMask(gameObject, ref balanceSystemObject.m_ActiveChildrenMask); } } } if (main_obj_destroyed && balanceSystemObject.m_ActiveChildrenMask == 0) { ReplicatedBalanceObjects.OnObjectDestroyed(balanceSystemObject); } else if (activeChildrenMask != balanceSystemObject.m_ActiveChildrenMask) { ReplicatedBalanceObjects.OnObjectChanged(balanceSystemObject); } return(true); } i++; } else { i++; } } return(false); }