using ABI_RC.Core; using ABI_RC.Core.EventSystem; using ABI_RC.Core.Savior; using MelonLoader; using UnityEngine; namespace NAK.AvatarCloneTest; public class AvatarCloneTestMod : MelonMod { #region Melon Preferences private static readonly MelonPreferences_Category Category = MelonPreferences.CreateCategory(nameof(AvatarCloneTest)); internal static readonly MelonPreferences_Entry EntryUseAvatarCloneTest = Category.CreateEntry("use_avatar_clone_test", true, "Use Avatar Clone", description: "Uses the Avatar Clone setup for the local avatar."); internal static readonly MelonPreferences_Entry EntryCloneMeshRenderers = Category.CreateEntry("clone_mesh_renderers", false, "Clone Mesh Renderers", description: "Clones the mesh renderers from the original avatar to the clone."); internal static readonly MelonPreferences_Entry EntryCopyBlendShapes = Category.CreateEntry("copy_blend_shapes", true, "Copy Blend Shapes", description: "Copies the blend shapes from the original avatar to the clone."); internal static readonly MelonPreferences_Entry EntryCopyMaterials = Category.CreateEntry("copy_materials", true, "Copy Materials", description: "Copies the materials from the original avatar to the clone."); #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? } public override void OnUpdate() { // press f1 to find all cameras that arent tagged main and set them tno not render CVRLayers.PlayerClone if (Input.GetKeyDown(KeyCode.F1)) { foreach (var camera in UnityEngine.Object.FindObjectsOfType()) { if (camera.tag != "MainCamera") { camera.cullingMask &= ~(1 << CVRLayers.PlayerClone); } } } // if pressing ctrl + r, reload avatar if (Input.GetKey(KeyCode.LeftControl) && Input.GetKeyDown(KeyCode.R)) { var player = MetaPort.Instance.currentAvatarGuid; AssetManagement.Instance.LoadLocalAvatar(player); } } #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 }