diff --git a/FrameLimiter.cs b/FrameLimiter.cs new file mode 100644 index 0000000..f5cb1e8 --- /dev/null +++ b/FrameLimiter.cs @@ -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(); + + } + + 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; + } + } + } + } +} \ No newline at end of file diff --git a/Mod/frame_limiter.dll b/Mod/frame_limiter.dll new file mode 100644 index 0000000..f899e3b Binary files /dev/null and b/Mod/frame_limiter.dll differ diff --git a/ModInfo.xml b/ModInfo.xml new file mode 100644 index 0000000..14ef391 --- /dev/null +++ b/ModInfo.xml @@ -0,0 +1,10 @@ + + 1.11b + + Frame Limiter + + + Limits the frame rate when the game is paused. + + 1.0.0.2 + \ No newline at end of file diff --git a/frame_limiter.csproj b/frame_limiter.csproj new file mode 100644 index 0000000..d5f10f9 --- /dev/null +++ b/frame_limiter.csproj @@ -0,0 +1,169 @@ + + + + + Release + x86 + {53821041-E269-4717-BAED-3C9C6836E83F} + Library + Properties + frame_limiter + frame_limiter + v4.8 + 512 + + + + pdbonly + true + Mod\ + TRACE + prompt + 4 + false + + + + + + ../../../libs/BaseModLib.dll + False + + + ../../../modlib/TheForest/TheForest_data/Managed/Assembly-CSharp-firstpass.dll + False + + + ../../../modlib/TheForest/TheForest_data/Managed/Assembly-CSharp.dll + False + + + ../../../modlib/TheForest/TheForest_data/Managed/Assembly-UnityScript-firstpass.dll + False + + + ../../../modlib/TheForest/TheForest_data/Managed/Assembly-UnityScript.dll + False + + + ../../../modlib/TheForest/TheForest_data/Managed/bolt.dll + False + + + ../../../modlib/TheForest/TheForest_data/Managed/bolt.user.dll + False + + + ../../../modlib/TheForest/TheForest_data/Managed/SteamworksManaged.dll + False + + + ../../../modlib/TheForest/TheForest_data/Managed/Boo.Lang.dll + False + + + ../../../modlib/TheForest/TheForest_data/Managed/Mono.Security.dll + False + + + ../../../modlib/TheForest/TheForest_data/Managed/UnityScript.Lang.dll + False + + + ../../../modlib/TheForest/TheForest_data/Managed/Boo.Lang.dll + False + + + ../../../modlib/TheForest/TheForest_data/Managed/Mono.Posix.dll + False + + + ../../../modlib/TheForest/TheForest_data/Managed/Mono.Security.dll + False + + + ../../../modlib/TheForest/TheForest_data/Managed/mscorlib.dll + False + + + ../../../modlib/TheForest/TheForest_data/Managed/Pathfinding.ClipperLib.dll + False + + + ../../../modlib/TheForest/TheForest_data/Managed/Pathfinding.Ionic.Zip.Reduced.dll + False + + + ../../../modlib/TheForest/TheForest_data/Managed/Pathfinding.JsonFx.dll + False + + + ../../../modlib/TheForest/TheForest_data/Managed/Pathfinding.Poly2Tri.dll + False + + + ../../../modlib/TheForest/TheForest_data/Managed/PlayMaker.dll + False + + + ../../../modlib/TheForest/TheForest_data/Managed/Rewired_Core.dll + False + + + ../../../modlib/TheForest/TheForest_data/Managed/System.Configuration.dll + False + + + ../../../modlib/TheForest/TheForest_data/Managed/System.Core.dll + False + + + ../../../modlib/TheForest/TheForest_data/Managed/System.dll + False + + + ../../../modlib/TheForest/TheForest_data/Managed/System.Security.dll + False + + + ../../../modlib/TheForest/TheForest_data/Managed/System.Xml.dll + False + + + ../../../modlib/TheForest/TheForest_data/Managed/TheForest.Commons.dll + False + + + ../../../modlib/TheForest/TheForest_data/Managed/TheForest.Modding.dll + False + + + ../../../modlib/TheForest/TheForest_data/Managed/UnityEngine.dll + False + + + ../../../modlib/TheForest/TheForest_data/Managed/UnityEngine.Networking.dll + False + + + ../../../modlib/TheForest/TheForest_data/Managed/UnityEngine.UI.dll + False + + + ../../../modlib/TheForest/TheForest_data/Managed/UnityScript.Lang.dll + False + + + ../../../modlib/TheForest/TheForest_data/Managed/udpkit.dll + False + + + ../../../modlib/TheForest/TheForest_data/Managed/udpkit.common.dll + False + + + + + + + \ No newline at end of file diff --git a/frame_limiter.sln b/frame_limiter.sln new file mode 100644 index 0000000..8418af8 --- /dev/null +++ b/frame_limiter.sln @@ -0,0 +1,18 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26403.7 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "frame_limiter", "frame_limiter.csproj", "{53821041-E269-4717-BAED-3C9C6836E83F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {53821041-E269-4717-BAED-3C9C6836E83F}.Release|x86.ActiveCfg = Release|x86 + {53821041-E269-4717-BAED-3C9C6836E83F}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal