Ejemplo n.º 1
0
    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++;
            }
        }
    }
Ejemplo n.º 2
0
    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);
    }