예제 #1
0
    private void ConfigureEntitySelector()
    {
        List <SelectorValue.SearchFilter> list = new List <SelectorValue.SearchFilter>();
        string name = UI.SANDBOXTOOLS.FILTERS.ENTITIES.FOOD;
        Func <object, bool> condition = delegate(object entity)
        {
            string idString = (entity as KPrefabID).PrefabID().ToString();
            return(!(entity as KPrefabID).HasTag(GameTags.Egg) && FOOD.FOOD_TYPES_LIST.Find((EdiblesManager.FoodInfo match) => match.Id == idString) != null);
        };
        Tuple <Sprite, Color> uISprite = Def.GetUISprite(Assets.GetPrefab("MushBar"), "ui", false);

        SelectorValue.SearchFilter item = new SelectorValue.SearchFilter(name, condition, null, uISprite);
        list.Add(item);
        name      = UI.SANDBOXTOOLS.FILTERS.ENTITIES.SPECIAL;
        condition = ((object entity) => (entity as KPrefabID).PrefabID().Name == MinionConfig.ID || (entity as KPrefabID).PrefabID().Name == DustCometConfig.ID || (entity as KPrefabID).PrefabID().Name == RockCometConfig.ID || (entity as KPrefabID).PrefabID().Name == IronCometConfig.ID);
        uISprite  = new Tuple <Sprite, Color>(Assets.GetSprite("ui_duplicant_portrait_placeholder"), Color.white);
        SelectorValue.SearchFilter item2 = new SelectorValue.SearchFilter(name, condition, null, uISprite);
        list.Add(item2);
        SelectorValue.SearchFilter searchFilter  = null;
        SelectorValue.SearchFilter searchFilter2 = null;
        name         = UI.SANDBOXTOOLS.FILTERS.ENTITIES.CREATURE;
        condition    = ((object entity) => false);
        uISprite     = Def.GetUISprite(Assets.GetPrefab("Hatch"), "ui", false);
        searchFilter = new SelectorValue.SearchFilter(name, condition, null, uISprite);
        list.Add(searchFilter);
        List <Tag> list2 = new List <Tag>();

        foreach (GameObject item7 in Assets.GetPrefabsWithTag("CreatureBrain".ToTag()))
        {
            CreatureBrain brain = item7.GetComponent <CreatureBrain>();
            if (!list2.Contains(brain.species))
            {
                Tuple <Sprite, Color> icon = new Tuple <Sprite, Color>(CodexCache.entries[brain.species.ToString().ToUpper()].icon, CodexCache.entries[brain.species.ToString().ToUpper()].iconColor);
                list2.Add(brain.species);
                string key = "STRINGS.CREATURES.FAMILY_PLURAL." + brain.species.ToString().ToUpper();
                SelectorValue.SearchFilter item3 = new SelectorValue.SearchFilter(Strings.Get(key), delegate(object entity)
                {
                    CreatureBrain component2 = Assets.GetPrefab((entity as KPrefabID).PrefabID()).GetComponent <CreatureBrain>();
                    return((entity as KPrefabID).HasTag("CreatureBrain".ToString()) && component2.species == brain.species);
                }, searchFilter, icon);
                list.Add(item3);
            }
        }
        searchFilter2 = new SelectorValue.SearchFilter(UI.SANDBOXTOOLS.FILTERS.ENTITIES.CREATURE_EGG, (object entity) => (entity as KPrefabID).HasTag(GameTags.Egg), searchFilter, Def.GetUISprite(Assets.GetPrefab("HatchEgg"), "ui", false));
        list.Add(searchFilter2);
        name      = UI.SANDBOXTOOLS.FILTERS.ENTITIES.EQUIPMENT;
        condition = delegate(object entity)
        {
            if ((UnityEngine.Object)(entity as KPrefabID).gameObject == (UnityEngine.Object)null)
            {
                return(false);
            }
            GameObject gameObject4 = (entity as KPrefabID).gameObject;
            if ((UnityEngine.Object)gameObject4 != (UnityEngine.Object)null)
            {
                return((UnityEngine.Object)gameObject4.GetComponent <Equippable>() != (UnityEngine.Object)null);
            }
            return(false);
        };
        uISprite = Def.GetUISprite(Assets.GetPrefab("Funky_Vest"), "ui", false);
        SelectorValue.SearchFilter item4 = new SelectorValue.SearchFilter(name, condition, null, uISprite);
        list.Add(item4);
        name      = UI.SANDBOXTOOLS.FILTERS.ENTITIES.PLANTS;
        condition = delegate(object entity)
        {
            if ((UnityEngine.Object)(entity as KPrefabID).gameObject == (UnityEngine.Object)null)
            {
                return(false);
            }
            GameObject gameObject3 = (entity as KPrefabID).gameObject;
            if ((UnityEngine.Object)gameObject3 != (UnityEngine.Object)null)
            {
                return((UnityEngine.Object)gameObject3.GetComponent <Harvestable>() != (UnityEngine.Object)null || (UnityEngine.Object)gameObject3.GetComponent <WiltCondition>() != (UnityEngine.Object)null);
            }
            return(false);
        };
        uISprite = Def.GetUISprite(Assets.GetPrefab("PrickleFlower"), "ui", false);
        SelectorValue.SearchFilter searchFilter3 = new SelectorValue.SearchFilter(name, condition, null, uISprite);
        list.Add(searchFilter3);
        SelectorValue.SearchFilter item5 = new SelectorValue.SearchFilter(UI.SANDBOXTOOLS.FILTERS.ENTITIES.SEEDS, delegate(object entity)
        {
            if ((UnityEngine.Object)(entity as KPrefabID).gameObject == (UnityEngine.Object)null)
            {
                return(false);
            }
            GameObject gameObject2 = (entity as KPrefabID).gameObject;
            if ((UnityEngine.Object)gameObject2 != (UnityEngine.Object)null)
            {
                return((UnityEngine.Object)gameObject2.GetComponent <PlantableSeed>() != (UnityEngine.Object)null);
            }
            return(false);
        }, searchFilter3, Def.GetUISprite(Assets.GetPrefab("PrickleFlowerSeed"), "ui", false));
        list.Add(item5);
        name      = UI.SANDBOXTOOLS.FILTERS.ENTITIES.INDUSTRIAL_PRODUCTS;
        condition = delegate(object entity)
        {
            if ((UnityEngine.Object)(entity as KPrefabID).gameObject == (UnityEngine.Object)null)
            {
                return(false);
            }
            GameObject gameObject = (entity as KPrefabID).gameObject;
            if ((UnityEngine.Object)gameObject != (UnityEngine.Object)null)
            {
                return(gameObject.HasTag(GameTags.IndustrialIngredient) || gameObject.HasTag(GameTags.IndustrialProduct) || gameObject.HasTag(GameTags.Medicine) || gameObject.HasTag(GameTags.MedicalSupplies));
            }
            return(false);
        };
        uISprite = Def.GetUISprite(Assets.GetPrefab("BasicCure"), "ui", false);
        SelectorValue.SearchFilter item6 = new SelectorValue.SearchFilter(name, condition, null, uISprite);
        list.Add(item6);
        List <KPrefabID> list3 = new List <KPrefabID>();

        foreach (KPrefabID prefab2 in Assets.Prefabs)
        {
            foreach (SelectorValue.SearchFilter item8 in list)
            {
                if (item8.condition(prefab2))
                {
                    list3.Add(prefab2);
                    break;
                }
            }
        }
        entitySelector = new SelectorValue(list3.ToArray(), delegate(object entity)
        {
            settings.SelectEntity(entity as KPrefabID);
        }, (object entity) => (entity as KPrefabID).GetProperName(), delegate(string filterString, object option)
        {
            if ((option as KPrefabID).GetProperName().ToUpper().Contains(filterString.ToUpper()))
            {
                return(true);
            }
            return(false);
        }, delegate(object entity)
        {
            GameObject prefab = Assets.GetPrefab((entity as KPrefabID).PrefabTag);
            if ((UnityEngine.Object)prefab != (UnityEngine.Object)null)
            {
                if (prefab.PrefabID() == (Tag)MinionConfig.ID)
                {
                    return(new Tuple <Sprite, Color>(Assets.GetSprite("ui_duplicant_portrait_placeholder"), Color.white));
                }
                KBatchedAnimController component = prefab.GetComponent <KBatchedAnimController>();
                if ((UnityEngine.Object)component != (UnityEngine.Object)null && component.AnimFiles.Length > 0)
                {
                    KAnimFile x = component.AnimFiles[0];
                    if ((UnityEngine.Object)x != (UnityEngine.Object)null)
                    {
                        return(Def.GetUISprite(prefab, "ui", false));
                    }
                }
            }
            return(null);
        }, list.ToArray());
    }
