mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2026-06-22 22:38:30 +00:00
[NAK_CVR_Mods] Unfucked for 2026r182
This commit is contained in:
parent
c13dc8375a
commit
281403d68b
209 changed files with 3936 additions and 1122 deletions
175
Stickers/Main.cs
175
Stickers/Main.cs
|
|
@ -1,175 +0,0 @@
|
|||
using ABI_RC.Core.Player;
|
||||
using ABI_RC.Core.UI.UIRework.Managers;
|
||||
using ABI_RC.Systems.InputManagement;
|
||||
using MelonLoader;
|
||||
using NAK.Stickers.Integrations;
|
||||
using NAK.Stickers.Networking;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NAK.Stickers;
|
||||
|
||||
public class StickerMod : MelonMod
|
||||
{
|
||||
internal static MelonLogger.Instance Logger;
|
||||
|
||||
#region Melon Mod Overrides
|
||||
|
||||
public override void OnInitializeMelon()
|
||||
{
|
||||
Logger = LoggerInstance;
|
||||
|
||||
ModNetwork.Subscribe();
|
||||
ModSettings.Initialize();
|
||||
StickerSystem.Initialize();
|
||||
|
||||
ApplyPatches(typeof(Patches.PlayerSetup_Patches));
|
||||
ApplyPatches(typeof(Patches.ControllerRay_Patches));
|
||||
ApplyPatches(typeof(Patches.ShaderFilterHelper_Patches));
|
||||
ApplyPatches(typeof(Patches.CVRTools_Patches));
|
||||
|
||||
LoadAssetBundle();
|
||||
|
||||
InitializeIntegration(nameof(BTKUILib), BTKUIAddon.Initialize); // quick menu ui
|
||||
}
|
||||
|
||||
public override void OnUpdate()
|
||||
{
|
||||
if (StickerSystem.Instance == null)
|
||||
return;
|
||||
|
||||
if (StickerSystem.Instance.IsInStickerMode)
|
||||
{
|
||||
if (Input.mouseScrollDelta.y != 0f
|
||||
&& Cursor.lockState == CursorLockMode.Locked // prevent scrolling while in menus
|
||||
&& !CVRInputManager.Instance.zoom) // prevent scrolling while using scroll zoom
|
||||
StickerSystem.Instance.SelectedStickerSlot += (int)Input.mouseScrollDelta.y;
|
||||
|
||||
StickerSystem.Instance.UpdateStickerPreview(); // flashy flash
|
||||
}
|
||||
|
||||
if (!ModSettings.Entry_UsePlaceBinding.Value)
|
||||
return;
|
||||
|
||||
if (!Input.GetKeyDown((KeyCode)ModSettings.Entry_PlaceBinding.Value))
|
||||
return;
|
||||
|
||||
if (CVRInputManager.Instance.EventSystemOverwritten
|
||||
|| KeyboardManager.Instance.IsViewShown) // BRUH
|
||||
return; // prevent placing stickers while typing
|
||||
|
||||
StickerSystem.Instance.PlaceStickerFromControllerRay(PlayerSetup.Instance.activeCam.transform);
|
||||
}
|
||||
|
||||
public override void OnApplicationQuit()
|
||||
{
|
||||
StickerSystem.Instance.CleanupAll();
|
||||
}
|
||||
|
||||
#endregion Melon Mod Overrides
|
||||
|
||||
#region Melon Mod Utilities
|
||||
|
||||
private static void InitializeIntegration(string modName, Action integrationAction)
|
||||
{
|
||||
if (RegisteredMelons.All(it => it.Info.Name != modName))
|
||||
return;
|
||||
|
||||
Logger.Msg($"Initializing {modName} integration.");
|
||||
integrationAction.Invoke();
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
#region Asset Bundle Loading
|
||||
|
||||
private const string DecaleryShaderAssets = "decalery_shaders.assets";
|
||||
private const string DecalerySimpleShader = "Assets/Decalery/Shaders/DecalerySimple.shader";
|
||||
private const string GPUDecalWriteShader = "Assets/Decalery/fGPUDecalWriteShader.shader";
|
||||
|
||||
private const string SourceSFX_PlayerSprayer = "Assets/Mods/Stickers/Source_sound_player_sprayer.wav";
|
||||
private const string LittleBigPlanetSFX_StickerPlace = "Assets/Mods/Stickers/LBP_Sticker_Place.wav";
|
||||
private const string FactorioSFX_AlertDestroyed = "Assets/Mods/Stickers/Factorio_alert_destroyed.wav";
|
||||
|
||||
internal static Shader DecalSimpleShader;
|
||||
internal static Shader DecalWriterShader;
|
||||
internal static AudioClip SourceSFXPlayerSprayer;
|
||||
internal static AudioClip LittleBigPlanetSFXStickerPlace;
|
||||
internal static AudioClip FactorioSFXAlertDestroyed;
|
||||
|
||||
private void LoadAssetBundle()
|
||||
{
|
||||
LoggerInstance.Msg($"Loading required asset bundle...");
|
||||
using Stream resourceStream = MelonAssembly.Assembly.GetManifestResourceStream(DecaleryShaderAssets);
|
||||
using MemoryStream memoryStream = new();
|
||||
if (resourceStream == null) {
|
||||
LoggerInstance.Error($"Failed to load {DecaleryShaderAssets}!");
|
||||
return;
|
||||
}
|
||||
|
||||
resourceStream.CopyTo(memoryStream);
|
||||
AssetBundle assetBundle = AssetBundle.LoadFromMemory(memoryStream.ToArray());
|
||||
if (assetBundle == null) {
|
||||
LoggerInstance.Error($"Failed to load {DecaleryShaderAssets}! Asset bundle is null!");
|
||||
return;
|
||||
}
|
||||
|
||||
DecalSimpleShader = assetBundle.LoadAsset<Shader>(DecalerySimpleShader);
|
||||
if (DecalSimpleShader == null) {
|
||||
LoggerInstance.Error($"Failed to load {DecalerySimpleShader}! Prefab is null!");
|
||||
return;
|
||||
}
|
||||
DecalSimpleShader.hideFlags |= HideFlags.DontUnloadUnusedAsset;
|
||||
LoggerInstance.Msg($"Loaded {DecalerySimpleShader}!");
|
||||
|
||||
DecalWriterShader = assetBundle.LoadAsset<Shader>(GPUDecalWriteShader);
|
||||
if (DecalWriterShader == null) {
|
||||
LoggerInstance.Error($"Failed to load {GPUDecalWriteShader}! Prefab is null!");
|
||||
return;
|
||||
}
|
||||
DecalWriterShader.hideFlags |= HideFlags.DontUnloadUnusedAsset;
|
||||
LoggerInstance.Msg($"Loaded {GPUDecalWriteShader}!");
|
||||
|
||||
SourceSFXPlayerSprayer = assetBundle.LoadAsset<AudioClip>(SourceSFX_PlayerSprayer);
|
||||
if (SourceSFXPlayerSprayer == null) {
|
||||
LoggerInstance.Error($"Failed to load {SourceSFX_PlayerSprayer}! Prefab is null!");
|
||||
return;
|
||||
}
|
||||
SourceSFXPlayerSprayer.hideFlags |= HideFlags.DontUnloadUnusedAsset;
|
||||
LoggerInstance.Msg($"Loaded {SourceSFX_PlayerSprayer}!");
|
||||
|
||||
LittleBigPlanetSFXStickerPlace = assetBundle.LoadAsset<AudioClip>(LittleBigPlanetSFX_StickerPlace);
|
||||
if (LittleBigPlanetSFXStickerPlace == null) {
|
||||
LoggerInstance.Error($"Failed to load {LittleBigPlanetSFX_StickerPlace}! Prefab is null!");
|
||||
return;
|
||||
}
|
||||
LittleBigPlanetSFXStickerPlace.hideFlags |= HideFlags.DontUnloadUnusedAsset;
|
||||
LoggerInstance.Msg($"Loaded {LittleBigPlanetSFX_StickerPlace}!");
|
||||
|
||||
FactorioSFXAlertDestroyed = assetBundle.LoadAsset<AudioClip>(FactorioSFX_AlertDestroyed);
|
||||
if (FactorioSFXAlertDestroyed == null) {
|
||||
LoggerInstance.Error($"Failed to load {FactorioSFX_AlertDestroyed}! Prefab is null!");
|
||||
return;
|
||||
}
|
||||
FactorioSFXAlertDestroyed.hideFlags |= HideFlags.DontUnloadUnusedAsset;
|
||||
LoggerInstance.Msg($"Loaded {FactorioSFX_AlertDestroyed}!");
|
||||
|
||||
// load
|
||||
|
||||
LoggerInstance.Msg("Asset bundle successfully loaded!");
|
||||
}
|
||||
|
||||
#endregion Asset Bundle Loading
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue