Skip to content

Commit

Permalink
Pre-Release Version 0.11
Browse files Browse the repository at this point in the history
  • Loading branch information
luvoid committed Aug 7, 2023
1 parent db8e10b commit 4a98081
Show file tree
Hide file tree
Showing 15 changed files with 1,210 additions and 340 deletions.
6 changes: 6 additions & 0 deletions ButtJiggle.sln
Expand Up @@ -5,6 +5,8 @@ VisualStudioVersion = 17.3.32922.545
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ButtJiggle", "ButtJiggle\ButtJiggle.csproj", "{21D55085-3997-4A44-B09B-2B1735CA6D2A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BepInEx.Configuration.Json", "..\BepInEx.Configuration.Json\BepInEx.Configuration.Json\BepInEx.Configuration.Json.csproj", "{FF4B6D69-D118-4506-B65E-DB55555F7F13}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -15,6 +17,10 @@ Global
{21D55085-3997-4A44-B09B-2B1735CA6D2A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{21D55085-3997-4A44-B09B-2B1735CA6D2A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{21D55085-3997-4A44-B09B-2B1735CA6D2A}.Release|Any CPU.Build.0 = Release|Any CPU
{FF4B6D69-D118-4506-B65E-DB55555F7F13}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FF4B6D69-D118-4506-B65E-DB55555F7F13}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FF4B6D69-D118-4506-B65E-DB55555F7F13}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FF4B6D69-D118-4506-B65E-DB55555F7F13}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
31 changes: 21 additions & 10 deletions ButtJiggle/BoneMorph_Patch.cs
Expand Up @@ -9,24 +9,35 @@ internal static class BoneMorph_Patch
[HarmonyPrefix, HarmonyPatch(nameof(BoneMorph_.Blend))]
static void Blend_Prefix(BoneMorph_ __instance)
{
if (!__instance.m_tbSkin.body.TryGetHipHelpers(out var jbhHipL, out var jbhHipR)) return;
// Copy helper's transform so we can see if it gets changed

// Copy helper's transform so we can see if it get's changed
jbhHipL.CopyLocalTransformToBone();
jbhHipR.CopyLocalTransformToBone();
if (__instance.m_tbSkin.body.TryGetHipHelpers(out var jbhHipL, out var jbhHipR))
{
jbhHipL.CheckForChanges();
jbhHipR.CheckForChanges();
}

jbhHipL.IsChangeCheck = true;
jbhHipR.IsChangeCheck = true;
if (__instance.m_tbSkin.body.TryGetPelvisHelper(out var jbhPelvis))
{
jbhPelvis.CheckForChanges();
}
}

[HarmonyPostfix, HarmonyPatch(nameof(BoneMorph_.Blend))]
static void Blend_Postfix(BoneMorph_ __instance)
{
if (!__instance.m_tbSkin.body.TryGetHipHelpers(out var jbhHipL, out var jbhHipR)) return;

// Copy the bones's transform and any changes back to the helper
jbhHipL.CopyLocalTransformFromBone();
jbhHipR.CopyLocalTransformFromBone();

if (__instance.m_tbSkin.body.TryGetHipHelpers(out var jbhHipL, out var jbhHipR))
{
jbhHipL.ApplyChanges();
jbhHipR.ApplyChanges();
}

if (__instance.m_tbSkin.body.TryGetPelvisHelper(out var jbhPelvis))
{
jbhPelvis.ApplyChanges();
}
}
}
}
123 changes: 97 additions & 26 deletions ButtJiggle/ButtJiggle.cs
@@ -1,24 +1,19 @@
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Configuration.Json;
using BepInEx.Logging;
using HarmonyLib;
using MaidStatus;
using PrivateMaidMode;
using RootMotion;
using Newtonsoft.Json;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Reflection;
using System.Security;
using System.Security.Permissions;
using System.Text;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using UniverseLib;
using UniverseLib.Input;
using UniverseLib.UI;
using UnityEngine.Events;
using static Newtonsoft.Json.JsonToken;



// If there are errors in the above using statements, restore the NuGet packages:
Expand All @@ -39,8 +34,9 @@

// This is the major & minor version with an asterisk (*) appended to auto increment numbers.
[assembly: AssemblyVersion(COM3D2.ButtJiggle.PluginInfo.PLUGIN_VERSION + ".*")]
[assembly: AssemblyFileVersion(COM3D2.ButtJiggle.PluginInfo.PLUGIN_VERSION)]

