mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 06:19:22 +00:00
braindead
This commit is contained in:
parent
453d8023c1
commit
ea1e0da1ce
2 changed files with 107 additions and 108 deletions
|
@ -4,87 +4,87 @@ using cohtml;
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace NAK.Melons.FuckMetrics
|
namespace NAK.Melons.FuckMetrics;
|
||||||
|
|
||||||
|
public static class FuckMetrics
|
||||||
{
|
{
|
||||||
public static class FuckMetrics
|
public enum SettingState
|
||||||
{
|
{
|
||||||
public enum SettingState
|
Always,
|
||||||
|
MenuOnly,
|
||||||
|
Disabled
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void ToggleMetrics(bool enable)
|
||||||
|
{
|
||||||
|
var job = SchedulerSystem.Instance.activeJobs.FirstOrDefault(pair => pair.Job.Method.Name == "UpdateMetrics").Job;
|
||||||
|
if (enable && job == null)
|
||||||
{
|
{
|
||||||
Always,
|
SchedulerSystem.AddJob(new SchedulerSystem.Job(ViewManager.Instance.UpdateMetrics), 0f, FuckMetricsMod.EntryMetricsUpdateRate.Value, -1);
|
||||||
MenuOnly,
|
|
||||||
Disabled
|
|
||||||
}
|
}
|
||||||
|
else if (!enable && job != null)
|
||||||
public static void ToggleMetrics(bool enable)
|
|
||||||
{
|
{
|
||||||
var job = SchedulerSystem.Instance.activeJobs.FirstOrDefault(pair => pair.Job.Method.Name == "UpdateMetrics").Job;
|
SchedulerSystem.RemoveJob(job);
|
||||||
if (enable && job == null)
|
|
||||||
{
|
|
||||||
SchedulerSystem.AddJob(new SchedulerSystem.Job(ViewManager.Instance.UpdateMetrics), 0f, FuckMetricsMod.EntryMetricsUpdateRate.Value, -1);
|
|
||||||
}
|
|
||||||
else if (!enable && job != null)
|
|
||||||
{
|
|
||||||
SchedulerSystem.RemoveJob(job);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void ToggleCoreUpdates(bool enable)
|
public static void ToggleCoreUpdates(bool enable)
|
||||||
|
{
|
||||||
|
var job = SchedulerSystem.Instance.activeJobs.FirstOrDefault(pair => pair.Job.Method.Name == "SendCoreUpdate").Job;
|
||||||
|
if (enable && job == null)
|
||||||
{
|
{
|
||||||
var job = SchedulerSystem.Instance.activeJobs.FirstOrDefault(pair => pair.Job.Method.Name == "SendCoreUpdate").Job;
|
SchedulerSystem.AddJob(new SchedulerSystem.Job(CVR_MenuManager.Instance.SendCoreUpdate), 0f, FuckMetricsMod.EntryCoreUpdateRate.Value, -1);
|
||||||
if (enable && job == null)
|
|
||||||
{
|
|
||||||
SchedulerSystem.AddJob(new SchedulerSystem.Job(CVR_MenuManager.Instance.SendCoreUpdate), 0f, FuckMetricsMod.EntryCoreUpdateRate.Value, -1);
|
|
||||||
}
|
|
||||||
else if (!enable && job != null)
|
|
||||||
{
|
|
||||||
SchedulerSystem.RemoveJob(job);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else if (!enable && job != null)
|
||||||
public static void ApplyMetricsSettings(bool show)
|
|
||||||
{
|
{
|
||||||
var disableMetrics = FuckMetricsMod.EntryDisableMetrics.Value;
|
SchedulerSystem.RemoveJob(job);
|
||||||
if (disableMetrics == FuckMetrics.SettingState.Always) return;
|
|
||||||
|
|
||||||
if (disableMetrics == FuckMetrics.SettingState.MenuOnly)
|
|
||||||
{
|
|
||||||
FuckMetrics.ToggleMetrics(show);
|
|
||||||
}
|
|
||||||
else if (disableMetrics == FuckMetrics.SettingState.Disabled && show)
|
|
||||||
{
|
|
||||||
ViewManager.Instance.UpdateMetrics();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void ApplyCoreUpdatesSettings(bool show)
|
public static void ApplyMetricsSettings(bool show)
|
||||||
|
{
|
||||||
|
var disableMetrics = FuckMetricsMod.EntryDisableMetrics.Value;
|
||||||
|
if (disableMetrics == FuckMetrics.SettingState.Always) return;
|
||||||
|
|
||||||
|
if (disableMetrics == FuckMetrics.SettingState.MenuOnly)
|
||||||
{
|
{
|
||||||
var disableCoreUpdates = FuckMetricsMod.EntryDisableCoreUpdates.Value;
|
FuckMetrics.ToggleMetrics(show);
|
||||||
if (disableCoreUpdates == FuckMetrics.SettingState.Always) return;
|
|
||||||
|
|
||||||
if (disableCoreUpdates == FuckMetrics.SettingState.MenuOnly)
|
|
||||||
{
|
|
||||||
FuckMetrics.ToggleCoreUpdates(show);
|
|
||||||
}
|
|
||||||
else if (disableCoreUpdates == FuckMetrics.SettingState.Disabled && show)
|
|
||||||
{
|
|
||||||
CVR_MenuManager.Instance.SendCoreUpdate();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else if (disableMetrics == FuckMetrics.SettingState.Disabled && show)
|
||||||
public static void CohtmlAdvanceView(CohtmlView cohtmlView, Traverse menuOpenTraverse)
|
|
||||||
{
|
{
|
||||||
if (!FuckMetricsMod.EntryDisableCohtmlViewOnIdle.Value) return;
|
ViewManager.Instance.UpdateMetrics();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Don't execute if menu is open
|
public static void ApplyCoreUpdatesSettings(bool show)
|
||||||
if (cohtmlView == null || menuOpenTraverse.GetValue<bool>()) return;
|
{
|
||||||
|
var disableCoreUpdates = FuckMetricsMod.EntryDisableCoreUpdates.Value;
|
||||||
|
if (disableCoreUpdates == FuckMetrics.SettingState.Always) return;
|
||||||
|
|
||||||
// Disable cohtmlView (opening should enable)
|
if (disableCoreUpdates == FuckMetrics.SettingState.MenuOnly)
|
||||||
|
{
|
||||||
|
FuckMetrics.ToggleCoreUpdates(show);
|
||||||
|
}
|
||||||
|
else if (disableCoreUpdates == FuckMetrics.SettingState.Disabled && show)
|
||||||
|
{
|
||||||
|
CVR_MenuManager.Instance.SendCoreUpdate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void CohtmlAdvanceView(CohtmlView cohtmlView, Traverse menuOpenTraverse)
|
||||||
|
{
|
||||||
|
if (!FuckMetricsMod.EntryDisableCohtmlViewOnIdle.Value) return;
|
||||||
|
|
||||||
|
FuckMetricsMod.Logger.Msg(cohtmlView != null && !menuOpenTraverse.GetValue<bool>());
|
||||||
|
FuckMetricsMod.Logger.Msg(menuOpenTraverse.GetValue<bool>());
|
||||||
|
|
||||||
|
if (cohtmlView != null && !menuOpenTraverse.GetValue<bool>())
|
||||||
|
{
|
||||||
cohtmlView.enabled = false;
|
cohtmlView.enabled = false;
|
||||||
|
|
||||||
// Death
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (cohtmlView.m_UISystem != null) cohtmlView.View.Advance(cohtmlView.m_UISystem.Id, (double)Time.unscaledTime * 1000.0);
|
cohtmlView.View.Advance(cohtmlView.m_UISystem?.Id ?? 0, (double)Time.unscaledTime * 1000.0);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,63 +3,62 @@ using ABI_RC.Core.IO;
|
||||||
using cohtml;
|
using cohtml;
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
|
|
||||||
namespace NAK.Melons.FuckMetrics.HarmonyPatches
|
namespace NAK.Melons.FuckMetrics.HarmonyPatches;
|
||||||
|
|
||||||
|
public static class CVR_MenuManagerPatches
|
||||||
{
|
{
|
||||||
public static class CVR_MenuManagerPatches
|
[HarmonyPostfix]
|
||||||
|
[HarmonyPatch(typeof(CVR_MenuManager), "ToggleQuickMenu", new Type[] { typeof(bool) })]
|
||||||
|
private static void Postfix_CVR_MenuManager_ToggleQuickMenu(bool show)
|
||||||
{
|
{
|
||||||
[HarmonyPostfix]
|
FuckMetrics.ApplyMetricsSettings(show);
|
||||||
[HarmonyPatch(typeof(CVR_MenuManager), "ToggleQuickMenu", new Type[] { typeof(bool) })]
|
FuckMetrics.ApplyCoreUpdatesSettings(show);
|
||||||
private static void Postfix_CVR_MenuManager_ToggleQuickMenu(bool show)
|
}
|
||||||
{
|
}
|
||||||
FuckMetrics.ApplyMetricsSettings(show);
|
|
||||||
FuckMetrics.ApplyCoreUpdatesSettings(show);
|
public static class ViewManagerPatches
|
||||||
}
|
{
|
||||||
|
[HarmonyPostfix]
|
||||||
|
[HarmonyPatch(typeof(ViewManager), "UiStateToggle", new Type[] { typeof(bool) })]
|
||||||
|
private static void Postfix_ViewManager_UiStateToggle(bool show)
|
||||||
|
{
|
||||||
|
FuckMetrics.ApplyMetricsSettings(show);
|
||||||
|
FuckMetrics.ApplyCoreUpdatesSettings(show);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class CohtmlViewPatches
|
||||||
|
{
|
||||||
|
private static CohtmlView _quickMenuView;
|
||||||
|
private static CohtmlView _gameMenuView;
|
||||||
|
private static Traverse _quickMenuOpenTraverse;
|
||||||
|
private static Traverse _gameMenuOpenTraverse;
|
||||||
|
|
||||||
|
[HarmonyPostfix]
|
||||||
|
[HarmonyPatch(typeof(CVR_MenuManager), "Start")]
|
||||||
|
private static void Postfix_CVRMenuManager_Start(ref CVR_MenuManager __instance, ref CohtmlView ___quickMenu)
|
||||||
|
{
|
||||||
|
_quickMenuView = ___quickMenu;
|
||||||
|
_quickMenuOpenTraverse = Traverse.Create(__instance).Field("_quickMenuOpen");
|
||||||
|
SchedulerSystem.AddJob(() => FuckMetrics.CohtmlAdvanceView(_quickMenuView, _quickMenuOpenTraverse), 15f, 6f, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ViewManagerPatches
|
[HarmonyPostfix]
|
||||||
|
[HarmonyPatch(typeof(ViewManager), "Start")]
|
||||||
|
private static void Postfix_ViewManager_Start(ref ViewManager __instance, ref CohtmlView ___gameMenuView)
|
||||||
{
|
{
|
||||||
[HarmonyPostfix]
|
_gameMenuView = ___gameMenuView;
|
||||||
[HarmonyPatch(typeof(ViewManager), "UiStateToggle", new Type[] { typeof(bool) })]
|
_gameMenuOpenTraverse = Traverse.Create(__instance).Field("_gameMenuOpen");
|
||||||
private static void Postfix_ViewManager_UiStateToggle(bool show)
|
SchedulerSystem.AddJob(() => FuckMetrics.CohtmlAdvanceView(_gameMenuView, _gameMenuOpenTraverse), 12f, 6f, -1);
|
||||||
{
|
|
||||||
FuckMetrics.ApplyMetricsSettings(show);
|
|
||||||
FuckMetrics.ApplyCoreUpdatesSettings(show);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class CohtmlViewPatches
|
[HarmonyPostfix]
|
||||||
|
[HarmonyPatch(typeof(ViewManager), "OnMicrophoneStatusSwitched")]
|
||||||
|
private static void Postfix_ViewManager_OnMicrophoneStatusSwitched()
|
||||||
{
|
{
|
||||||
private static CohtmlView _quickMenuView;
|
if (_quickMenuOpenTraverse.GetValue<bool>())
|
||||||
private static CohtmlView _gameMenuView;
|
|
||||||
private static Traverse _quickMenuOpenTraverse;
|
|
||||||
private static Traverse _gameMenuOpenTraverse;
|
|
||||||
|
|
||||||
[HarmonyPostfix]
|
|
||||||
[HarmonyPatch(typeof(CVR_MenuManager), "Start")]
|
|
||||||
private static void Postfix_CVRMenuManager_Start(ref CohtmlView ___quickMenu)
|
|
||||||
{
|
{
|
||||||
_quickMenuView = ___quickMenu;
|
CVR_MenuManager.Instance.SendCoreUpdate();
|
||||||
_quickMenuOpenTraverse = Traverse.Create<CVR_MenuManager>().Field("_quickMenuOpen");
|
|
||||||
SchedulerSystem.AddJob(() => FuckMetrics.CohtmlAdvanceView(_quickMenuView, _quickMenuOpenTraverse), 15f, 6f, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
[HarmonyPostfix]
|
|
||||||
[HarmonyPatch(typeof(ViewManager), "Start")]
|
|
||||||
private static void Postfix_ViewManager_Start(ref CohtmlView ___gameMenuView)
|
|
||||||
{
|
|
||||||
_gameMenuView = ___gameMenuView;
|
|
||||||
_gameMenuOpenTraverse = Traverse.Create<ViewManager>().Field("_gameMenuOpen");
|
|
||||||
SchedulerSystem.AddJob(() => FuckMetrics.CohtmlAdvanceView(_gameMenuView, _gameMenuOpenTraverse), 12f, 6f, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
[HarmonyPostfix]
|
|
||||||
[HarmonyPatch(typeof(ViewManager), "OnMicrophoneStatusSwitched")]
|
|
||||||
private static void Postfix_ViewManager_OnMicrophoneStatusSwitched()
|
|
||||||
{
|
|
||||||
if (_quickMenuOpenTraverse.GetValue<bool>())
|
|
||||||
{
|
|
||||||
CVR_MenuManager.Instance.SendCoreUpdate();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue