inital mod

This commit is contained in:
Lee
2024-01-03 01:20:51 +00:00
parent 3da63b56cf
commit 66f28b4b45
5 changed files with 248 additions and 0 deletions

51
FrameLimiter.cs Normal file
View File

@ -0,0 +1,51 @@
using ModAPI.Attributes;
using TheForest.Items.Inventory;
using TheForest.Utils;
using UnityEngine;
namespace frame_limiter
{
class FrameLimiter : MonoBehaviour
{
/**
* The frame limit to apply when the player is in the pause menu or loading screen.
*/
private const int FrameLimit = 30;
[ExecuteOnGameStart]
private static void AddMeToScene()
{
new GameObject("__FrameLimiter__").AddComponent<FrameLimiter>();
}
private void Update()
{
PlayerInventory inventory = LocalPlayer.Inventory;
if (inventory == null)
{
return;
}
switch (inventory.CurrentView)
{
case PlayerInventory.PlayerViews.Pause:
{
Application.targetFrameRate = FrameLimit;
break;
}
case PlayerInventory.PlayerViews.Loading:
{
Application.targetFrameRate = FrameLimit;
break;
}
default: // The frame limiter is set to the max frame rate that the user has set in the options.
{
Application.targetFrameRate = PlayerPreferences.MaxFrameRate;
break;
}
}
}
}
}