Beispiel #1
0
 private void OnSetAcre()
 {
     for (int i = 0; i < this.m_ToCollect.Count; i++)
     {
         Item component = this.m_ToCollect[i].GetComponent <Item>();
         if (component != null)
         {
             component.m_Acre = this.m_Acre;
         }
         else
         {
             PlantFruit component2 = this.m_ToCollect[i].GetComponent <PlantFruit>();
             if (component2 != null)
             {
                 component2.m_Acre = this.m_Acre;
             }
             else
             {
                 ItemReplacer component3 = this.m_ToCollect[i].GetComponent <ItemReplacer>();
                 if (component3 != null)
                 {
                     component3.m_Acre = this.m_Acre;
                 }
             }
         }
     }
 }
Beispiel #2
0
 public void OnDestroyPlant()
 {
     for (int i = 0; i < this.m_ToCollect.Count; i++)
     {
         if (this.m_ToCollect[i] != null)
         {
             PlantFruit component = this.m_ToCollect[i].GetComponent <PlantFruit>();
             if (component && component.m_ItemInfo != null)
             {
                 ItemsManager.Get().CreateItem(component.m_ItemInfo.m_ID, true, this.m_ToCollect[i].transform);
             }
             else
             {
                 ItemReplacer component2 = this.m_ToCollect[i].GetComponent <ItemReplacer>();
                 if (component2)
                 {
                     ItemsManager.Get().CreateItem(component2.m_ReplaceInfo.m_ID, true, this.m_ToCollect[i].transform);
                 }
                 else
                 {
                     Food component3 = this.m_ToCollect[i].GetComponent <Food>();
                     if (component3)
                     {
                         component3.transform.SetParent(null);
                     }
                 }
             }
         }
     }
 }
Beispiel #3
0
 public void OnTake(PlantFruit item)
 {
     for (int i = 0; i < this.m_ToCollect.Count; i++)
     {
         if (this.m_ToCollect[i] != null && this.m_ToCollect[i] == item.gameObject)
         {
             this.m_ToCollect[i] = null;
         }
     }
 }
Beispiel #4
0
 public void OnEat(PlantFruit item)
 {
     if (this.m_GrownPlant)
     {
         AcreRespawnFruits component = this.m_GrownPlant.GetComponent <AcreRespawnFruits>();
         if (component != null)
         {
             component.OnEat(item);
         }
     }
 }
Beispiel #5
0
 public bool Activate(PlantFruit fruit)
 {
     this.ResetItems();
     this.m_PlantFruit = fruit;
     this.ClearSlots();
     this.AddSlot(HUDItem.Action.Take);
     if (fruit.m_Eatable)
     {
         this.AddSlot(HUDItem.Action.Eat);
     }
     this.Activate();
     return(true);
 }
Beispiel #6
0
 public void OnDestroyPlant()
 {
     if (DestroyablePlant.s_StandardShader == null)
     {
         DestroyablePlant.s_StandardShader = Shader.Find("Custom/WindLeavesC2Standard_not_moving");
     }
     if (DestroyablePlant.m_Layer == -1)
     {
         DestroyablePlant.m_Layer = LayerMask.NameToLayer("SmallPlant");
     }
     new Dictionary <ItemReplacer, ItemReplacer>();
     for (int i = 0; i < this.m_Chunks.Count; i++)
     {
         if (!(this.m_Chunks[i] == null) && this.m_Chunks[i].activeSelf)
         {
             PlantFruit component = this.m_Chunks[i].GetComponent <PlantFruit>();
             if (component)
             {
                 ItemID item_id = (ItemID)Enum.Parse(typeof(ItemID), component.m_InfoName);
                 ItemsManager.Get().CreateItem(item_id, true, this.m_Chunks[i].transform.position + component.m_BoxCollider.center, this.m_Chunks[i].transform.rotation);
             }
             else
             {
                 ItemReplacer component2 = this.m_Chunks[i].GetComponent <ItemReplacer>();
                 if (component2)
                 {
                     component2.m_FromPlant = true;
                 }
                 DestroyablePlantChunk component3 = this.m_Chunks[i].GetComponent <DestroyablePlantChunk>();
                 if (component3 != null)
                 {
                     component3.Init(this.m_DontDestroy, this.m_ActivateScripts, DestroyablePlant.m_Layer);
                     component3.OnPlantDestroy();
                 }
             }
         }
     }
 }
    public void OnDestroyPlant()
    {
        if (DestroyablePlant.s_StandardShader == null)
        {
            DestroyablePlant.s_StandardShader = Shader.Find("Custom/WindLeavesC2Standard_not_moving");
        }
        if (DestroyablePlant.m_Layer == -1)
        {
            DestroyablePlant.m_Layer = LayerMask.NameToLayer("SmallPlant");
        }
        List <MeshCollider> list = new List <MeshCollider>();
        Dictionary <ItemReplacer, ItemReplacer> dictionary = new Dictionary <ItemReplacer, ItemReplacer>();

        for (int i = 0; i < this.m_Chunks.Count; i++)
        {
            if (!(this.m_Chunks[i] == null) && this.m_Chunks[i].activeSelf)
            {
                PlantFruit component = this.m_Chunks[i].GetComponent <PlantFruit>();
                if (component)
                {
                    ItemID item_id = (ItemID)Enum.Parse(typeof(ItemID), component.m_InfoName);
                    ItemsManager.Get().CreateItem(item_id, true, this.m_Chunks[i].transform);
                }
                else
                {
                    GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(this.m_Chunks[i], this.m_Chunks[i].transform.position, this.m_Chunks[i].transform.rotation);
                    if (!this.m_DontDestroy)
                    {
                        gameObject.AddComponent <TinyPhysicsObject>();
                    }
                    gameObject.AddComponent <Rigidbody>();
                    MeshCollider meshCollider = gameObject.AddComponent <MeshCollider>();
                    meshCollider.convex = true;
                    this.ReplaceShader(gameObject);
                    ObjectMaterial objectMaterial = gameObject.AddComponent <ObjectMaterial>();
                    objectMaterial.m_ObjectMaterial = EObjectMaterial.Bush;
                    gameObject.layer = DestroyablePlant.m_Layer;
                    list.Add(meshCollider);
                    if (this.m_CopyScripts)
                    {
                        this.CopyComponents(this.m_Chunks[i], gameObject);
                    }
                    ItemReplacer component2 = this.m_Chunks[i].GetComponent <ItemReplacer>();
                    ItemReplacer component3 = gameObject.GetComponent <ItemReplacer>();
                    if (component2 && component3)
                    {
                        dictionary[component2] = component3;
                    }
                    this.DisableCollisionWithPlayer(meshCollider);
                }
            }
        }
        for (int j = 0; j < list.Count; j++)
        {
            for (int k = j + 1; k < list.Count; k++)
            {
                Physics.IgnoreCollision(list[j], list[k], true);
            }
        }
        this.SetupItemReplacer(dictionary);
    }