mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-10-20 21:35:49 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
50030c113b | ||
|
|
20e51cc993 | ||
|
|
64b5e01ba1 | ||
|
|
d4469153ab | ||
|
|
ab67c233d8 | ||
|
|
c72eacc7a2 | ||
|
|
13072d6834 | ||
|
|
c6342750ef | ||
|
|
5c2e95376d | ||
|
|
067859b9fd | ||
|
|
fe3bfcdbc4 | ||
|
|
5d01462a32 | ||
|
|
a9b6f40ed0 | ||
|
|
eae0024ec3 | ||
|
|
2907564d6a |
No files matched your search
@@ -8,7 +8,7 @@
|
||||
|
||||
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
|
||||
|
||||
<VersionPrefix>0.3.4</VersionPrefix>
|
||||
<VersionPrefix>0.3.6</VersionPrefix>
|
||||
<VersionSuffix>dev</VersionSuffix>
|
||||
|
||||
<Authors>All Of Us, XtraCube, Angxl</Authors>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Linq;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using MiraAPI.Events;
|
||||
using MiraAPI.Events.Mira;
|
||||
using MiraAPI.Events.Vanilla.Gameplay;
|
||||
@@ -17,7 +18,7 @@ public static class ExampleEventHandlers
|
||||
{
|
||||
public static void Initialize()
|
||||
{
|
||||
// You can register event handlers with the MiraEventManager class.
|
||||
// You can register event handlers with the MiraEventManager class
|
||||
var handle = MiraEventManager.RegisterEventHandler<BeforeMurderEvent>(@event =>
|
||||
{
|
||||
Logger<ExamplePlugin>.Info($"{@event.Source.Data.PlayerName} is about to kill {@event.Target.Data.PlayerName}");
|
||||
@@ -37,6 +38,21 @@ public static class ExampleEventHandlers
|
||||
MiraEventManager.UnregisterEventHandler(handle);
|
||||
}
|
||||
|
||||
// If you want to check vanilla buttons, use something like this!
|
||||
[RegisterEvent]
|
||||
public static void VanillaButtonClickHandler(VanillaButtonClickEvent @event)
|
||||
{
|
||||
Logger<ExamplePlugin>.Info($"{@event.Button.buttonLabelText.text} is being used!");
|
||||
if (@event.PlayerTarget != null)
|
||||
{
|
||||
Logger<ExamplePlugin>.Info($"{@event.PlayerTarget.Data.PlayerName} is being targeted!");
|
||||
}
|
||||
else if (@event.VentTarget != null)
|
||||
{
|
||||
Logger<ExamplePlugin>.Info($"Vent with id {@event.VentTarget.Id.ToString(CultureInfo.InvariantCulture)} is being targeted!");
|
||||
}
|
||||
}
|
||||
|
||||
// If you want to add extra votes to a player, do something like this.
|
||||
[RegisterEvent]
|
||||
public static void StartMeetingEvent(StartMeetingEvent _)
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
using MiraAPI.Hud;
|
||||
|
||||
namespace MiraAPI.Events.Vanilla.Gameplay;
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when a Vanilla Button click is cancelled. Do not use for custom buttons.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The Vanilla Button type.</typeparam>
|
||||
public sealed class VanillaButtonCancelledEvent<T> : MiraEvent where T : AbilityButton
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets Vanilla Button whose click was cancelled.
|
||||
/// </summary>
|
||||
public T Button { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="VanillaButtonCancelledEvent{T}"/> class.
|
||||
/// </summary>
|
||||
/// <param name="button">The Mira Button whose click was cancelled.</param>
|
||||
public VanillaButtonCancelledEvent(T button)
|
||||
{
|
||||
Button = button;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when a Vanilla Button click is cancelled. Do not use for custom buttons.
|
||||
/// </summary>
|
||||
public sealed class VanillaButtonCancelledEvent : MiraEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets Vanilla Button whose click was cancelled.
|
||||
/// </summary>
|
||||
public AbilityButton Button { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="VanillaButtonCancelledEvent"/> class.
|
||||
/// </summary>
|
||||
/// <param name="button">The Vanilla Button whose click was cancelled.</param>
|
||||
public VanillaButtonCancelledEvent(AbilityButton button)
|
||||
{
|
||||
Button = button;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
using MiraAPI.Hud;
|
||||
|
||||
namespace MiraAPI.Events.Vanilla.Gameplay;
|
||||
|
||||
/// <summary>
|
||||
/// Button click event for Vanilla Buttons only. Do not use for custom buttons.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The Vanilla Button type.</typeparam>
|
||||
public sealed class VanillaButtonClickEvent<T> : MiraCancelableEvent where T : AbilityButton
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets Vanilla Button that was clicked.
|
||||
/// </summary>
|
||||
public T Button { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the generic click event that is invoked before this button-specific event.
|
||||
/// </summary>
|
||||
public VanillaButtonClickEvent GenericClickEvent { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="VanillaButtonClickEvent{T}"/> class.
|
||||
/// </summary>
|
||||
/// <param name="button">The Mira Button that was clicked.</param>
|
||||
/// <param name="genericClickEvent">The generic click event invoked before button-specific events.</param>
|
||||
public VanillaButtonClickEvent(T button, VanillaButtonClickEvent genericClickEvent)
|
||||
{
|
||||
GenericClickEvent = genericClickEvent;
|
||||
Button = button;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Button click event for Vanilla Buttons only. Do not use for custom buttons.
|
||||
/// </summary>
|
||||
public sealed class VanillaButtonClickEvent : MiraCancelableEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets Vanilla Button that was clicked.
|
||||
/// </summary>
|
||||
public AbilityButton Button { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the target player, if any, of the Vanilla Button that was clicked.
|
||||
/// </summary>
|
||||
public PlayerControl? PlayerTarget { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the target vent, if any, of the Vanilla Button that was clicked.
|
||||
/// </summary>
|
||||
public Vent? VentTarget { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="VanillaButtonClickEvent"/> class.
|
||||
/// </summary>
|
||||
/// <param name="button">The Vanilla Button that was clicked.</param>
|
||||
/// <param name="playerTarget">The Player target, if any.</param>
|
||||
/// <param name="ventTarget">The Vent target, if any.</param>
|
||||
public VanillaButtonClickEvent(AbilityButton button, PlayerControl? playerTarget = null, Vent? ventTarget = null)
|
||||
{
|
||||
Button = button;
|
||||
PlayerTarget = playerTarget;
|
||||
VentTarget = ventTarget;
|
||||
}
|
||||
}
|
||||
@@ -69,4 +69,4 @@ public class BaseKeybind
|
||||
{
|
||||
Handler -= action;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ namespace MiraAPI.Keybinds;
|
||||
public class MiraKeybind : BaseKeybind
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets name of the keybind
|
||||
/// Gets name of the keybind.
|
||||
/// </summary>
|
||||
public string Name { get; }
|
||||
|
||||
|
||||
@@ -21,6 +21,11 @@ namespace MiraAPI;
|
||||
[ReactorModFlags(ModFlags.RequireOnAllClients)]
|
||||
public partial class MiraApiPlugin : BasePlugin
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets whether the current device is running Starlight (on mobile).
|
||||
/// </summary>
|
||||
public static bool IsMobile => Constants.GetPlatformType() is Platforms.Android or Platforms.IPhone;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the branding Mira API color.
|
||||
/// </summary>
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
using BepInEx.Configuration;
|
||||
using MiraAPI.LocalSettings;
|
||||
using MiraAPI.LocalSettings.Attributes;
|
||||
using MiraAPI.Patches;
|
||||
using MiraAPI.Utilities;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MiraAPI;
|
||||
|
||||
/// <summary>
|
||||
/// Mira API Config File Handler
|
||||
/// Mira API Config File Handler.
|
||||
/// </summary>
|
||||
public class MiraApiSettings(ConfigFile config) : LocalSettingsTab(config)
|
||||
{
|
||||
@@ -21,22 +24,78 @@ public class MiraApiSettings(ConfigFile config) : LocalSettingsTab(config)
|
||||
HideIconOnHover = false,
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value stored for scaling buttons properly.
|
||||
/// </summary>
|
||||
public static float OldButtonScaleFactor { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Open()
|
||||
{
|
||||
base.Open();
|
||||
OldButtonScaleFactor = ButtonUIFactorSlider.Value;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnOptionChanged(ConfigEntryBase configEntry)
|
||||
{
|
||||
base.OnOptionChanged(configEntry);
|
||||
if (configEntry == ButtonUIFactorSlider)
|
||||
{
|
||||
if (HudManager.InstanceExists)
|
||||
{
|
||||
HudManagerPatches.ResizeUI(1f / OldButtonScaleFactor);
|
||||
HudManagerPatches.ResizeUI(ButtonUIFactorSlider.Value);
|
||||
}
|
||||
OldButtonScaleFactor = ButtonUIFactorSlider.Value;
|
||||
}
|
||||
else if (configEntry == SetFpsSlider)
|
||||
{
|
||||
Application.targetFrameRate = (int)SetFpsSlider.Value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether the modifiers hud should be on the left side of the screen (under roles/task tab). Recommended for streamers.
|
||||
/// </summary>
|
||||
[LocalToggleSetting]
|
||||
public ConfigEntry<bool> ModifiersHudLeftSide { get; private set; } = config.Bind("Displays", "Show Modifiers HUD on Left Side", false);
|
||||
public ConfigEntry<bool> ModifiersHudLeftSide { get; private set; } = config.Bind("Visuals/UI", "Show Modifiers HUD on Left Side", false);
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether to show keybinds on buttons.
|
||||
/// </summary>
|
||||
[LocalToggleSetting]
|
||||
public ConfigEntry<bool> ShowKeybinds { get; private set; } = config.Bind("Keybinds", "Show Keybinds on Buttons", true);
|
||||
// This would be placed in the keybinds menu, but it crashes for Epic Games users. - Atony
|
||||
public ConfigEntry<bool> ShowKeybinds { get; private set; } = config.Bind("Visuals/UI", "Show Keybinds on Buttons", true);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the scale of the buttons.
|
||||
/// </summary>
|
||||
[LocalSliderSetting(min: 0.5f, max: 1.5f, suffixType: MiraNumberSuffixes.Multiplier, formatString: "0.00", displayValue: true)]
|
||||
public ConfigEntry<float> ButtonUIFactorSlider { get; private set; } =
|
||||
config.Bind("Visuals/UI", "Button Scale Factor", 0.75f);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the fps specified by the player.
|
||||
/// </summary>
|
||||
[LocalSliderSetting(min: 60f, max: 240f, suffixType: MiraNumberSuffixes.None, formatString: "0", displayValue: true, roundValue: true)]
|
||||
public ConfigEntry<float> SetFpsSlider { get; private set; } =
|
||||
config.Bind("Visuals/UI", "Frames Per Seconds", 120f);
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether to apply cosmetic changes to the TaskAdder.
|
||||
/// </summary>
|
||||
[LocalToggleSetting]
|
||||
public ConfigEntry<bool> PrettyTaskAdder { get; private set; } = config.Bind("Freeplay", "Pretty Task Laptop", true);
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether to show the red flash from sabotages.
|
||||
/// </summary>
|
||||
[LocalToggleSetting]
|
||||
public ConfigEntry<bool> EnableSabotageFlashes { get; private set; } = config.Bind("Accessibility", "Enable Sabotage Flashes", true);
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether to enable the sabotage sound effects or not.
|
||||
/// </summary>
|
||||
[LocalToggleSetting]
|
||||
public ConfigEntry<bool> EnableSabotageBlares { get; private set; } = config.Bind("Accessibility", "Enable Sabotage Blare", true);
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
using System.Collections;
|
||||
using BepInEx.Unity.IL2CPP.Utils.Collections;
|
||||
using HarmonyLib;
|
||||
using MiraAPI.LocalSettings;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MiraAPI.Patches.Accessibility;
|
||||
[HarmonyPatch]
|
||||
public static class HudManagerFlashPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(HudManager), nameof(HudManager.StartReactorFlash))]
|
||||
[HarmonyPrefix]
|
||||
public static bool ReactorFlashPrefix(HudManager __instance)
|
||||
{
|
||||
if (__instance.ReactorFlash == null)
|
||||
{
|
||||
__instance.ReactorFlash = __instance.StartCoroutine(CoReactorFlash().WrapToIl2Cpp());
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
[HarmonyPatch(typeof(HudManager), nameof(HudManager.StartOxyFlash))]
|
||||
[HarmonyPrefix]
|
||||
public static bool OxygenFlashPrefix(HudManager __instance)
|
||||
{
|
||||
if (__instance.OxyFlash == null)
|
||||
{
|
||||
__instance.OxyFlash = __instance.StartCoroutine(CoReactorFlash().WrapToIl2Cpp());
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
public static IEnumerator CoReactorFlash()
|
||||
{
|
||||
if (!HudManager.InstanceExists)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
var hudManager = HudManager.Instance;
|
||||
WaitForSeconds wait = new WaitForSeconds(1f);
|
||||
bool light = false;
|
||||
|
||||
hudManager.FullScreen.color = new Color(1f, 0f, 0f, 0.37254903f);
|
||||
while (true)
|
||||
{
|
||||
var settins = LocalSettingsTabSingleton<MiraApiSettings>.Instance;
|
||||
hudManager.FullScreen.gameObject.SetActive(settins.EnableSabotageFlashes.Value && !hudManager.FullScreen.gameObject.activeSelf);
|
||||
if (settins.EnableSabotageBlares.Value)
|
||||
{
|
||||
SoundManager.Instance.PlaySound(ShipStatus.Instance.SabotageSound, false, 1f, null);
|
||||
}
|
||||
light = !light;
|
||||
|
||||
/*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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
using System.Linq;
|
||||
using AmongUs.GameOptions;
|
||||
using HarmonyLib;
|
||||
using MiraAPI.Events;
|
||||
using MiraAPI.Events.Vanilla.Gameplay;
|
||||
using MiraAPI.Events.Vanilla.Usables;
|
||||
|
||||
namespace MiraAPI.Patches.Events;
|
||||
|
||||
/// <summary>
|
||||
/// Patches to invoke vent related MiraEvents.
|
||||
/// </summary>
|
||||
[HarmonyPatch]
|
||||
public static class VanillaButtonPatches
|
||||
{
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(AbilityButton), nameof(AbilityButton.DoClick))]
|
||||
public static bool DoClickPrefix(AbilityButton __instance)
|
||||
{
|
||||
// Invoke the generic button click event.
|
||||
PlayerControl? playerTarget = null;
|
||||
Vent? ventTarget = null;
|
||||
var role = PlayerControl.LocalPlayer.Data.Role;
|
||||
if (role.Role is RoleTypes.Tracker)
|
||||
{
|
||||
playerTarget = role.Cast<TrackerRole>().currentTarget;
|
||||
}
|
||||
else if (role.Role is RoleTypes.GuardianAngel)
|
||||
{
|
||||
playerTarget = role.Cast<GuardianAngelRole>().currentTarget;
|
||||
}
|
||||
else if (role.Role is RoleTypes.Engineer)
|
||||
{
|
||||
ventTarget = role.Cast<EngineerRole>().currentTarget;
|
||||
}
|
||||
var genericEvent = new VanillaButtonClickEvent(__instance, playerTarget, ventTarget);
|
||||
MiraEventManager.InvokeEvent(genericEvent);
|
||||
if (genericEvent.IsCancelled)
|
||||
{
|
||||
MiraEventManager.InvokeEvent(new VanillaButtonCancelledEvent(__instance));
|
||||
}
|
||||
|
||||
if (!genericEvent.IsCancelled)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(SecondaryAbilityButton), nameof(SecondaryAbilityButton.DoClick))]
|
||||
public static bool SecondaryDoClickPrefix(AbilityButton __instance)
|
||||
{
|
||||
// Invoke the generic button click event.
|
||||
PlayerControl? playerTarget = null;
|
||||
var role = PlayerControl.LocalPlayer.Data.Role;
|
||||
if (role.Role is RoleTypes.Detective)
|
||||
{
|
||||
playerTarget = role.Cast<DetectiveRole>().currentTarget;
|
||||
}
|
||||
var genericEvent = new VanillaButtonClickEvent(__instance, playerTarget);
|
||||
MiraEventManager.InvokeEvent(genericEvent);
|
||||
if (genericEvent.IsCancelled)
|
||||
{
|
||||
MiraEventManager.InvokeEvent(new VanillaButtonCancelledEvent(__instance));
|
||||
}
|
||||
|
||||
if (!genericEvent.IsCancelled)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using HarmonyLib;
|
||||
using MiraAPI.Hud;
|
||||
@@ -29,6 +30,84 @@ public static class HudManagerPatches
|
||||
|
||||
internal static List<TextMeshPro> ModdedKeybindIcons = new();
|
||||
|
||||
public static IEnumerator CoResizeUI()
|
||||
{
|
||||
while (!HudManager.Instance)
|
||||
{
|
||||
yield return null;
|
||||
}
|
||||
|
||||
yield return new WaitForSeconds(0.01f);
|
||||
ResizeUI(LocalSettingsTabSingleton<MiraApiSettings>.Instance.ButtonUIFactorSlider.Value);
|
||||
}
|
||||
|
||||
public static void ResizeUI(float scaleFactor)
|
||||
{
|
||||
var baseButtons = HudManager.Instance.transform.FindChild("Buttons");
|
||||
if (baseButtons != null)
|
||||
{
|
||||
foreach (var aspect in baseButtons.GetComponentsInChildren<AspectPosition>(true))
|
||||
{
|
||||
if (aspect.gameObject == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (aspect.gameObject.transform.parent.name == "TopRight")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (aspect.gameObject.transform.parent.transform.parent.name == "TopRight")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
aspect.gameObject.SetActive(!aspect.isActiveAndEnabled);
|
||||
aspect.DistanceFromEdge *= new Vector2(scaleFactor, scaleFactor);
|
||||
aspect.gameObject.SetActive(!aspect.isActiveAndEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var button in HudManager.Instance.GetComponentsInChildren<ActionButton>(true))
|
||||
{
|
||||
if (button.gameObject == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
button.gameObject.SetActive(!button.isActiveAndEnabled);
|
||||
button.gameObject.transform.localScale *= scaleFactor;
|
||||
button.gameObject.SetActive(!button.isActiveAndEnabled);
|
||||
}
|
||||
|
||||
if (baseButtons != null)
|
||||
{
|
||||
foreach (var arrange in baseButtons.GetComponentsInChildren<GridArrange>(true))
|
||||
{
|
||||
if (!arrange.gameObject || !arrange.transform)
|
||||
{
|
||||
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)
|
||||
{
|
||||
try
|
||||
{
|
||||
arrange.ArrangeChilds();
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Error($"Error arranging child objects in GridArrange: {e}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
/// <summary>
|
||||
/// Trigger hudstart on current custom gamemode
|
||||
@@ -146,9 +225,15 @@ public static class HudManagerPatches
|
||||
}
|
||||
var icon = Helpers.CreateKeybindIcon(buttonObj, key, keybindIconPos);
|
||||
vanillaKeybindIcons.Add(icon.transform.GetChild(0).GetComponent<TextMeshPro>(), actionId);
|
||||
var comp = buttonObj.GetComponent<ActionButton>();
|
||||
KeybindManager.VanillaKeybinds[comp.GetType()].Button = comp;
|
||||
if (!MiraApiPlugin.IsMobile)
|
||||
{
|
||||
var comp = buttonObj.GetComponent<ActionButton>();
|
||||
KeybindManager.VanillaKeybinds[comp.GetType()].Button = comp;
|
||||
}
|
||||
}
|
||||
MiraApiSettings.OldButtonScaleFactor =
|
||||
LocalSettingsTabSingleton<MiraApiSettings>.Instance.ButtonUIFactorSlider.Value;
|
||||
Coroutines.Start(CoResizeUI());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -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<MiraApiSettings>.Instance.SetFpsSlider.Value;
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -35,6 +35,19 @@ public static class RoleSettingMenuPatches
|
||||
private static RoleBehaviour? CurrentRole { get; set; }
|
||||
private static List<IModdedOption>? 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)
|
||||
|
||||
@@ -39,7 +39,7 @@ public static class LogicRoleSelectionHnsPatch
|
||||
foreach (RoleManager.RoleAssignmentData roleAssignmentData in guaranteedRoles.Select((x) =>
|
||||
new RoleManager.RoleAssignmentData(x, roleOptions.GetNumPerGame(x.Role), 100)))
|
||||
{
|
||||
for (;;)
|
||||
while (true)
|
||||
{
|
||||
RoleManager.RoleAssignmentData roleAssignmentData2 = roleAssignmentData;
|
||||
int count = roleAssignmentData2.Count;
|
||||
@@ -122,7 +122,7 @@ public static class LogicRoleSelectionHnsPatch
|
||||
foreach (RoleManager.RoleAssignmentData roleAssignmentData in guaranteedRoles.Select((x) =>
|
||||
new RoleManager.RoleAssignmentData(x, roleOptions.GetNumPerGame(x.Role), 100)))
|
||||
{
|
||||
for (;;)
|
||||
while (true)
|
||||
{
|
||||
RoleManager.RoleAssignmentData roleAssignmentData2 = roleAssignmentData;
|
||||
int count = roleAssignmentData2.Count;
|
||||
|
||||
@@ -36,7 +36,7 @@ public static class LogicRoleSelectionNormalPatch
|
||||
foreach (RoleManager.RoleAssignmentData roleAssignmentData in guaranteedRoles.Select((x) =>
|
||||
new RoleManager.RoleAssignmentData(x, roleOptions.GetNumPerGame(x.Role), 100)))
|
||||
{
|
||||
for (;;)
|
||||
while (true)
|
||||
{
|
||||
RoleManager.RoleAssignmentData roleAssignmentData2 = roleAssignmentData;
|
||||
int count = roleAssignmentData2.Count;
|
||||
|
||||
@@ -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
|
||||
/// <summary>
|
||||
/// Gets or sets the Sprite used for the Role Options menu screenshot.
|
||||
/// </summary>
|
||||
[HideFromIl2Cpp]
|
||||
public LoadableAsset<Sprite>? OptionsScreenshot { get; set; } = null;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Sprite used for the Role Icon.
|
||||
/// </summary>
|
||||
[HideFromIl2Cpp]
|
||||
public LoadableAsset<Sprite>? Icon { get; set; } = null;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Intro sound for the Role.
|
||||
/// </summary>
|
||||
[HideFromIl2Cpp]
|
||||
public LoadableAsset<AudioClip>? IntroSound { get; set; } = null;
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user