diff --git a/GorillaTagLIV.sln.DotSettings.user b/GorillaTagLIV.sln.DotSettings.user index 0372522..afaaf9a 100644 --- a/GorillaTagLIV.sln.DotSettings.user +++ b/GorillaTagLIV.sln.DotSettings.user @@ -1,3 +1,12 @@  + True + True + True + True True - True \ No newline at end of file + True + <AssemblyExplorer> + <Assembly Path="C:\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\BepInEx\plugins\Extenject\Zenject-usage.dll" /> + <Assembly Path="C:\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\BepInEx\plugins\Extenject\Zenject.dll" /> + <Assembly Path="C:\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\BepInEx\plugins\ComputerInterface\ComputerInterface.dll" /> +</AssemblyExplorer> \ No newline at end of file diff --git a/GorillaTagLIV/GorillaTagLIV.csproj b/GorillaTagLIV/GorillaTagLIV.csproj index e8b1be2..833e9e2 100644 --- a/GorillaTagLIV/GorillaTagLIV.csproj +++ b/GorillaTagLIV/GorillaTagLIV.csproj @@ -36,6 +36,10 @@ $(BepInExAssemblyPath)\BepInEx.Harmony.dll False + + $(GamePath)\BepInEx\plugins\Bepinject-Auros\Bepinject.dll + False + $(GameAssemblyPath)\Cinemachine.dll False @@ -44,6 +48,10 @@ $(GameAssemblyPath)\clipper_library.dll False + + $(GamePath)\BepInEx\plugins\ComputerInterface\ComputerInterface.dll + False + ..\GorillaTagLIVUnity\Build\GorillaTagLIVUnity_Data\Managed\LIV.dll @@ -387,6 +395,14 @@ $(GameAssemblyPath)\websocket-sharp.dll False + + $(GamePath)\BepInEx\plugins\Extenject\Zenject.dll + False + + + $(GamePath)\BepInEx\plugins\Extenject\Zenject-usage.dll + False + diff --git a/GorillaTagLIV/LivComputerView.cs b/GorillaTagLIV/LivComputerView.cs new file mode 100644 index 0000000..24be794 --- /dev/null +++ b/GorillaTagLIV/LivComputerView.cs @@ -0,0 +1,89 @@ +using System; +using Bepinject; +using ComputerInterface; +using ComputerInterface.Interfaces; +using ComputerInterface.ViewLib; +using UnityEngine; +using Zenject; + +namespace GorillaTagLIV +{ + public class LivComputerView : ComputerView + { + private const string highlightColor = "52fc03"; + private readonly UISelectionHandler selectionHandler; + + public LivComputerView() + { + selectionHandler = new UISelectionHandler(EKeyboardKey.Up, EKeyboardKey.Down, EKeyboardKey.Enter); + selectionHandler.MaxIdx = 3; + selectionHandler.OnSelected += OnEntrySelected; + selectionHandler.ConfigureSelectionIndicator($"> ", "", " ", ""); + } + + private void OnEntrySelected(int index) + { + if (index == 0) + { + Plugin.Instance.ShowGorillaBody.Value = !Plugin.Instance.ShowGorillaBody.Value; + } + UpdateScreen(); + } + public override void OnShow(object[] args) + { + base.OnShow(args); + UpdateScreen(); + } + + public override void OnKeyPressed(EKeyboardKey key) + { + if (selectionHandler.HandleKeypress(key)) + { + UpdateScreen(); + return; + } + + switch (key) + { + case EKeyboardKey.Back: + ReturnToMainMenu(); + break; + } + } + + private void UpdateScreen() + { + SetText(str => + { + str.BeginCenter(); + str.MakeBar('-', SCREEN_WIDTH, 0, "ffffff10"); + str.AppendClr("LIV", highlightColor).EndColor().AppendLine(); + str.MakeBar('-', SCREEN_WIDTH, 0, "ffffff10"); + str.EndAlign().AppendLines(1); + str.AppendLine(selectionHandler.GetIndicatedText(0, $"Show Gorilla Body: Yes" : "white>No")}")); + str.AppendLines(2); + str.AppendClr("Press ENTER to toggle setting", "ffffff10").EndColor().AppendLine(); + }); + } + } + + public class LivModComputerEntry : IComputerModEntry + { + public string EntryName => "LIV"; + + public Type EntryViewType => typeof(LivComputerView); + } + + internal class LivModComputerInstaller : Installer + { + public override void InstallBindings() + { + Container.Bind().To().AsSingle(); + } + + public static void Install() + { + Zenjector.Install().OnProject(); + } + } +} \ No newline at end of file diff --git a/GorillaTagLIV/Plugin.cs b/GorillaTagLIV/Plugin.cs index fe6878b..f744802 100644 --- a/GorillaTagLIV/Plugin.cs +++ b/GorillaTagLIV/Plugin.cs @@ -1,6 +1,7 @@ using System; using System.IO; using BepInEx; +using BepInEx.Configuration; using Cinemachine; using UnityEngine; using Utilla; @@ -13,23 +14,41 @@ namespace GorillaTagLIV [BepInPlugin(PluginInfo.GUID, PluginInfo.Name, PluginInfo.Version)] public class Plugin : BaseUnityPlugin { + public static Plugin Instance; + public ConfigEntry ShowGorillaBody; + private const string assetsDir = "/BepInEx/plugins/GorillaTagLIV/Assets/"; private Camera thirdPersonCamera; - private LIV.SDK.Unity.LIV liv; + private void Awake() + { + Instance = this; + ShowGorillaBody = Config.Bind("Settings", "ShowGorillaBody", false); + } + private void OnEnable() { HarmonyPatches.ApplyHarmonyPatches(); Events.GameInitialized += OnGameInitialized; var shaderBundle = LoadBundle("liv-shaders"); SDKShaders.LoadFromAssetBundle(shaderBundle); + + LivModComputerInstaller.Install(); + + Config.SettingChanged += OnSettingChanged; } + private void OnSettingChanged(object sender, SettingChangedEventArgs e) + { + SetUpLivLayerMask(); + } + private void OnDisable() { DestroyExistingLiv(); HarmonyPatches.RemoveHarmonyPatches(); - } + Config.SettingChanged -= OnSettingChanged; + } private void OnGameInitialized(object sender, EventArgs e) { @@ -56,9 +75,8 @@ private static AssetBundle LoadBundle(string assetName) private void SetUpLiv(Camera camera, Transform parent) { if (!enabled) return; - - Debug.Log(string.Format("Setting up LIV with camera {0}", camera.name)); + Debug.Log($"Setting up LIV with camera {camera.name}"); DestroyExistingLiv(); @@ -70,15 +88,25 @@ private void SetUpLiv(Camera camera, Transform parent) liv.stage = parent; liv.HMDCamera = camera; liv.fixPostEffectsAlpha = true; - liv.spectatorLayerMask = camera.cullingMask; - - liv.spectatorLayerMask &= ~(1 << (int) CustomLayers.HideFromLiv); - Debug.Log(string.Format("LIV created successfully with stage {0}", parent.name)); + liv.onActivate += SetUpLivLayerMask; + + Debug.Log($"LIV created successfully with stage {parent.name}"); livObject.gameObject.SetActive(true); } + private void SetUpLivLayerMask() + { + if (!liv || !liv.isActive) return; + + liv.spectatorLayerMask = liv.HMDCamera.cullingMask; + if (!ShowGorillaBody.Value) + { + liv.spectatorLayerMask &= ~(1 << (int) CustomLayers.HideFromLiv); + } + } + private void SetUpThridPersonCamera() { var cinemachineBrain = FindObjectOfType();