// These two lines tell your plugin to not give a flying fuck about accessing private variables/classes whatever.
// These two lines tell your plugin to not give a flying flip about accessing private variables/classes whatever.
// It requires a publicized stubb of the library with those private objects though.
[module: UnverifiableCode]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
Expand All @@ -55,7 +51,7 @@ public static class PluginInfo
// The name of this plugin.
public const string PLUGIN_NAME = "Butt Jiggle";
// The version of this plugin.
public const string PLUGIN_VERSION = "0.7";
public const string PLUGIN_VERSION = "0.11";
}
}

Expand All @@ -76,51 +72,126 @@ public sealed partial class ButtJiggle : BaseUnityPlugin
private ManualLogSource _Logger => base.Logger;

internal static ConfigEntry<KeyboardShortcut> UIHotkey;


internal static ConfigEntry<double> ButtJiggle_ConfigVersion;

internal static ConfigEntry<bool> ButtJiggle_Enabled;
internal static ConfigEntry<float> ButtJiggle_DefaultSoftness;
internal static ConfigEntry<float> ButtJiggle_DefaultSoftness_Hip;
internal static ConfigEntry<float> ButtJiggle_DefaultSoftness_Pelvis;

//internal static ConfigEntry<bool> Experimental_PelvisEnabled;

internal static ConfigEntry<bool> GlobalOverride_Enabled;
internal static ConfigEntry<string> GlobalOverride_Json;
internal static ConfigEntryJson<MaidJiggleOverride> GlobalOverride_Settings;

public UnityEvent OnGlobalOverrideUpdated;

void Awake()
{
// Useful for engaging coroutines or accessing non-static variables. Completely optional though.
Instance = this;

// Binds the configuration. In other words it sets your ConfigEntry var to your config setup.
ButtJiggle_Enabled = Config.Bind("Butt Jiggle", "Enabled" , true, "Description");
ButtJiggle_DefaultSoftness = Config.Bind("Butt Jiggle", "DefaultSoftness", 0.5f, "Description");
ButtJiggle_ConfigVersion = Config.Bind("ButtJiggle", "ConfigVersion", 0.0, new ConfigDescription(
"Do not change this",
null,
new ConfigurationManagerAttributes()
{
IsAdvanced = true,
ReadOnly = true,
}
));

ButtJiggle_Enabled = Config.Bind("ButtJiggle", "Enabled", true);
ButtJiggle_DefaultSoftness_Hip = Config.Bind("ButtJiggle", "DefaultSoftness.Hip" , MaidJiggleOverride.Default.HipOverride.Softness.Value);
ButtJiggle_DefaultSoftness_Pelvis = Config.Bind("ButtJiggle", "DefaultSoftness.Pelvis", MaidJiggleOverride.Default.PelvisOverride.Softness.Value);
if (ButtJiggle_ConfigVersion.Value < 1.11)
{
ButtJiggle_DefaultSoftness_Pelvis.Value = MaidJiggleOverride.Default.PelvisOverride.Softness.Value;
}

//Experimental_PelvisEnabled = Config.Bind("Experimental", "PelvisEnabled", false);


ConfigBindGlobalOverride();

// Add the keybind
KeyboardShortcut hotkey = new KeyboardShortcut(KeyCode.A, KeyCode.LeftControl);
UIHotkey = Config.Bind("UI", "Toggle", hotkey, "Recomend using Ctrl A for 'Ass'");
UIHotkey = Config.Bind("UI", "Toggle", hotkey, "Recommend using Ctrl A for 'Ass'");

Logger.LogInfo("Patching ButtJiggle");
ButtJiggle_ConfigVersion.Value = double.Parse(PluginInfo.PLUGIN_VERSION);

Logger.LogDebug("Patching ButtJiggle");
Harmony.CreateAndPatchAll(typeof(ButtJiggle));

Logger.LogInfo("Patching TBodyPatch");
Logger.LogDebug("Patching TBodyPatch");
Harmony.CreateAndPatchAll(typeof(TBodyPatch));

Logger.LogInfo("Patching BoneMorph_Patch");
Logger.LogDebug("Patching BoneMorph_Patch");
Harmony.CreateAndPatchAll(typeof(BoneMorph_Patch));

Logger.LogInfo("Finished patching");
Logger.LogDebug("Finished patching");
}

void Start()
{
Universe_Init();
}

