Compare commits

..
Author SHA1 Message Date
Atony e901abfc60 Merge branch 'dev' into dev-update 2026-08-24 15:49:12 -05:00
Atony 853a94681a Merge pull request #17 from All-Of-Us-Mods/game-modes
Game modes
2026-08-24 15:41:24 -05:00
Atony f230cff5e5 Add RoleMedDescription for the role guide 2026-08-19 23:28:00 -05:00
Atony 7c7d184d1f Wip faction display for roles
These need to be their own text object later.
2026-08-19 17:24:54 -05:00
Atony 6b923cfe01 Show nameplate on player list menu 2026-08-19 17:10:41 -05:00
Atony 247c765176 Fix bad ui because sloth sucx 2026-08-19 15:56:13 -05:00
Atony a3668b3150 Add proper support for modded roles in wiki 2026-08-19 13:52:33 -05:00
Atony aa4dd24ac3 Change options to V11 2026-08-19 13:31:36 -05:00
Atony cb0afe3095 Add ui resizing + wiki in the lobby 2026-08-19 13:29:03 -05:00
Atony 883222be82 Merge branch 'dev-update' into game-modes 2026-08-19 00:18:25 -05:00
Atony 6b774500dd Fix reimplemented Judge for good 2026-08-18 23:07:39 -05:00
Atony f96f75cea1 Fix issues with Judge and new meeting changes 2026-08-18 15:10:11 -05:00
Atony 75662a6c25 Improve vent checks 2026-08-17 17:47:33 -05:00
Atony 73e4506016 Fix role tab issue 2026-08-17 17:41:24 -05:00
Atony a491592669 Allow gamemodes to be hidden when registered 2026-08-16 23:01:58 -05:00
Atony 01fef0f747 Fix vanilla advanced role settings tab breaking 2026-08-16 22:36:57 -05:00
Atony e22f4daf3e Fix the first role option being duped in the menu 2026-08-16 22:00:24 -05:00
Atony b83cb5cc29 Force role menu to be refreshed on gamemode change 2026-08-16 21:56:48 -05:00
Atony fb164a54e3 Fix broken game options tab for mods 2026-08-16 20:05:30 -05:00
Atony b6475161f1 Merge branch 'dev' into game-modes 2026-08-16 17:03:11 -05:00
Atony 411340d9e9 Fix role screenshots for combined spritesheets 2026-08-15 16:27:49 -05:00
Atony 57d2a6a9b5 Expose button event types 2026-08-15 16:00:05 -05:00
Atony 6f61a75bb7 Add BundleSubAssetHolder for packed spritesheets 2026-08-15 13:18:05 -05:00
36 changed files with 1158 additions and 87 deletions

No files matched your search

