Optimization (Part 1?) (#589)

* Well lets try check this

* Some changes

* Change

* Well

* Change ControllerManager.Update

* Nothing

* Optimaze more?

* Fix error build

* Fix win check

* Change

* Fix

* Optimaze some roles in OnCheckPlayerPosition

* More optimaze

* Full optimaze roles in OnGlobalFixedUpdate

* Optimaze some add-ons

* ProgressText

* Change

* Optimaze NameNotifyManager

* Optimaze NotifyRoles and some roles

* Move the displayed version

* Some changes

* Optimaze OnFixedUpdate in some roles

* Fix bugs

* Optimaze IsActive & V4 version

* Optimaze MapRoom.DoorsUpdate

* Cache TryCatch in IsActive

* Change

* Fix

* More optimze TaskPanelBehaviour

* Cache GetRoleColor & ColorString & AllStringNames & Change RemoveHtmlTags

* Cache TryCast VentilationSystem & ICriticalSabotage & IUsable and more optimaze

* Fix CountAlivePlayers

* Fix exceptios

* Replace some CachedAllPlayerControls to EnumeratePlayerControls

* Replace some CachedAlivePlayerControls to EnumerateAlivePlayerControls

* Fixes

* Fix modded clients

* Fix errors

* Fix again

* Optimaze & add null check

* Fix crash in Starlight

* Use only Main.PluginVersion in LobbySharingAPI

* Optimaze code in FixedUpdate

* Fix

* Optimize GetProgressText for Roles

* Some changes in Translations

* Cache Enum.GetValues and StringBuilder

* Changes

* CustomRole.ColoredTextByRole()

* Optimaze Lobby & Meeting

* ColorStringPrefix => ColorPrefix

* Add null check

* Remove

* Fixes & optimaze

* Fixes

* Changes

* Fix

* Fix

* Fix

* Remove

* Fix

* Change

* Revert
This commit is contained in:
TommyXL authored and GitHub committed 2026-05-15 20:01:54 +02:00
1 parent 3370ac8483
commit 7929a4b83e
245 files changed
+5603 -3340

No files matched your search

+13 -13
View File
@@ -86,10 +86,10 @@ static class CoShowIntroPatch
yield return CoBegin(Object.Instantiate(__instance.IntroPrefab, __instance.transform));
PlayerControl.LocalPlayer.SetKillTimer(10f);
(ShipStatus.Instance.Systems[SystemTypes.Sabotage].CastFast<SabotageSystemType>()).SetInitialSabotageCooldown();
ShipStatus.Instance.Systems[SystemTypes.Sabotage].CastFast<SabotageSystemType>().SetInitialSabotageCooldown();
if (ShipStatus.Instance.Systems.TryGetValue(SystemTypes.Doors, out ISystemType systemType) && systemType.TryCast<IDoorSystem>() != null)
(systemType.CastFast<IDoorSystem>()).SetInitialSabotageCooldown();
systemType.CastFast<IDoorSystem>().SetInitialSabotageCooldown();
yield return ShipStatus.Instance.PrespawnStep();
PlayerControl.LocalPlayer.AdjustLighting();
@@ -477,7 +477,7 @@ internal static class BeginCrewmatePatch
{
teamToDisplay = new();
foreach (PlayerControl pc in Main.EnumeratePlayerControls())
foreach (PlayerControl pc in Main.CachedAllPlayerControls())
{
if (pc.Is(Team.Coven))
teamToDisplay.Add(pc);
@@ -500,7 +500,7 @@ internal static class BeginCrewmatePatch
{
teamToDisplay = new();
foreach (PlayerControl pc in Main.EnumeratePlayerControls())
foreach (PlayerControl pc in Main.CachedAllPlayerControls())
{
if (CustomTeamManager.AreInSameCustomTeam(pc.PlayerId, PlayerControl.LocalPlayer.PlayerId))
teamToDisplay.Add(pc);
@@ -512,7 +512,7 @@ internal static class BeginCrewmatePatch
{
teamToDisplay = new();
foreach (PlayerControl pc in Main.EnumeratePlayerControls())
foreach (PlayerControl pc in Main.CachedAllPlayerControls())
{
if (FreeForAll.PlayerTeams.TryGetValue(pc.PlayerId, out int team) && team == ffaTeam)
teamToDisplay.Add(pc);
@@ -862,7 +862,7 @@ internal static class BeginCrewmatePatch
__instance.ImpostorText.gameObject.SetActive(team.RoleRevealScreenSubtitle != "*");
__instance.ImpostorText.text = team.RoleRevealScreenSubtitle;
foreach (PlayerControl pc in Main.EnumeratePlayerControls())
foreach (PlayerControl pc in Main.CachedAllPlayerControls())
{
if (CustomTeamManager.AreInSameCustomTeam(pc.PlayerId, PlayerControl.LocalPlayer.PlayerId))
teamToDisplay.Add(pc);
@@ -1047,7 +1047,7 @@ internal static class BeginImpostorPatch
if (PlayerControl.LocalPlayer.IsImpostor() && Options.ImpKnowWhosMadmate.GetBool())
{
foreach (var pc in Main.EnumeratePlayerControls())
foreach (var pc in Main.CachedAllPlayerControls())
{
if (pc.IsMadmate() && !pc.AmOwner)
yourTeam.Add(pc);
@@ -1061,7 +1061,7 @@ internal static class BeginImpostorPatch
if (Options.MadmateKnowWhosImp.GetBool())
{
foreach (var pc in Main.EnumeratePlayerControls())
foreach (var pc in Main.CachedAllPlayerControls())
{
if (pc.IsImpostor() && !pc.AmOwner)
yourTeam.Add(pc);
@@ -1070,7 +1070,7 @@ internal static class BeginImpostorPatch
if (Options.MadmateKnowWhosMadmate.GetBool())
{
foreach (var pc in Main.EnumeratePlayerControls())
foreach (var pc in Main.CachedAllPlayerControls())
{
if (pc.IsMadmate() && !pc.AmOwner)
yourTeam.Add(pc);
@@ -1131,8 +1131,8 @@ internal static class IntroCutsceneDestroyPatch
PreventKill = true;
LateTask.New(() => PreventKill = false, 10f, "PreventKillReset");
var apc = Main.AllPlayerControls;
var apc = Main.AllPlayerControlsToList;
// Set roleAssigned as false for overriding roles for modded players
// for vanilla clients we use "Data.Disconnected"
apc.Do(x => x.roleAssigned = false);
@@ -1141,7 +1141,7 @@ internal static class IntroCutsceneDestroyPatch
{
LateTask.New(() => apc.DoIf(x => x && ((x.AmOwner && Main.GM.Value) || ChatCommands.Spectators.Contains(x.PlayerId)), x => x.RpcSetCustomRole(CustomRoles.GM)), 8f);
var aapc = Main.AllAlivePlayerControls;
var aapc = Main.AllAlivePlayerControlsToList;
Utils.NumSnapToCallsThisRound = aapc.Count;
@@ -1179,7 +1179,7 @@ internal static class IntroCutsceneDestroyPatch
case CustomGameMode.HideAndSeek when CustomHnS.Chat:
case CustomGameMode.NaturalDisasters when NaturalDisasters.Chat:
case CustomGameMode.Standard when Options.ChatDuringGame.GetBool():
LateTask.New(() => Main.AllAlivePlayerControls.SetChatVisible(true), 4f);
LateTask.New(() => Main.AllAlivePlayerControlsToList.SetChatVisible(true), 4f);
break;
}