diff --git a/Directory.Build.props b/Directory.Build.props
index 498ea91..3e674bc 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -8,7 +8,7 @@
true
- 0.3.5
+ 0.3.6
dev
All Of Us, XtraCube, Angxl
diff --git a/MiraAPI/MiraApiPlugin.cs b/MiraAPI/MiraApiPlugin.cs
index 469ffd2..99a961f 100644
--- a/MiraAPI/MiraApiPlugin.cs
+++ b/MiraAPI/MiraApiPlugin.cs
@@ -21,6 +21,11 @@ namespace MiraAPI;
[ReactorModFlags(ModFlags.RequireOnAllClients)]
public partial class MiraApiPlugin : BasePlugin
{
+ ///
+ /// Gets whether the current device is running Starlight (on mobile).
+ ///
+ public static bool IsMobile => Constants.GetPlatformType() is Platforms.Android or Platforms.IPhone;
+
///
/// Gets the branding Mira API color.
///
diff --git a/MiraAPI/MiraApiSettings.cs b/MiraAPI/MiraApiSettings.cs
index 0543cf9..0898eed 100644
--- a/MiraAPI/MiraApiSettings.cs
+++ b/MiraAPI/MiraApiSettings.cs
@@ -4,6 +4,7 @@ using MiraAPI.LocalSettings.Attributes;
using MiraAPI.Patches;
using MiraAPI.Utilities;
using MiraAPI.Utilities.Assets;
+using UnityEngine;
namespace MiraAPI;
@@ -48,6 +49,10 @@ public class MiraApiSettings(ConfigFile config) : LocalSettingsTab(config)
}
OldButtonScaleFactor = ButtonUIFactorSlider.Value;
}
+ else if (configEntry == SetFpsSlider)
+ {
+ Application.targetFrameRate = (int)SetFpsSlider.Value;
+ }
}
///
@@ -69,6 +74,13 @@ public class MiraApiSettings(ConfigFile config) : LocalSettingsTab(config)
public ConfigEntry ButtonUIFactorSlider { get; private set; } =
config.Bind("Visuals/UI", "Button Scale Factor", 0.75f);
+ ///
+ /// Gets the fps specified by the player.
+ ///
+ [LocalSliderSetting(min: 60f, max: 240f, suffixType: MiraNumberSuffixes.None, formatString: "0", displayValue: true, roundValue: true)]
+ public ConfigEntry SetFpsSlider { get; private set; } =
+ config.Bind("Visuals/UI", "Frames Per Seconds", 120f);
+
///
/// Gets whether to apply cosmetic changes to the TaskAdder.
///
diff --git a/MiraAPI/Patches/Accessibility/HudManagerFlashPatches.cs b/MiraAPI/Patches/Accessibility/HudManagerFlashPatches.cs
index e3d3ab4..2fda4c5 100644
--- a/MiraAPI/Patches/Accessibility/HudManagerFlashPatches.cs
+++ b/MiraAPI/Patches/Accessibility/HudManagerFlashPatches.cs
@@ -49,14 +49,18 @@ public static class HudManagerFlashPatches
{
SoundManager.Instance.PlaySound(ShipStatus.Instance.SabotageSound, false, 1f, null);
}
- if (hudManager.lightFlashHandle == null)
- {
- hudManager.lightFlashHandle = DestroyableSingleton.Instance.AllocateLight();
- hudManager.lightFlashHandle.color = new Color(1f, 0f, 0f, 1f);
- hudManager.lightFlashHandle.intensity = 1f;
- }
light = !light;
- hudManager.lightFlashHandle.color.SetAlpha(light ? 1f : 0f);
+
+ /*if (!MiraApiPlugin.IsMobile)
+ {
+ if (hudManager.lightFlashHandle == null)
+ {
+ hudManager.lightFlashHandle = DualshockLightManager.Instance.AllocateLight();
+ hudManager.lightFlashHandle.color = new Color(1f, 0f, 0f, 1f);
+ hudManager.lightFlashHandle.intensity = 1f;
+ }
+ hudManager.lightFlashHandle.color.SetAlpha(light ? 1f : 0f);
+ }*/
yield return wait;
}
}
diff --git a/MiraAPI/Patches/HudManagerPatches.cs b/MiraAPI/Patches/HudManagerPatches.cs
index c5340b2..f46cd53 100644
--- a/MiraAPI/Patches/HudManagerPatches.cs
+++ b/MiraAPI/Patches/HudManagerPatches.cs
@@ -225,9 +225,14 @@ public static class HudManagerPatches
}
var icon = Helpers.CreateKeybindIcon(buttonObj, key, keybindIconPos);
vanillaKeybindIcons.Add(icon.transform.GetChild(0).GetComponent(), actionId);
- var comp = buttonObj.GetComponent();
- KeybindManager.VanillaKeybinds[comp.GetType()].Button = comp;
+ if (!MiraApiPlugin.IsMobile)
+ {
+ var comp = buttonObj.GetComponent();
+ KeybindManager.VanillaKeybinds[comp.GetType()].Button = comp;
+ }
}
+ MiraApiSettings.OldButtonScaleFactor =
+ LocalSettingsTabSingleton.Instance.ButtonUIFactorSlider.Value;
Coroutines.Start(CoResizeUI());
}
diff --git a/MiraAPI/Patches/Menu/MainMenuManagerPatches.cs b/MiraAPI/Patches/Menu/MainMenuManagerPatches.cs
index 6f44ac5..d5a66cf 100644
--- a/MiraAPI/Patches/Menu/MainMenuManagerPatches.cs
+++ b/MiraAPI/Patches/Menu/MainMenuManagerPatches.cs
@@ -1,5 +1,7 @@
using HarmonyLib;
+using MiraAPI.LocalSettings;
using MiraAPI.Utilities.Assets;
+using UnityEngine;
namespace MiraAPI.Patches.Menu;
@@ -17,5 +19,6 @@ public static class MainMenuManagerPatches
public static void AwakePostfix()
{
AddressablesLoader.LoadAll();
+ Application.targetFrameRate = (int)LocalSettingsTabSingleton.Instance.SetFpsSlider.Value;
}
}
diff --git a/MiraAPI/Patches/Options/GameOptionsMenuPatch.cs b/MiraAPI/Patches/Options/GameOptionsMenuPatch.cs
index 218c6a5..fd6704e 100644
--- a/MiraAPI/Patches/Options/GameOptionsMenuPatch.cs
+++ b/MiraAPI/Patches/Options/GameOptionsMenuPatch.cs
@@ -17,6 +17,19 @@ namespace MiraAPI.Patches.Options;
[HarmonyPatch(typeof(GameOptionsMenu))]
internal static class GameOptionsMenuPatch
{
+ [HarmonyPostfix]
+ [HarmonyPatch(nameof(GameOptionsMenu.OnEnable))]
+ public static void OpenPatch(GameOptionsMenu __instance)
+ {
+ HudManager.Instance.PlayerCam.OverrideScreenShakeEnabled = false;
+ }
+ [HarmonyPostfix]
+ [HarmonyPatch(nameof(GameOptionsMenu.OnDisable))]
+ public static void ClosePatch(GameOptionsMenu __instance)
+ {
+ HudManager.Instance.PlayerCam.OverrideScreenShakeEnabled = true;
+ }
+
[HarmonyPostfix]
[HarmonyPatch(nameof(GameOptionsMenu.Update))]
// ReSharper disable once InconsistentNaming
diff --git a/MiraAPI/Patches/Options/RoleSettingMenuPatches.cs b/MiraAPI/Patches/Options/RoleSettingMenuPatches.cs
index 7aa7a61..09530d4 100644
--- a/MiraAPI/Patches/Options/RoleSettingMenuPatches.cs
+++ b/MiraAPI/Patches/Options/RoleSettingMenuPatches.cs
@@ -35,6 +35,19 @@ public static class RoleSettingMenuPatches
private static RoleBehaviour? CurrentRole { get; set; }
private static List? CurrentRoleOptions { get; set; }
+ [HarmonyPostfix]
+ [HarmonyPatch(nameof(RolesSettingsMenu.OnEnable))]
+ public static void OpenPatch(RolesSettingsMenu __instance)
+ {
+ HudManager.Instance.PlayerCam.OverrideScreenShakeEnabled = false;
+ }
+ [HarmonyPostfix]
+ [HarmonyPatch(nameof(RolesSettingsMenu.OnDisable))]
+ public static void ClosePatch(RolesSettingsMenu __instance)
+ {
+ HudManager.Instance.PlayerCam.OverrideScreenShakeEnabled = true;
+ }
+
[HarmonyPostfix]
[HarmonyPatch(nameof(RolesSettingsMenu.SetQuotaTab))]
public static void SetQuotaTabPostfix(RolesSettingsMenu __instance)
diff --git a/MiraAPI/Roles/CustomRoleConfiguration.cs b/MiraAPI/Roles/CustomRoleConfiguration.cs
index de02f57..a11ddc0 100644
--- a/MiraAPI/Roles/CustomRoleConfiguration.cs
+++ b/MiraAPI/Roles/CustomRoleConfiguration.cs
@@ -1,5 +1,6 @@
using AmongUs.GameOptions;
using System;
+using Il2CppInterop.Runtime.Attributes;
using MiraAPI.Patches.Freeplay;
using MiraAPI.Utilities.Assets;
using UnityEngine;
@@ -77,16 +78,19 @@ public record struct CustomRoleConfiguration
///
/// Gets or sets the Sprite used for the Role Options menu screenshot.
///
+ [HideFromIl2Cpp]
public LoadableAsset? OptionsScreenshot { get; set; } = null;
///
/// Gets or sets the Sprite used for the Role Icon.
///
+ [HideFromIl2Cpp]
public LoadableAsset? Icon { get; set; } = null;
///
/// Gets or sets the Intro sound for the Role.
///
+ [HideFromIl2Cpp]
public LoadableAsset? IntroSound { get; set; } = null;
///
diff --git a/MiraAPI/Roles/CustomRoleManager.cs b/MiraAPI/Roles/CustomRoleManager.cs
index 922765e..0bbf4eb 100644
--- a/MiraAPI/Roles/CustomRoleManager.cs
+++ b/MiraAPI/Roles/CustomRoleManager.cs
@@ -89,15 +89,22 @@ public static class CustomRoleManager
foreach (var roleType in roles)
{
- ClassInjector.RegisterTypeInIl2Cpp(roleType);
-
- var role = RegisterRole(roleType, pluginInfo);
- if (role is null)
+ try
{
- continue;
- }
+ ClassInjector.RegisterTypeInIl2Cpp(roleType);
- pluginInfo.InternalRoles.Add((ushort)role.Role, role);
+ var role = RegisterRole(roleType, pluginInfo);
+ if (role is null)
+ {
+ continue;
+ }
+
+ pluginInfo.InternalRoles.Add((ushort)role.Role, role);
+ }
+ catch (Exception ex)
+ {
+ Error($"Failed to register role type {roleType.Name}: {ex}");
+ }
}
pluginInfo.PluginConfig.Save();
diff --git a/MiraAPI/Utilities/Helpers.cs b/MiraAPI/Utilities/Helpers.cs
index c89fc74..b537ef0 100644
--- a/MiraAPI/Utilities/Helpers.cs
+++ b/MiraAPI/Utilities/Helpers.cs
@@ -546,10 +546,6 @@ public static class Helpers
public static bool IsRoleBlacklisted(this RoleBehaviour role)
{
// This should be patchable by mods when a vanilla role is meant to be replaced by a custom role.
- if (role.Role is RoleTypes.Engineer)
- {
- return true;
- }
return false;
}
}