Move many mods to Deprecated folder, fix spelling

This commit is contained in:
NotAKidoS 2025-04-03 02:57:35 -05:00
parent 5e822cec8d
commit 0042590aa6
539 changed files with 7475 additions and 3120 deletions

View file

@ -0,0 +1,44 @@
using System;
using MelonLoader;
namespace NAK.VisualCloneFix;
public class VisualCloneFixMod : MelonMod
{
#region Melon Preferences
private static readonly MelonPreferences_Category Category =
MelonPreferences.CreateCategory(nameof(VisualCloneFix));
internal static readonly MelonPreferences_Entry<bool> EntryUseVisualClone =
Category.CreateEntry("use_visual_clone", true,
"Use Visual Clone", description: "Uses the potentially faster Visual Clone setup for the local avatar.");
#endregion Melon Preferences
#region Melon Events
public override void OnInitializeMelon()
{
ApplyPatches(typeof(Patches)); // slapped together a fix cause HarmonyInstance.Patch was null ref for no reason?
}
#endregion Melon Events
#region Melon Mod Utilities
private void ApplyPatches(Type type)
{
try
{
HarmonyInstance.PatchAll(type);
}
catch (Exception e)
{
LoggerInstance.Msg($"Failed while patching {type.Name}!");
LoggerInstance.Error(e);
}
}
#endregion Melon Mod Utilities
}

View file

@ -0,0 +1,157 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using ABI_RC.Core.Player.LocalClone;
using ABI_RC.Core.Player.TransformHider;
using ABI.CCK.Components;
using HarmonyLib;
using UnityEngine;
using Debug = UnityEngine.Debug;
namespace NAK.VisualCloneFix;
public static class Patches
{
[HarmonyPrefix]
[HarmonyPatch(typeof(TransformHiderUtils), nameof(TransformHiderUtils.SetupAvatar))]
private static bool OnSetupAvatar(GameObject avatar)
{
if (!VisualCloneFixMod.EntryUseVisualClone.Value) return true;
LocalCloneHelper.SetupAvatar(avatar);
return false;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(LocalCloneHelper), nameof(LocalCloneHelper.CollectTransformToExclusionMap))]
private static bool CollectTransformToExclusionMap(
Component root, Transform headBone,
ref Dictionary<Transform, FPRExclusion> __result)
{
// add an fpr exclusion to the head bone
if (!headBone.TryGetComponent(out FPRExclusion headExclusion))
{
headExclusion = headBone.gameObject.AddComponent<FPRExclusion>();
headExclusion.isShown = false; // default to hidden
headExclusion.target = headBone;
}
MeshHiderExclusion headExclusionBehaviour = new();
headExclusion.behaviour = headExclusionBehaviour;
headExclusionBehaviour.id = 1; // head bone is always 1
// get all FPRExclusions
var fprExclusions = root.GetComponentsInChildren<FPRExclusion>(true);
// get all valid exclusion targets, and destroy invalid exclusions
Dictionary<Transform, FPRExclusion> exclusionTargets = new();
int nextId = 2;
foreach (FPRExclusion exclusion in fprExclusions)
{
if (exclusion.target == null
|| exclusionTargets.ContainsKey(exclusion.target)
|| !exclusion.target.gameObject.scene.IsValid())
continue; // invalid exclusion
if (exclusion.behaviour == null) // head exclusion is already created
{
MeshHiderExclusion meshHiderExclusion = new();
exclusion.behaviour = meshHiderExclusion;
meshHiderExclusion.id = nextId++;
}
// first to add wins
exclusionTargets.TryAdd(exclusion.target, exclusion);
}
// process each FPRExclusion (recursive)
int exclusionCount = exclusionTargets.Values.Count;
for (var index = 0; index < exclusionCount; index++)
{
FPRExclusion exclusion = exclusionTargets.Values.ElementAt(index);
ProcessExclusion(exclusion, exclusion.target);
exclusion.UpdateExclusions(); // initial state
}
__result = exclusionTargets;
return false;
void ProcessExclusion(FPRExclusion exclusion, Transform transform)
{
if (exclusionTargets.ContainsKey(transform)
&& exclusionTargets[transform] != exclusion) return; // found other exclusion root
exclusionTargets.TryAdd(transform, exclusion); // add to the dictionary (yes its wasteful)
foreach (Transform child in transform)
ProcessExclusion(exclusion, child); // process children
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(SkinnedLocalClone), nameof(SkinnedLocalClone.FindExclusionVertList))]
private static bool FindExclusionVertList(
SkinnedMeshRenderer renderer, IReadOnlyDictionary<Transform, FPRExclusion> exclusions,
ref int[] __result)
{
// Start the stopwatch
Stopwatch stopwatch = new();
stopwatch.Start();
var boneWeights = renderer.sharedMesh.boneWeights;
var bones = renderer.bones;
int boneCount = bones.Length;
bool[] boneHasExclusion = new bool[boneCount];
// Populate the weights array
for (int i = 0; i < boneCount; i++)
{
Transform bone = bones[i];
if (bone == null) continue;
if (exclusions.ContainsKey(bone))
boneHasExclusion[i] = true;
}
const float minWeightThreshold = 0.2f;
int[] vertexIndices = new int[renderer.sharedMesh.vertexCount];
// Check bone weights and add vertex to exclusion list if needed
for (int i = 0; i < boneWeights.Length; i++)
{
BoneWeight weight = boneWeights[i];
Transform bone;
if (boneHasExclusion[weight.boneIndex0] && weight.weight0 > minWeightThreshold)
bone = bones[weight.boneIndex0];
else if (boneHasExclusion[weight.boneIndex1] && weight.weight1 > minWeightThreshold)
bone = bones[weight.boneIndex1];
else if (boneHasExclusion[weight.boneIndex2] && weight.weight2 > minWeightThreshold)
bone = bones[weight.boneIndex2];
else if (boneHasExclusion[weight.boneIndex3] && weight.weight3 > minWeightThreshold)
bone = bones[weight.boneIndex3];
else continue;
if (exclusions.TryGetValue(bone, out FPRExclusion exclusion))
vertexIndices[i] = ((MeshHiderExclusion)(exclusion.behaviour)).id;
}
// Stop the stopwatch
stopwatch.Stop();
// Log the execution time
Debug.Log($"FindExclusionVertList execution time: {stopwatch.ElapsedMilliseconds} ms");
__result = vertexIndices;
return false;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(MeshHiderExclusion), nameof(MeshHiderExclusion.UpdateExclusions))]
private static bool OnUpdateExclusions(bool isShown, bool shrinkToZero, ref int ___id)
{
if (isShown) LocalCloneManager.cullingMask &= ~(1 << ___id);
else LocalCloneManager.cullingMask |= 1 << ___id;
return false;
}
}

