Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mosirnik committed Jul 19, 2023
1 parent 0e02f06 commit 9a49cb1
Show file tree
Hide file tree
Showing 6 changed files with 152 additions and 86 deletions.
2 changes: 1 addition & 1 deletion src/PluginTemplate.sln → src/MaterialGreeting.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
99 changes: 99 additions & 0 deletions src/PluginCode/DebugPlugin.cs
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// 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.
/// </summary>
public const string PluginName = "MaterialGreetingDebugPlugin";

/// <summary>
/// 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.
/// </summary>
public const string GUID = "mosirnik.material-greeting-debug-plugin";

/// <summary>
/// Version of the plugin. Must be in form <major>.<minor>.<build>.<revision>.
/// Major and minor versions are mandatory, but build and revision can be left unspecified.
/// </summary>
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<DebugController>(GUID);
GameAPI.PeriodChange += OnPeriodChange;
}

private static void OnPeriodChange(object sender, GameAPI.PeriodChangeEventArgs args)
{
foreach (var heroine in Singleton<Manager.Game>.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;
}
}
}
}
}
61 changes: 0 additions & 61 deletions src/PluginCode/ExamplePlugin.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<ProjectGuid>{799E8918-D6E9-47AF-9218-466D328960FC}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>PluginCode</RootNamespace>
<AssemblyName>PluginCode</AssemblyName>
<RootNamespace>MaterialGreeting</RootNamespace>
<AssemblyName>MaterialGreeting</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
Expand All @@ -23,6 +23,7 @@
<DefineConstants>TRACE;DEBUG</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>embedded</DebugType>
Expand All @@ -32,26 +33,39 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DebugSymbols>true</DebugSymbols>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Reference Include="0Harmony, Version=2.2.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\IllusionLibs.BepInEx.Harmony.2.2.0.1\lib\net35\0Harmony.dll</HintPath>
<Reference Include="0Harmony, Version=2.5.4.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\IllusionLibs.BepInEx.Harmony.2.5.4\lib\net35\0Harmony.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Assembly-CSharp, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\IllusionLibs.Koikatu.Assembly-CSharp.2019.4.27.2\lib\net35\Assembly-CSharp.dll</HintPath>
<HintPath>..\packages\IllusionLibs.Koikatu.Assembly-CSharp.2019.4.27.4\lib\net35\Assembly-CSharp.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="BepInEx, Version=5.4.4.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\IllusionLibs.BepInEx.5.4.4\lib\net35\BepInEx.dll</HintPath>
<Reference Include="Assembly-CSharp-firstpass, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\IllusionLibs.Koikatu.Assembly-CSharp-firstpass.2019.4.27.4\lib\net35\Assembly-CSharp-firstpass.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="BepInEx.Harmony, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\IllusionLibs.BepInEx.Harmony.2.2.0.1\lib\net35\BepInEx.Harmony.dll</HintPath>
<Reference Include="BepInEx, Version=5.4.15.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\IllusionLibs.BepInEx.5.4.15\lib\net35\BepInEx.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="KKAPI, Version=1.14.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\IllusionModdingAPI.KKAPI.1.14.0\lib\net35\KKAPI.dll</HintPath>
<Reference Include="ExtensibleSaveFormat, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\ExtensibleSaveFormat.Koikatu.16.4.0\lib\net35\ExtensibleSaveFormat.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="KKAPI, Version=1.30.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\IllusionModdingAPI.KKAPI.1.30.0\lib\net35\KKAPI.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="MonoMod.RuntimeDetour, Version=21.8.5.1, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\IllusionLibs.BepInEx.MonoMod.21.8.5.1\lib\net35\MonoMod.RuntimeDetour.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="MonoMod.Utils, Version=21.8.5.1, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\IllusionLibs.BepInEx.MonoMod.21.8.5.1\lib\net35\MonoMod.Utils.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System" />
Expand All @@ -64,27 +78,36 @@
<HintPath>..\packages\IllusionLibs.Koikatu.UnityEngine.5.6.2.2\lib\net35\UnityEngine.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.UI, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\IllusionLibs.Koikatu.UnityEngine.UI.5.6.2\lib\net35\UnityEngine.UI.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="ExamplePlugin.cs" />
<Compile Include="DebugPlugin.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Analyzer Include="..\packages\KoikatuCompatibilityAnalyzer.1.0.1\analyzers\dotnet\cs\KoikatuCompatibilityAnalyzer.dll" />
<Analyzer Include="..\packages\Microsoft.Unity.Analyzers.1.9.0\analyzers\dotnet\cs\Microsoft.Unity.Analyzers.dll" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\IllusionLibs.BepInEx.Harmony.2.2.0.1\build\IllusionLibs.BepInEx.Harmony.targets" Condition="Exists('..\packages\IllusionLibs.BepInEx.Harmony.2.2.0.1\build\IllusionLibs.BepInEx.Harmony.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>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}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\IllusionLibs.BepInEx.Harmony.2.2.0.1\build\IllusionLibs.BepInEx.Harmony.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\IllusionLibs.BepInEx.Harmony.2.2.0.1\build\IllusionLibs.BepInEx.Harmony.targets'))" />
<Error Condition="!Exists('..\packages\IllusionLibs.Koikatu.Assembly-CSharp.2019.4.27.2\build\IllusionLibs.Koikatu.Assembly-CSharp.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\IllusionLibs.Koikatu.Assembly-CSharp.2019.4.27.2\build\IllusionLibs.Koikatu.Assembly-CSharp.targets'))" />
<Error Condition="!Exists('..\packages\IllusionLibs.Koikatu.UnityEngine.5.6.2.2\build\IllusionLibs.Koikatu.UnityEngine.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\IllusionLibs.Koikatu.UnityEngine.5.6.2.2\build\IllusionLibs.Koikatu.UnityEngine.targets'))" />
<Error Condition="!Exists('..\packages\IllusionLibs.BepInEx.Harmony.2.5.4\build\IllusionLibs.BepInEx.Harmony.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\IllusionLibs.BepInEx.Harmony.2.5.4\build\IllusionLibs.BepInEx.Harmony.targets'))" />
<Error Condition="!Exists('..\packages\IllusionLibs.BepInEx.MonoMod.21.8.5.1\build\IllusionLibs.BepInEx.MonoMod.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\IllusionLibs.BepInEx.MonoMod.21.8.5.1\build\IllusionLibs.BepInEx.MonoMod.targets'))" />
<Error Condition="!Exists('..\packages\IllusionLibs.Koikatu.Assembly-CSharp.2019.4.27.4\build\IllusionLibs.Koikatu.Assembly-CSharp.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\IllusionLibs.Koikatu.Assembly-CSharp.2019.4.27.4\build\IllusionLibs.Koikatu.Assembly-CSharp.targets'))" />
<Error Condition="!Exists('..\packages\IllusionLibs.Koikatu.Assembly-CSharp-firstpass.2019.4.27.4\build\IllusionLibs.Koikatu.Assembly-CSharp-firstpass.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\IllusionLibs.Koikatu.Assembly-CSharp-firstpass.2019.4.27.4\build\IllusionLibs.Koikatu.Assembly-CSharp-firstpass.targets'))" />
</Target>
<Import Project="..\packages\IllusionLibs.Koikatu.Assembly-CSharp.2019.4.27.2\build\IllusionLibs.Koikatu.Assembly-CSharp.targets" Condition="Exists('..\packages\IllusionLibs.Koikatu.Assembly-CSharp.2019.4.27.2\build\IllusionLibs.Koikatu.Assembly-CSharp.targets')" />
<Import Project="..\packages\IllusionLibs.Koikatu.UnityEngine.5.6.2.2\build\IllusionLibs.Koikatu.UnityEngine.targets" Condition="Exists('..\packages\IllusionLibs.Koikatu.UnityEngine.5.6.2.2\build\IllusionLibs.Koikatu.UnityEngine.targets')" />
<Import Project="..\packages\IllusionLibs.BepInEx.Harmony.2.5.4\build\IllusionLibs.BepInEx.Harmony.targets" Condition="Exists('..\packages\IllusionLibs.BepInEx.Harmony.2.5.4\build\IllusionLibs.BepInEx.Harmony.targets')" />
<Import Project="..\packages\IllusionLibs.BepInEx.MonoMod.21.8.5.1\build\IllusionLibs.BepInEx.MonoMod.targets" Condition="Exists('..\packages\IllusionLibs.BepInEx.MonoMod.21.8.5.1\build\IllusionLibs.BepInEx.MonoMod.targets')" />
<Import Project="..\packages\IllusionLibs.Koikatu.Assembly-CSharp.2019.4.27.4\build\IllusionLibs.Koikatu.Assembly-CSharp.targets" Condition="Exists('..\packages\IllusionLibs.Koikatu.Assembly-CSharp.2019.4.27.4\build\IllusionLibs.Koikatu.Assembly-CSharp.targets')" />
<Import Project="..\packages\IllusionLibs.Koikatu.Assembly-CSharp-firstpass.2019.4.27.4\build\IllusionLibs.Koikatu.Assembly-CSharp-firstpass.targets" Condition="Exists('..\packages\IllusionLibs.Koikatu.Assembly-CSharp-firstpass.2019.4.27.4\build\IllusionLibs.Koikatu.Assembly-CSharp-firstpass.targets')" />
</Project>
8 changes: 4 additions & 4 deletions src/PluginCode/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -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("")]
Expand All @@ -16,4 +16,4 @@
[assembly: ComVisible(false)]
[assembly: Guid("799e8918-d6e9-47af-9218-466d328960fc")]

