diff --git a/AutoMount.sln b/AutoMount.sln new file mode 100644 index 0000000..24e7858 --- /dev/null +++ b/AutoMount.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.3.32825.248 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoMount", "AutoMount\AutoMount.csproj", "{F3501134-B86C-49F5-9779-D700E83FAF1F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F3501134-B86C-49F5-9779-D700E83FAF1F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F3501134-B86C-49F5-9779-D700E83FAF1F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F3501134-B86C-49F5-9779-D700E83FAF1F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F3501134-B86C-49F5-9779-D700E83FAF1F}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {C53C5852-A5EC-49E2-9C37-51CFBF435D00} + EndGlobalSection +EndGlobal diff --git a/AutoMount/AutoMount.csproj b/AutoMount/AutoMount.csproj new file mode 100644 index 0000000..68d8f34 --- /dev/null +++ b/AutoMount/AutoMount.csproj @@ -0,0 +1,91 @@ + + + + net472 + enable + disable + $(OutputPath) + True + preview + Always + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + $(WrathPath)\Wrath_Data\Managed\UnityModManager\0Harmony.dll + False + + + $(SolutionDir)lib\Assembly-CSharp_public.dll + False + + + $(WrathPath)\Wrath_Data\Managed\Assembly-CSharp-firstpass.dll + False + + + $(WrathPath)\Wrath_Data\Managed\Owlcat.Runtime.UI.dll + + + $(WrathPath)\Wrath_Data\Managed\UnityEngine.dll + + + $(WrathPath)\Wrath_Data\Managed\UnityEngine.CoreModule.dll + False + + + $(WrathPath)\Wrath_Data\Managed\UnityEngine.IMGUIModule.dll + False + + + $(WrathPath)\Wrath_Data\Managed\UnityEngine.TextRenderingModule.dll + + + $(WrathPath)\Wrath_Data\Managed\UnityModManager\UnityModManager.dll + False + + + + + + True + True + Resources.resx + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + + + + PreserveNewest + + + + + + + + + + + + + + + + + + diff --git a/AutoMount/Info.json b/AutoMount/Info.json new file mode 100644 index 0000000..5123d61 --- /dev/null +++ b/AutoMount/Info.json @@ -0,0 +1,13 @@ +{ + "Id": "AutoMount", + "DisplayName": "Auto Mount", + "Author": "zepheon", + "Version": "0.0.1", + "ManagerVersion": "0.24.5.0", + "GameVersion": "1.4.2", + "Requirements": [], + "AssemblyName": "AutoMount.dll", + "EntryMethod": "AutoMount.Main.Load", + "Repository": "https://raw.githubusercontent.com/zephe0n/AutoMount/main/AutoMount/Repository.json", + "HomePage": "https://github.com/zephe0n/AutoMount" +} \ No newline at end of file diff --git a/AutoMount/Main.cs b/AutoMount/Main.cs new file mode 100644 index 0000000..af1c70b --- /dev/null +++ b/AutoMount/Main.cs @@ -0,0 +1,103 @@ +using HarmonyLib; +using UnityModManagerNet; +using System.Reflection; +using static UnityModManagerNet.UnityModManager.ModEntry; +using Kingmaker.PubSubSystem; +using Kingmaker.EntitySystem.Entities; +using Kingmaker; +using Kingmaker.UnitLogic.Parts; + +namespace AutoMount +{ +#if DEBUG + [EnableReloading] +#endif + public static class Main + { + public static Settings Settings; + public static bool Enabled; + public static ModLogger Logger; + + private static Harmony m_harmony; + private static Guid m_mount_ability_guid = new Guid("d340d820867cf9741903c9be9aed1ccc"); + + public static bool Load(UnityModManager.ModEntry modEntry) + { + Logger = modEntry.Logger; + Settings = Settings.Load(modEntry); + modEntry.OnToggle = OnToggle; + modEntry.OnGUI = OnGUI; + modEntry.OnSaveGUI = OnSaveGUI; + modEntry.OnUpdate = OnUpdate; +#if DEBUG + modEntry.OnUnload = Unload; +#endif + m_harmony = new Harmony(modEntry.Info.Id); + m_harmony.PatchAll(Assembly.GetExecutingAssembly()); + return true; + } + + static bool OnToggle(UnityModManager.ModEntry modEntry, bool value) + { + Enabled = value; + return true; + } + +#if DEBUG + static bool Unload(UnityModManager.ModEntry modEntry) + { + m_harmony.UnpatchAll(); + return true; + } +#endif + + static void OnGUI(UnityModManager.ModEntry modEntry) + { + Settings.Draw(); + } + + static void OnSaveGUI(UnityModManager.ModEntry modEntry) + { + Settings.Save(modEntry); + } + + static void OnUpdate(UnityModManager.ModEntry modEntry, float delta) + { + if (Settings.AutoMountHotKey.Up()) + { + Mount(); + } + } + + static void Mount() + { + foreach (var rider in Game.Instance.Player.Party) + { + var pet = rider.GetPet(Kingmaker.Enums.PetType.AnimalCompanion); + + if (pet != null && (rider.State.Size < pet.State.Size)) + { + var mount = rider.ActivatableAbilities.Enumerable.Find(a => a.Blueprint.AssetGuid.CompareTo(m_mount_ability_guid) == 0); + + if (mount != null) + { + if (mount.IsOn) + { +#if DEBUG + Logger.Log(rider.CharacterName + " -> " + pet.CharacterName + " OFF"); +#endif + rider.RiderPart?.Dismount(); + } + else + { +#if DEBUG + Logger.Log(rider.CharacterName + " -> " + pet.CharacterName + " ON"); +#endif + rider.Ensure().Mount(pet); + } + } + } + } + } + } +} \ No newline at end of file diff --git a/AutoMount/README.md b/AutoMount/README.md new file mode 100644 index 0000000..1066274 --- /dev/null +++ b/AutoMount/README.md @@ -0,0 +1,8 @@ +# About + +Mount all your pets automatically with a customizable keybind. By default: **Ctrl + Shift + A**. + +## How it works + +It detects which characters in your active party have pets and are able to mount them and just mounts/dismount it on keybind detection. This means that it actually **toggles** the mounted state. Maybe in future updates it may take into account a global desired mounted state and apply it to all elegible characters. + diff --git a/AutoMount/Repository.json b/AutoMount/Repository.json new file mode 100644 index 0000000..f8e657c --- /dev/null +++ b/AutoMount/Repository.json @@ -0,0 +1,8 @@ +{ + "Releases": [ + { + "Id": "AutoMount", + "Version": "0.0.1" + } + ] +} \ No newline at end of file diff --git a/AutoMount/Settings.cs b/AutoMount/Settings.cs new file mode 100644 index 0000000..d8a175f --- /dev/null +++ b/AutoMount/Settings.cs @@ -0,0 +1,28 @@ +using AutoMount; +using UnityEngine; +using UnityModManagerNet; + +namespace AutoMount +{ + public class Settings : UnityModManager.ModSettings + { + public KeyBinding AutoMountHotKey = new() { keyCode = KeyCode.A, modifiers = 1 | 2 }; // ctrl+shift+A + + public override void Save(UnityModManager.ModEntry modEntry) + { + Save(this, modEntry); + } + + public static void Draw() + { + GUILayout.Space(10); + + GUILayout.BeginHorizontal(GUILayout.Width(300)); + GUILayout.Label("Hotkey"); + UnityModManager.UI.DrawKeybinding(ref Main.Settings.AutoMountHotKey, "Hotkey"); + GUILayout.EndHorizontal(); + + GUILayout.Space(10); + } + } +} diff --git a/lib/Assembly-CSharp_public.dll b/lib/Assembly-CSharp_public.dll new file mode 100644 index 0000000..bca8c9b Binary files /dev/null and b/lib/Assembly-CSharp_public.dll differ diff --git a/lib/Assembly-CSharp_public.hash b/lib/Assembly-CSharp_public.hash new file mode 100644 index 0000000..ae20543 --- /dev/null +++ b/lib/Assembly-CSharp_public.hash @@ -0,0 +1 @@ +EFB3C8766100E246CD10F62589AC3DA62FF51CD6 \ No newline at end of file