diff --git a/Directory.Build.props b/Directory.Build.props index 9cc1b57..622c97b 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -8,7 +8,7 @@ true - 0.3.1 + 0.3.2 dev All Of Us, XtraCube, Angxl diff --git a/MiraAPI/Networking/CustomMurderRpc.cs b/MiraAPI/Networking/CustomMurderRpc.cs index e3005c9..dea86ae 100644 --- a/MiraAPI/Networking/CustomMurderRpc.cs +++ b/MiraAPI/Networking/CustomMurderRpc.cs @@ -1,4 +1,5 @@ -using System.Collections; +using System; +using System.Collections; using System.Linq; using AmongUs.Data; using AmongUs.GameOptions; @@ -8,8 +9,10 @@ using MiraAPI.Events; using MiraAPI.Events.Vanilla.Gameplay; using Reactor.Networking.Attributes; using Reactor.Networking.Rpc; +using Reactor.Utilities; using Reactor.Utilities.Extensions; using UnityEngine; +using Object = UnityEngine.Object; namespace MiraAPI.Networking; @@ -169,7 +172,14 @@ public static class CustomMurderRpc if (showKillAnim) { - HudManager.Instance.KillOverlay.ShowKillAnimation(source.Data, data); + try + { + HudManager.Instance.KillOverlay.ShowKillAnimation(source.Data, data); + } + catch (Exception e) + { + Logger.Error($"Error with kill animation: {e.ToString()}"); + } } target.cosmetics.SetNameMask(false); @@ -202,7 +212,7 @@ public static class CustomMurderRpc bool teleportMurderer = true) { var cam = Camera.main?.GetComponent(); - var isParticipant = PlayerControl.LocalPlayer == source || PlayerControl.LocalPlayer == target; + var isParticipant = source.AmOwner || target.AmOwner; var sourcePhys = source.MyPhysics; if (teleportMurderer) @@ -222,7 +232,7 @@ public static class CustomMurderRpc if (createDeadBody) { - deadBody = Object.Instantiate(GameManager.Instance.deadBodyPrefab[0]); + deadBody = Object.Instantiate(GameManager.Instance.GetDeadBody(source.Data.Role)); deadBody.enabled = false; deadBody.ParentId = target.PlayerId; deadBody.bodyRenderers.ToList().ForEach(target.SetPlayerMaterialColors); @@ -233,6 +243,13 @@ public static class CustomMurderRpc deadBody.transform.position = vector; } + source.Data.Role.KillAnimSpecialSetup(deadBody, source, target); + target.Data.Role.KillAnimSpecialSetup(deadBody, source, target); + + // no idea if this causes bugs, but innersloth is brain-dead + // I HATE INNERSCUFF I HATE INNERSCUFF I HATE INNERSCUFF I HATE INNERSCUFF I HATE INNERSCUFF I HATE INNERSCUFF + PlayerControl.LocalPlayer.Data.Role.KillAnimSpecialSetup(deadBody, source, target); + if (isParticipant) { if (cam != null) diff --git a/MiraAPI/Patches/Events/EndGamePatches.cs b/MiraAPI/Patches/Events/EndGamePatches.cs index fe5a7bb..aa47539 100644 --- a/MiraAPI/Patches/Events/EndGamePatches.cs +++ b/MiraAPI/Patches/Events/EndGamePatches.cs @@ -7,15 +7,6 @@ namespace MiraAPI.Patches.Events; internal static class EndGamePatches { - [HarmonyPatch(typeof(GameManager), nameof(GameManager.Awake))] - public static class GameManagerAwakePatch - { - public static void Postfix(GameManager __instance) - { - __instance.enabled = true; - } - } - [HarmonyPatch(typeof(GameManager), nameof(GameManager.RpcEndGame))] public static class GameManagerRpcEndGamePatch { diff --git a/MiraAPI/Patches/HudManagerPatches.cs b/MiraAPI/Patches/HudManagerPatches.cs index e8c13ac..7665deb 100644 --- a/MiraAPI/Patches/HudManagerPatches.cs +++ b/MiraAPI/Patches/HudManagerPatches.cs @@ -73,6 +73,22 @@ public static class HudManagerPatches gridArrange.Alignment = GridArrange.StartAlign.Right; aspectPosition.Alignment = AspectPosition.EdgeAlignments.LeftBottom; + if (Constants.GetPlatformType() is Platforms.Android or Platforms.IPhone) + { + var fakeButton = Object.Instantiate(__instance.AbilityButton, BottomLeft.transform); + foreach (var renderer in fakeButton.GetComponentsInChildren()) + { + renderer.enabled = false; + } + + fakeButton.buttonLabelText.Destroy(); + fakeButton.cooldownTimerText.Destroy(); + fakeButton.usesRemainingText.Destroy(); + fakeButton.GetComponent().Destroy(); + fakeButton.ToggleVisible(true); + fakeButton.Destroy(); + } + foreach (var button in CustomButtonManager.CustomButtons) { var location = button.Location switch diff --git a/MiraAPI/Patches/Options/LobbyViewPanePatches.cs b/MiraAPI/Patches/Options/LobbyViewPanePatches.cs index d05a5a4..901d21c 100644 --- a/MiraAPI/Patches/Options/LobbyViewPanePatches.cs +++ b/MiraAPI/Patches/Options/LobbyViewPanePatches.cs @@ -344,7 +344,7 @@ public static class LobbyViewPanePatches } viewSettingsInfoPanelRoleVariant.SetInfo( - roleBehaviour.NiceName, + roleBehaviour.GetRoleName(), numPerGame, chancePerGame, 61, diff --git a/MiraAPI/Patches/Options/RoleSettingMenuPatches.cs b/MiraAPI/Patches/Options/RoleSettingMenuPatches.cs index 9d25635..1733ce1 100644 --- a/MiraAPI/Patches/Options/RoleSettingMenuPatches.cs +++ b/MiraAPI/Patches/Options/RoleSettingMenuPatches.cs @@ -473,9 +473,7 @@ public static class RoleSettingMenuPatches RolePositions[GameSettingMenuPatches.SelectedModIdx] = __instance.scrollBar.Inner.localPosition; __instance.roleDescriptionText.text = customRole.RoleLongDescription; - __instance.roleTitleText.text = TranslationController.Instance.GetString( - role.StringName, - new Il2CppReferenceArray(0)); + __instance.roleTitleText.text = role.GetRoleName(); var imgBg = __instance.AdvancedRolesSettings.transform.FindChild("Imagebackground"); var labelBg = __instance.AdvancedRolesSettings.transform.FindChild("InfoLabelBackground"); @@ -579,6 +577,7 @@ public static class RoleSettingMenuPatches roleOptionSetting.transform.localPosition = new Vector3(-0.1f, ScrollerNum, -2f); roleOptionSetting.SetRole(GameOptionsManager.Instance.CurrentGameOptions.RoleOptions, role, 20); + roleOptionSetting.titleText.text = role.GetRoleName(); roleOptionSetting.labelSprite.color = customRole.OptionsMenuColor; roleOptionSetting.OnValueChanged = new Action(ValueChanged); roleOptionSetting.SetClickMask(__instance.ButtonClickMask); diff --git a/MiraAPI/Patches/Roles/HauntMenuPatch.cs b/MiraAPI/Patches/Roles/HauntMenuPatch.cs index 6f0a0a5..da272a6 100644 --- a/MiraAPI/Patches/Roles/HauntMenuPatch.cs +++ b/MiraAPI/Patches/Roles/HauntMenuPatch.cs @@ -1,11 +1,12 @@ using HarmonyLib; using MiraAPI.Roles; +using MiraAPI.Utilities; using UnityEngine; namespace MiraAPI.Patches.Roles; /// -/// Patches the haunt menu to show the actual role name rather then team. +/// Patches the haunt menu to show the actual role name rather than team. /// [HarmonyPatch(typeof(HauntMenuMinigame), nameof(HauntMenuMinigame.SetHauntTarget))] // SetFilterText was INLINED @@ -22,7 +23,7 @@ public static class HauntMenuMinigamePatch var role = __instance.HauntTarget.Data.Role; var color = role is ICustomRole custom ? custom.RoleColor : role.TeamColor; - __instance.FilterText.text = role.NiceName; + __instance.FilterText.text = role.GetRoleName(); __instance.FilterText.color = color; } } diff --git a/MiraAPI/Resources/mirabundle-android.bundle b/MiraAPI/Resources/mirabundle-android.bundle new file mode 100644 index 0000000..0e09603 Binary files /dev/null and b/MiraAPI/Resources/mirabundle-android.bundle differ diff --git a/MiraAPI/Roles/CustomRoleManager.cs b/MiraAPI/Roles/CustomRoleManager.cs index d16153b..22e8465 100644 --- a/MiraAPI/Roles/CustomRoleManager.cs +++ b/MiraAPI/Roles/CustomRoleManager.cs @@ -4,6 +4,7 @@ using System.Linq; using AmongUs.GameOptions; using Il2CppInterop.Runtime; using Il2CppInterop.Runtime.Injection; +using Il2CppInterop.Runtime.InteropTypes.Arrays; using MiraAPI.Networking; using MiraAPI.PluginLoading; using MiraAPI.Utilities; @@ -53,6 +54,9 @@ public static class CustomRoleManager internal static readonly Dictionary CustomRoles = []; internal static readonly Dictionary RoleIds = []; + private static Il2CppSystem.Collections.Generic.List? _emptySettings; + private static Il2CppReferenceArray? _emptyKillAnimations; + private static ushort _roleId = 100; private static ushort GetNextRoleId() @@ -133,6 +137,12 @@ public static class CustomRoleManager roleBehaviour.MaxCount = customRole.Configuration.MaxRoleCount; roleBehaviour.RoleScreenshot = customRole.Configuration.OptionsScreenshot?.LoadAsset(); + _emptySettings ??= new(0); + _emptyKillAnimations ??= new(0); + + roleBehaviour.AllGameSettings = _emptySettings; + roleBehaviour.CustomKillAnimations = _emptyKillAnimations; + if (customRole.Configuration.Icon != null) { var asset = customRole.Configuration.Icon.LoadAsset(); diff --git a/MiraAPI/Utilities/Assets/SpriteTools.cs b/MiraAPI/Utilities/Assets/SpriteTools.cs index 667d0c9..8bea6f1 100644 --- a/MiraAPI/Utilities/Assets/SpriteTools.cs +++ b/MiraAPI/Utilities/Assets/SpriteTools.cs @@ -19,7 +19,10 @@ public static class SpriteTools /// Thrown when the resource cannot be found in the specified assembly. public static Texture2D LoadTextureFromResourcePath(string resourcePath, Assembly assembly) { - var tex = new Texture2D(1, 1, TextureFormat.ARGB32, false); + var tex = new Texture2D(1, 1, TextureFormat.ARGB32, false) + { + wrapMode = TextureWrapMode.Clamp, + }; var myStream = assembly.GetManifestResourceStream(resourcePath); if (myStream != null) {