コード例 #1
0
        public static void DebugComponent(this Component component)
        {
            List <string> keywords = new List <string>();

            BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.IgnoreReturn;

            keywords.Add("Properties:");

            foreach (PropertyInfo propertyInfo in component.GetType().GetProperties(bindingFlags))
            {
                keywords.Add($"{propertyInfo.Name}  [{propertyInfo.GetValue(component, bindingFlags, null, null, null).ToString()}]");
            }

            keywords.Add("Fields:");

            foreach (FieldInfo fieldInfo in component.GetType().GetFields(bindingFlags))
            {
                keywords.Add($"{fieldInfo.Name}  [{fieldInfo.GetValue(component).ToString()}]");
            }

            foreach (string key in keywords)
            {
                SNLogger.Log($"{key}");
            }
        }
コード例 #2
0
        public virtual void Patch()
        {
            Atlas.Sprite sprite = null;

            if (IconFilename != null)
            {
                string iconfilePath = $"./QMods/{IconFilename}/Assets/{IconFilename}.png";

                try
                {
                    sprite = ImageUtils.LoadSpriteFromFile(iconfilePath);
                }
                catch
                {
                    SNLogger.Log($"[{NameID}] ***ERROR! File [{iconfilePath}] not Found! ");
                }
            }
            else if (IconTechType != TechType.None)
            {
                try
                {
                    sprite = GetResourceIcon(IconTechType);
                }
                catch
                {
                    SNLogger.Log($"[{NameID}] ***ERROR! Resource TechType icon [{IconTechType.ToString()}] not Found! ");
                }
            }
            else
            {
                try
                {
                    sprite = GetResourceIcon(PrefabTemplate);
                }
                catch
                {
                    SNLogger.Log($"[{NameID}] ***ERROR! Resource template icon [{PrefabTemplate.ToString()}] not Found! ");
                }
            }


            TechType = TechTypeHandler.AddTechType(NameID, FriendlyName, Description, sprite, false);
            SpriteHandler.RegisterSprite(TechType, sprite);
            CraftTreeHandler.AddCraftingNode(FabricatorType, TechType, FabricatorTab);
            CraftDataHandler.SetTechData(TechType, GetRecipe());
            CraftDataHandler.AddToGroup(GroupForPDA, CategoryForPDA, TechType);
            CraftDataHandler.SetEquipmentType(TechType, TypeForEquipment);
            CraftDataHandler.SetQuickSlotType(TechType, TypeForQuickslot);
            CraftDataHandler.SetItemSize(TechType, ItemSize);
            CraftDataHandler.SetBackgroundType(TechType, BackgroundType);
            KnownTechHandler.SetAnalysisTechEntry(RequiredForUnlock, new TechType[1] {
                TechType
            }, $"{FriendlyName} blueprint discovered!");

            PrefabHandler.RegisterPrefab(this);
        }
コード例 #3
0
        public static void ExecuteCommand(object message, object command)
        {
            if (message != null)
            {
                ErrorMessage.AddMessage(message.ToString());
            }

            if (command != null)
            {
                SNLogger.Log((string)command);
                DevConsole.SendConsoleCommand(command.ToString());
            }
        }
コード例 #4
0
        public virtual void Patch_B()
        {
            Atlas.Sprite sprite = null;

            if (IconFilename != null)
            {
                try
                {
                    sprite = ImageUtils.LoadSpriteFromFile($"./QMods/{IconFilename}/Assets/{IconFilename}.png");
                }
                catch
                {
                    SNLogger.Log($"[{_ClassID}] ***ERROR! File [{IconFilename}.png] not Found! ");
                }
            }
            else if (IconTechType != TechType.None)
            {
                try
                {
                    sprite = GetResourceIcon(IconTechType);
                }
                catch
                {
                    SNLogger.Log($"[{_ClassID}] ***ERROR! Resource TechType icon [{IconTechType.ToString()}] not Found! ");
                }
            }
            else
            {
                try
                {
                    sprite = GetResourceIcon(PrefabTemplate);
                }
                catch
                {
                    SNLogger.Log($"[{_ClassID}] ***ERROR! Resource template icon [{PrefabTemplate.ToString()}] not Found! ");
                }
            }


            TechType = TechTypeHandler.AddTechType(_ClassID, _FriendlyName, _Description, sprite, false);
            SpriteHandler.RegisterSprite(TechType, sprite);
            CraftDataHandler.SetTechData(TechType, GetRecipe());
            CraftDataHandler.AddToGroup(GroupForPDA, CategoryForPDA, TechType);
            KnownTechHandler.SetAnalysisTechEntry(RequiredForUnlock, new TechType[1] {
                TechType
            }, $"{_FriendlyName} blueprint discovered!");

            PrefabHandler.RegisterPrefab(this);
        }
コード例 #5
0
        public static void GetPrefabInfo(this GameObject prefab)
        {
            List <string> keywords = new List <string>();

            BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static;

            keywords.Add($"prefab name: {prefab.name}");
            keywords.Add("Properties:");

            foreach (PropertyInfo propertyInfo in prefab.GetType().GetProperties(bindingFlags))
            {
                try
                {
                    keywords.Add($"{propertyInfo.Name} = [{propertyInfo.GetValue(prefab, bindingFlags, null, null, null).ToString()}]");
                }
                catch
                {
                    continue;
                }
            }

            keywords.Add("Fields:");

            foreach (FieldInfo fieldInfo in prefab.GetType().GetFields(bindingFlags))
            {
                try
                {
                    keywords.Add($"{fieldInfo.Name} = [{fieldInfo.GetValue(prefab).ToString()}]");
                }
                catch
                {
                    continue;
                }

                if (fieldInfo.GetValue(prefab).GetType() == typeof(GameObject))
                {
                    GameObject go = (GameObject)fieldInfo.GetValue(prefab);
                    go.GetPrefabInfo();
                }
            }

            foreach (string keyword in keywords)
            {
                SNLogger.Log(keyword);
            }
        }