public void Harvest() { base.gameObject.ReplRequestOwnership(false); AIParams aiparams = AIManager.Get().m_AIParamsMap[(int)this.m_AIID]; foreach (GameObject gameObject in aiparams.m_HarvestingResult) { Item component = gameObject.GetComponent <Item>(); DebugUtils.Assert(component != null, "[DeadBody:OnExecute] Harvesting result list contains object without Item component - " + gameObject.name, true, DebugUtils.AssertType.Info); ItemID itemID = (ItemID)Enum.Parse(typeof(ItemID), component.m_InfoName); if (MainLevel.s_GameTime - this.m_StartTime >= aiparams.m_DeadBodyFoodSpoilTime) { ItemInfo info = ItemsManager.Get().GetInfo(itemID); if (info.IsFood()) { FoodInfo foodInfo = (FoodInfo)info; if (foodInfo.m_SpoilEffectID != ItemID.None) { itemID = foodInfo.m_SpoilEffectID; } } } for (int i = 0; i < Skill.Get <HarvestingAnimalsSkill>().GetItemsCountMul(); i++) { ItemsManager.Get().CreateItem(itemID, false, base.transform).Take(); } } if (this.m_AddHarvestingItem != ItemID.None) { ItemsManager.Get().CreateItem(this.m_AddHarvestingItem, false, base.transform).Take(); } Item[] componentsInChildren = base.transform.GetComponentsInChildren <Item>(); for (int j = 0; j < componentsInChildren.Length; j++) { componentsInChildren[j].transform.parent = null; componentsInChildren[j].StaticPhxRequestRemove(); componentsInChildren[j].Take(); } this.OnHarvest(); UnityEngine.Object.Destroy(base.gameObject); if (!AI.IsHuman(this.m_AIID)) { Skill.Get <HarvestingAnimalsSkill>().OnSkillAction(); } }
private void InitializeAIParams() { TextAsset textAsset = Resources.Load("Scripts/AI/AIData") as TextAsset; if (!textAsset) { DebugUtils.Assert("Can't load AIData script!", true, DebugUtils.AssertType.Info); return; } TextAssetParser textAssetParser = new TextAssetParser(textAsset); for (int i = 0; i < textAssetParser.GetKeysCount(); i++) { Key key = textAssetParser.GetKey(i); if (key.GetName() == "AI") { AIParams aiparams = new AIParams(); aiparams.Load(key); this.m_AIParamsMap.Add((int)Enum.Parse(typeof(AI.AIID), key.GetVariable(0).SValue), aiparams); } } Resources.UnloadAsset(textAsset); }
private void OnHarvest() { AIParams aiparams = AIManager.Get().m_AIParamsMap[(int)this.m_AIID]; Player.Get().DirtAddOnHarvest(aiparams.m_DirtAddOnHarvest); }