From ca285d4af665eb3d75454fa8a3a9345784fe5735 Mon Sep 17 00:00:00 2001 From: Az <56699741+AlchlcDvl@users.noreply.github.com> Date: Thu, 5 Nov 2026 23:48:28 -0500 Subject: [PATCH] removing even more useless calls --- MiraAPI/Hud/CustomPhoneMenu.cs | 4 ++-- MiraAPI/MeetingAbilities/TargetedMeetingButton.cs | 2 +- MiraAPI/MiraApiSettings.cs | 12 ++++++------ MiraAPI/Patches/Freeplay/TaskAdderPatches.cs | 3 +-- MiraAPI/Patches/GameModes/HudPatches.cs | 4 ++-- MiraAPI/Patches/HudManagerPatches.cs | 10 +++++----- MiraAPI/Patches/Options/GamePresetsTabPatches.cs | 2 +- MiraAPI/Patches/Options/MenuState.cs | 4 ++-- MiraAPI/Patches/Options/RoleSettingMenuPatches.cs | 4 ++-- MiraAPI/Patches/PlayerControlPatches.cs | 4 ++-- MiraAPI/Patches/Roles/RoleManagerPatches.cs | 2 +- MiraAPI/Patches/Roles/TaskPanelPatch.cs | 2 +- MiraAPI/Presets/SavePresetPopup.cs | 2 +- MiraAPI/Roles/CustomRoleManager.cs | 2 +- 14 files changed, 28 insertions(+), 29 deletions(-) diff --git a/MiraAPI/Hud/CustomPhoneMenu.cs b/MiraAPI/Hud/CustomPhoneMenu.cs index 1f636f73..55af740f 100644 --- a/MiraAPI/Hud/CustomPhoneMenu.cs +++ b/MiraAPI/Hud/CustomPhoneMenu.cs @@ -260,7 +260,7 @@ public abstract class CustomPhoneMenu : ICustomMenu MenuEntries.Add(menuEntry); var button = shapeshifterPanel.Button; - var nameplate = shapeshifterPanel.gameObject.transform.FindChild("Nameplate"); + var nameplate = shapeshifterPanel.transform.FindChild("Nameplate"); var highlight = nameplate.FindChild("Highlight").GetComponent(); var icon = highlight.transform.GetChild(0).GetComponent(); @@ -317,7 +317,7 @@ public abstract class CustomPhoneMenu : ICustomMenu { ShapeshifterPanel panel = menuEntry.Panel; - var nameplate = panel.gameObject.transform.FindChild("Nameplate"); + var nameplate = panel.transform.FindChild("Nameplate"); var highlight = nameplate.FindChild("Highlight").GetComponent(); var icon = highlight.transform.GetChild(0).GetComponent(); if (sprite != null) diff --git a/MiraAPI/MeetingAbilities/TargetedMeetingButton.cs b/MiraAPI/MeetingAbilities/TargetedMeetingButton.cs index 2d4766e4..aeeeedd8 100644 --- a/MiraAPI/MeetingAbilities/TargetedMeetingButton.cs +++ b/MiraAPI/MeetingAbilities/TargetedMeetingButton.cs @@ -89,7 +89,7 @@ public abstract class TargetedMeetingButton if (MeetingHud.Instance == null) return null!; var btn = Object.Instantiate(MeetingHud.Instance.PlayerButtonPrefab.ConfirmButton).GetComponent(); - btn.gameObject.name = Name + "Button"; + btn.name = Name + "Button"; var spriteRenderer = btn.GetComponent(); spriteRenderer.sprite = Sprite.LoadAsset(); diff --git a/MiraAPI/MiraApiSettings.cs b/MiraAPI/MiraApiSettings.cs index 2240d0c1..ce722351 100644 --- a/MiraAPI/MiraApiSettings.cs +++ b/MiraAPI/MiraApiSettings.cs @@ -144,15 +144,15 @@ public class MiraApiSettings(ConfigFile config) : LocalSettingsTab(config) if (button.transform.name.Contains("Friends List Button")) { - button.gameObject.transform.localScale = new Vector3(0.2675f * actualScaleVal, 0.2675f * actualScaleVal, 1); + button.transform.localScale = new Vector3(0.2675f * actualScaleVal, 0.2675f * actualScaleVal, 1); continue; } - button.gameObject.transform.localScale = actualScale; + button.transform.localScale = actualScale; } baseGrid.CellSize = new Vector2(alteredScale, alteredScale); - if (baseGrid.gameObject.transform.childCount != 0) + if (baseGrid.transform.childCount != 0) { baseGrid.ArrangeChilds(); } @@ -175,15 +175,15 @@ public class MiraApiSettings(ConfigFile config) : LocalSettingsTab(config) if (button.transform.name.Contains("Modifiers")) { - button.gameObject.transform.localScale = new Vector3(0.65f * scaleFactor, 0.65f * scaleFactor, 1); + button.transform.localScale = new Vector3(0.65f * scaleFactor, 0.65f * scaleFactor, 1); continue; } - button.gameObject.transform.localScale = actualScale; + button.transform.localScale = actualScale; } extraGrid.CellSize = new Vector2(alteredScale, alteredScale); - if (extraGrid.gameObject.transform.childCount != 0) + if (extraGrid.transform.childCount != 0) { extraGrid.ArrangeChilds(); } diff --git a/MiraAPI/Patches/Freeplay/TaskAdderPatches.cs b/MiraAPI/Patches/Freeplay/TaskAdderPatches.cs index 6a97687f..a4ba9cbd 100644 --- a/MiraAPI/Patches/Freeplay/TaskAdderPatches.cs +++ b/MiraAPI/Patches/Freeplay/TaskAdderPatches.cs @@ -111,8 +111,7 @@ public static class TaskAdderPatches if (plugin.InternalModifiers.Exists(x => x.ShowInFreeplay)) { - __instance.CreateFolder(plugin.PluginInfo.Metadata.Name, modifiersFolder) - .gameObject.name = plugin.PluginId; + __instance.CreateFolder(plugin.PluginInfo.Metadata.Name, modifiersFolder).name = plugin.PluginId; } } diff --git a/MiraAPI/Patches/GameModes/HudPatches.cs b/MiraAPI/Patches/GameModes/HudPatches.cs index 3c2d815d..325d193d 100644 --- a/MiraAPI/Patches/GameModes/HudPatches.cs +++ b/MiraAPI/Patches/GameModes/HudPatches.cs @@ -34,8 +34,8 @@ internal static class HudPatches yield return new WaitUntil((Il2CppSystem.Func)(() => GameManager.Instance != null)); if (GameManager.Instance.IsHideAndSeek()) yield return null; - var infoPane = instance.gameObject.transform.FindChild("LobbyInfoPane"); - var aspect = infoPane.gameObject.transform.Find("AspectSize"); + var infoPane = instance.transform.FindChild("LobbyInfoPane"); + var aspect = infoPane.transform.Find("AspectSize"); var modeLabel = aspect!.Find("ModeLabel"); var modeValue = aspect.Find("ModeValue"); var modelText = modeLabel!.Find("Text_TMP").gameObject; diff --git a/MiraAPI/Patches/HudManagerPatches.cs b/MiraAPI/Patches/HudManagerPatches.cs index 75b0e5e7..a6959ead 100644 --- a/MiraAPI/Patches/HudManagerPatches.cs +++ b/MiraAPI/Patches/HudManagerPatches.cs @@ -47,9 +47,9 @@ public static class HudManagerPatches { if (!aspect.gameObject) continue; - if (aspect.gameObject.transform.parent.name == "TopRight") continue; + if (aspect.transform.parent.name == "TopRight") continue; - if (aspect.gameObject.name.Contains("TopRight")) continue; + if (aspect.name.Contains("TopRight")) continue; aspect.gameObject.SetActive(!aspect.isActiveAndEnabled); aspect.DistanceFromEdge *= new Vector2(scaleFactor, scaleFactor); @@ -62,7 +62,7 @@ public static class HudManagerPatches if (!button.gameObject) continue; button.gameObject.SetActive(!button.isActiveAndEnabled); - button.gameObject.transform.localScale *= scaleFactor; + button.transform.localScale *= scaleFactor; button.gameObject.SetActive(!button.isActiveAndEnabled); } @@ -71,12 +71,12 @@ public static class HudManagerPatches { if (!arrange.gameObject || !arrange.transform) continue; - if (arrange.gameObject.name.Contains("TopRight")) continue; + if (arrange.name.Contains("TopRight")) continue; arrange.gameObject.SetActive(!arrange.isActiveAndEnabled); arrange.CellSize = new Vector2(scaleFactor, scaleFactor); arrange.gameObject.SetActive(!arrange.isActiveAndEnabled); - if (!arrange.isActiveAndEnabled || arrange.gameObject.transform.childCount == 0) continue; + if (!arrange.isActiveAndEnabled || arrange.transform.childCount == 0) continue; try { arrange.ArrangeChilds(); diff --git a/MiraAPI/Patches/Options/GamePresetsTabPatches.cs b/MiraAPI/Patches/Options/GamePresetsTabPatches.cs index a759cc1e..fe6ac117 100644 --- a/MiraAPI/Patches/Options/GamePresetsTabPatches.cs +++ b/MiraAPI/Patches/Options/GamePresetsTabPatches.cs @@ -184,7 +184,7 @@ internal static class GamePresetsTabPatches { saveButton = Object.Instantiate(prefab, presetTab.transform); _saveButton = saveButton.gameObject; - _saveButton.gameObject.name = "SaveButton"; + _saveButton.name = "SaveButton"; _saveButton.transform.localPosition = new Vector3(3.2f, 1.7f, -2); // set the button text and alignment diff --git a/MiraAPI/Patches/Options/MenuState.cs b/MiraAPI/Patches/Options/MenuState.cs index ee3c75f9..cd5e6c87 100644 --- a/MiraAPI/Patches/Options/MenuState.cs +++ b/MiraAPI/Patches/Options/MenuState.cs @@ -322,7 +322,7 @@ public class MenuState(IntPtr cppPtr) : MonoBehaviour(cppPtr) // Create game options container var gameContainer = Containers[MenuCategory.Game][idx + 1] = Instantiate( Gsm.GameSettingsTab.settingsContainer.gameObject, - Gsm.GameSettingsTab.settingsContainer.gameObject.transform.parent); + Gsm.GameSettingsTab.settingsContainer.transform.parent); gameContainer.name = $"GameSettings_{mod.PluginInfo.Metadata.Name}"; gameContainer.transform.DestroyChildren(); gameContainer.SetActive(false); @@ -340,7 +340,7 @@ public class MenuState(IntPtr cppPtr) : MonoBehaviour(cppPtr) { var cont = Containers[i][idx + 1] = Instantiate( Gsm.GameSettingsTab.settingsContainer.gameObject, - Gsm.GameSettingsTab.settingsContainer.gameObject.transform.parent); + Gsm.GameSettingsTab.settingsContainer.transform.parent); cont.name = $"{i}_{mod.PluginInfo.Metadata.Name}"; cont.transform.DestroyChildren(); cont.SetActive(false); diff --git a/MiraAPI/Patches/Options/RoleSettingMenuPatches.cs b/MiraAPI/Patches/Options/RoleSettingMenuPatches.cs index 41e376d3..b6372387 100644 --- a/MiraAPI/Patches/Options/RoleSettingMenuPatches.cs +++ b/MiraAPI/Patches/Options/RoleSettingMenuPatches.cs @@ -604,14 +604,14 @@ public static class RoleSettingMenuPatches var categoryHeaderMasked = __instance.AdvancedRolesSettings.transform.Find("CategoryHeaderMasked").GetComponent(); - if (categoryHeaderMasked.Title.gameObject.TryGetComponent(out var comp)) + if (categoryHeaderMasked.Title.TryGetComponent(out var comp)) { comp.Destroy(); } categoryHeaderMasked.Title.text = "MiraApi.ReturnToRoleSettings".Translate(); - if (!categoryHeaderMasked.gameObject.TryGetComponent(out _)) + if (!categoryHeaderMasked.TryGetComponent(out _)) { var boxCol = categoryHeaderMasked.gameObject.AddComponent(); boxCol.size = new Vector2(7, 0.7f); diff --git a/MiraAPI/Patches/PlayerControlPatches.cs b/MiraAPI/Patches/PlayerControlPatches.cs index 791334d8..89c78e36 100644 --- a/MiraAPI/Patches/PlayerControlPatches.cs +++ b/MiraAPI/Patches/PlayerControlPatches.cs @@ -22,12 +22,12 @@ internal static class PlayerControlPatches [HarmonyPatch(nameof(PlayerControl.Start))] public static void PlayerControlStartPostfix(PlayerControl __instance) { - if (__instance.gameObject.TryGetComponent(out var modifierComp)) + if (__instance.TryGetComponent(out var modifierComp)) { modifierComp.DestroyImmediate(); } - if (__instance.gameObject.TryGetComponent(out var voteComp)) + if (__instance.TryGetComponent(out var voteComp)) { voteComp.DestroyImmediate(); } diff --git a/MiraAPI/Patches/Roles/RoleManagerPatches.cs b/MiraAPI/Patches/Roles/RoleManagerPatches.cs index 82e937fc..82cf9911 100644 --- a/MiraAPI/Patches/Roles/RoleManagerPatches.cs +++ b/MiraAPI/Patches/Roles/RoleManagerPatches.cs @@ -37,7 +37,7 @@ public static class RoleManagerPatches Object.Destroy(data.Role.gameObject); } - var roleBehaviour = Object.Instantiate(__instance.AllRoles.ToArray().First(r => r.Role == roleType), data.gameObject.transform); + var roleBehaviour = Object.Instantiate(__instance.AllRoles.ToArray().First(r => r.Role == roleType), data.transform); roleBehaviour.Initialize(targetPlayer); targetPlayer.Data.Role = roleBehaviour; targetPlayer.Data.RoleType = roleType; diff --git a/MiraAPI/Patches/Roles/TaskPanelPatch.cs b/MiraAPI/Patches/Roles/TaskPanelPatch.cs index c858d9f0..e97646da 100644 --- a/MiraAPI/Patches/Roles/TaskPanelPatch.cs +++ b/MiraAPI/Patches/Roles/TaskPanelPatch.cs @@ -15,7 +15,7 @@ internal static class TaskPanelPatch [HarmonyPatch(nameof(TaskPanelBehaviour.Update))] public static bool UpdatePrefix(TaskPanelBehaviour __instance) { - if (__instance.gameObject.name != "RolePanel") + if (__instance.name != "RolePanel") { return true; } diff --git a/MiraAPI/Presets/SavePresetPopup.cs b/MiraAPI/Presets/SavePresetPopup.cs index 9405e83b..d2db31ba 100644 --- a/MiraAPI/Presets/SavePresetPopup.cs +++ b/MiraAPI/Presets/SavePresetPopup.cs @@ -70,7 +70,7 @@ public class SavePresetPopup(nint cppPtr) : Minigame(cppPtr) foreach (var tmp in gameObject.GetComponentsInChildren()) { - if (tmp.gameObject.transform.parent.name == "Textbox") + if (tmp.transform.parent.name == "Textbox") { continue; } diff --git a/MiraAPI/Roles/CustomRoleManager.cs b/MiraAPI/Roles/CustomRoleManager.cs index 3b48087c..d9325e6a 100644 --- a/MiraAPI/Roles/CustomRoleManager.cs +++ b/MiraAPI/Roles/CustomRoleManager.cs @@ -257,7 +257,7 @@ public static class CustomRoleManager internal static void UpdateRoleTab(TaskPanelBehaviour panel, ICustomRole role) { - var tabText = panel.tab.gameObject.GetComponentInChildren(); + var tabText = panel.tab.GetComponentInChildren(); var ogPanel = HudManager.Instance.TaskStuff.transform.FindChild("TaskPanel").GetComponent(); if (tabText.text != role.RoleName) {