mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-03 23:09:22 +00:00
thirdperson, propundobutton, mirror clone test, you are a clone test, bettershadowclone test, nevermind, anotherlocaltestmod, and some changes to avatarscaling ???
This commit is contained in:
parent
df45fb50d9
commit
9944ad7611
43 changed files with 1076 additions and 173 deletions
119
YouAreAClone/Main.cs
Normal file
119
YouAreAClone/Main.cs
Normal file
|
@ -0,0 +1,119 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using MelonLoader;
|
||||
using System.Reflection;
|
||||
using ABI_RC.Core.Player;
|
||||
using ABI_RC.Core.Util;
|
||||
using ABI_RC.Core.Util.AssetFiltering;
|
||||
using ABI_RC.Systems.Camera;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NAK.YouAreAClone;
|
||||
|
||||
public class YouAreAClone : MelonMod
|
||||
{
|
||||
internal static MelonLogger.Instance Logger;
|
||||
|
||||
|
||||
public override void OnInitializeMelon()
|
||||
{
|
||||
Logger = LoggerInstance;
|
||||
|
||||
//VRModeSwitchEvents.OnCompletedVRModeSwitch.AddListener(_ => FindCameras());
|
||||
|
||||
SharedFilter._avatarWhitelist.Add(typeof(FPRExclusion));
|
||||
SharedFilter._localComponentWhitelist.Add(typeof(FPRExclusion));
|
||||
|
||||
try
|
||||
{
|
||||
LoadAssetBundle();
|
||||
InitializePatches();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Error(e);
|
||||
}
|
||||
}
|
||||
|
||||
#region Asset Bundle Loading
|
||||
|
||||
private const string YouAreACloneAssets = "YouAreAClone.assets";
|
||||
|
||||
private const string BoneHiderComputePath = "Assets/Koneko/ComputeShaders/BoneHider.compute";
|
||||
//private const string MeshCopyComputePath = "Assets/Koneko/ComputeShaders/MeshCopy.compute";
|
||||
|
||||
private const string ShadowCloneComputePath = "Assets/NotAKid/Shaders/ShadowClone.compute";
|
||||
private const string ShadowCloneShaderPath = "Assets/NotAKid/Shaders/ShadowClone.shader";
|
||||
private const string DummyCloneShaderPath = "Assets/NotAKid/Shaders/DummyClone.shader";
|
||||
|
||||
private void LoadAssetBundle()
|
||||
{
|
||||
Logger.Msg($"Loading required asset bundle...");
|
||||
using Stream resourceStream = MelonAssembly.Assembly.GetManifestResourceStream(YouAreACloneAssets);
|
||||
using MemoryStream memoryStream = new();
|
||||
if (resourceStream == null) {
|
||||
Logger.Error($"Failed to load {YouAreACloneAssets}!");
|
||||
return;
|
||||
}
|
||||
|
||||
resourceStream.CopyTo(memoryStream);
|
||||
AssetBundle assetBundle = AssetBundle.LoadFromMemory(memoryStream.ToArray());
|
||||
if (assetBundle == null) {
|
||||
Logger.Error($"Failed to load {YouAreACloneAssets}! Asset bundle is null!");
|
||||
return;
|
||||
}
|
||||
|
||||
// load shaders
|
||||
ComputeShader shader = assetBundle.LoadAsset<ComputeShader>(BoneHiderComputePath);
|
||||
shader.hideFlags |= HideFlags.DontUnloadUnusedAsset;
|
||||
TransformHiderManager.shader = shader;
|
||||
Logger.Msg($"Loaded {BoneHiderComputePath}!");
|
||||
|
||||
// load shadow clone shader
|
||||
ComputeShader shadowCloneCompute = assetBundle.LoadAsset<ComputeShader>(ShadowCloneComputePath);
|
||||
shadowCloneCompute.hideFlags |= HideFlags.DontUnloadUnusedAsset;
|
||||
ShadowCloneHelper.shader = shadowCloneCompute;
|
||||
Logger.Msg($"Loaded {ShadowCloneComputePath}!");
|
||||
|
||||
// load shadow clone material
|
||||
Shader shadowCloneShader = assetBundle.LoadAsset<Shader>(ShadowCloneShaderPath);
|
||||
shadowCloneShader.hideFlags |= HideFlags.DontUnloadUnusedAsset;
|
||||
ShadowCloneHelper.shadowMaterial = new Material(shadowCloneShader);
|
||||
Logger.Msg($"Loaded {ShadowCloneShaderPath}!");
|
||||
|
||||
Logger.Msg("Asset bundle successfully loaded!");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Harmony Patches
|
||||
|
||||
private void InitializePatches()
|
||||
{
|
||||
HarmonyInstance.Patch(
|
||||
typeof(TransformHiderForMainCamera).GetMethod(nameof(TransformHiderForMainCamera.ProcessHierarchy)),
|
||||
prefix: new HarmonyLib.HarmonyMethod(typeof(YouAreAClone).GetMethod(nameof(OnTransformHiderForMainCamera_ProcessHierarchy_Prefix), BindingFlags.NonPublic | BindingFlags.Static))
|
||||
);
|
||||
|
||||
HarmonyInstance.Patch(
|
||||
typeof(PlayerSetup).GetMethod(nameof(PlayerSetup.ClearAvatar)),
|
||||
prefix: new HarmonyLib.HarmonyMethod(typeof(YouAreAClone).GetMethod(nameof(OnPlayerSetup_ClearAvatar_Prefix), BindingFlags.NonPublic | BindingFlags.Static))
|
||||
);
|
||||
}
|
||||
|
||||
private static void OnPlayerSetup_ClearAvatar_Prefix()
|
||||
{
|
||||
TransformHiderManager.Instance.OnAvatarCleared();
|
||||
ShadowCloneManager.Instance.OnAvatarCleared();
|
||||
}
|
||||
|
||||
private static void OnTransformHiderForMainCamera_ProcessHierarchy_Prefix(ref bool __runOriginal)
|
||||
{
|
||||
if (!__runOriginal || (__runOriginal = !ModSettings.EntryEnabled.Value))
|
||||
return; // if something else disabled, or we are disabled, don't run
|
||||
|
||||
ShadowCloneHelper.SetupAvatar(PlayerSetup.Instance._avatar);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
60
YouAreAClone/ModSettings.cs
Normal file
60
YouAreAClone/ModSettings.cs
Normal file
|
@ -0,0 +1,60 @@
|
|||
using MelonLoader;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NAK.BetterShadowClone;
|
||||
|
||||
public static class ModSettings
|
||||
{
|
||||
#region Melon Prefs
|
||||
|
||||
private const string SettingsCategory = nameof(ShadowCloneMod);
|
||||
|
||||
private static readonly MelonPreferences_Category Category =
|
||||
MelonPreferences.CreateCategory(SettingsCategory);
|
||||
|
||||
internal static readonly MelonPreferences_Entry<bool> EntryEnabled =
|
||||
Category.CreateEntry("Enabled", true,
|
||||
description: "Enable Mirror Clone.");
|
||||
|
||||
internal static readonly MelonPreferences_Entry<bool> EntryUseShadowClone =
|
||||
Category.CreateEntry("Use Shadow Clone", true,
|
||||
description: "Should you have shadow clones?");
|
||||
|
||||
internal static readonly MelonPreferences_Entry<bool> EntryCopyMaterialToShadow =
|
||||
Category.CreateEntry("Copy Material to Shadow", true,
|
||||
description: "Should the shadow clone copy the material from the original mesh? Note: This can have a slight performance hit.");
|
||||
|
||||
internal static readonly MelonPreferences_Entry<bool> EntryDontRespectFPR =
|
||||
Category.CreateEntry("Dont Respect FPR", false,
|
||||
description: "Should the transform hider not respect FPR?");
|
||||
|
||||
internal static readonly MelonPreferences_Entry<bool> EntryDebugHeadHide =
|
||||
Category.CreateEntry("Debug Head Hide", false,
|
||||
description: "Should head be hidden for first render?");
|
||||
|
||||
internal static readonly MelonPreferences_Entry<bool> EntryDebugShowShadow =
|
||||
Category.CreateEntry("Debug Show Shadow", false,
|
||||
description: "Should the shadow clone be shown?");
|
||||
|
||||
internal static readonly MelonPreferences_Entry<bool> EntryDebugShowInFront =
|
||||
Category.CreateEntry("Debug Show in Front", false,
|
||||
description: "Should the shadow clone be shown in front?");
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
internal static void Initialize()
|
||||
{
|
||||
foreach (MelonPreferences_Entry setting in Category.Entries)
|
||||
setting.OnEntryValueChangedUntyped.Subscribe(OnSettingsChanged);
|
||||
}
|
||||
|
||||
private static void OnSettingsChanged(object oldValue = null, object newValue = null)
|
||||
{
|
||||
TransformHiderManager.s_DisallowFprExclusions = EntryDontRespectFPR.Value;
|
||||
TransformHiderManager.s_DebugHeadHide = EntryDebugHeadHide.Value;
|
||||
ShadowCloneManager.s_CopyMaterialsToShadow = EntryCopyMaterialToShadow.Value;
|
||||
ShadowCloneManager.s_DebugShowShadow = EntryDebugShowShadow.Value;
|
||||
ShadowCloneManager.s_DebugShowInFront = EntryDebugShowInFront.Value;
|
||||
}
|
||||
}
|
29
YouAreAClone/Properties/AssemblyInfo.cs
Normal file
29
YouAreAClone/Properties/AssemblyInfo.cs
Normal file
|
@ -0,0 +1,29 @@
|
|||
using MelonLoader;
|
||||
using NAK.BetterShadowClone.Properties;
|
||||
using System.Reflection;
|
||||
|
||||
[assembly: AssemblyVersion(AssemblyInfoParams.Version)]
|
||||
[assembly: AssemblyFileVersion(AssemblyInfoParams.Version)]
|
||||
[assembly: AssemblyInformationalVersion(AssemblyInfoParams.Version)]
|
||||
[assembly: AssemblyTitle(nameof(NAK.BetterShadowClone))]
|
||||
[assembly: AssemblyCompany(AssemblyInfoParams.Author)]
|
||||
[assembly: AssemblyProduct(nameof(NAK.BetterShadowClone))]
|
||||
|
||||
[assembly: MelonInfo(
|
||||
typeof(NAK.BetterShadowClone.ShadowCloneMod),
|
||||
nameof(NAK.BetterShadowClone),
|
||||
AssemblyInfoParams.Version,
|
||||
AssemblyInfoParams.Author,
|
||||
downloadLink: "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/tree/main/ShadowCloneMod"
|
||||
)]
|
||||
|
||||
[assembly: MelonGame("Alpha Blend Interactive", "ChilloutVR")]
|
||||
[assembly: MelonPlatform(MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)]
|
||||
[assembly: MelonPlatformDomain(MelonPlatformDomainAttribute.CompatibleDomains.MONO)]
|
||||
|
||||
namespace NAK.BetterShadowClone.Properties;
|
||||
internal static class AssemblyInfoParams
|
||||
{
|
||||
public const string Version = "1.0.0";
|
||||
public const string Author = "NotAKidoS & Exterrata";
|
||||
}
|
2
YouAreAClone/YouAreAClone.csproj
Normal file
2
YouAreAClone/YouAreAClone.csproj
Normal file
|
@ -0,0 +1,2 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project Sdk="Microsoft.NET.Sdk" />
|
Loading…
Add table
Add a link
Reference in a new issue