예제 #2
0
    private void ConfigureElementSelector()
    {
        Func <object, bool> func           = (object element) => (element as Element).IsSolid;
        Func <object, bool> func2          = (object element) => (element as Element).IsLiquid;
        Func <object, bool> func3          = (object element) => (element as Element).IsGas;
        List <Element>      commonElements = new List <Element>();
        Func <object, bool> condition      = (object element) => commonElements.Contains(element as Element);

        commonElements.Insert(0, ElementLoader.FindElementByHash(SimHashes.Oxygen));
        commonElements.Insert(0, ElementLoader.FindElementByHash(SimHashes.Water));
        commonElements.Insert(0, ElementLoader.FindElementByHash(SimHashes.Vacuum));
        commonElements.Insert(0, ElementLoader.FindElementByHash(SimHashes.Dirt));
        commonElements.Insert(0, ElementLoader.FindElementByHash(SimHashes.SandStone));
        commonElements.Insert(0, ElementLoader.FindElementByHash(SimHashes.Cuprite));
        commonElements.Insert(0, ElementLoader.FindElementByHash(SimHashes.Algae));
        commonElements.Insert(0, ElementLoader.FindElementByHash(SimHashes.CarbonDioxide));
        commonElements.Insert(0, ElementLoader.FindElementByHash(SimHashes.Sand));
        commonElements.Insert(0, ElementLoader.FindElementByHash(SimHashes.SlimeMold));
        commonElements.Insert(0, ElementLoader.FindElementByHash(SimHashes.Granite));
        List <Element> list = new List <Element>();

        foreach (Element element in ElementLoader.elements)
        {
            if (!element.disabled)
            {
                list.Add(element);
            }
        }
        list.Sort((Element a, Element b) => a.name.CompareTo(b.name));
        Element[]       options        = list.ToArray();
        Action <object> onValueChanged = delegate(object element)
        {
            settings.SelectElement(element as Element);
        };
        Func <object, string>       getOptionName        = (object element) => (element as Element).name + " (" + (element as Element).GetStateString() + ")";
        Func <string, object, bool> filterOptionFunction = delegate(string filterString, object option)
        {
            if (((option as Element).name.ToUpper() + (option as Element).GetStateString().ToUpper()).Contains(filterString.ToUpper()))
            {
                return(true);
            }
            return(false);
        };
        Func <object, Tuple <Sprite, Color> > getOptionSprite = (object element) => Def.GetUISprite(element as Element, "ui", false);

        SelectorValue.SearchFilter[] obj = new SelectorValue.SearchFilter[4]
        {
            new SelectorValue.SearchFilter(UI.SANDBOXTOOLS.FILTERS.COMMON, condition, null, null),
            null,
            null,
            null
        };
        string name = UI.SANDBOXTOOLS.FILTERS.SOLID;
        Func <object, bool>   condition2 = func;
        Tuple <Sprite, Color> uISprite   = Def.GetUISprite(ElementLoader.FindElementByHash(SimHashes.SandStone), "ui", false);

        obj[1]          = new SelectorValue.SearchFilter(name, condition2, null, uISprite);
        name            = UI.SANDBOXTOOLS.FILTERS.LIQUID;
        condition2      = func2;
        uISprite        = Def.GetUISprite(ElementLoader.FindElementByHash(SimHashes.Water), "ui", false);
        obj[2]          = new SelectorValue.SearchFilter(name, condition2, null, uISprite);
        name            = UI.SANDBOXTOOLS.FILTERS.GAS;
        condition2      = func3;
        uISprite        = Def.GetUISprite(ElementLoader.FindElementByHash(SimHashes.Oxygen), "ui", false);
        obj[3]          = new SelectorValue.SearchFilter(name, condition2, null, uISprite);
        elementSelector = new SelectorValue(options, onValueChanged, getOptionName, filterOptionFunction, getOptionSprite, obj);
    }