示例#1
0
    public static void RegisterStackableMapIcon(StackableMapIcon icon)
    {
        if (StackableMapIconManager.s_instance == null)
        {
            Debug.LogError("ERROR: RegisterStackableMapIcon with null s_instance");
            return;
        }
        if (icon == null)
        {
            Debug.LogError("ERROR: RegisterStackableMapIcon with null icon");
            return;
        }
        bool flag = false;

        using (List <StackableMapIconContainer> .Enumerator enumerator = StackableMapIconManager.s_instance.m_containers.GetEnumerator())
        {
            while (enumerator.MoveNext())
            {
                StackableMapIconContainer current = enumerator.get_Current();
                if (!(current == null))
                {
                    if (current.get_gameObject().get_activeSelf())
                    {
                        Rect worldRect = current.GetWorldRect();
                        if (icon.GetWorldRect().Overlaps(worldRect))
                        {
                            current.AddStackableMapIcon(icon);
                            icon.SetContainer(current);
                            StackableMapIconManager.s_instance.m_containers.Add(current);
                            flag = true;
                            break;
                        }
                    }
                }
            }
        }
        if (!flag)
        {
            GameObject gameObject = Object.Instantiate <GameObject>(StackableMapIconManager.s_instance.m_stackableMapContainerPrefab);
            gameObject.get_transform().SetParent(icon.get_transform().get_parent(), false);
            RectTransform component  = gameObject.GetComponent <RectTransform>();
            RectTransform component2 = icon.GetComponent <RectTransform>();
            component.set_anchorMin(component2.get_anchorMin());
            component.set_anchorMax(component2.get_anchorMax());
            component.set_sizeDelta(icon.m_iconBoundsRT.get_sizeDelta());
            component.set_anchoredPosition(Vector2.get_zero());
            StackableMapIconContainer component3 = gameObject.GetComponent <StackableMapIconContainer>();
            if (component3 != null)
            {
                component3.AddStackableMapIcon(icon);
                icon.SetContainer(component3);
                StackableMapIconManager.s_instance.m_containers.Add(component3);
            }
            else
            {
                Debug.LogError("ERROR: containerObj has no StackableMapIconContainer!!");
            }
        }
    }
    public void AddStackableMapIcon(StackableMapIcon icon)
    {
        StackableMapIcon componentInChildren = this.m_singleRoot.GetComponentInChildren <StackableMapIcon>(true);

        StackableMapIcon[] componentsInChildren = this.m_multiRoot.GetComponentsInChildren <StackableMapIcon>(true);
        bool flag = true;

        if (componentInChildren == null && componentsInChildren.Length == 0)
        {
            icon.get_transform().SetParent(this.m_singleRoot.get_transform(), false);
            icon.get_transform().get_transform().set_localPosition(Vector3.get_zero());
        }
        else if (componentInChildren != null && componentsInChildren.Length == 0)
        {
            componentInChildren.get_transform().SetParent(this.m_multiRoot.get_transform(), false);
            icon.get_transform().SetParent(this.m_multiRoot.get_transform(), false);
            flag = false;
        }
        else
        {
            icon.get_transform().SetParent(this.m_multiRoot.get_transform(), false);
            flag = false;
        }
        this.ShowExplodedList(false);
        if (flag)
        {
            this.m_countainerPreviewIconsGroup.SetActive(false);
        }
        else
        {
            this.m_countainerPreviewIconsGroup.SetActive(true);
        }
        componentsInChildren = this.m_multiRoot.GetComponentsInChildren <StackableMapIcon>(true);
        this.m_iconCount.set_text(string.Empty + componentsInChildren.Length);
        base.get_gameObject().set_name("IconContainer (" + ((componentsInChildren.Length <= 0) ? "Single" : (string.Empty + componentsInChildren.Length)) + ")");
        base.get_gameObject().SetActive(true);
    }