From 9a49cb1711c74640051bd21a5f77c6af33b5e97a Mon Sep 17 00:00:00 2001 From: mosirnik Date: Thu, 20 Jul 2023 00:48:44 +0900 Subject: [PATCH] First commit --- ...luginTemplate.sln => MaterialGreeting.sln} | 2 +- src/PluginCode/DebugPlugin.cs | 99 +++++++++++++++++++ src/PluginCode/ExamplePlugin.cs | 61 ------------ ...ginCode.csproj => MaterialGreeting.csproj} | 55 ++++++++--- src/PluginCode/Properties/AssemblyInfo.cs | 8 +- src/PluginCode/packages.config | 13 ++- 6 files changed, 152 insertions(+), 86 deletions(-) rename src/{PluginTemplate.sln => MaterialGreeting.sln} (86%) create mode 100644 src/PluginCode/DebugPlugin.cs delete mode 100644 src/PluginCode/ExamplePlugin.cs rename src/PluginCode/{PluginCode.csproj => MaterialGreeting.csproj} (51%) diff --git a/src/PluginTemplate.sln b/src/MaterialGreeting.sln similarity index 86% rename from src/PluginTemplate.sln rename to src/MaterialGreeting.sln index c95d3e8..d6e209d 100644 --- a/src/PluginTemplate.sln +++ b/src/MaterialGreeting.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.30804.86 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PluginCode", "PluginCode\PluginCode.csproj", "{799E8918-D6E9-47AF-9218-466D328960FC}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MaterialGreeting", "PluginCode\MaterialGreeting.csproj", "{799E8918-D6E9-47AF-9218-466D328960FC}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/src/PluginCode/DebugPlugin.cs b/src/PluginCode/DebugPlugin.cs new file mode 100644 index 0000000..d712608 --- /dev/null +++ b/src/PluginCode/DebugPlugin.cs @@ -0,0 +1,99 @@ +using BepInEx; +using BepInEx.Configuration; +using BepInEx.Logging; +using HarmonyLib; +using KKAPI; +using KKAPI.Chara; +using System; +using System.Collections; +using UnityEngine; +using KKAPI.MainGame; + +namespace MaterialGreeting +{ + [BepInPlugin(GUID, PluginName, Version)] + // Tell BepInEx that this plugin needs KKAPI of at least the specified version. + // If not found, this plugi will not be loaded and a warning will be shown. + [BepInDependency(KoikatuAPI.GUID, KoikatuAPI.VersionConst)] + public class DebugPlugin : BaseUnityPlugin + { + /// + /// Human-readable name of the plugin. In general, it should be short and concise. + /// This is the name that is shown to the users who run BepInEx and to modders that inspect BepInEx logs. + /// + public const string PluginName = "MaterialGreetingDebugPlugin"; + + /// + /// Unique ID of the plugin. Will be used as the default config file name. + /// This must be a unique string that contains only characters a-z, 0-9 underscores (_) and dots (.) + /// When creating Harmony patches or any persisting data, it's best to use this ID for easier identification. + /// + public const string GUID = "mosirnik.material-greeting-debug-plugin"; + + /// + /// Version of the plugin. Must be in form .... + /// Major and minor versions are mandatory, but build and revision can be left unspecified. + /// + public const string Version = "1.0.0"; + + internal static new ManualLogSource Logger; + + private void Awake() + { + Logger = base.Logger; + + Harmony.CreateAndPatchAll(typeof(Hooks), GUID); + CharacterApi.RegisterExtraBehaviour(GUID); + GameAPI.PeriodChange += OnPeriodChange; + } + + private static void OnPeriodChange(object sender, GameAPI.PeriodChangeEventArgs args) + { + foreach (var heroine in Singleton.Instance.HeroineList) + { + if (heroine.fixCharaID == 0 && heroine.relation < 0) + { + heroine.talkEvent.Add(1); + DebugPlugin.Logger.LogWarning($"Increasing relationship with {heroine.Name}"); + } + } + } + + [HarmonyPatch(typeof(Illusion.Utils.ProbabilityCalclator))] + private static class Hooks + { + [HarmonyPatch(nameof(Illusion.Utils.ProbabilityCalclator.DetectFromPercent))] + [HarmonyPostfix] + public static void PostDetectFromPercent(float percent, ref bool __result) + { + DebugPlugin.Logger.LogWarning($"Cheating on {percent}% chance ({__result})"); + __result = true; + } + } + + private class DebugController : CharaCustomFunctionController + { + protected override void OnCardBeingSaved(GameMode mode) + { + } + + protected override void OnReload(GameMode currentGameMode) + { + DebugPlugin.Logger.LogWarning($"[{Time.frameCount}] OnReload"); + StartCoroutine(OnReloadCo()); + } + + private IEnumerator OnReloadCo() + { + while (true) + { + bool top = ChaControl.objTop; + bool head = ChaControl.objHead; + DebugPlugin.Logger.LogWarning($"[{Time.frameCount}] top={top} head={head}"); + if (top && head) break; + yield return null; + } + } + } + } +} diff --git a/src/PluginCode/ExamplePlugin.cs b/src/PluginCode/ExamplePlugin.cs deleted file mode 100644 index 921c06b..0000000 --- a/src/PluginCode/ExamplePlugin.cs +++ /dev/null @@ -1,61 +0,0 @@ -using BepInEx; -using BepInEx.Configuration; -using BepInEx.Logging; -using HarmonyLib; -using KKAPI; - -namespace PluginCode -{ - [BepInPlugin(GUID, PluginName, Version)] - // Tell BepInEx that this plugin needs KKAPI of at least the specified version. - // If not found, this plugi will not be loaded and a warning will be shown. - [BepInDependency(KoikatuAPI.GUID, KoikatuAPI.VersionConst)] - public class ExamplePlugin : BaseUnityPlugin - { - /// - /// Human-readable name of the plugin. In general, it should be short and concise. - /// This is the name that is shown to the users who run BepInEx and to modders that inspect BepInEx logs. - /// - public const string PluginName = "BepInEx Plugin"; - - /// - /// Unique ID of the plugin. Will be used as the default config file name. - /// This must be a unique string that contains only characters a-z, 0-9 underscores (_) and dots (.) - /// When creating Harmony patches or any persisting data, it's best to use this ID for easier identification. - /// - public const string GUID = "org.pluginid"; - - /// - /// Version of the plugin. Must be in form .... - /// Major and minor versions are mandatory, but build and revision can be left unspecified. - /// - public const string Version = "1.0.0"; - - internal static new ManualLogSource Logger; - - private ConfigEntry _exampleConfigEntry; - - private void Awake() - { - Logger = base.Logger; - - _exampleConfigEntry = Config.Bind("General", "Enable this plugin", true, "If false, this plugin will do nothing"); - - if (_exampleConfigEntry.Value) - { - Harmony.CreateAndPatchAll(typeof(Hooks), GUID); - //CharacterApi.RegisterExtraBehaviour(GUID); - } - } - - private static class Hooks - { - // [HarmonyPrefix] - // [HarmonyPatch(typeof(SomeClass), nameof(SomeClass.SomeInstanceMethod))] - // private static void SomeMethodPrefix(SomeClass __instance, int someParameter, ref int __result) - // { - // ... - // } - } - } -} diff --git a/src/PluginCode/PluginCode.csproj b/src/PluginCode/MaterialGreeting.csproj similarity index 51% rename from src/PluginCode/PluginCode.csproj rename to src/PluginCode/MaterialGreeting.csproj index 969ef96..b5afd21 100644 --- a/src/PluginCode/PluginCode.csproj +++ b/src/PluginCode/MaterialGreeting.csproj @@ -7,8 +7,8 @@ {799E8918-D6E9-47AF-9218-466D328960FC} Library Properties - PluginCode - PluginCode + MaterialGreeting + MaterialGreeting v3.5 512 true @@ -23,6 +23,7 @@ TRACE;DEBUG prompt 4 + true embedded @@ -32,26 +33,39 @@ prompt 4 true + true - - ..\packages\IllusionLibs.BepInEx.Harmony.2.2.0.1\lib\net35\0Harmony.dll + + ..\packages\IllusionLibs.BepInEx.Harmony.2.5.4\lib\net35\0Harmony.dll False - ..\packages\IllusionLibs.Koikatu.Assembly-CSharp.2019.4.27.2\lib\net35\Assembly-CSharp.dll + ..\packages\IllusionLibs.Koikatu.Assembly-CSharp.2019.4.27.4\lib\net35\Assembly-CSharp.dll False - - ..\packages\IllusionLibs.BepInEx.5.4.4\lib\net35\BepInEx.dll + + ..\packages\IllusionLibs.Koikatu.Assembly-CSharp-firstpass.2019.4.27.4\lib\net35\Assembly-CSharp-firstpass.dll False - - ..\packages\IllusionLibs.BepInEx.Harmony.2.2.0.1\lib\net35\BepInEx.Harmony.dll + + ..\packages\IllusionLibs.BepInEx.5.4.15\lib\net35\BepInEx.dll False - - ..\packages\IllusionModdingAPI.KKAPI.1.14.0\lib\net35\KKAPI.dll + + ..\packages\ExtensibleSaveFormat.Koikatu.16.4.0\lib\net35\ExtensibleSaveFormat.dll + False + + + ..\packages\IllusionModdingAPI.KKAPI.1.30.0\lib\net35\KKAPI.dll + False + + + ..\packages\IllusionLibs.BepInEx.MonoMod.21.8.5.1\lib\net35\MonoMod.RuntimeDetour.dll + False + + + ..\packages\IllusionLibs.BepInEx.MonoMod.21.8.5.1\lib\net35\MonoMod.Utils.dll False @@ -64,27 +78,36 @@ ..\packages\IllusionLibs.Koikatu.UnityEngine.5.6.2.2\lib\net35\UnityEngine.dll False + + ..\packages\IllusionLibs.Koikatu.UnityEngine.UI.5.6.2\lib\net35\UnityEngine.UI.dll + False + - + + - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - + + + + - + + + + \ No newline at end of file diff --git a/src/PluginCode/Properties/AssemblyInfo.cs b/src/PluginCode/Properties/AssemblyInfo.cs index 559ce7f..a1f1f4b 100644 --- a/src/PluginCode/Properties/AssemblyInfo.cs +++ b/src/PluginCode/Properties/AssemblyInfo.cs @@ -1,12 +1,12 @@ using System.Reflection; using System.Runtime.InteropServices; -using PluginCode; +using MaterialGreeting; [assembly: AssemblyDescription("")] [assembly: AssemblyCompany("")] -[assembly: AssemblyTitle(ExamplePlugin.PluginName)] -[assembly: AssemblyProduct(ExamplePlugin.PluginName)] +[assembly: AssemblyTitle(DebugPlugin.PluginName)] +[assembly: AssemblyProduct(DebugPlugin.PluginName)] [assembly: AssemblyCopyright("Copyright © 2020")] [assembly: AssemblyTrademark("")] @@ -16,4 +16,4 @@ [assembly: ComVisible(false)] [assembly: Guid("799e8918-d6e9-47af-9218-466d328960fc")] -[assembly: AssemblyVersion(ExamplePlugin.Version)] +[assembly: AssemblyVersion(DebugPlugin.Version)] diff --git a/src/PluginCode/packages.config b/src/PluginCode/packages.config index 31f0ae3..9aeb29a 100644 --- a/src/PluginCode/packages.config +++ b/src/PluginCode/packages.config @@ -1,9 +1,14 @@  - - - + + + + + + - + + + \ No newline at end of file