+1 -1
View File
@@ -2,7 +2,7 @@
<ItemGroup>
<PackageReference Include="Reactor" Version="2.5.0-ci.371" />
<PackageReference Include="BepInEx.Unity.IL2CPP" Version="6.0.0-be.735" Private="false" ExcludeAssets="runtime;native" />
<PackageReference Include="AmongUs.GameLibs.Steam" Version="2026.6.5" PrivateAssets="all" />
<PackageReference Include="AmongUs.GameLibs.Steam" Version="2026.8.18" PrivateAssets="all" />
<PackageReference Include="BepInEx.AutoPlugin" Version="1.1.0" PrivateAssets="all" />
<PackageReference Include="BepInEx.IL2CPP.MSBuild" Version="2.1.0-rc.1" PrivateAssets="all" ExcludeAssets="runtime" />
+2 -2
View File
@@ -6,7 +6,7 @@ namespace MiraAPI.Events.Mira;
/// Button click event for <see cref="CustomActionButton"/>s only. Do not use for vanilla <see cref="AbilityButton"/>s.
/// </summary>
/// <typeparam name="T">The <see cref="CustomActionButton"/> type.</typeparam>
public sealed class MiraButtonClickEvent<T> : MiraCancelableEvent where T : CustomActionButton
public class MiraButtonClickEvent<T> : MiraCancelableEvent where T : CustomActionButton
{
/// <summary>
/// Gets the <see cref="CustomActionButton"/> that was clicked.
@@ -33,7 +33,7 @@ public sealed class MiraButtonClickEvent<T> : MiraCancelableEvent where T : Cust
/// <summary>
/// Button click event for <see cref="CustomActionButton"/>s only. Do not use for vanilla <see cref="AbilityButton"/>s.
/// </summary>
public sealed class MiraButtonClickEvent : MiraCancelableEvent
public class MiraButtonClickEvent : MiraCancelableEvent
{
/// <summary>
/// Gets the <see cref="CustomActionButton"/> that was clicked.
@@ -34,6 +34,11 @@ public class HandleVoteEvent : MiraCancelableEvent
/// </summary>
public NetworkedPlayerInfo TargetPlayerInfo { get; }
/// <summary>
/// Gets or sets a value indicating whether the vote event is an Overrule caused by a Judge.
/// </summary>
public bool IsOverruling { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="HandleVoteEvent"/> class.
/// </summary>
@@ -47,4 +52,20 @@ public class HandleVoteEvent : MiraCancelableEvent
PreventVote = false;
TargetPlayerInfo = GameData.Instance.GetPlayerById(targetId);
}
/// <summary>
/// Initializes a new instance of the <see cref="HandleVoteEvent"/> class.
/// </summary>
/// <param name="playerVoteData">The voter's <see cref="PlayerVoteData"/>.</param>
/// <param name="targetId">The target's playerId.</param>
/// <param name="isOverruling">Whether the vote is actually for a Judge.</param>
public HandleVoteEvent(PlayerVoteData playerVoteData, byte targetId, bool isOverruling)
{
VoteData = playerVoteData;
Player = playerVoteData.Owner;
TargetId = targetId;
PreventVote = false;
IsOverruling = isOverruling;
TargetPlayerInfo = GameData.Instance.GetPlayerById(targetId);
}
}
@@ -33,6 +33,16 @@ public class ProcessVotesEvent(List<CustomVote> votes, NetworkedPlayerInfo? exil
/// </summary>
public List<CustomVote> Votes { get; } = votes;
/// <summary>
/// Gets or sets a value indicating whether an overruling was done. Normally set by judge but can be overwritten.
/// </summary>
public bool OverruledVote { get; set; }
/// <summary>
/// Gets or sets a value specifically to determine which Judge (if any) caused the overruling. Normally set by judge but can be overwritten.
/// </summary>
public ushort OverruledNonce { get; set; }
/// <summary>
/// Gets or sets the player to be exiled. Will be <see langword="null"/> if no player is to be exiled.
/// </summary>
+5
View File
@@ -21,6 +21,11 @@ public abstract class AbstractGameMode : IOptionable
/// </summary>
public abstract string Name { get; }
/// <summary>
/// Gets a value indicating whether the mode is visible in the menu. Only checked at startup.
/// </summary>
public virtual bool HideMode => false;
/// <summary>
/// Gets the game mode description.
/// </summary>
+9 -8
View File
@@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using MiraAPI.PluginLoading;
using MiraAPI.Utilities.Assets;
using Reactor.Utilities;
namespace MiraAPI.GameModes;
@@ -40,10 +39,13 @@ public static class CustomGameModeManager
return false;
}
IdToModeMap.Add(GetNextId(), mode);
pluginInfo.GameModes.Add(LastId, mode);
mode.ID = LastId;
GameModeOption.AddOption(mode);
if (!mode.HideMode)
{
IdToModeMap.Add(GetNextId(), mode);
pluginInfo.GameModes.Add(LastId, mode);
mode.ID = LastId;
GameModeOption.AddOption(mode);
}
return true;
}
@@ -95,10 +97,9 @@ public static class CustomGameModeManager
// no need to add to game mode option as it already contains it
// because we cannot have the option be created with no values
defaultMode.ID = 0;
// TODO: Once Hide n Seek port is ready for release, we will remove this case.
if (MiraApiPlugin.IsDevBuild)
var hnsMode = new HideAndSeekMode();
if (!hnsMode.HideMode)
{
var hnsMode = new HideAndSeekMode();
IdToModeMap.Add(1, hnsMode);
hnsMode.ID = 1;
GameModeOption.AddOption(hnsMode);
+19 -7
View File
@@ -109,16 +109,28 @@ public static class GameModeOption
internal static void Set(int val)
{
Value = val;
var previousMode = CustomGameModeManager.ActiveMode;
CustomGameModeManager.GetAndSetGameMode();
HudPatches.SetGameModeText(CustomGameModeManager.GetMode(Values.ElementAt(_lastValue).Key).ColoredName);
var gm = CustomGameModeManager.ActiveMode!;
ModdedOptionsManager.AddSettingsChangeMessage(
HudManager.Instance.Notifier,
GamemodeName,
gm.ColoredName,
new Color(0.7333f, 0.7333f, 0.7333f, 1),
gm.TmpIcon,
true);
if (gm != previousMode)
{
ModdedOptionsManager.AddSettingsChangeMessage(
HudManager.Instance.Notifier,
GamemodeName,
gm.ColoredName,
new Color(0.7333f, 0.7333f, 0.7333f, 1),
gm.TmpIcon,
true);
if (MenuState.Instance)
{
// should force reset roles for gamemodes properly
foreach (var roleMenu in MenuState.Instance.QueuedRoleMenuRefresh)
{
MenuState.Instance.QueuedRoleMenuRefresh[roleMenu.Key] = true;
}
}
}
// could make Values a dict of AbstractGameMode too
}
+3
View File
@@ -30,6 +30,9 @@ public class HideAndSeekMode : AbstractGameMode
/// <inheritdoc/>
public override string Description => "You can run, but you can't hide!\nOutlive the timer or eliminate the crew.";
// TODO: Once the Hide n Seek port is ready for release, we will remove this.
public override bool HideMode => !MiraApiPlugin.IsDevBuild;
public override Color Color { get; } = new Color32(255, 88, 90, 255);
public override LoadableAsset<Sprite>? Icon => MiraAssets.HnSGamemodeIcon;
public override bool CanReport(DeadBody body) => false;
+14
View File
@@ -17,6 +17,20 @@ public static class CustomButtonManager
/// </summary>
public static ReadOnlyCollection<CustomActionButton> Buttons { get; internal set; } = new([]);
/// <summary>
/// Gets a list of all registered button-specific <see cref="MiraButtonClickEvent"/>s.
/// </summary>
public static ReadOnlyDictionary<Type, Type> EventTypes { get; internal set; } = new(
new Dictionary<Type, Type>
{ });
/// <summary>
/// Gets a list of all registered button-specific <see cref="MiraButtonCancelledEvent"/>s.
/// </summary>
public static ReadOnlyDictionary<Type, Type> CancelledEventTypes { get; internal set; } = new(
new Dictionary<Type, Type>
{ });
internal static readonly List<CustomActionButton> CustomButtons = [];
internal static readonly Dictionary<Type, Type> ButtonEventTypes = [];
internal static readonly Dictionary<Type, Type> ButtonCancelledEventTypes = [];
+203
View File
@@ -0,0 +1,203 @@
using BepInEx.Unity.IL2CPP.Utils.Collections;
using InnerNet;
using MiraAPI.LocalSettings;
using MiraAPI.Modifiers.ModifierDisplay;
using Reactor.Utilities.Attributes;
using Reactor.Utilities.Extensions;
using UnityEngine;
namespace MiraAPI.Hud;
[RegisterInIl2Cpp]
public sealed class MiraHudHelper(nint cppPtr) : MonoBehaviour(cppPtr)
{
public static MiraHudHelper Instance { get; private set; }
public static GameObject ModifierDisplayObject;
public static GameObject VanillaMatchInfoButton;
public static bool ModifierDisplayOnRight;
public static GameObject ClonedChatButton;
public static GameObject ExtraUiTopRight;
public static GridArrange ExtraUiGrid;
public static AspectPosition ExtraUiAspectPos;
public static GameObject UiTopRight;
public static GridArrange UiGrid;
public static AspectPosition UiAspectPos;
public static GameObject SubmergedFloorButton;
public static SpriteRenderer SubmergedFloorButtonRenderer;
public static SpriteRenderer SubmergedFloorButtonRendererHover;
public void Awake()
{
Instance = this;
}
public void Start()
{
MiraApiSettings.OldButtonScaleFactor =
LocalSettingsTabSingleton<MiraApiSettings>.Instance.TopRightButtonsFactorSlider.Value;
StartCoroutine(MiraApiSettings.CoResizeSettingsUI().WrapToIl2Cpp());
}
#pragma warning disable S2325
#pragma warning disable CA1822
public void FixedUpdate()
{
if (!HudManager.InstanceExists || !PlayerControl.LocalPlayer || !PlayerControl.LocalPlayer.Data)
{
return;
}
var instance = HudManager.Instance;
CreateUiRow(instance);
CreateNewUiRow(instance);
AdjustModifierTab();
if (!PlayerControl.LocalPlayer || !PlayerControl.LocalPlayer.Data || !PlayerControl.LocalPlayer.Data.Role ||
!ShipStatus.Instance ||
(AmongUsClient.Instance.GameState != InnerNetClient.GameStates.Started &&
!TutorialManager.InstanceExists))
{
return;
}
UpdateSubmergedButtons(instance);
}
#pragma warning restore CA1822
#pragma warning restore S2325
public static Vector3 BelowOptionPos = new(0.435f, 1.25f, 0f);
public static Vector3 FullTopPos = new(0.435f, 0.475f, 0f);
public static void CreateUiRow(HudManager instance)
{
if (!UiTopRight)
{
UiTopRight = instance.MapButton.transform.parent.gameObject;
UiGrid = UiTopRight.AddComponent<GridArrange>();
UiAspectPos = UiTopRight.AddComponent<AspectPosition>();
UiGrid.Alignment = GridArrange.StartAlign.Left;
UiGrid.CellSize = new Vector2(0.85f, 0.85f);
UiGrid.MaxColumns = 6;
UiAspectPos.Alignment = AspectPosition.EdgeAlignments.RightTop;
UiGrid.Start();
UiAspectPos.DistanceFromEdge = FullTopPos;
var mapButton = instance.MapButton.gameObject;
mapButton.GetComponent<AspectPosition>().Destroy();
var settingsButton = instance.SettingsButton;
settingsButton.GetComponent<AspectPosition>().Destroy();
VanillaMatchInfoButton = instance.MatchInfoButton.gameObject;
VanillaMatchInfoButton.GetComponent<AspectPosition>().Destroy();
var oldPos = settingsButton.transform.localPosition;
settingsButton.transform.localPosition = new Vector3(oldPos.x, oldPos.y, -100);
var chatButton = instance.Chat.chatButton.gameObject;
ClonedChatButton = Object.Instantiate(chatButton, chatButton.transform.parent);
ClonedChatButton.SetActive(false);
instance.Chat.chatButtonAspectPosition = ClonedChatButton.GetComponent<AspectPosition>();
chatButton.GetComponent<AspectPosition>().Destroy();
var inactivePos = settingsButton.transform.GetChild(1).transform.localPosition;
var bg = settingsButton.transform.GetChild(2).gameObject;
var bgPos = bg.transform.localPosition;
var bgSprite = bg.GetComponent<SpriteRenderer>().sprite;
var activePos = settingsButton.transform.GetChild(3).transform.localPosition;
var selectedPos = settingsButton.transform.GetChild(4).transform.localPosition;
chatButton.transform.GetChild(2).transform.localPosition = inactivePos;
var chatBg = chatButton.transform.GetChild(3);
chatBg.transform.localPosition = bgPos;
chatBg.GetComponent<SpriteRenderer>().sprite = bgSprite;
chatButton.transform.GetChild(4).transform.localPosition = activePos;
chatButton.transform.GetChild(5).transform.localPosition = selectedPos;
var collider = chatButton.GetComponent<BoxCollider2D>();
collider.size = new Vector2(0.4354f, 0.4003f);
collider.offset = new Vector2(0.0025f, 0.0254f);
if (FriendsListManager.InstanceExists && !TutorialManager.InstanceExists)
{
var listButton = FriendsListManager.Instance.FriendsListButton.transform.GetChild(0);
listButton.transform.SetParent(UiTopRight.transform, false);
FriendsListManager.Instance.FriendsListButton = listButton.GetComponent<FriendsListButton>();
listButton.GetComponent<AspectPosition>().Destroy();
listButton.localPosition = new Vector3(0, 0, 0);
}
settingsButton.transform.SetAsLastSibling();
chatButton.transform.SetParent(UiTopRight.transform, false);
instance.Chat.chatButton = chatButton.GetComponent<PassiveButton>();
var iconContainer = new GameObject("iconContainer")
{
layer = LayerMask.NameToLayer("UI"),
};
iconContainer.transform.SetParent(chatButton.transform, false);
iconContainer.transform.localPosition = new Vector3(0.1f, -0.1f, 0);
instance.Chat.chatNotifyDot.transform.SetParent(iconContainer.transform, false);
instance.Chat.chatNotifyDot = iconContainer.transform.GetChild(0).GetComponent<SpriteRenderer>();
}
if (UiTopRight && UiGrid)
{
var isChatButtonVisible = HudManager.Instance.Chat.isActiveAndEnabled;
instance.Chat.chatButton.gameObject.SetActive(isChatButtonVisible);
if (VanillaMatchInfoButton)
{
VanillaMatchInfoButton.SetActive(!GameSettingMenu.Instance && !Minigame.Instance);
}
}
}
public static void UpdateSubmergedButtons(HudManager instance)
{
if (ModCompatibility.IsSubmerged() && !SubmergedFloorButton && ExtraUiTopRight)
{
if (!SubmergedFloorButton && ExtraUiTopRight)
{
var transform = instance.MapButton.transform.parent.Find(instance.MapButton.name + "(Clone)");
if (transform != null)
{
SubmergedFloorButton = transform.gameObject;
SubmergedFloorButton.transform.SetParent(ExtraUiTopRight.transform, false);
SubmergedFloorButtonRenderer =
SubmergedFloorButton.transform.Find("Inactive").GetComponent<SpriteRenderer>();
SubmergedFloorButtonRendererHover =
SubmergedFloorButton.transform.Find("Active").GetComponent<SpriteRenderer>();
MiraApiSettings.SetUpButtonPositions();
}
}
}
}
public static void AdjustModifierTab()
{
if (!ModifierDisplayObject && UiTopRight && ExtraUiTopRight && ModifierDisplayComponent.Instance)
{
ModifierDisplayObject = ModifierDisplayComponent.Instance?.gameObject ?? null!;
ModifierDisplayOnRight = !LocalSettingsTabSingleton<MiraApiSettings>.Instance.ModifiersHudLeftSide.Value;
if (ModifierDisplayOnRight)
{
ModifierDisplayObject.transform.SetParent(ExtraUiTopRight.transform, false);
ModifierDisplayObject.GetComponent<AspectPosition>().Destroy();
var oldPos = ModifierDisplayObject.transform.GetChild(0).localPosition;
ModifierDisplayObject.transform.GetChild(0).localPosition = new Vector3(-1.1757f, -2.1633f, oldPos.z);
oldPos = ModifierDisplayObject.transform.GetChild(1).localPosition;
ModifierDisplayObject.transform.GetChild(1).localPosition = new Vector3(-0.45f, 0.3f, oldPos.z);
}
MiraApiSettings.SetUpButtonPositions();
}
}
public static void CreateNewUiRow(HudManager instance)
{
if (!ExtraUiTopRight && UiTopRight)
{
ExtraUiTopRight = new GameObject("ExtraUiTopRight")
{
layer = UiTopRight.layer
};
ExtraUiTopRight.transform.SetParent(instance.MapButton.transform.parent.parent, false);
ExtraUiGrid = ExtraUiTopRight.AddComponent<GridArrange>();
ExtraUiAspectPos = ExtraUiTopRight.AddComponent<AspectPosition>();
ExtraUiGrid.Alignment = GridArrange.StartAlign.Left;
ExtraUiGrid.CellSize = new Vector2(0.85f, 0.85f);
ExtraUiAspectPos.Alignment = AspectPosition.EdgeAlignments.RightTop;
ExtraUiAspectPos.DistanceFromEdge = BelowOptionPos;
ExtraUiGrid.Start();
}
}
}
+6 -1
View File
@@ -5,6 +5,7 @@ using BepInEx.Configuration;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using MiraAPI.PluginLoading;
using MiraAPI.VanillaEvents;
using Reactor;
using Reactor.Networking;
using Reactor.Networking.Attributes;
@@ -19,7 +20,6 @@ namespace MiraAPI;
[BepInAutoPlugin("mira.api", "MiraAPI")]
[BepInProcess("Among Us.exe")]
[BepInDependency(ReactorPlugin.Id)]
[BepInDependency(ModCompatibility.SubmergedId, BepInDependency.DependencyFlags.SoftDependency)]
[ReactorModFlags(ModFlags.RequireOnAllClients)]
public partial class MiraApiPlugin : BasePlugin, IMiraPlugin
{
@@ -62,10 +62,15 @@ public partial class MiraApiPlugin : BasePlugin, IMiraPlugin
public override void Load()
{
Harmony.PatchAll();
JudgeEvents.Initialize();
ReactorCredits.Register("Mira API", Version, IsDevBuild, ReactorCredits.AlwaysShow);
PluginManager = new MiraPluginManager();
PluginManager.Initialize(this, this);
IL2CPPChainloader.Instance.Finished +=
ModCompatibility
.Initialize; // Initialise AFTER the mods are loaded to ensure maximum parity (no need for the soft dependency either then)
}
}
+163 -3
View File
@@ -1,4 +1,6 @@
using BepInEx.Configuration;
using System.Collections;
using BepInEx.Configuration;
using MiraAPI.Hud;
using MiraAPI.LocalSettings;
using MiraAPI.LocalSettings.Attributes;
using MiraAPI.Patches;
@@ -25,15 +27,21 @@ public class MiraApiSettings(ConfigFile config) : LocalSettingsTab(config)
};
/// <summary>
/// Gets or sets the value stored for scaling buttons properly.
/// Gets or sets the value stored for scaling ability buttons properly.
/// </summary>
public static float OldButtonScaleFactor { get; set; }
/// <summary>
/// Gets or sets the value stored for scaling UI buttons properly.
/// </summary>
public static float OldUiButtonScaleFactor { get; set; }
/// <inheritdoc />
public override void Open()
{
base.Open();
OldButtonScaleFactor = ButtonUIFactorSlider.Value;
OldUiButtonScaleFactor = TopRightButtonsFactorSlider.Value;
}
/// <inheritdoc />
@@ -49,12 +57,153 @@ public class MiraApiSettings(ConfigFile config) : LocalSettingsTab(config)
}
OldButtonScaleFactor = ButtonUIFactorSlider.Value;
}
else if (configEntry == TopRightButtonsFactorSlider)
{
if (MiraHudHelper.Instance)
{
ResizeUI(TopRightButtonsFactorSlider.Value);
}
OldUiButtonScaleFactor = TopRightButtonsFactorSlider.Value;
}
else if (configEntry == WikiOnBottomRow)
{
SetUpButtonPositions();
}
else if (configEntry == SetFpsSlider)
{
Application.targetFrameRate = (int)SetFpsSlider.Value;
}
}
public static void SetUpButtonPositions()
{
var topUi = MiraHudHelper.UiTopRight;
var extraTopUi = MiraHudHelper.ExtraUiTopRight;
var wikiButton = MiraHudHelper.VanillaMatchInfoButton;
var subButton = MiraHudHelper.SubmergedFloorButton;
var modDisplay = MiraHudHelper.ModifierDisplayOnRight ? MiraHudHelper.ModifierDisplayObject : null!;
ResetButtonPositions();
if (topUi && extraTopUi)
{
var opts = LocalSettingsTabSingleton<MiraApiSettings>.Instance;
if (wikiButton)
{
wikiButton.transform.SetParent(opts.WikiOnBottomRow.Value ? extraTopUi.transform : topUi.transform);
}
if (subButton)
{
subButton.transform.SetParent(extraTopUi.transform);
}
if (modDisplay)
{
modDisplay.transform.SetParent(extraTopUi.transform);
}
MiraHudHelper.UiGrid.ArrangeChilds();
MiraHudHelper.ExtraUiGrid.ArrangeChilds();
}
}
public static void ResetButtonPositions()
{
var topUi = MiraHudHelper.UiTopRight;
var extraTopUi = MiraHudHelper.ExtraUiTopRight;
var subButton = MiraHudHelper.SubmergedFloorButton;
var modDisplay = MiraHudHelper.ModifierDisplayOnRight ? MiraHudHelper.ModifierDisplayObject : null!;
if (topUi && extraTopUi)
{
var wikiButton = MiraHudHelper.VanillaMatchInfoButton;
if (wikiButton)
{
wikiButton.transform.SetParent(null);
}
if (subButton)
{
subButton.transform.SetParent(null);
}
if (modDisplay)
{
modDisplay.transform.SetParent(null);
}
}
}
public static IEnumerator CoResizeSettingsUI()
{
while (!HudManager.Instance || !MiraHudHelper.UiGrid || !MiraHudHelper.ExtraUiGrid)
{
yield return null;
}
yield return new WaitForSeconds(0.01f);
ResizeUI(LocalSettingsTabSingleton<MiraApiSettings>.Instance.TopRightButtonsFactorSlider.Value);
}
public static void ResizeUI(float scaleFactor)
{
var alteredScale = scaleFactor * 0.85f;
var actualScaleVal = scaleFactor * 1.176470588235294f;
var actualScale = new Vector3(actualScaleVal, actualScaleVal, 1);
var baseAspect = MiraHudHelper.UiAspectPos;
var baseGrid = MiraHudHelper.UiGrid;
var baseUi = MiraHudHelper.UiTopRight;
if (baseUi && baseAspect && baseGrid)
{
baseAspect.DistanceFromEdge = new Vector2(0.435f * scaleFactor, 0.475f * scaleFactor);
foreach (var button in baseUi.GetComponentsInChildren<PassiveButton>(true))
{
if (button.gameObject == null)
{
continue;
}
if (button.transform.name.Contains("Friends List Button"))
{
button.gameObject.transform.localScale = new Vector3(0.2675f * actualScaleVal, 0.2675f * actualScaleVal, 1);
continue;
}
button.gameObject.transform.localScale = actualScale;
}
baseGrid.CellSize = new Vector2(alteredScale, alteredScale);
if (baseGrid.gameObject.transform.childCount != 0)
{
baseGrid.ArrangeChilds();
}
baseAspect.AdjustPosition();
}
var extraAspect = MiraHudHelper.ExtraUiAspectPos;
var extraGrid = MiraHudHelper.ExtraUiGrid;
var extraUi = MiraHudHelper.ExtraUiTopRight;
if (extraUi && extraAspect && extraGrid)
{
extraAspect.DistanceFromEdge = new Vector3(0.435f * scaleFactor, 1.25f * scaleFactor, 0f);
foreach (var button in extraUi.GetAllChildren())
{
if (button.gameObject == null)
{
continue;
}
if (button.transform.name.Contains("Modifiers"))
{
button.gameObject.transform.localScale = new Vector3(0.65f * scaleFactor, 0.65f * scaleFactor, 1);
continue;
}
button.gameObject.transform.localScale = actualScale;
}
extraGrid.CellSize = new Vector2(alteredScale, alteredScale);
if (extraGrid.gameObject.transform.childCount != 0)
{
extraGrid.ArrangeChilds();
}
extraAspect.AdjustPosition();
}
}
/// <summary>
/// Gets whether the modifiers hud should be on the left side of the screen (under roles/task tab). Recommended for streamers.
/// </summary>
@@ -68,12 +217,19 @@ public class MiraApiSettings(ConfigFile config) : LocalSettingsTab(config)
public ConfigEntry<bool> ShowKeybinds { get; private set; } = config.Bind("Visuals/UI", "Show Keybinds on Buttons", true);
/// <summary>
/// Gets the scale of the buttons.
/// Gets the scale of the ability 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 scale of the UI buttons.
/// </summary>
[LocalSliderSetting(min: 0.3f, max: 2f, suffixType: MiraNumberSuffixes.Multiplier, formatString: "0.00", displayValue: true)]
public ConfigEntry<float> TopRightButtonsFactorSlider { get; private set; } =
config.Bind("Visuals/UI", "Top-Right UI Scale Factor", 1f);
/// <summary>
/// Gets the fps specified by the player.
/// </summary>
@@ -81,6 +237,10 @@ public class MiraApiSettings(ConfigFile config) : LocalSettingsTab(config)
public ConfigEntry<float> SetFpsSlider { get; private set; } =
config.Bind("Visuals/UI", "Max FPS", 120f);
[LocalToggleSetting]
public ConfigEntry<bool> WikiOnBottomRow { get; private set; } =
config.Bind("Visuals/UI", "Display Wiki on Bottom Row", true);
/// <summary>
/// Gets whether to apply cosmetic changes to the TaskAdder.
/// </summary>
+32 -11
View File
@@ -1,6 +1,6 @@
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using System.Reflection;
using BepInEx.Unity.IL2CPP;
using SemanticVersioning;
namespace MiraAPI;
@@ -14,15 +14,36 @@ public static class ModCompatibility
/// </summary>
public const string SubmergedId = "Submerged";
/// <summary>
/// Checks if the Submerged mod is loaded.
/// </summary>
/// <param name="submergedAssembly">Submerged mod assembly if loaded, <see langword="null"/> otherwise.</param>
/// <returns><see langword="true"/> if the Submerged mod is loaded, <see langword="false"/> otherwise.</returns>
public static bool SubmergedLoaded([NotNullWhen(true)] out Assembly? submergedAssembly)
public static Version SubVersion { get; private set; }
public static bool SubLoaded { get; private set; }
public static BasePlugin SubPlugin { get; private set; }
public static Assembly SubAssembly { get; private set; }
public const ShipStatus.MapType SubmergedMapType = (ShipStatus.MapType)6;
public static void Initialize()
{
var result = IL2CPPChainloader.Instance.Plugins.TryGetValue(SubmergedId, out var plugin);
submergedAssembly = result ? plugin?.Instance.GetType().Assembly : null;
return result;
InitSubmerged();
}
public static void InitSubmerged()
{
if (!IL2CPPChainloader.Instance.Plugins.TryGetValue(SubmergedId, out var plugin))
{
return;
}
SubPlugin = (plugin!.Instance as BasePlugin)!;
SubVersion = plugin.Metadata.Version;
SubAssembly = SubPlugin.GetType().Assembly;
SubLoaded = true;
Message("Submerged was detected");
}
public static bool IsSubmerged()
{
return SubLoaded && ShipStatus.Instance && ShipStatus.Instance.Type == SubmergedMapType;
}
}
+5
View File
@@ -75,6 +75,11 @@ public enum MiraRpc : uint
/// </summary>
CastVote,
/// <summary>
/// Custom RPC to replace Among Us QueueOverruleVotes.
/// </summary>
QueueOverruleVotes,
/// <summary>
/// Custom RPC to sync the Gamemode option.
/// </summary>
+10 -8
View File
@@ -12,7 +12,7 @@ internal static class ConsolePatches
{
if (AmongUsClient.Instance.GameState == InnerNetClient.GameStates.Started && ShipStatus.Instance)
{
if (CustomGameModeManager.ActiveMode != null && CustomGameModeManager.ActiveMode.CanUseTasks(__instance))
if (CustomGameModeManager.ActiveMode == null || CustomGameModeManager.ActiveMode.CanUseTasks(__instance))
{
var task = __instance.FindTask(pc.Object);
@@ -40,9 +40,10 @@ internal static class ConsolePatches
{
if (AmongUsClient.Instance.GameState == InnerNetClient.GameStates.Started && ShipStatus.Instance)
{
if (CustomGameModeManager.ActiveMode != null && CustomGameModeManager.ActiveMode.CanUseSystemConsole(__instance))
if (CustomGameModeManager.ActiveMode == null || CustomGameModeManager.ActiveMode.CanUseSystemConsole(__instance))
{
return canUse = couldUse = true;
canUse = couldUse = true;
return true;
}
canUse = couldUse = false;
@@ -58,9 +59,10 @@ internal static class ConsolePatches
{
if (AmongUsClient.Instance.GameState == InnerNetClient.GameStates.Started && ShipStatus.Instance)
{
if (CustomGameModeManager.ActiveMode != null && CustomGameModeManager.ActiveMode.CanUseMapConsole(__instance))
if (CustomGameModeManager.ActiveMode == null || CustomGameModeManager.ActiveMode.CanUseMapConsole(__instance))
{
return canUse = couldUse = true;
canUse = couldUse = true;
return true;
}
canUse = couldUse = false;
@@ -77,7 +79,7 @@ internal static class ConsolePatches
if (AmongUsClient.Instance.GameState == InnerNetClient.GameStates.Started && ShipStatus.Instance)
{
return CustomGameModeManager.ActiveMode == null ||
CustomGameModeManager.ActiveMode!.CanUseMapConsole(__instance);
CustomGameModeManager.ActiveMode.CanUseMapConsole(__instance);
}
return true;
@@ -89,7 +91,7 @@ internal static class ConsolePatches
if (AmongUsClient.Instance.GameState == InnerNetClient.GameStates.Started && ShipStatus.Instance)
{
return CustomGameModeManager.ActiveMode == null ||
CustomGameModeManager.ActiveMode!.CanUseSystemConsole(__instance);
CustomGameModeManager.ActiveMode.CanUseSystemConsole(__instance);
}
return true;
@@ -101,7 +103,7 @@ internal static class ConsolePatches
if (AmongUsClient.Instance.GameState == InnerNetClient.GameStates.Started && ShipStatus.Instance)
{
return CustomGameModeManager.ActiveMode == null ||
CustomGameModeManager.ActiveMode!.CanUseTasks(__instance);
CustomGameModeManager.ActiveMode.CanUseTasks(__instance);
}
return true;
+1 -1
View File
@@ -7,7 +7,7 @@ internal static class TaskPanelPatch
{
public static bool Prefix(TaskPanelBehaviour __instance)
{
if (CustomGameModeManager.ActiveMode != null)
if (__instance != Roles.HudManagerPatches.RoleTab && CustomGameModeManager.ActiveMode != null)
{
CustomGameModeManager.ActiveMode.UpdateTaskPanel(__instance);
return false;
+55
View File
@@ -1,9 +1,11 @@
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using HarmonyLib;
using MiraAPI.Hud;
using MiraAPI.Keybinds;
using MiraAPI.LocalSettings;
using MiraAPI.Roles;
using MiraAPI.Utilities;
using Reactor.Utilities;
using Reactor.Utilities.Extensions;
@@ -112,6 +114,58 @@ public static class HudManagerPatches
}
}
/*
/// <summary>
/// Trigger hudstart on current custom gamemode
/// </summary>
[HarmonyPostfix]
[HarmonyPatch(nameof(HudManager.OnGameStart))]
public static void GameStartPatch(HudManager __instance)
{
CustomGameModeManager.ActiveMode?.HudStart(__instance);
}*/
[HarmonyPrefix]
[HarmonyPriority(Priority.First)]
[HarmonyPatch(typeof(FriendsListManager), nameof(FriendsListManager.SetFriendButtonColor))]
public static bool SetFriendButtonColor(FriendsListManager __instance, bool isGrayedOut)
{
__instance.FriendsListButton?.SetGlyphColor(isGrayedOut);
return false;
}
[HarmonyPrefix]
[HarmonyPriority(Priority.First)]
[HarmonyPatch(typeof(ChatController), nameof(ChatController.Toggle))]
[HarmonyPatch(typeof(ChatController), nameof(ChatController.Close))]
public static void TogglePrefix(ChatController __instance)
{
if (!MiraHudHelper.ClonedChatButton)
{
return;
}
__instance.chatButton.transform.localPosition = MiraHudHelper.ClonedChatButton.transform.localPosition + new Vector3(-0.3f, 0);
}
[HarmonyPostfix]
[HarmonyPriority(Priority.First)]
[HarmonyPatch(typeof(ChatController), nameof(ChatController.Toggle))]
[HarmonyPatch(typeof(ChatController), nameof(ChatController.Close))]
public static void TogglePostfix(ChatController __instance)
{
MiraHudHelper.UiGrid.ArrangeChilds();
}
[HarmonyPrefix]
[HarmonyPriority(Priority.First)]
[HarmonyPatch(typeof(ChatController), nameof(ChatController.AddChatNote))]
[HarmonyPatch(typeof(ChatController), nameof(ChatController.AddChat))]
[HarmonyPatch(typeof(ChatController), nameof(ChatController.AddChatWarning))]
public static void ChatBubbleUpdatePrefix(ChatController __instance)
{
__instance.chatNotifyDot.transform.localPosition = new Vector3(-0.34f, 0.373f, -1f);
}
/// <summary>
/// Create custom buttons and arrange them on the hud.
/// </summary>
@@ -120,6 +174,7 @@ public static class HudManagerPatches
[HarmonyPatch(nameof(HudManager.Start))]
public static void StartPostfix(HudManager __instance)
{
__instance.gameObject.AddComponent<MiraHudHelper>();
if (Buttons == null)
{
Buttons = __instance.transform.Find("Buttons");
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections;
using System.Linq;
using BepInEx.Unity.IL2CPP.Utils.Collections;
@@ -404,14 +404,14 @@ internal static class GameOptionsMenuPatch
// ReSharper disable once InconsistentNaming
public static void UpdatePatch(GameOptionsMenu __instance)
{
if (MenuState.Instance.CurrentModIdx == 0 && _gameModeGroups.Count <= 0) return;
var num = MenuState.Instance.CurrentMenu == MenuCategory.Game ? -1.217f : 2.1f;
if (MenuState.Instance.CurrentModIdx == 0 && _gameModeGroups.Count <= 0)
{
return;
}
var num = 2.1f;
switch (MenuState.Instance.CurrentMenu)
{
case MenuCategory.Game:
GamemodeOptionsUpdate(ref num);
break;
case MenuCategory.Modifiers:
ModifiersUpdate(ref num);
break;
@@ -422,9 +422,15 @@ internal static class GameOptionsMenuPatch
CustomMenuTwoUpdate(ref num);
break;
default:
if (MenuState.Instance.CurrentModIdx == 0)
{
num = -1.217f;
GamemodeOptionsUpdate(ref num);
break;
}
var filteredGroups =
MenuState.Instance.CurrentMod.InternalOptionGroups
.Where(x => x.OptionableType == null &&
.Where(x => (x.OptionableType == null || CustomGameModeManager.ActiveMode!.GetType().IsAssignableTo(x.OptionableType)) &&
x.ParentMenu == MenuCategory.Game) ?? [];
foreach (var group in filteredGroups)
+2
View File
@@ -63,6 +63,8 @@ public class MenuState(IntPtr cppPtr) : MonoBehaviour(cppPtr)
[HideFromIl2Cpp]
internal Dictionary<int, bool> FinishedRoleMenus { get; } = [];
[HideFromIl2Cpp]
internal Dictionary<int, bool> QueuedRoleMenuRefresh { get; } = [];
public void Awake()
{
@@ -75,7 +75,24 @@ public static class RoleSettingMenuPatches
dividerImage.gameObject.SetActive(false);
}
if (MenuState.Instance.FinishedRoleMenus.TryGetValue(MenuState.Instance.CurrentModIdx, out var finished) && finished)
var queuedRefresh = false;
if (MenuState.Instance.QueuedRoleMenuRefresh.TryGetValue(MenuState.Instance.CurrentModIdx, out var queued) && queued)
{
queuedRefresh = true;
var roleOptionSettings = roleMenu.scrollBar.Inner.GetComponentsInChildren<RoleOptionSetting>(true);
var headers = roleMenu.scrollBar.Inner.GetComponentsInChildren<CategoryHeaderMasked>(true);
foreach (var child in roleOptionSettings)
{
Object.Destroy(child.gameObject);
}
foreach (var child in headers)
{
Object.Destroy(child.gameObject);
}
yield return new WaitForEndOfFrame();
MenuState.Instance.QueuedRoleMenuRefresh[MenuState.Instance.CurrentModIdx] = false;
}
if (!queuedRefresh && MenuState.Instance.FinishedRoleMenus.TryGetValue(MenuState.Instance.CurrentModIdx, out var finished) && finished)
{
var roleOptionSettings = roleMenu.scrollBar.Inner.GetComponentsInChildren<RoleOptionSetting>(true);
foreach (var r in roleOptionSettings)
@@ -154,6 +171,17 @@ public static class RoleSettingMenuPatches
ScrollerNum = 0.522f;
var num4 = 0;
var roleOptionSettings = roleMenu.scrollBar.Inner.GetComponentsInChildren<RoleOptionSetting>(false);
var headers = roleMenu.scrollBar.Inner.GetComponentsInChildren<CategoryHeaderMasked>(false);
foreach (var child in roleOptionSettings)
{
Object.Destroy(child.gameObject);
}
foreach (var child in headers)
{
Object.Destroy(child.gameObject);
}
yield return new WaitForEndOfFrame();
var roleGroups = MenuState.Instance.CurrentMod.InternalRoles.Values.OfType<ICustomRole>()
.ToLookup(x => x.RoleOptionsGroup);
@@ -308,6 +336,7 @@ public static class RoleSettingMenuPatches
RoleGroupHidden[group] = !groupHidden;
}
MenuState.Instance.QueuedRoleMenuRefresh[MenuState.Instance.CurrentModIdx] = false;
MenuState.Instance.FinishedRoleMenus[MenuState.Instance.CurrentModIdx] = false;
foreach (var child in roleMenu.RoleChancesSettings.transform)
@@ -327,6 +356,7 @@ public static class RoleSettingMenuPatches
}
}
}
MenuState.Instance.QueuedRoleMenuRefresh[MenuState.Instance.CurrentModIdx] = false;
MenuState.Instance.FinishedRoleMenus[MenuState.Instance.CurrentModIdx] = true;
}
@@ -517,6 +547,26 @@ public static class RoleSettingMenuPatches
CurrentRoleOptions = filteredOptions;
}
[HarmonyPrefix]
[HarmonyPatch(nameof(RolesSettingsMenu.ChangeTab))]
public static void ChangeTabPatch(RolesSettingsMenu __instance)
{
var categoryHeaderMasked = __instance.AdvancedRolesSettings.transform.Find("CategoryHeaderMasked").GetComponent<CategoryHeaderMasked>();
categoryHeaderMasked.Title.text = TranslationController.Instance.GetString(StringNames.RoleSettingsLabel);
var labelBg = __instance.AdvancedRolesSettings.transform.FindChild("InfoLabelBackground");
var imgBg = __instance.AdvancedRolesSettings.transform.FindChild("Imagebackground");
imgBg.gameObject.SetActive(true);
__instance.roleScreenshot.gameObject.SetActive(true);
__instance.roleDescriptionText.transform.parent.localPosition = new Vector3(2.5176f, -0.2731f, -1f);
__instance.roleDescriptionText.transform.parent.localScale = new Vector3(0.0675f, 0.1494f, 0.5687f);
labelBg.transform.localPosition = new Vector3(1.082f, 0.1054f, -2.5f);
__instance.roleScreenshot.drawMode = SpriteDrawMode.Simple;
foreach (var optBehaviour in __instance.AdvancedRolesSettings.GetComponentsInChildren<OptionBehaviour>())
{
optBehaviour.gameObject.Destroy();
}
}
private static void ChangeTab(RoleBehaviour role, RolesSettingsMenu __instance)
{
if (role is not ICustomRole customRole)
@@ -546,12 +596,8 @@ public static class RoleSettingMenuPatches
__instance.roleDescriptionText.transform.parent.localScale = new Vector3(0.0675f, 0.1494f, 0.5687f);
labelBg.transform.localPosition = new Vector3(1.082f, 0.1054f, -2.5f);
__instance.roleScreenshot.sprite = Sprite.Create(
role.RoleScreenshot.texture,
new Rect(0, 0, 370, 230),
Vector2.one / 2,
100);
__instance.roleScreenshot.drawMode = SpriteDrawMode.Sliced;
__instance.roleScreenshot.sprite = role.RoleScreenshot;
__instance.roleScreenshot.drawMode = SpriteDrawMode.Simple;
}
__instance.roleHeaderSprite.color = customRole.OptionsMenuColor;
+164
View File
@@ -0,0 +1,164 @@
using System.Globalization;
using System.Linq;
using HarmonyLib;
using Innersloth.Assets;
using MiraAPI.Roles;
using MiraAPI.Utilities;
using UnityEngine;
namespace MiraAPI.Patches;
[HarmonyPatch]
public static class RoleGuidePatches
{
[HarmonyPostfix]
[HarmonyPriority(Priority.First)]
[HarmonyPatch(typeof(MatchInfoGuide), nameof(MatchInfoGuide.CreateNormalModeSettings))]
[HarmonyPatch(typeof(MatchInfoGuide), nameof(MatchInfoGuide.CreateHnSModeSettings))]
public static void CreateNormalModeSettings(MatchInfoGuide __instance)
{
__instance.MatchInfoRoleMaskArea.transform.localPosition = new Vector3(-0.0184f, 0.15f, -0.1f);
__instance.matchInfoPlayersMaskArea.transform.localPosition =
__instance.matchInfoSettingsMaskArea.transform.localPosition = new Vector3(1.22f, -0.335f, -0.1f);
__instance.matchInfoPlayersMaskArea.size =
__instance.matchInfoSettingsMaskArea.size =
__instance.MatchInfoRoleMaskArea.size = new Vector2(-6, 1.8f);
__instance.matchInfoPlayersMaskArea.transform.parent.GetAllChildren().First(x => x.name.Contains("BG_Gradient"))
.GetComponent<SpriteRenderer>()
.maskInteraction =
__instance.matchInfoSettingsMaskArea.transform.parent.GetAllChildren()
.First(x => x.name.Contains("BG_Gradient")).GetComponent<SpriteRenderer>()
.maskInteraction =
__instance.MatchInfoRoleMaskArea.transform.parent.GetAllChildren()
.First(x => x.name.Contains("BG_Gradient")).GetComponent<SpriteRenderer>()
.maskInteraction = SpriteMaskInteraction.VisibleInsideMask;
}
[HarmonyPrefix]
[HarmonyPriority(Priority.First)]
[HarmonyPatch(typeof(MatchInfoGuide), nameof(MatchInfoGuide.Awake))]
public static void Awake(MatchInfoGuide __instance)
{
__instance.transitionOpen.targetSize = 1.3f;
}
[HarmonyPrefix]
[HarmonyPriority(Priority.First)]
[HarmonyPatch(typeof(MatchInfoGuide), nameof(MatchInfoGuide.Open))]
public static bool Open(MatchInfoGuide __instance)
{
if (HudManager.Instance.GameMenu.IsOpen || HudManager.Instance.Chat.IsOpenOrOpening)
{
return false;
}
if (Minigame.Instance != null)
{
Minigame.Instance.Close();
}
if (MapBehaviour.Instance)
{
MapBehaviour.Instance.Close();
}
if (HudManager.InstanceExists)
{
ConsoleJoystick.SetMode_MenuAdditive();
}
ControllerManager.Instance.OpenOverlayMenu("MatchInfoGuide", __instance.closeButton);
bool enabled = ActiveInputManager.currentControlType == ActiveInputManager.InputType.Joystick;
__instance.glyphL.enabled = enabled;
__instance.glyphR.enabled = enabled;
if (GameManager.Instance.TryCast<NormalGameManager>() != null)
{
if (__instance.NormalModeSettings.Count == 0)
{
__instance.numOfTabs = 3;
__instance.TabButtons[0].SelectButton(true);
__instance.CreateNormalModeSettings();
}
}
else if (__instance.HnSModeSettings.Count == 0)
{
__instance.numOfTabs = 2;
__instance.TabButtons[0].SelectButton(true);
__instance.CreateHnSModeSettings();
}
PlayerControl.LocalPlayer.NetTransform.Halt();
__instance.MatchInfoParent.SetActive(true);
ControllerManager instance = ControllerManager.Instance;
ControllerUiElementsState currentUiState = ControllerManager.Instance.CurrentUiState;
Il2CppSystem.Collections.Generic.List<UiElement> controllerSelectable = __instance.ControllerSelectable;
instance.SetUpSelectables(currentUiState, controllerSelectable[controllerSelectable.Count - 1], __instance.ControllerSelectable);
ControllerManager instance2 = ControllerManager.Instance;
Il2CppSystem.Collections.Generic.List<UiElement> controllerSelectable2 = __instance.ControllerSelectable;
instance2.SetCurrentSelected(controllerSelectable2[controllerSelectable2.Count - 1]);
__instance.SetActiveTab(0);
return false;
}
[HarmonyPrefix]
[HarmonyPriority(Priority.First)]
[HarmonyPatch(typeof(MatchInfoGuide), nameof(MatchInfoGuide.CreatePlayerEntries))]
private static bool CreatePlayerEntries(MatchInfoGuide __instance)
{
__instance.PlayerPool.ReclaimAll();
int num = 51;
foreach (NetworkedPlayerInfo networkedPlayerInfo in GameData.Instance.AllPlayers)
{
PlayerIdentifierButton component =
__instance.PlayerPool.Get<PoolableBehavior>().GetComponent<PlayerIdentifierButton>();
component.transform.localPosition = new Vector3(0f, 0f, -1f);
component.Populate(networkedPlayerInfo);
__instance.ControllerSelectable.Add(component.Button);
component.SetTextStencil(num++);
component.PlatformIdentifier.transform.localPosition = new Vector3(0.314f, 0.088f, -2.78f);
component.NameText.transform.localPosition = new Vector3(0.3563f, 0, -2.98f);
component.NameText.text += $"\n<size=75%>{networkedPlayerInfo.GetPlayerColorString()}</size>";
var namePlate = HatManager.Instance.GetNamePlateById(networkedPlayerInfo.DefaultOutfit.NamePlateId);
var x = (NamePlateViewData viewdata) =>
{
component.buttonSprite.sprite = viewdata?.Image;
component.buttonSprite.transform.localScale = new Vector3(0.7f, 1.075f, 1);
component.buttonSprite.transform.localPosition = new Vector3(-0.395f, 0, 0.1f);
};
__instance.StartCoroutine(
AddressableAssetExtensions.CoLoadAssetAsync<NamePlateViewData>(
__instance,
namePlate.GetAssetReference(),
x));
}
return false;
}
[HarmonyPrefix]
[HarmonyPriority(Priority.First)]
[HarmonyPatch(typeof(MatchInfoRolePanel), nameof(MatchInfoRolePanel.SetPanel))]
public static bool SetPanel(MatchInfoRolePanel __instance, RoleBehaviour role, int numPerGame, int chancePerGame)
{
__instance.roleCount.text = string.Format(CultureInfo.InvariantCulture, "{0} at {1}%", numPerGame.ToString(CultureInfo.InvariantCulture), chancePerGame);
if (role is ICustomRole customRole)
{
__instance.roleName.text = customRole.RoleName;
__instance.roleDescription.text = $"<size=60%>{customRole.RoleFactionTitle}</size>\n" + customRole.RoleMedDescription;
__instance.roleIcon.sprite = customRole.Configuration.Icon?.LoadAsset();
__instance.roleCount.text += $" ({customRole.ParentMod.MiraPlugin.GetAbbreviatedModName()})";
}
else
{
__instance.roleName.text = role.NiceName;
__instance.roleDescription.text = $"<size=60%>{TranslationController.Instance.GetString(role.TeamType is RoleTeamTypes.Crewmate ? StringNames.Crewmate : StringNames.Impostor)}</size>\n" + role.BlurbMed;
__instance.roleIcon.sprite = role.RoleIconColor;
__instance.roleCount.text += " (AU)";
}
__instance.roleIcon.SetSizeLimit(0.13f);
__instance.roleIcon.material.SetInt(PlayerMaterial.MaskLayer, 50);
__instance.roleName.fontMaterial.SetFloat(__instance.STENCIL_NAME, 50f);
__instance.roleDescription.fontMaterial.SetFloat(__instance.STENCIL_NAME, 50f);
__instance.roleCount.fontMaterial.SetFloat(__instance.STENCIL_NAME, 50f);
__instance.roleIcon.transform.localScale = new Vector3(4f, 4f, 1f);
return false;
}
}
@@ -8,17 +8,17 @@ namespace MiraAPI.Patches.Roles;
/// <summary>
/// Patches to return the correct role counts.
/// </summary>
[HarmonyPatch(typeof(RoleOptionsCollectionV10))]
[HarmonyPatch(typeof(RoleOptionsCollectionV11))]
public static class RoleOptionsCollectionPatch
{
/// <summary>
/// This patch fixes <see cref="RoleOptionsCollectionV10.GetNumPerGame(RoleTypes)"/> being inlined (2025.9.9) in the original code.
/// This patch fixes <see cref="RoleOptionsCollectionV11.GetNumPerGame(RoleTypes)"/> being inlined (2025.9.9) in the original code.
/// </summary>
[HarmonyPrefix]
[HarmonyPatch(nameof(RoleOptionsCollectionV10.AnyRolesEnabled))]
public static bool AnyRolesEnabledPrefix(RoleOptionsCollectionV10 __instance, ref bool __result)
[HarmonyPatch(nameof(RoleOptionsCollectionV11.AnyRolesEnabled))]
public static bool AnyRolesEnabledPrefix(RoleOptionsCollectionV11 __instance, ref bool __result)
{
foreach (KeyValuePair<RoleTypes, RoleDataV10> keyValuePair in __instance.roles)
foreach (KeyValuePair<RoleTypes, RoleDataV11> keyValuePair in __instance.roles)
{
if (__instance.GetNumPerGame(keyValuePair.Key) > 0)
{
@@ -33,7 +33,7 @@ public static class RoleOptionsCollectionPatch
/// </summary>
/// <returns>Return <see langword="false"/> to skip original method, <see langword="true"/> to not.</returns>
[HarmonyPrefix]
[HarmonyPatch(nameof(RoleOptionsCollectionV10.GetChancePerGame))]
[HarmonyPatch(nameof(RoleOptionsCollectionV11.GetChancePerGame))]
public static bool GetChancePrefix(RoleTypes role, ref int __result)
{
if (!CustomRoleManager.GetCustomRoleBehaviour(role, out var customRole) || customRole == null)
@@ -63,7 +63,7 @@ public static class RoleOptionsCollectionPatch
/// </summary>
/// <returns>Return <see langword="false"/> to skip original method, <see langword="true"/> to not.</returns>
[HarmonyPrefix]
[HarmonyPatch(nameof(RoleOptionsCollectionV10.GetNumPerGame))]
[HarmonyPatch(nameof(RoleOptionsCollectionV11.GetNumPerGame))]
public static bool GetNumPrefix(RoleTypes role, ref int __result)
{
if (!CustomRoleManager.GetCustomRoleBehaviour(role, out var customRole) || customRole == null)
+16 -5
View File
@@ -2,6 +2,7 @@
using System.Linq;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using InnerNet;
using MiraAPI.Events;
using MiraAPI.Events.Vanilla.Meeting;
using MiraAPI.Events.Vanilla.Meeting.Voting;
@@ -77,7 +78,7 @@ internal static class MeetingHudPatches
[HarmonyPatch(nameof(MeetingHud.Update))]
public static void ForceSkipPatch(MeetingHud __instance)
{
if (__instance.state is not (MeetingHud.VoteStates.NotVoted or MeetingHud.VoteStates.Voted))
if (__instance.state is not (MeetingHud.MeetingStates.NotVoted or MeetingHud.MeetingStates.Voted))
{
return;
}
@@ -127,13 +128,13 @@ internal static class MeetingHudPatches
return false;
}
var playerVoteArea = __instance.playerStates.First(pv => pv.TargetPlayerId == pc.PlayerId);
var playerVoteArea = __instance.playerStates.First(pv => pv.PlayerId == pc.PlayerId);
playerVoteArea.AmDead = true;
playerVoteArea.Overlay.gameObject.SetActive(true);
foreach (var player in Helpers.GetAlivePlayers())
{
var pva = __instance.playerStates.First(pv => pv.TargetPlayerId == player.PlayerId);
var pva = __instance.playerStates.First(pv => pv.PlayerId == player.PlayerId);
var voteData = player.GetVoteData();
if (pva.AmDead || !voteData.VotedFor(pc.PlayerId))
@@ -150,7 +151,7 @@ internal static class MeetingHudPatches
__instance.SetDirtyBit(1U);
__instance.CheckForEndVoting();
if (__instance.state == MeetingHud.VoteStates.Results)
if (__instance.state == MeetingHud.MeetingStates.Results)
{
__instance.SetupProceedButton();
}
@@ -199,7 +200,7 @@ internal static class MeetingHudPatches
})
]);
__instance.RpcVotingComplete(voterStates, exiled, isTie);
__instance.RpcVotingComplete(voterStates, exiled, isTie, @event.OverruledVote, @event.OverruledNonce);
return false;
}
@@ -223,6 +224,16 @@ internal static class MeetingHudPatches
return false;
}
// TODO: figure out a way to do host-authorization since right now any player can send RpcQueueOverruleVotes
[HarmonyPrefix]
[HarmonyPatch(nameof(MeetingHud.CmdQueueOverruleVotes))]
// Although this method is inlined in MeetingHud.Confirm, the next patch fixes that.
public static bool CmdQueueOverruleVotesPatch(MeetingHud __instance, PlayerId judgePlayerId, PlayerId targetPlayerId, ushort overruleNonce)
{
VotingUtils.RpcQueueOverruleVotes(PlayerControl.LocalPlayer, judgePlayerId.Value, targetPlayerId.Value, overruleNonce);
return false;
}
[HarmonyPrefix]
[HarmonyPatch(nameof(MeetingHud.Confirm))]
public static bool ConfirmPatch(MeetingHud __instance, [HarmonyArgument(0)] byte suspect)
@@ -250,6 +250,8 @@ public sealed class MiraPluginManager
{
// Save all buttons into a read-only collection for easy access
CustomButtonManager.Buttons = new ReadOnlyCollection<CustomActionButton>(CustomButtonManager.CustomButtons);
CustomButtonManager.EventTypes = new ReadOnlyDictionary<Type, Type>(CustomButtonManager.ButtonEventTypes);
CustomButtonManager.CancelledEventTypes = new ReadOnlyDictionary<Type, Type>(CustomButtonManager.ButtonCancelledEventTypes);
// Cache all the registered plugins into an array for easy access
RegisteredPlugins = [.. _registeredPlugins.Values];
Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

+12 -5
View File
@@ -141,11 +141,18 @@ public static class CustomRoleManager
roleBehaviour.CanVent = customRole.Configuration.CanUseVent || customRole.Configuration.GetsVentData;
roleBehaviour.DefaultGhostRole = customRole.Configuration.GhostRole;
roleBehaviour.MaxCount = customRole.Configuration.MaxRoleCount;
roleBehaviour.RoleScreenshot = Sprite.Create(
customRole.Configuration.OptionsScreenshot?.LoadAsset().texture,
new Rect(0, 0, 370, 230),
Vector2.one / 2,
100);
if (customRole.Configuration.OptionsScreenshot != null)
{
roleBehaviour.RoleScreenshot = customRole.Configuration.OptionsScreenshot.LoadAsset();
}
else
{
roleBehaviour.RoleScreenshot = Sprite.Create(
null,
new Rect(0, 0, 370, 230),
Vector2.one / 2,
100);
}
_emptySettings ??= new(0);
_emptyKillAnimations ??= new(0);
+16
View File
@@ -23,11 +23,27 @@ public interface ICustomRole : IOptionable
/// </summary>
string RoleDescription { get; }
/// <summary>
/// Gets the medium description of the role. Used in the role guide.
/// </summary>
string RoleMedDescription => RoleDescription;
/// <summary>
/// Gets the long description of the role. Used in the Role Tab and Role Options.
/// </summary>
string RoleLongDescription { get; }
/// <summary>
/// Gets the faction / alignment of the role. Used in the role guide.
/// </summary>
string RoleFactionTitle => Team switch
{
ModdedRoleTeams.Crewmate => TranslationController.Instance.GetString(StringNames.Crewmate),
ModdedRoleTeams.Impostor => TranslationController.Instance.GetString(StringNames.Impostor),
ModdedRoleTeams.Custom => "Neutral",
_ => "Other",
};
/// <summary>
/// Gets the <see cref="Color"/> of the role.
/// </summary>
@@ -0,0 +1,37 @@
using System;
using System.Linq;
using UnityEngine;
namespace MiraAPI.Utilities.Assets;
/// <summary>
/// A utility class for loading multiple assets from an <see cref="LoadableBundleSubAssetHolder"/>.
/// </summary>
/// <param name="name">The name of the asset.</param>
/// <param name="assetHolder">The <see cref="LoadableBundleSubAssetHolder"/> that contains the asset.</param>
public class LoadableBundleSubAsset(string name, LoadableBundleSubAssetHolder assetHolder) : LoadableAsset<Sprite>
{
/// <summary>
/// Loads the asset from the <see cref="LoadableBundleSubAssetHolder"/>.
/// </summary>
/// <returns>The asset.</returns>
/// <exception cref="Exception">The asset did not load properly.</exception>
public override Sprite LoadAsset()
{
if (LoadedAsset != null)
{
return LoadedAsset;
}
assetHolder.TryInit();
var loadedAsset = assetHolder.SubSprites.FirstOrDefault(x => x.name == name);
if (loadedAsset == null)
{
throw new InvalidOperationException($"INVALID ASSETS: {name}");
}
LoadedAsset = loadedAsset;
return LoadedAsset;
}
}
@@ -0,0 +1,86 @@
using System;
using System.Linq;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Reactor.Utilities.Extensions;
using UnityEngine;
namespace MiraAPI.Utilities.Assets;
/// <summary>
/// A utility class for loading multiple assets from an <see cref="AssetBundle"/>.
/// </summary>
public class LoadableBundleSubAssetHolder
{
/// <summary>
/// Initializes a new instance of the <see cref="LoadableBundleSubAssetHolder"/> class.
/// </summary>
/// <param name="names">The name of the assets to pull from.</param>
/// <param name="bundle">The <see cref="AssetBundle"/> that contains the assets.</param>
public LoadableBundleSubAssetHolder(string[] names, AssetBundle bundle)
{
Bundle = bundle;
SpriteNames = names;
}
/// <summary>
/// Initializes a new instance of the <see cref="LoadableBundleSubAssetHolder"/> class.
/// </summary>
/// <param name="name">The name of the asset.</param>
/// <param name="bundle">The <see cref="AssetBundle"/> that contains the assets.</param>
public LoadableBundleSubAssetHolder(string name, AssetBundle bundle)
{
Bundle = bundle;
SpriteNames = [name];
}
internal string[] SpriteNames = [];
internal AssetBundle Bundle;
public Sprite[] SubSprites = [];
public void TryInit()
{
if (SubSprites.Length == 0)
{
var newSprites = Array.Empty<Sprite>();
foreach (var name in SpriteNames)
{
var loadedAssets = Bundle.LoadAssetWithSubAssets(name, Il2CppType.From(typeof(Sprite))).ToArray();
if (loadedAssets == null)
{
throw new InvalidOperationException($"INVALID ASSETS: {name}");
}
foreach (var obj in loadedAssets)
{
var img = obj.TryCast<Sprite>();
if (img != null)
{
img.DontDestroy().DontUnload();
newSprites = newSprites.AddToArray(img);
}
}
}
SubSprites = newSprites;
}
}
/// <summary>
/// Unloads an asset.
/// </summary>
/// <returns>True if the asset was unloaded, false otherwise.</returns>
public bool UnloadAsset()
{
if (SubSprites.Length == 0)
{
return false;
}
foreach (var sprite in SubSprites)
{
sprite.DestroyImmediate();
}
SubSprites = [];
return true;
}
}
+15
View File
@@ -145,5 +145,20 @@ public static class MiraAssets
/// </summary>
public static LoadableResourceAsset TimedModifierFile { get; } = new("MiraAPI.Resources.TimedModifierFile.png");
/// <summary>
/// Gets the sprite used for the new chat button while hovering.
/// </summary>
public static LoadableResourceAsset ChatHoverSprite { get; } = new("MiraAPI.Resources.NormalChatHover.png");
/// <summary>
/// Gets the sprite used for the new chat button while hovering.
/// </summary>
public static LoadableResourceAsset ChatIdleSprite { get; } = new("MiraAPI.Resources.NormalChatIdle.png");
/// <summary>
/// Gets the sprite used for the new chat button while hovering.
/// </summary>
public static LoadableResourceAsset ChatOpenSprite { get; } = new("MiraAPI.Resources.NormalChatOpen.png");
internal static LoadableResourceAsset BlankSprite { get; } = new("MiraAPI.Resources.BlankSprite.png");
}
+2 -2
View File
@@ -71,8 +71,8 @@ public static class TmpSpriteUtils
{
name = spriteName,
hashCode = TMP_TextUtilities.GetSimpleHashCode(spriteName),
x = 0,
y = 0,
x = rect.x,
y = rect.y,
width = rect.width,
height = rect.height,
xOffset = -(rect.width / 3) + (scale - 1) * (rect.width / 2),
+66 -1
View File
@@ -165,7 +165,7 @@ public static class Extensions
/// </summary>
/// <param name="state">The <see cref="PlayerVoteArea"/>.</param>
/// <returns>The player's <see cref="PlayerControl"/>.</returns>
public static PlayerControl? GetPlayer(this PlayerVoteArea state) => GameData.Instance.GetPlayerById(state.TargetPlayerId)?.Object;
public static PlayerControl? GetPlayer(this PlayerVoteArea state) => GameData.Instance.GetPlayerById(state.PlayerId)?.Object;
/// <summary>
/// Gets an <see langword="int"/> representing the amount of tasks a player has left.
@@ -367,6 +367,71 @@ public static class Extensions
GC.Collect();
}
/// <summary>
/// Gets all child objects in a parent object.
/// </summary>
/// <returns>An <see cref="IEnumerable"/> that contains <see cref="GameObject"/>s.</returns>
public static IEnumerable<GameObject> GetAllChildren(this GameObject go)
{
for (var i = 0; i < go.transform.childCount; i++)
{
yield return go.transform.GetChild(i).gameObject;
}
}
/// <summary>
/// Gets all child objects in a parent Transform.
/// </summary>
/// <returns>An <see cref="IEnumerable"/> that contains <see cref="GameObject"/>s.</returns>
public static IEnumerable<GameObject> GetAllChildren(this Transform go)
{
for (var i = 0; i < go.transform.childCount; i++)
{
yield return go.transform.GetChild(i).gameObject;
}
}
/// <summary>
/// Resizes a <see cref="SpriteRenderer"/> appropriate to the maximum pixel size without messing up ratios.
/// </summary>
/// <param name="sprite">The <see cref="SpriteRenderer"/> to adjust.</param>
/// <param name="pixelSize">The scale for the sprite to be adjusted to.</param>
public static void SetSizeLimit(this SpriteRenderer sprite, float pixelSize)
{
sprite.drawMode = SpriteDrawMode.Sliced;
if (!sprite.sprite)
{
return;
}
float spriteWidth = sprite.sprite.rect.width;
float spriteHeight = sprite.sprite.rect.height;
if (spriteWidth < spriteHeight)
{
sprite.size = new Vector2(pixelSize * spriteWidth / spriteHeight, pixelSize);
}
else
{
sprite.size = new Vector2(pixelSize, pixelSize * spriteHeight / spriteWidth);
}
}
/// <summary>
/// Resizes a <see cref="SpriteRenderer"/> appropriate to the maximum pixel size without messing up ratios.
/// </summary>
/// <param name="spriteObj">The <see cref="GameObject"/> to adjust.</param>
/// <param name="pixelSize">The scale for the sprite to be adjusted to.</param>
public static void SetSizeLimit(this GameObject spriteObj, float pixelSize)
{
if (!spriteObj.TryGetComponent<SpriteRenderer>(out var sprite))
{
return;
}
sprite.SetSizeLimit(pixelSize);
}
/// <summary>
/// Gets a cache of <see cref="PlayerControl"/>'s <see cref="PlayerVoteData"/> to improve performance.
/// </summary>
+28
View File
@@ -0,0 +1,28 @@
using MiraAPI.Events;
using MiraAPI.Events.Vanilla.Meeting.Voting;
using MiraAPI.Roles;
namespace MiraAPI.VanillaEvents;
public static class JudgeEvents
{
public static void Initialize()
{
// This is required because MiraAPI isn't an IMiraPlugin (besides in the gamemodes branch)
MiraEventManager.RegisterEventHandler<ProcessVotesEvent>(@event => ProcessVotesEventHandler(@event), -1000);
}
public static void ProcessVotesEventHandler(ProcessVotesEvent @event)
{
if (MeetingHud.Instance.TryGetWinningOverrule(out var judgeOverrule, out var networkedPlayerInfo, out var networkedPlayerInfo2))
{
Error("Judge has overruled votes!");
@event.OverruledVote = true;
@event.OverruledNonce = judgeOverrule.OverruleNonce;
@event.ExiledPlayer = networkedPlayerInfo2.Role is ICustomRole { Team: not ModdedRoleTeams.Crewmate } || networkedPlayerInfo2.Role.TeamType == RoleTeamTypes.Impostor
? GameData.Instance.GetPlayerById(judgeOverrule.OverruledPlayerId)
: networkedPlayerInfo;
}
}
}
+80 -11
View File
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Linq;
using InnerNet;
using MiraAPI.Events;
using MiraAPI.Events.Vanilla.Meeting.Voting;
using MiraAPI.Networking;
@@ -41,9 +42,9 @@ public static class VotingUtils
/// <param name="voteData">The player's <see cref="PlayerVoteData"/>.</param>
/// <param name="suspectIdx">Who the player voted for.</param>
/// <param name="cancelVote">Whether you want the vote to commence or not.</param>
private static void HandleVote(PlayerVoteData voteData, byte suspectIdx, out bool cancelVote)
private static void HandleVote(PlayerVoteData voteData, byte suspectIdx, bool byJudge, out bool cancelVote)
{
var @event = new HandleVoteEvent(voteData, suspectIdx);
var @event = new HandleVoteEvent(voteData, suspectIdx, byJudge);
MiraEventManager.InvokeEvent(@event);
cancelVote = @event.PreventVote;
@@ -60,7 +61,14 @@ public static class VotingUtils
return;
}
voteData.DecreaseRemainingVotes(1);
if (byJudge)
{
voteData.SetRemainingVotes(0);
}
else
{
voteData.DecreaseRemainingVotes(1);
}
voteData.VoteForPlayer(suspectIdx);
}
@@ -75,14 +83,14 @@ public static class VotingUtils
{
if (!source.IsHost()) return;
MeetingHud.Instance.playerStates.First(state => state.TargetPlayerId == voterId).UnsetVote();
MeetingHud.Instance.playerStates.First(state => state.PlayerId == voterId).UnsetVote();
if (PlayerControl.LocalPlayer.PlayerId != voterId)
{
return;
}
MeetingHud.Instance.playerStates.First(state => state.TargetPlayerId == votedFor).ThumbsDown.enabled = false;
MeetingHud.Instance.playerStates.First(state => state.PlayerId == votedFor).ThumbsDown.enabled = false;
if (!AmongUsClient.Instance.AmHost)
{
@@ -93,13 +101,74 @@ public static class VotingUtils
foreach (var t in MeetingHud.Instance.playerStates)
{
t.voteComplete = false;
t.VoteComplete = false;
}
MeetingHud.Instance.SkipVoteButton.voteComplete = false;
MeetingHud.Instance.SkipVoteButton.VoteComplete = false;
MeetingHud.Instance.SkipVoteButton.gameObject.SetActive(true);
}
/// <summary>
/// Networks the casting of a vote. We replace the vanilla solution with a custom version that works for Judge specifically.
/// </summary>
/// <param name="source">The <see cref="PlayerControl"/> who sent this RPC.</param>
/// <param name="srcPlayerId">The id of the player who casted the vote.</param>
/// <param name="suspectPlayerId">The voted player's id.</param>
/// <param name="overruleNonce">Data that is checked by the Judge role to determine which Judge takes priority.</param>
[MethodRpc((uint)MiraRpc.QueueOverruleVotes)]
public static void RpcQueueOverruleVotes(PlayerControl source, byte srcPlayerId, byte suspectPlayerId, ushort overruleNonce)
{
CustomCastJudgeVote(srcPlayerId, suspectPlayerId, overruleNonce);
}
private static void CustomCastJudgeVote(PlayerId judgePlayerId, PlayerId targetPlayerId, ushort overruleNonce)
{
var plr = GameData.Instance.GetPlayerById(judgePlayerId.Value);
if (!plr) return;
var voteData = plr.Object.GetVoteData();
if (!voteData) return;
HandleVote(voteData, targetPlayerId.Value, true, out var cancelVote);
// Handle local behaviour for the voter (for some reason checking AmOwner does not work for host)
if (PlayerControl.LocalPlayer.PlayerId == judgePlayerId.Value)
{
if (!cancelVote) SoundManager.Instance.PlaySound(MeetingHud.Instance.VoteLockinSound, false);
foreach (var playerVoteArea in MeetingHud.Instance.playerStates)
{
playerVoteArea.ClearButtons();
}
MeetingHud.Instance.SkipVoteButton.ClearButtons();
var localVoteData = PlayerControl.LocalPlayer.GetVoteData();
if (!localVoteData || localVoteData.VotesRemaining != 0) return;
MeetingHud.Instance.SkipVoteButton.VoteComplete = true;
MeetingHud.Instance.SkipVoteButton.gameObject.SetActive(false);
}
if (cancelVote) return;
// If player has no more votes, then make it show that the player has used all their votes.
if (voteData.VotesRemaining == 0)
{
MeetingHud.Instance.AddOrUpdateJudgeOverrule(judgePlayerId, targetPlayerId, overruleNonce);
MeetingHud.Instance.playerStates.First(x => x.PlayerId == judgePlayerId.Value).SetVote(targetPlayerId.Value);
}
// If host, then check end voting, and set votes/send chat if applicable
if (!PlayerControl.LocalPlayer.IsHost()) return;
MeetingHud.Instance.SetDirtyBit(1U);
MeetingHud.Instance.CheckForEndVoting();
if (voteData.VotesRemaining != 0) return;
PlayerControl.LocalPlayer.RpcSendChatNote(judgePlayerId.Value, ChatNoteTypes.DidVote);
}
/// <summary>
/// Networks the casting of a vote. We replace the vanilla solution with a custom version that works for the use case.
/// </summary>
@@ -120,7 +189,7 @@ public static class VotingUtils
var voteData = plr.Object.GetVoteData();
if (!voteData) return;
HandleVote(voteData, suspectPlayerId, out var cancelVote);
HandleVote(voteData, suspectPlayerId, false, out var cancelVote);
// Handle local behaviour for the voter (for some reason checking AmOwner does not work for host)
if (PlayerControl.LocalPlayer.PlayerId == srcPlayerId)
@@ -137,7 +206,7 @@ public static class VotingUtils
var localVoteData = PlayerControl.LocalPlayer.GetVoteData();
if (!localVoteData || localVoteData.VotesRemaining != 0) return;
MeetingHud.Instance.SkipVoteButton.voteComplete = true;
MeetingHud.Instance.SkipVoteButton.VoteComplete = true;
MeetingHud.Instance.SkipVoteButton.gameObject.SetActive(false);
}
@@ -146,7 +215,7 @@ public static class VotingUtils
// If player has no more votes, then make it show that the player has used all their votes.
if (voteData.VotesRemaining == 0)
{
MeetingHud.Instance.playerStates.First(x => x.TargetPlayerId == srcPlayerId).SetVote(suspectPlayerId);
MeetingHud.Instance.playerStates.First(x => x.PlayerId == srcPlayerId).SetVote(suspectPlayerId);
}
// If host, then check end voting, and set votes/send chat if applicable
@@ -233,7 +302,7 @@ public static class VotingUtils
MeetingHud.Instance.BloopAVoteIcon(playerById, num, MeetingHud.Instance.SkippedVoting.transform);
num++;
}
else if (vote.Suspect == playerVoteArea.TargetPlayerId)
else if (vote.Suspect == playerVoteArea.PlayerId)
{
if (!delays.TryAdd(vote.Suspect, 0))
{