mirror of
https://github.com/D1GQ/BetterAmongUs.git
synced 2026-10-20 01:46:19 +00:00
Fix fps drops
This commit is contained in:
1 parent
d6bbb76f97
commit
837e0e0b17
4 files changed
+24
-11
No files matched your search
@@ -91,7 +91,7 @@ public class BetterOptionPlayerItem : BetterOptionItem
|
||||
ThisOption.ValueText.text = "<color=#ababab>Random</color>";
|
||||
}
|
||||
|
||||
if (CurrentIndex >= Main.AllPlayerControls.Length - 1)
|
||||
if (CurrentIndex >= Main.AllPlayerControls.Count - 1)
|
||||
{
|
||||
ThisOption.PlusBtn.SetInteractable(false);
|
||||
ThisOption.MinusBtn.SetInteractable(true);
|
||||
@@ -112,7 +112,7 @@ public class BetterOptionPlayerItem : BetterOptionItem
|
||||
|
||||
public void Increase()
|
||||
{
|
||||
if (CurrentIndex < Main.AllPlayerControls.Length)
|
||||
if (CurrentIndex < Main.AllPlayerControls.Count)
|
||||
{
|
||||
CurrentIndex++;
|
||||
AdjustButtonsActiveState();
|
||||
@@ -135,7 +135,7 @@ public class BetterOptionPlayerItem : BetterOptionItem
|
||||
var saveindex = TempPlayerOptionData[Id];
|
||||
|
||||
if (saveindex != -1 && Utils.PlayerFromPlayerId(saveindex) == null)
|
||||
saveindex = Main.AllPlayerControls.Length - 1;
|
||||
saveindex = Main.AllPlayerControls.Count - 1;
|
||||
|
||||
CurrentIndex = saveindex;
|
||||
}
|
||||
|
||||
@@ -14,6 +14,20 @@ namespace BetterAmongUs.Patches;
|
||||
[HarmonyPatch(typeof(PlayerControl))]
|
||||
class PlayerControlPatch
|
||||
{
|
||||
[HarmonyPatch(nameof(PlayerControl.Awake))]
|
||||
[HarmonyPostfix]
|
||||
public static void Awake_Postfix(PlayerControl __instance)
|
||||
{
|
||||
Main.AllPlayerControls.Add(__instance);
|
||||
}
|
||||
|
||||
[HarmonyPatch(nameof(PlayerControl.OnDestroy))]
|
||||
[HarmonyPostfix]
|
||||
public static void OnDestroy_Postfix(PlayerControl __instance)
|
||||
{
|
||||
Main.AllPlayerControls.Remove(__instance);
|
||||
}
|
||||
|
||||
[HarmonyPatch(nameof(PlayerControl.FixedUpdate))]
|
||||
[HarmonyPrefix]
|
||||
public static void FixedUpdate_Prefix(PlayerControl __instance)
|
||||
|
||||
@@ -45,7 +45,7 @@ public class RoleManagerPatch
|
||||
|
||||
int NumImpostors = GameOptionsManager.Instance.CurrentGameOptions.NumImpostors;
|
||||
|
||||
int NumPlayers = Main.AllPlayerControls.Length;
|
||||
int NumPlayers = Main.AllPlayerControls.Count;
|
||||
|
||||
var impostorLimits = new Dictionary<int, int>
|
||||
{
|
||||
@@ -270,8 +270,8 @@ public class RoleManagerPatch
|
||||
|
||||
int NumImpostors = BetterGameSettings.HideAndSeekImpNum.GetInt();
|
||||
|
||||
if (NumImpostors > Main.AllPlayerControls.Length)
|
||||
NumImpostors = Main.AllPlayerControls.Length;
|
||||
if (NumImpostors > Main.AllPlayerControls.Count)
|
||||
NumImpostors = Main.AllPlayerControls.Count;
|
||||
|
||||
List<NetworkedPlayerInfo> Impostors = [];
|
||||
List<NetworkedPlayerInfo> Crewmates = [];
|
||||
|
||||
@@ -9,7 +9,6 @@ using BetterAmongUs.Modules;
|
||||
using BetterAmongUs.Patches;
|
||||
using HarmonyLib;
|
||||
using Il2CppInterop.Runtime.Injection;
|
||||
using Innersloth.IO;
|
||||
using System.Reflection;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
@@ -110,8 +109,8 @@ public class Main : BasePlugin
|
||||
"2024.6.18",
|
||||
];
|
||||
|
||||
public static PlayerControl[] AllPlayerControls => PlayerControl.AllPlayerControls.ToArray().Where(pc => pc != null).ToArray();
|
||||
public static PlayerControl[] AllAlivePlayerControls => AllPlayerControls.ToArray().Where(pc => pc.IsAlive()).ToArray();
|
||||
public static List<PlayerControl> AllPlayerControls = [];
|
||||
public static List<PlayerControl> AllAlivePlayerControls => AllPlayerControls.Where(pc => pc.IsAlive()).ToList();
|
||||
public static DeadBody[] AllDeadBodys => UnityEngine.Object.FindObjectsOfType<DeadBody>().ToArray();
|
||||
public static Vent[] AllVents => UnityEngine.Object.FindObjectsOfType<Vent>();
|
||||
|
||||
@@ -261,6 +260,6 @@ public class Main : BasePlugin
|
||||
CommandPrefix = Config.Bind("Client Options", "CommandPrefix", "/");
|
||||
}
|
||||
|
||||
public static string GetDataPathToAmongUs() => FileIO.GetRootDataPath();
|
||||
public static string GetGamePathToAmongUs() => Environment.CurrentDirectory;
|
||||
public static string GetDataPathToAmongUs() => Application.persistentDataPath;
|
||||
public static string GetGamePathToAmongUs() => Path.GetDirectoryName(Application.dataPath) ?? Application.dataPath;
|
||||
}
|
||||
Reference in new issue
Block a user