private bool m_IsHotkeyHandled = false;
void Update()
{
if (UIHotkey.Value.IsDown() && !m_IsHotkeyHandled)
if (UIHotkey.Value.IsDown())
{
ToggleUI();
m_IsHotkeyHandled = true;
}
else if (UIHotkey.Value.IsUp())
}

private void ConfigBindGlobalOverride()
{
if (GlobalOverride_Enabled != null) return;

string defaultJson = SerializeGlobalOverride();

GlobalOverride_Enabled = Config.Bind("GlobalOverride", "Enabled", false , "Enable global override of jiggle settings");
//GlobalOverride_Json = Config.Bind("Global Override", "Json" , defaultJson, "The jiggle settings in JSON format" );
GlobalOverride_Settings = Config.BindJson("GlobalOverride", "Settings", MaidJiggleOverride.Default, "The settings used for the global override");

if (ButtJiggle_ConfigVersion.Value < 1.11)
{
m_IsHotkeyHandled = false;
GlobalOverride_Settings.Value = MaidJiggleOverride.Default;
}

JiggleBoneHelper.UseGlobalOverride = GlobalOverride_Enabled.Value;
JiggleBoneHelper.GlobalOverride = GlobalOverride_Settings.Value;

GlobalOverride_Enabled.SettingChanged += delegate (object sender, EventArgs eventArgs)
{
JiggleBoneHelper.UseGlobalOverride = GlobalOverride_Enabled.Value;
OnGlobalOverrideUpdated.Invoke();
};
GlobalOverride_Settings.SettingChanged += delegate (object sender, EventArgs eventArgs)
{
JiggleBoneHelper.GlobalOverride = GlobalOverride_Settings.Value;
OnGlobalOverrideUpdated.Invoke();
};
}

public static void ConfigSaveGlobalOverride()
{
Logger.LogDebug("ConfigSaveGlobalOverride");
GlobalOverride_Enabled .Value = JiggleBoneHelper.UseGlobalOverride;
//GlobalOverride_Json .Value = SerializeGlobalOverride();
GlobalOverride_Settings.Value = JiggleBoneHelper.GlobalOverride;
}

private static string SerializeGlobalOverride()
{
JsonSerializer serializer = new JsonSerializer();
StringWriter writer = new StringWriter();
serializer.Serialize(writer, JiggleBoneHelper.GlobalOverride);
return writer.ToString();
}
}
}
16 changes: 14 additions & 2 deletions ButtJiggle/ButtJiggle.csproj
Expand Up @@ -49,10 +49,10 @@
<PackageReference Include="Mono.Cecil" Version="0.10.4" targetFramework="net35" />
<PackageReference Include="MonoMod.RuntimeDetour" Version="21.12.13.1" targetFramework="net35" />
<PackageReference Include="MonoMod.Utils" Version="21.12.13.1" targetFramework="net35" />
<PackageReference Include="UniverseLib.Analyzers" Version="1.0.3" targetFramework="net35" developmentDependency="true">
<PackageReference Include="UniverseLib.Analyzers" Version="1.0.4" targetFramework="net35" developmentDependency="true">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="UniverseLib.Mono" Version="1.3.3" targetFramework="net35" />
<PackageReference Include="UniverseLib.Mono" Version="1.5.1" targetFramework="net35" />
</ItemGroup>
<ItemGroup>
<Reference Include="System">
Expand Down Expand Up @@ -81,17 +81,29 @@
</PropertyGroup>
<ItemGroup>
<Compile Include="ButtJiggleUI.cs" />
<Compile Include="ConfigurationManagerAttributes.cs" />
<Compile Include="JiggleBoneHelper.cs" />
<Compile Include="BoneMorph_Patch.cs" />
<Compile Include="JiggleBoneOverride.cs" />
<Compile Include="MaidJiggleOverride.cs" />
<Compile Include="Override.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ButtJiggle.cs" />
<Compile Include="UnityRuntimeGizmos.cs" />
<Compile Include="SphereRenderer.cs" />
<Compile Include="Stiffness.cs" />
<Compile Include="TBodyPatch.cs" />
<Compile Include="UIControlFactory.cs" />
</ItemGroup>
<ItemGroup>
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\BepInEx.Configuration.Json\BepInEx.Configuration.Json\BepInEx.Configuration.Json.csproj">
<Project>{ff4b6d69-d118-4506-b65e-db55555f7f13}</Project>
<Name>BepInEx.Configuration.Json</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>
Expand Down

0 comments on commit 4a98081

Please sign in to comment.