From aa64f89781dd19f58ef924cc465e19e37b8c92cf Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Fri, 27 Sep 2024 21:04:18 +0200 Subject: [PATCH] Update template --- .gitignore | 3 + MelonTemplate/MelonTemplate.cs | 121 ++++++----------------- MelonTemplate/MelonTemplate.csproj | 20 ++-- MelonTemplate/Properties/AssemblyInfo.cs | 8 +- 4 files changed, 47 insertions(+), 105 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ba66cca --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*/obj +*/bin +**/.idea diff --git a/MelonTemplate/MelonTemplate.cs b/MelonTemplate/MelonTemplate.cs index cce2b8d..4a9f551 100644 --- a/MelonTemplate/MelonTemplate.cs +++ b/MelonTemplate/MelonTemplate.cs @@ -1,103 +1,40 @@ -using System; -using System.Linq; -using BepInEx; -using BepInEx.Configuration; -using HarmonyLib; -using HarmonyLib.Tools; +using System.Linq; +using MelonLoader; -namespace TavernDave { - [BepInPlugin(pluginGuid, pluginName, pluginVersion)] - public class Main : BaseUnityPlugin { - private const string pluginGuid = "TavernDave"; - private const string pluginName = "TavernDave"; - private const string pluginVersion = "1.0.0"; - - public static ConfigEntry debug; - - public static ConfigEntry moneyMultiplier; - public static ConfigEntry fastSpeed; - public static ConfigEntry staffXpMultiplier; - public static ConfigEntry peoplePerMinuteMultiplier; - public static ConfigEntry peoplePerMinuteOffset; - public static ConfigEntry prestigeMultiplier; - - public void Awake() { - debug = Config.Bind("General", "Debug", false); - - moneyMultiplier = Config.Bind("General", "MoneyMultiplier", 1f); - fastSpeed = Config.Bind("General", "FastSpeed", 1); - staffXpMultiplier = Config.Bind("General", "StaffXpMultiplier", 1f); - peoplePerMinuteMultiplier = Config.Bind("General", "PeoplePerMinuteMultiplier", 1f); - peoplePerMinuteOffset = Config.Bind("General", "PeoplePerMinuteOffset", 0f); - prestigeMultiplier = Config.Bind("General", "PrestigeMultiplier", 1f); - - Logger.LogInfo("Cyka mod loaded"); - HarmonyFileLog.Enabled = true; - Harmony harmony = new Harmony(pluginGuid); +namespace MelonTemplate { + public class MelonTemplateMod : MelonMod { + public override void OnInitializeMelon() { + LoggerInstance.Msg("Phat Melon mod loaded"); + HarmonyLib.Harmony harmony = HarmonyInstance; harmony.PatchAll(); var originalMethods = harmony.GetPatchedMethods(); - Logger.LogInfo("Patched " + originalMethods.Count() + " methods"); - foreach (var method in originalMethods) { - Logger.LogInfo("Patched " + method.Name); + var methodBases = originalMethods.ToList(); + LoggerInstance.Msg("Patched " + methodBases.Count() + " methods"); + foreach (var method in methodBases) { + LoggerInstance.Msg("Patched " + method.Name); } } } - [HarmonyPatch] + [HarmonyLib.HarmonyPatch] public class Patches { - [HarmonyPrefix] - [HarmonyPatch(typeof(TavernModel), "ChangeMoney")] - public static void PrefixMoney(ref int value) { - if (Main.debug.Value) - Console.WriteLine($"Money is {value}"); - if (value > 0) { - value = (int)(value * Main.moneyMultiplier.Value); - if (Main.debug.Value) - Console.WriteLine($"Money modified to {value}"); - } - } - - [HarmonyPrefix] - [HarmonyPatch(typeof(UiController), "ChangeGameSpeed")] - public static void PrefixSpeed(ref int gameSpeed) { - if (Main.debug.Value) - Console.WriteLine($"Game speed is {gameSpeed}"); - if (gameSpeed > 1) { - gameSpeed = Main.fastSpeed.Value; - if (Main.debug.Value) - Console.WriteLine($"Game speed modified to {gameSpeed}"); - } - } + // [HarmonyLib.HarmonyPrefix] + // [HarmonyLib.HarmonyPatch(typeof(TavernModel), "ChangeMoney")] + // public static void PrefixMoney(ref int value) { + // if (Main.debug.Value) + // Console.WriteLine($"Money is {value}"); + // if (value > 0) { + // value = (int)(value * Main.moneyMultiplier.Value); + // if (Main.debug.Value) + // Console.WriteLine($"Money modified to {value}"); + // } + // } - [HarmonyPrefix] - [HarmonyPatch(typeof(StaffModel), "UpdateXp")] - public static void PrefixXp(ref int id, ref int amount) { - if (Main.debug.Value) - Console.WriteLine($"Staff xp is {amount}"); - if (amount > 0) { - amount = (int)(amount * Main.staffXpMultiplier.Value); - if (Main.debug.Value) - Console.WriteLine($"Staff xp modified to {amount}"); - } - } - - [HarmonyPostfix] - [HarmonyPatch(typeof(TechTreeModel), nameof(TechTreeModel.GetBonusPeoplePerMinute))] - public static void PostfixPeoplePerMinute(ref float __result) { - __result *= Main.peoplePerMinuteMultiplier.Value; - __result += Main.peoplePerMinuteOffset.Value; - } - - [HarmonyPostfix] - [HarmonyPatch(typeof(TavernModel), nameof(TavernModel.GetQuality))] - public static void PostfixQuality(ref int __result) { - if (Main.debug.Value) - Console.WriteLine($"Quality is {__result}"); - if (__result > 0) { - __result = (int)(__result * Main.prestigeMultiplier.Value); - if (Main.debug.Value) - Console.WriteLine($"Quality modified to {__result}"); - } - } + // [HarmonyLib.HarmonyPostfix] + // [HarmonyLib.HarmonyPatch(typeof(TechTreeModel), nameof(TechTreeModel.GetBonusPeoplePerMinute))] + // public static void PostfixPeoplePerMinute(ref float __result) { + // __result *= Main.peoplePerMinuteMultiplier.Value; + // __result += Main.peoplePerMinuteOffset.Value; + // } } } \ No newline at end of file diff --git a/MelonTemplate/MelonTemplate.csproj b/MelonTemplate/MelonTemplate.csproj index 46d5d7a..495baff 100644 --- a/MelonTemplate/MelonTemplate.csproj +++ b/MelonTemplate/MelonTemplate.csproj @@ -2,9 +2,10 @@ - {foo/bar} - $(GAME_DIR)/{foo/bar}/Managed - $(GAME_DIR)/BepInEx + C:/Games/Arms Trade Tycoon Tanks + + $(GAME_DIR)/MelonLoader + $(GAME_MELON)/Il2CppAssemblies Debug AnyCPU {DA9D274E-486F-4F82-84FF-CD9388CB0B09} @@ -35,18 +36,15 @@ 4 - + + + $(GAME_MELON)/net6/MelonLoader.dll + - $(GAME_BEPINEX)/core/0Harmony.dll - - - $(GAME_BEPINEX)/core/BepInEx.dll - - - $(GAME_BEPINEX)/plugins/ConfigurationManager/ConfigurationManager.dll + $(GAME_MELON)/net6/0Harmony.dll $(GAME_MANAGED)/Assembly-CSharp.dll diff --git a/MelonTemplate/Properties/AssemblyInfo.cs b/MelonTemplate/Properties/AssemblyInfo.cs index 7b22a2f..d762300 100644 --- a/MelonTemplate/Properties/AssemblyInfo.cs +++ b/MelonTemplate/Properties/AssemblyInfo.cs @@ -1,14 +1,18 @@ using System.Reflection; using System.Runtime.InteropServices; +using MelonLoader; +using MelonTemplate; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. -[assembly: AssemblyTitle("DaveCEO")] +[assembly: MelonInfo(typeof(MelonTemplateMod), "Phat Melon Mod", "1.0.0", "Phat Phuck Dave")] +[assembly: MelonGame("Game Developer", "Game Name")] +[assembly: AssemblyTitle("Phat Melon Mod")] +[assembly: AssemblyProduct("Phat Melon Mod")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("DaveCEO")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")]