Exemple #1
0
        internal static Button EnsureButton(string name, string key, Device device)
        {
            if (!cacheManager.TryParse(name, out Button button))
            {
                EnumTypeCache cache = cacheManager.RequestCacheForTypeName(name);

                if (cache == null)
                {
                    cache = new EnumTypeCache()
                    {
                        Name  = name,
                        Index = cacheManager.GetNextAvailableIndex()
                    };
                }

                if (cacheManager.IsIndexAvailable(cache.Index))
                {
                    cache.Index = cacheManager.GetNextAvailableIndex();
                }

                button = (Button)cache.Index;
                cacheManager.Add(button, cache.Index, cache.Name);
                RegisterNewButton(name, key, button, device);

                Logger.Log($"Successfully added Button: '{name}' to Index: '{cache.Index}'", LogLevel.Debug);
                return(button);
            }
            else
            {
                return(button);
            }
        }
        internal static bool Prefix_Parse(Type enumType, string value, bool ignoreCase, ref object __result)
        {
            if (enumType.Equals(typeof(CraftTree.Type)))
            {
                if (cacheManager.TryParse(value, out CraftTree.Type craftTreeType))
                {
                    __result = craftTreeType;
                    return(false);
                }
            }

            return(true);
        }
Exemple #3
0
        private static bool Prefix_Parse(Type enumType, string value, bool ignoreCase, ref object __result)
        {
            if (enumType.Equals(typeof(TechType)))
            {
                if (cacheManager.TryParse(value, out TechType techType))
                {
                    __result = techType;
                    return(false);
                }
            }

            return(true);
        }