View file

@ -0,0 +1,32 @@
using MelonLoader;
using NAK.VisualCloneFix.Properties;
using System.Reflection;
[assembly: AssemblyVersion(AssemblyInfoParams.Version)]
[assembly: AssemblyFileVersion(AssemblyInfoParams.Version)]
[assembly: AssemblyInformationalVersion(AssemblyInfoParams.Version)]
[assembly: AssemblyTitle(nameof(NAK.VisualCloneFix))]
[assembly: AssemblyCompany(AssemblyInfoParams.Author)]
[assembly: AssemblyProduct(nameof(NAK.VisualCloneFix))]
[assembly: MelonInfo(
typeof(NAK.VisualCloneFix.VisualCloneFixMod),
nameof(NAK.VisualCloneFix),
AssemblyInfoParams.Version,
AssemblyInfoParams.Author,
downloadLink: "https://github.com/NotAKidoS/NAK_CVR_Mods/tree/main/VisualCloneFix"
)]
[assembly: MelonGame("Alpha Blend Interactive", "ChilloutVR")]
[assembly: MelonPlatform(MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)]
[assembly: MelonPlatformDomain(MelonPlatformDomainAttribute.CompatibleDomains.MONO)]
[assembly: MelonColor(255, 246, 25, 99)] // red-pink
[assembly: MelonAuthorColor(255, 158, 21, 32)] // red
[assembly: HarmonyDontPatchAll]
namespace NAK.VisualCloneFix.Properties;
internal static class AssemblyInfoParams
{
public const string Version = "1.0.1";
public const string Author = "NotAKidoS";
}

View file

@ -0,0 +1,18 @@
# VisualCloneFix
Fixes the Visual Clone system and allows you to use it again.
Using the Visual Clone should be faster than the default Head Hiding & Shadow Clones, but will add a longer hitch on initial avatar load.
**NOTE:** The Visual Clone is still an experimental feature that was temporarily removed in [ChilloutVR 2024r175 Hotfix 1](https://abinteractive.net/blog/chilloutvr_2024r175_hotfix_1), so there may be bugs or issues with it.
---
Here is the block of text where I tell you this mod is not affiliated with or endorsed by ABI.
https://documentation.abinteractive.net/official/legal/tos/#7-modding-our-games
> This mod is an independent creation not affiliated with, supported by, or approved by Alpha Blend Interactive.
> Use of this mod is done so at the user's own risk and the creator cannot be held responsible for any issues arising from its use.
> To the best of my knowledge, I have adhered to the Modding Guidelines established by Alpha Blend Interactive.

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<RootNamespace>LocalCloneFix</RootNamespace>
</PropertyGroup>
</Project>

View file

@ -0,0 +1,23 @@
{
"_id": 221,
"name": "VisualCloneFix",
"modversion": "1.0.1",
"gameversion": "2024r175",
"loaderversion": "0.6.1",
"modtype": "Mod",
"author": "NotAKidoS",
"description": "Fixes the Visual Clone system and allows you to use it again.\n\nUsing the Visual Clone should be faster than the default Head Hiding & Shadow Clones, but will add a longer hitch on initial avatar load.\n\n**NOTE:** The Visual Clone is still an experimental feature that was temporarily removed in [ChilloutVR 2024r175 Hotfix 1](https://abinteractive.net/blog/chilloutvr_2024r175_hotfix_1), so there may be bugs or issues with it.",
"searchtags": [
"visual",
"clone",
"head",
"hiding"
],
"requirements": [
"None"
],
"downloadlink": "https://github.com/NotAKidoS/NAK_CVR_Mods/releases/download/r36/VisualCloneFix.dll",
"sourcelink": "https://github.com/NotAKidoS/NAK_CVR_Mods/tree/main/VisualCloneFix/",
"changelog": "- Fixed FPRExclusions IsShown state being inverted when toggled.\n- Fixed head FPRExclusion generation not checking for existing exclusion.\n- Sped up FindExclusionVertList by 100x by not being an idiot. This heavily reduces avatar hitch with Visual Clone active.",
"embedcolor": "#f61963"
}