Add back CohtmlView disabling.

This commit is contained in:
NotAKidoS 2023-03-16 03:22:03 -05:00
parent f6e2c1622a
commit 87bb3fcb89
4 changed files with 81 additions and 4 deletions

View file

@ -1,5 +1,8 @@
using ABI_RC.Core.InteractionSystem;
using ABI_RC.Core.IO;
using cohtml;
using HarmonyLib;
using UnityEngine;
namespace NAK.Melons.FuckMetrics
{
@ -30,5 +33,26 @@ namespace NAK.Melons.FuckMetrics
SchedulerSystem.RemoveJob(job);
}
}
public static void CohtmlAdvanceView(CohtmlView cohtmlView, Traverse menuOpenTraverse)
{
if (!FuckMetricsMod.EntryDisableCohtmlViewOnIdle.Value) return;
// Don't execute if menu is open
if (cohtmlView == null || menuOpenTraverse.GetValue<bool>()) return;
// Disable cohtmlView (opening should enable)
cohtmlView.enabled = false;
// Death
try
{
if (cohtmlView.m_UISystem != null) cohtmlView.View.Advance(cohtmlView.m_UISystem.Id, (double)Time.unscaledTime * 1000.0);
}
catch (Exception e)
{
FuckMetricsMod.Logger.Error($"An exception was thrown while calling CohtmlView.Advance(). Error message: {e.Message}");
}
}
}
}