예제 #1
0
 public static void Patch()
 {
     HarmonyInstance.Create("qprawn_upgrade_access.mod").PatchAll(Assembly.GetExecutingAssembly());
     QPatch.Path = QPatch.Path ?? "QMods\\QPrawnUpgradeAccess";
     QPatch.LoadConfig();
     Console.WriteLine("[QPrawnUpgradeAccess] Patched");
 }
예제 #2
0
        private static void LoadConfig()
        {
            string modInfoPath = QPatch.GetModInfoPath();

            if (!File.Exists(modInfoPath))
            {
                Console.WriteLine("[QPrawnUpgradeAccess] Couldn't load: " + modInfoPath);
            }
            else
            {
                QPatch.ModConfig modConfig = (QPatch.ModConfig)null;
                try
                {
                    modConfig = (QPatch.ModConfig)JsonConvert.DeserializeObject <QPatch.ModConfig>(File.ReadAllText(modInfoPath));
                }
                catch
                {
                }
                if (modConfig == null)
                {
                    Console.WriteLine("[QPrawnUpgradeAccess] Invalid mod.json format");
                }
                else
                {
                    List <GameInput.Button> buttonList1 = new List <GameInput.Button>();
                    List <GameInput.Button> buttonList2 = new List <GameInput.Button>();
                    string[] strArray1 = new string[2]
                    {
                        modConfig.Config.Upgrade0,
                        modConfig.Config.Upgrade1
                    };
                    foreach (string str in strArray1)
                    {
                        GameInput.Button?nullable = QPatch.ToEnum(str);
                        if (nullable.HasValue)
                        {
                            buttonList1.Add(nullable.Value);
                        }
                        else if (str != "")
                        {
                            Console.WriteLine("[QPrawnUpgradeAccess]: Invalid buton value: " + str);
                        }
                    }
                    string[] strArray2 = new string[2]
                    {
                        modConfig.Config.Storage0,
                        modConfig.Config.Storage1
                    };
                    foreach (string str in strArray2)
                    {
                        GameInput.Button?nullable = QPatch.ToEnum(str);
                        if (nullable.HasValue)
                        {
                            buttonList2.Add(nullable.Value);
                        }
                        else if (str != "")
                        {
                            Console.WriteLine("[QPrawnUpgradeAccess]: Invalid buton value: " + str);
                        }
                    }
                    QPatch.UpgradeButtons = buttonList1;
                    QPatch.StorageButtons = buttonList2;
                }
            }
        }