[assembly: AssemblyVersion(ExamplePlugin.Version)]
[assembly: AssemblyVersion(DebugPlugin.Version)]
13 changes: 9 additions & 4 deletions src/PluginCode/packages.config
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="IllusionLibs.BepInEx" version="5.4.4" targetFramework="net35" />
<package id="IllusionLibs.BepInEx.Harmony" version="2.2.0.1" targetFramework="net35" />
<package id="IllusionLibs.Koikatu.Assembly-CSharp" version="2019.4.27.2" targetFramework="net35" />
<package id="ExtensibleSaveFormat.Koikatu" version="16.4.0" targetFramework="net35" developmentDependency="true" />
<package id="IllusionLibs.BepInEx" version="5.4.15" targetFramework="net35" />
<package id="IllusionLibs.BepInEx.Harmony" version="2.5.4" targetFramework="net35" />
<package id="IllusionLibs.BepInEx.MonoMod" version="21.8.5.1" targetFramework="net35" />
<package id="IllusionLibs.Koikatu.Assembly-CSharp" version="2019.4.27.4" targetFramework="net35" />
<package id="IllusionLibs.Koikatu.Assembly-CSharp-firstpass" version="2019.4.27.4" targetFramework="net35" />
<package id="IllusionLibs.Koikatu.UnityEngine" version="5.6.2.2" targetFramework="net35" />
<package id="IllusionModdingAPI.KKAPI" version="1.14.0" targetFramework="net35" developmentDependency="true" />
<package id="IllusionLibs.Koikatu.UnityEngine.UI" version="5.6.2" targetFramework="net35" developmentDependency="true" />
<package id="IllusionModdingAPI.KKAPI" version="1.30.0" targetFramework="net35" developmentDependency="true" />
<package id="KoikatuCompatibilityAnalyzer" version="1.0.1" targetFramework="net35" developmentDependency="true" />
<package id="Microsoft.Unity.Analyzers" version="1.9.0" targetFramework="net35" developmentDependency="true" />
</packages>

0 comments on commit 9a49cb1

Please sign in to comment.