mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-10-19 15:51:48 +00:00
Add Accessibility settings for sabotages
This commit is contained in:
1 parent
2907564d6a
commit
eae0024ec3
6 files changed
+81
-6
No files matched your search
@@ -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; }
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ using MiraAPI.Utilities.Assets;
|
||||
namespace MiraAPI;
|
||||
|
||||
/// <summary>
|
||||
/// Mira API Config File Handler
|
||||
/// Mira API Config File Handler.
|
||||
/// </summary>
|
||||
public class MiraApiSettings(ConfigFile config) : LocalSettingsTab(config)
|
||||
{
|
||||
@@ -39,4 +39,16 @@ public class MiraApiSettings(ConfigFile config) : LocalSettingsTab(config)
|
||||
/// </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,63 @@
|
||||
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);
|
||||
}
|
||||
if (hudManager.lightFlashHandle == null)
|
||||
{
|
||||
hudManager.lightFlashHandle = DestroyableSingleton<DualshockLightManager>.Instance.AllocateLight();
|
||||
hudManager.lightFlashHandle.color = new Color(1f, 0f, 0f, 1f);
|
||||
hudManager.lightFlashHandle.intensity = 1f;
|
||||
}
|
||||
light = !light;
|
||||
hudManager.lightFlashHandle.color.SetAlpha(light ? 1f : 0f);
|
||||
yield return wait;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user