Ejemplo n.º 1
0
    protected override void OnSpawn()
    {
        base.OnSpawn();
        element    = SimHashes.Ice;
        diseaseIdx = byte.MaxValue;
        ConfigureElements();
        List <string> list = new List <string>();

        list.Insert(0, "None");
        foreach (Disease resource in Db.Get().Diseases.resources)
        {
            list.Add(resource.Name);
        }
        diseasePopup.SetOptions(list.ToArray());
        KPopupMenu kPopupMenu = diseasePopup;

        kPopupMenu.OnSelect = (Action <string, int>)Delegate.Combine(kPopupMenu.OnSelect, new Action <string, int>(OnSelectDisease));
        SelectDiseaseOption(diseaseIdx);
        paintButton.onClick  += OnClickPaint;
        fillButton.onClick   += OnClickFill;
        sampleButton.onClick += OnClickSample;
        spawnButton.enabled   = false;
        KPopupMenu kPopupMenu2 = elementPopup;

        kPopupMenu2.OnSelect   = (Action <string, int>)Delegate.Combine(kPopupMenu2.OnSelect, new Action <string, int>(OnSelectElement));
        elementButton.onClick += elementPopup.OnClick;
        diseaseButton.onClick += diseasePopup.OnClick;
    }
    protected override void OnPrefabInit()
    {
        instance = this;
        KPopupMenu componentInChildren = GetComponentInChildren <KPopupMenu>();

        componentInChildren.SetOptions(new string[5]
        {
            "None",
            "Rooms",
            "Lighting",
            "Style",
            "Flow"
        });
        KPopupMenu kPopupMenu = componentInChildren;

        kPopupMenu.OnSelect = (Action <string, int>)Delegate.Combine(kPopupMenu.OnSelect, new Action <string, int>(OnSelect));
        base.gameObject.SetActive(false);
    }
Ejemplo n.º 3
0
    private void ConfigureElements()
    {
        if (filter != null)
        {
            filter = filter.ToLower();
        }
        List <ElemDisplayInfo> list = new List <ElemDisplayInfo>();

        foreach (Element element2 in ElementLoader.elements)
        {
            if (element2.name != "Element Not Loaded" && element2.substance != null && element2.substance.showInEditor && (string.IsNullOrEmpty(filter) || element2.name.ToLower().Contains(filter)))
            {
                list.Add(new ElemDisplayInfo
                {
                    id         = element2.id,
                    displayStr = element2.name + " (" + element2.GetStateString() + ")"
                });
            }
        }
        list.Sort((ElemDisplayInfo a, ElemDisplayInfo b) => a.displayStr.CompareTo(b.displayStr));
        if (string.IsNullOrEmpty(filter))
        {
            SimHashes[] array = new SimHashes[6]
            {
                SimHashes.SlimeMold,
                SimHashes.Vacuum,
                SimHashes.Dirt,
                SimHashes.CarbonDioxide,
                SimHashes.Water,
                SimHashes.Oxygen
            };
            SimHashes[] array2 = array;
            foreach (SimHashes hash in array2)
            {
                Element element = ElementLoader.FindElementByHash(hash);
                list.Insert(0, new ElemDisplayInfo
                {
                    id         = element.id,
                    displayStr = element.name + " (" + element.GetStateString() + ")"
                });
            }
        }
        options_list = new List <string>();
        List <string> list2 = new List <string>();

        foreach (ElemDisplayInfo item in list)
        {
            ElemDisplayInfo current2 = item;
            list2.Add(current2.displayStr);
            options_list.Add(current2.id.ToString());
        }
        elementPopup.SetOptions(list2);
        for (int j = 0; j < list.Count; j++)
        {
            ElemDisplayInfo elemDisplayInfo = list[j];
            if (elemDisplayInfo.id == this.element)
            {
                elementPopup.SelectOption(list2[j], j);
            }
        }
        elementPopup.GetComponent <ScrollRect>().normalizedPosition = new Vector2(0f, 1f);
    }