diff --git a/AmongUs.props b/AmongUs.props index eae6aa9..afc343f 100644 --- a/AmongUs.props +++ b/AmongUs.props @@ -1,8 +1,8 @@  - + - + diff --git a/Directory.Build.props b/Directory.Build.props index 4b87d91..e60aaf9 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -8,7 +8,7 @@ true - 0.3.8 + 0.4.0 dev All Of Us, XtraCube, Angxl diff --git a/MiraAPI/Networking/CustomMurderRpc.cs b/MiraAPI/Networking/CustomMurderRpc.cs index d45c580..f9c6e87 100644 --- a/MiraAPI/Networking/CustomMurderRpc.cs +++ b/MiraAPI/Networking/CustomMurderRpc.cs @@ -93,11 +93,21 @@ public static class CustomMurderRpc beforeMurderEvent.Cancel(); } - if (beforeMurderEvent.IsCancelled) + if (target.ProtectedByGa()) + { + beforeMurderEvent.Cancel(); + murderResultFlags = MurderResultFlags.FailedProtected; + } + else if (beforeMurderEvent.IsCancelled) { murderResultFlags = MurderResultFlags.FailedError; } + if (beforeMurderEvent.IsCancelled && source.AmOwner) + { + source.isKilling = true; + } + if (!PlayerControl.LocalPlayer.IsHost()) { return; @@ -141,6 +151,7 @@ public static class CustomMurderRpc { if (LobbyBehaviour.Instance || !host.IsHost() || target.Data.IsDead || target.Data.Disconnected) { + source.isKilling = false; return; } diff --git a/MiraAPI/Patches/Keybinds/OptionsMenuBehaviourPatch.cs b/MiraAPI/Patches/Keybinds/OptionsMenuBehaviourPatch.cs index 2511168..816ebf4 100644 --- a/MiraAPI/Patches/Keybinds/OptionsMenuBehaviourPatch.cs +++ b/MiraAPI/Patches/Keybinds/OptionsMenuBehaviourPatch.cs @@ -16,8 +16,15 @@ public static class OptionsMenuBehaviourPatch private static void OpenPostfix(OptionsMenuBehaviour __instance) { _remap_rollover = GameObject.Find("Remap Controls")?.GetComponent()!; - _remap_background = _remap_rollover.transform.FindChild("Background").GetComponent(); - _remap_background.color = _conflicts ? Color.red : Color.white; + try + { + _remap_background = _remap_rollover.transform.FindChild("Background").GetComponent(); + _remap_background.color = _conflicts ? Color.red : Color.white; + } + catch + { + // ignored, this normally breaks when on mobile since there's no remap button screen. + } } [HarmonyPostfix] diff --git a/MiraAPI/Patches/Menu/MainMenuManagerPatches.cs b/MiraAPI/Patches/Menu/MainMenuManagerPatches.cs index d5a66cf..b2377fe 100644 --- a/MiraAPI/Patches/Menu/MainMenuManagerPatches.cs +++ b/MiraAPI/Patches/Menu/MainMenuManagerPatches.cs @@ -1,6 +1,8 @@ -using HarmonyLib; +using System.Collections; +using HarmonyLib; using MiraAPI.LocalSettings; using MiraAPI.Utilities.Assets; +using Reactor.Utilities; using UnityEngine; namespace MiraAPI.Patches.Menu; @@ -19,6 +21,14 @@ public static class MainMenuManagerPatches public static void AwakePostfix() { AddressablesLoader.LoadAll(); + Coroutines.Start(SetFps()); + } + + private static IEnumerator SetFps() + { + Application.targetFrameRate = (int)LocalSettingsTabSingleton.Instance.SetFpsSlider.Value; + yield return new WaitForSeconds(1f); + Application.targetFrameRate = (int)LocalSettingsTabSingleton.Instance.SetFpsSlider.Value; } } diff --git a/MiraAPI/PluginLoading/MiraPluginManager.cs b/MiraAPI/PluginLoading/MiraPluginManager.cs index 4e29988..26a881f 100644 --- a/MiraAPI/PluginLoading/MiraPluginManager.cs +++ b/MiraAPI/PluginLoading/MiraPluginManager.cs @@ -6,6 +6,7 @@ using System.Linq; using System.Reflection; using BepInEx.Configuration; using BepInEx.Unity.IL2CPP; +using HarmonyLib; using MiraAPI.Colors; using MiraAPI.Events; using MiraAPI.GameEnd; @@ -21,7 +22,6 @@ using MiraAPI.Roles; using MiraAPI.Utilities; using Reactor.Networking; using Reactor.Utilities; -using Rewired; namespace MiraAPI.PluginLoading; @@ -60,7 +60,7 @@ public sealed class MiraPluginManager continue; } - foreach (var method in type.GetMethods()) + foreach (var method in AccessTools.GetDeclaredMethods(type)) { var eventAttribute = method.GetCustomAttribute(); if (eventAttribute == null) diff --git a/MiraAPI/Utilities/Extensions.cs b/MiraAPI/Utilities/Extensions.cs index fcb072a..8c4acc7 100644 --- a/MiraAPI/Utilities/Extensions.cs +++ b/MiraAPI/Utilities/Extensions.cs @@ -181,6 +181,16 @@ public static class Extensions return TutorialManager.InstanceExists || AmongUsClient.Instance.HostId == playerControl.OwnerId; } + /// + /// Checks if a PlayerControl is protected by a Guardian Angel. + /// + /// The player you're checking for. + /// If the player is protected, true, else false. + public static bool ProtectedByGa(this PlayerControl playerControl) + { + return playerControl.protectedByGuardianId > -1; + } + /// /// Used to convert a System.Collections.Generic.List to Il2cppSystem. /// diff --git a/MiraAPI/Utilities/StateMachineWrapper.cs b/MiraAPI/Utilities/StateMachineWrapper.cs index a760e8e..e590f57 100644 --- a/MiraAPI/Utilities/StateMachineWrapper.cs +++ b/MiraAPI/Utilities/StateMachineWrapper.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Reflection; using HarmonyLib; using Il2CppInterop.Runtime.InteropTypes; +using Object = Il2CppSystem.Object; namespace MiraAPI.Utilities; @@ -17,6 +18,7 @@ public class StateMachineWrapper where T : Il2CppObjectBase // normally it is fields, but IL2CPP turns them into properties private readonly PropertyInfo _thisProperty; private readonly PropertyInfo _stateProperty; + private readonly PropertyInfo _currentProperty; private readonly Dictionary _propertyCache; private T? _parentInstance; @@ -37,8 +39,9 @@ public class StateMachineWrapper where T : Il2CppObjectBase var type = _stateMachine.GetType(); _thisProperty = AccessTools.Property(type, "__4__this"); _stateProperty = AccessTools.Property(type, "__1__state"); + _currentProperty = AccessTools.Property(type, "__2__current"); - if (_thisProperty == null || _stateProperty == null) + if (_thisProperty == null || _stateProperty == null || _currentProperty == null) { throw new MissingMemberException($"Could not find required properties in type '{type}'."); } @@ -52,6 +55,18 @@ public class StateMachineWrapper where T : Il2CppObjectBase /// The current state as an integer. public int GetState() => (int)_stateProperty.GetValue(_stateMachine)!; + /// + /// Sets the current state of the state machine. + /// + /// The new state to use. + public void SetState(int newState) => _stateProperty.SetValue(_stateMachine, newState); + + /// + /// Sets the newest yield return of the state machine. + /// + /// The new return to use. + public void SetRecentReturn(Object newReturn) => _currentProperty.SetValue(_stateMachine, newReturn); + /// /// Gets a parameter from the state machine by its name. /// diff --git a/packages/reactor.2.5.0-ci.371.nupkg b/packages/reactor.2.5.0-ci.371.nupkg new file mode 100644 index 0000000..e558f6f Binary files /dev/null and b/packages/reactor.2.5.0-ci.371.nupkg differ