mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 22:39:22 +00:00
Job Removal
This commit is contained in:
parent
1ce18e6aa6
commit
a5fa241fb1
8 changed files with 94 additions and 47 deletions
|
@ -1,57 +1,46 @@
|
|||
using ABI_RC.Core.InteractionSystem;
|
||||
using ABI_RC.Core.IO;
|
||||
using cohtml;
|
||||
using ABI_RC.Core.Player;
|
||||
using HarmonyLib;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NAK.Melons.FuckCohtml.HarmonyPatches;
|
||||
|
||||
public static class CohtmlViewPatches
|
||||
class PlayerSetupPatches
|
||||
{
|
||||
private static CohtmlView _quickMenuView;
|
||||
private static CohtmlView _gameMenuView;
|
||||
private static Traverse _quickMenuOpenTraverse;
|
||||
private static Traverse _gameMenuOpenTraverse;
|
||||
private static readonly FieldInfo m_UISystemFieldInfo = AccessTools.Field(typeof(CohtmlView), "m_UISystem");
|
||||
|
||||
private static void CohtmlAdvanceView(CohtmlView cohtmlView, Traverse menuOpenTraverse)
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(PlayerSetup), "Start")]
|
||||
private static void Postfix_PlayerSetup_Start()
|
||||
{
|
||||
if (!FuckCohtmlMod.EntryEnabled.Value) return;
|
||||
FuckCohtml.ToggleMetrics(FuckCohtmlMod.EntryDisableMetrics.Value);
|
||||
FuckCohtml.ToggleCoreUpdates(FuckCohtmlMod.EntryDisableCoreUpdates.Value);
|
||||
}
|
||||
}
|
||||
|
||||
// Don't execute if menu is open
|
||||
if (cohtmlView == null || menuOpenTraverse.GetValue<bool>()) return;
|
||||
|
||||
// Disable cohtmlView (opening should enable)
|
||||
cohtmlView.enabled = false;
|
||||
|
||||
// Death
|
||||
try
|
||||
class CVR_MenuManagerPatches
|
||||
{
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(CVR_MenuManager), "ToggleQuickMenu", new Type[] { typeof(bool) })]
|
||||
private static void Postfix_CVR_MenuManager_ToggleQuickMenu(bool show)
|
||||
{
|
||||
if (!FuckCohtmlMod.EntryDisableCoreUpdates.Value) return;
|
||||
if (show)
|
||||
{
|
||||
CohtmlUISystem cohtmlUISystem = (CohtmlUISystem)m_UISystemFieldInfo.GetValue(cohtmlView);
|
||||
if (cohtmlUISystem != null) cohtmlView.View.Advance(cohtmlUISystem.Id, (double)Time.unscaledTime * 1000.0);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
FuckCohtmlMod.Logger.Error($"An exception was thrown while calling CohtmlView.Advance(). Error message: {e.Message}");
|
||||
CVR_MenuManager.Instance.SendCoreUpdate();
|
||||
ViewManager.Instance.UpdateMetrics();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ViewManagerPatches
|
||||
{
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(CVR_MenuManager), "Start")]
|
||||
private static void Postfix_CVR_MenuManager_Start(ref CVR_MenuManager __instance, ref CohtmlView ___quickMenu)
|
||||
[HarmonyPatch(typeof(ViewManager), "UiStateToggle", new Type[] { typeof(bool) })]
|
||||
private static void Postfix_ViewManager_UiStateToggle(bool show)
|
||||
{
|
||||
_quickMenuView = ___quickMenu;
|
||||
_quickMenuOpenTraverse = Traverse.Create(__instance).Field("_quickMenuOpen");
|
||||
SchedulerSystem.AddJob(new SchedulerSystem.Job(() => CohtmlAdvanceView(_quickMenuView, _quickMenuOpenTraverse)), 15f, 6f, -1);
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(ViewManager), "Start")]
|
||||
private static void Postfix_ViewManager_Start(ref ViewManager __instance, ref CohtmlView ___gameMenuView)
|
||||
{
|
||||
_gameMenuView = ___gameMenuView;
|
||||
_gameMenuOpenTraverse = Traverse.Create(__instance).Field("_gameMenuOpen");
|
||||
SchedulerSystem.AddJob(new SchedulerSystem.Job(() => CohtmlAdvanceView(_gameMenuView, _gameMenuOpenTraverse)), 12f, 6f, -1);
|
||||
if (!FuckCohtmlMod.EntryDisableMetrics.Value) return;
|
||||
if (show)
|
||||
{
|
||||
CVR_MenuManager.Instance.SendCoreUpdate();
|
||||
ViewManager.Instance.UpdateMetrics();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue