inital mod
This commit is contained in:
51
FrameLimiter.cs
Normal file
51
FrameLimiter.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user