mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-10-19 15:51:48 +00:00
make resharper happy
This commit is contained in:
92 files changed
+692
-710
No files matched your search
Executable
+29
@@ -0,0 +1,29 @@
|
||||
<assembly name="0Harmony">
|
||||
<member name="T:HarmonyLib.HarmonyPatch">
|
||||
<attribute ctor="M:JetBrains.Annotations.MeansImplicitUseAttribute.#ctor(JetBrains.Annotations.ImplicitUseTargetFlags)">
|
||||
<argument>3</argument>
|
||||
</attribute>
|
||||
</member>
|
||||
|
||||
<member name="T:HarmonyLib.HarmonyPrefix">
|
||||
<attribute ctor="M:JetBrains.Annotations.MeansImplicitUseAttribute.#ctor" />
|
||||
</member>
|
||||
<member name="T:HarmonyLib.HarmonyPostfix">
|
||||
<attribute ctor="M:JetBrains.Annotations.MeansImplicitUseAttribute.#ctor" />
|
||||
</member>
|
||||
<member name="T:HarmonyLib.HarmonyTranspiler">
|
||||
<attribute ctor="M:JetBrains.Annotations.MeansImplicitUseAttribute.#ctor" />
|
||||
</member>
|
||||
<member name="T:HarmonyLib.HarmonyFinalizer">
|
||||
<attribute ctor="M:JetBrains.Annotations.MeansImplicitUseAttribute.#ctor" />
|
||||
</member>
|
||||
<member name="T:HarmonyLib.HarmonyPrepare">
|
||||
<attribute ctor="M:JetBrains.Annotations.MeansImplicitUseAttribute.#ctor" />
|
||||
</member>
|
||||
<member name="T:HarmonyLib.HarmonyTargetMethod">
|
||||
<attribute ctor="M:JetBrains.Annotations.MeansImplicitUseAttribute.#ctor" />
|
||||
</member>
|
||||
<member name="T:HarmonyLib.HarmonyTargetMethods">
|
||||
<attribute ctor="M:JetBrains.Annotations.MeansImplicitUseAttribute.#ctor" />
|
||||
</member>
|
||||
</assembly>
|
||||
@@ -3,7 +3,6 @@ using MiraAPI.Patches.Stubs;
|
||||
using MiraAPI.Roles;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using Reactor.Utilities;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MiraAPI.Example.Roles;
|
||||
@@ -55,8 +54,8 @@ public class ChameleonRole : CrewmateRole, ICustomRole
|
||||
}
|
||||
else
|
||||
{
|
||||
SpriteRenderer rend = Player.cosmetics.currentBodySprite.BodySprite;
|
||||
TextMeshPro tmp = Player.cosmetics.nameText;
|
||||
var rend = Player.cosmetics.currentBodySprite.BodySprite;
|
||||
var tmp = Player.cosmetics.nameText;
|
||||
tmp.color = Color.Lerp(
|
||||
tmp.color,
|
||||
new Color(tmp.color.r, tmp.color.g, tmp.color.b, Player.AmOwner ? 0.3f : 0),
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace MiraAPI.Events.Vanilla.Meeting.Voting;
|
||||
/// <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 class HandleVoteEvent(PlayerVoteData playerVoteData, byte targetId, bool isOverruling) : MiraCancelableEvent
|
||||
public class HandleVoteEvent(PlayerVoteData playerVoteData, byte targetId, bool isOverruling = false) : MiraCancelableEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the instance of the voter's <see cref="PlayerVoteData"/>.
|
||||
@@ -43,13 +43,4 @@ public class HandleVoteEvent(PlayerVoteData playerVoteData, byte targetId, bool
|
||||
/// Gets or sets a value indicating whether the vote event is an Overrule caused by a Judge.
|
||||
/// </summary>
|
||||
public bool IsOverruling { get; set; } = isOverruling;
|
||||
|
||||
/// <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>
|
||||
public HandleVoteEvent(PlayerVoteData playerVoteData, byte targetId) : this(playerVoteData, targetId, false)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
[*.cs]
|
||||
|
||||
# CS1591: Missing XML comment for publicly visible type or member.
|
||||
# dotnet_diagnostic.CS1591.severity = none
|
||||
@@ -278,11 +278,11 @@ public abstract class AbstractGameMode : IOptionable
|
||||
instance.background.transform.localScale = (instance.taskText.textBounds.size.x > 0f)
|
||||
? new Vector3(instance.taskText.textBounds.size.x + 0.2f, instance.taskText.textBounds.size.y + 0.2f, 1f)
|
||||
: Vector3.zero;
|
||||
Vector3 vector = instance.background.sprite.bounds.extents;
|
||||
var vector = instance.background.sprite.bounds.extents;
|
||||
vector.y = -vector.y;
|
||||
vector = vector.Mul(instance.background.transform.localScale);
|
||||
instance.background.transform.localPosition = vector;
|
||||
Vector3 vector2 = instance.tab.sprite.bounds.extents;
|
||||
var vector2 = instance.tab.sprite.bounds.extents;
|
||||
vector2 = vector2.Mul(instance.tab.transform.localScale);
|
||||
vector2.y = -vector2.y;
|
||||
vector2.x += vector.x * 2f;
|
||||
|
||||
@@ -17,5 +17,5 @@ public class ClassicMode : AbstractGameMode
|
||||
public override string Description => "MiraApi.Gamemode.Classic.Description";
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override LoadableAsset<Sprite>? Icon => MiraAssets.ClassicGamemodeIcon;
|
||||
public override LoadableAsset<Sprite> Icon => MiraAssets.ClassicGamemodeIcon;
|
||||
}
|
||||
@@ -56,6 +56,7 @@ public static class GameModeOption
|
||||
if (!Values.ContainsKey(mode.ID))
|
||||
Values.Add(mode.ID, MiraLocaleManager.GetOrCreateLocaleString(mode.Name));
|
||||
}
|
||||
|
||||
/*[HarmonyPatch(typeof(GameOptionsMenu), nameof(GameOptionsMenu.CreateSettings))]
|
||||
[HarmonyPostfix]
|
||||
private static void CreateSettingsPatch(GameOptionsMenu __instance)
|
||||
@@ -126,7 +127,7 @@ public static class GameModeOption
|
||||
}
|
||||
}
|
||||
}
|
||||
// could make Values a dict of AbstractGameMode too
|
||||
// TODO: could make Values a dict of AbstractGameMode too
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(GameOptionsMenu), nameof(GameOptionsMenu.ValueChanged))]
|
||||
|
||||
@@ -97,19 +97,66 @@ public class HideAndSeekMode : AbstractGameMode
|
||||
.Where(c => c.Character != null && c.Character.Data != null && !c.Character.Data.Disconnected &&
|
||||
!c.Character.Data.IsDead).OrderBy(c => c.Id).Select(c => c.Character.Data)];
|
||||
|
||||
foreach (NetworkedPlayerInfo networkedPlayerInfo in GameData.Instance.AllPlayers)
|
||||
foreach (var networkedPlayerInfo in GameData.Instance.AllPlayers)
|
||||
{
|
||||
if (networkedPlayerInfo.Object != null && networkedPlayerInfo.Object.isDummy)
|
||||
{
|
||||
list2.Add(networkedPlayerInfo);
|
||||
}
|
||||
}
|
||||
IGameOptions currentGameOptions = GameOptionsManager.Instance.CurrentGameOptions;
|
||||
int adjustedNumImpostors = GameOptionsManager.Instance.CurrentGameOptions.GetAdjustedNumImpostors(list2.Count);
|
||||
var currentGameOptions = GameOptionsManager.Instance.CurrentGameOptions;
|
||||
var adjustedNumImpostors = GameOptionsManager.Instance.CurrentGameOptions.GetAdjustedNumImpostors(list2.Count);
|
||||
AssignRolesForTeam(list2, currentGameOptions, RoleTeamTypes.Impostor, Math.Max(adjustedNumImpostors, 1), RoleTypes.Impostor);
|
||||
AssignRolesForTeam(list2, currentGameOptions, RoleTeamTypes.Crewmate, int.MaxValue, RoleTypes.Engineer);
|
||||
}
|
||||
|
||||
private static void AddGuaranteedRoles(IEnumerable<RoleBehaviour> guaranteedRoles, IGameOptions opts, List<RoleTypes> list)
|
||||
{
|
||||
var roleOptions = opts.RoleOptions;
|
||||
foreach (var roleAssignmentData in guaranteedRoles.Select(x =>
|
||||
new RoleManager.RoleAssignmentData(x, roleOptions.GetNumPerGame(x.Role), 100)))
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
var count = roleAssignmentData.Count;
|
||||
roleAssignmentData.Count = count - 1;
|
||||
if (count <= 0) break;
|
||||
|
||||
list.Add(roleAssignmentData.Role.Role);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void AddPotentialRoles(IEnumerable<RoleBehaviour> source, IGameOptions opts, List<RoleTypes> list)
|
||||
{
|
||||
var roleOptions = opts.RoleOptions;
|
||||
var potentialRoles = source.Where(x => !x.IsDead).Select(role =>
|
||||
new RoleManager.RoleAssignmentData(
|
||||
role,
|
||||
roleOptions.GetNumPerGame(role.Role),
|
||||
roleOptions.GetChancePerGame(role.Role))).ToList();
|
||||
|
||||
list.Clear();
|
||||
foreach (var roleData in potentialRoles)
|
||||
{
|
||||
for (var i = 0; i < roleData.Count; i++)
|
||||
{
|
||||
if (HashRandom.Next(101) < roleData.Chance)
|
||||
{
|
||||
list.Add(roleData.Role.Role);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void AddFallbackRoles(List<RoleTypes> list, int targetPlayerCount, int teamMax, int rolesAssigned, RoleTypes basicRole)
|
||||
{
|
||||
while (list.Count < targetPlayerCount && list.Count + rolesAssigned < teamMax)
|
||||
{
|
||||
list.Add(basicRole);
|
||||
}
|
||||
}
|
||||
|
||||
private static void AssignRolesForTeam(
|
||||
List<NetworkedPlayerInfo> players,
|
||||
IGameOptions opts,
|
||||
@@ -117,151 +164,90 @@ public class HideAndSeekMode : AbstractGameMode
|
||||
int teamMax,
|
||||
RoleTypes defaultRole)
|
||||
{
|
||||
Error($"Hide And Seek Mode - AssignRolesForTeam: Team: {team}, Max: {teamMax}, Players: {players.Count}, DefaultRole: {defaultRole}");
|
||||
int num = 0;
|
||||
IRoleOptionsCollection roleOptions = opts.RoleOptions;
|
||||
Info($"Hide And Seek Mode - AssignRolesForTeam: Team: {team}, Max: {teamMax}, Players: {players.Count}, DefaultRole: {defaultRole}");
|
||||
var num = 0;
|
||||
var roleOptions = opts.RoleOptions;
|
||||
var source = RoleManager.Instance.AllRoles.ToArray()
|
||||
.Where(role => role.TeamType == team && !RoleManager.IsGhostRole(role.Role) &&
|
||||
CustomRoleUtils.CanSpawnOnCurrentMode(role))
|
||||
.ToList();
|
||||
|
||||
var assignmentData = source.Where(x => !x.IsDead).Select(role =>
|
||||
new RoleManager.RoleAssignmentData(
|
||||
role,
|
||||
roleOptions.GetNumPerGame(role.Role),
|
||||
roleOptions.GetChancePerGame(role.Role))).ToList();
|
||||
|
||||
var source2 = CustomRoleUtils.GetPossibleRoles(assignmentData, x => x.Chance == 100);
|
||||
var guaranteedRoles = source.Where(x => source2.Contains(((ushort)x.Role, 100)));
|
||||
var guaranteedRoles = source.Where(x => source2.Contains(((ushort)x.Role, 100))).ToList();
|
||||
List<RoleTypes> list = [];
|
||||
if (team == RoleTeamTypes.Crewmate)
|
||||
{
|
||||
Error($"MiraAPI.Patches.Roles.LogicRoleSelectionHnsPatch - AssignRolesForTeam: Before Guaranteed Assignment");
|
||||
foreach (RoleManager.RoleAssignmentData roleAssignmentData in guaranteedRoles.Select((x) =>
|
||||
new RoleManager.RoleAssignmentData(x, roleOptions.GetNumPerGame(x.Role), 100)))
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
RoleManager.RoleAssignmentData roleAssignmentData2 = roleAssignmentData;
|
||||
int count = roleAssignmentData2.Count;
|
||||
roleAssignmentData2.Count = count - 1;
|
||||
if (count <= 0)
|
||||
|
||||
switch (team)
|
||||
{
|
||||
case RoleTeamTypes.Crewmate:
|
||||
Info($"MiraAPI.Patches.Roles.LogicRoleSelectionHnsPatch - AssignRolesForTeam: Before Guaranteed Assignment");
|
||||
AddGuaranteedRoles(guaranteedRoles, opts, list);
|
||||
Info($"MiraAPI.Patches.Roles.LogicRoleSelectionHnsPatch - AssignRolesForTeam: After Guaranteed Assignment");
|
||||
AssignRolesFromList(players, teamMax, list, ref num);
|
||||
|
||||
AddPotentialRoles(source, opts, list);
|
||||
Info($"MiraAPI.Patches.Roles.LogicRoleSelectionHnsPatch - AssignRolesForTeam: After Potential Assignment");
|
||||
AssignRolesFromList(players, teamMax, list, ref num);
|
||||
|
||||
const RoleTypes basicCrewRole = RoleTypes.Engineer;
|
||||
AddFallbackRoles(list, players.Count, teamMax, num, basicCrewRole);
|
||||
AssignRolesFromList(players, teamMax, list, ref num);
|
||||
Info($"MiraAPI.Patches.Roles.LogicRoleSelectionHnsPatch - AssignRolesForTeam: After Fallback Assignment");
|
||||
break;
|
||||
}
|
||||
|
||||
list.Add(roleAssignmentData.Role.Role);
|
||||
}
|
||||
}
|
||||
Error($"MiraAPI.Patches.Roles.LogicRoleSelectionHnsPatch - AssignRolesForTeam: After Guaranteed Assignment");
|
||||
AssignRolesFromList(players, teamMax, list, ref num);
|
||||
|
||||
var list2 = source.Where(x => !x.IsDead).Select(role =>
|
||||
new RoleManager.RoleAssignmentData(
|
||||
role,
|
||||
roleOptions.GetNumPerGame(role.Role),
|
||||
roleOptions.GetChancePerGame(role.Role))).ToList();
|
||||
|
||||
list.Clear();
|
||||
foreach (RoleManager.RoleAssignmentData roleAssignmentData3 in list2)
|
||||
{
|
||||
for (int i = 0; i < roleAssignmentData3.Count; i++)
|
||||
{
|
||||
if (HashRandom.Next(101) < roleAssignmentData3.Chance)
|
||||
{
|
||||
list.Add(roleAssignmentData3.Role.Role);
|
||||
}
|
||||
}
|
||||
}
|
||||
Error($"MiraAPI.Patches.Roles.LogicRoleSelectionHnsPatch - AssignRolesForTeam: After Potential Assignment");
|
||||
|
||||
AssignRolesFromList(players, teamMax, list, ref num);
|
||||
var basicRole = RoleTypes.Engineer;
|
||||
while (list.Count < players.Count && list.Count + num < teamMax)
|
||||
{
|
||||
list.Add(basicRole);
|
||||
}
|
||||
|
||||
AssignRolesFromList(players, teamMax, list, ref num);
|
||||
Error($"MiraAPI.Patches.Roles.LogicRoleSelectionHnsPatch - AssignRolesForTeam: After Fallback Assignment");
|
||||
}
|
||||
else if (team == RoleTeamTypes.Impostor)
|
||||
{
|
||||
Error($"MiraAPI.Patches.Roles.LogicRoleSelectionHnsPatch - AssignRolesForTeam: Before Guaranteed Assignment");
|
||||
case RoleTeamTypes.Impostor:
|
||||
Info($"MiraAPI.Patches.Roles.LogicRoleSelectionHnsPatch - AssignRolesForTeam: Before Guaranteed Assignment");
|
||||
var newImpostors = new List<NetworkedPlayerInfo>();
|
||||
|
||||
// Specified Seeker
|
||||
if (HasImpostorPlayerID() &&
|
||||
ValidateImpostorPlayerID(players) &&
|
||||
!AmongUsClient.Instance.IsGamePublic)
|
||||
{
|
||||
NetworkedPlayerInfo networkedPlayerInfo = players
|
||||
.First(p => p.PlayerId == ImpostorPlayerID());
|
||||
var networkedPlayerInfo = players.First(p => p.PlayerId == ImpostorPlayerID());
|
||||
players.Remove(networkedPlayerInfo);
|
||||
newImpostors.Add(networkedPlayerInfo);
|
||||
Error($"MiraAPI.Patches.Roles.LogicRoleSelectionHnsPatch - AssignRolesForTeam: Seeker is {networkedPlayerInfo.PlayerName}, ID: {networkedPlayerInfo.PlayerId}");
|
||||
Info($"MiraAPI.Patches.Roles.LogicRoleSelectionHnsPatch - AssignRolesForTeam: Seeker is {networkedPlayerInfo.PlayerName}, ID: {networkedPlayerInfo.PlayerId}");
|
||||
}
|
||||
// Random Seeker
|
||||
else
|
||||
{
|
||||
int num2 = 0;
|
||||
var num2 = 0;
|
||||
while (num2 < teamMax && players.Count > 0)
|
||||
{
|
||||
PseudoRandomList<NetworkedPlayerInfo> pseudoRandomList = new(AmongUsClient.Instance.GameId);
|
||||
players.Do(pseudoRandomList.Add);
|
||||
for (int i = 0; i < GameData.RoundsPlayedInSession; i++)
|
||||
for (var i = 0; i < GameData.RoundsPlayedInSession; i++)
|
||||
{
|
||||
pseudoRandomList.PickRandom();
|
||||
}
|
||||
NetworkedPlayerInfo networkedPlayerInfo = pseudoRandomList.PickRandom();
|
||||
var networkedPlayerInfo = pseudoRandomList.PickRandom();
|
||||
players.Remove(networkedPlayerInfo);
|
||||
newImpostors.Add(networkedPlayerInfo);
|
||||
num2++;
|
||||
Error($"MiraAPI.Patches.Roles.LogicRoleSelectionHnsPatch - AssignRolesForTeam: Seeker is {networkedPlayerInfo.PlayerName}, ID: {networkedPlayerInfo.PlayerId}");
|
||||
Info($"MiraAPI.Patches.Roles.LogicRoleSelectionHnsPatch - AssignRolesForTeam: Seeker is {networkedPlayerInfo.PlayerName}, ID: {networkedPlayerInfo.PlayerId}");
|
||||
}
|
||||
}
|
||||
Error($"MiraAPI.Patches.Roles.LogicRoleSelectionHnsPatch - AssignRolesForTeam: After Guaranteed Assignment");
|
||||
foreach (RoleManager.RoleAssignmentData roleAssignmentData in guaranteedRoles.Select((x) =>
|
||||
new RoleManager.RoleAssignmentData(x, roleOptions.GetNumPerGame(x.Role), 100)))
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
RoleManager.RoleAssignmentData roleAssignmentData2 = roleAssignmentData;
|
||||
int count = roleAssignmentData2.Count;
|
||||
roleAssignmentData2.Count = count - 1;
|
||||
if (count <= 0)
|
||||
{
|
||||
Info($"MiraAPI.Patches.Roles.LogicRoleSelectionHnsPatch - AssignRolesForTeam: After Guaranteed Assignment");
|
||||
|
||||
AddGuaranteedRoles(guaranteedRoles, opts, list);
|
||||
AssignRolesFromList(newImpostors, teamMax, list, ref num);
|
||||
|
||||
AddPotentialRoles(source, opts, list);
|
||||
AssignRolesFromList(newImpostors, teamMax, list, ref num);
|
||||
|
||||
const RoleTypes basicImpRole = RoleTypes.Impostor;
|
||||
AddFallbackRoles(list, newImpostors.Count, teamMax, num, basicImpRole);
|
||||
AssignRolesFromList(newImpostors, teamMax, list, ref num);
|
||||
break;
|
||||
}
|
||||
|
||||
list.Add(roleAssignmentData.Role.Role);
|
||||
}
|
||||
}
|
||||
AssignRolesFromList(newImpostors, teamMax, list, ref num);
|
||||
|
||||
var list2 = source.Where(x => !x.IsDead).Select(role =>
|
||||
new RoleManager.RoleAssignmentData(
|
||||
role,
|
||||
roleOptions.GetNumPerGame(role.Role),
|
||||
roleOptions.GetChancePerGame(role.Role))).ToList();
|
||||
|
||||
list.Clear();
|
||||
foreach (RoleManager.RoleAssignmentData roleAssignmentData3 in list2)
|
||||
{
|
||||
for (int i = 0; i < roleAssignmentData3.Count; i++)
|
||||
{
|
||||
if (HashRandom.Next(101) < roleAssignmentData3.Chance)
|
||||
{
|
||||
list.Add(roleAssignmentData3.Role.Role);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AssignRolesFromList(newImpostors, teamMax, list, ref num);
|
||||
var basicRole = RoleTypes.Impostor;
|
||||
while (list.Count < newImpostors.Count && list.Count + num < teamMax)
|
||||
{
|
||||
list.Add(basicRole);
|
||||
}
|
||||
|
||||
AssignRolesFromList(newImpostors, teamMax, list, ref num);
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(team), team, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -269,10 +255,10 @@ public class HideAndSeekMode : AbstractGameMode
|
||||
{
|
||||
while (roleList.Count > 0 && players.Count > 0 && rolesAssigned < teamMax)
|
||||
{
|
||||
int index = HashRandom.FastNext(roleList.Count);
|
||||
RoleTypes roleType = roleList[index];
|
||||
var index = HashRandom.FastNext(roleList.Count);
|
||||
var roleType = roleList[index];
|
||||
roleList.RemoveAt(index);
|
||||
int index2 = HashRandom.FastNext(players.Count);
|
||||
var index2 = HashRandom.FastNext(players.Count);
|
||||
players[index2].Object.RpcSetRole(roleType);
|
||||
players.RemoveAt(index2);
|
||||
rolesAssigned++;
|
||||
@@ -377,7 +363,7 @@ public class HideAndSeekMode : AbstractGameMode
|
||||
PlayerControl.LocalPlayer.CurrentOutfitType,
|
||||
PlayerMaterial.MaskType.None,
|
||||
false);
|
||||
SpriteAnim component = poolablePlayer.GetComponent<SpriteAnim>();
|
||||
var component = poolablePlayer.GetComponent<SpriteAnim>();
|
||||
poolablePlayer.gameObject.SetActive(true);
|
||||
poolablePlayer.ToggleName(false);
|
||||
component.Play(anim);
|
||||
@@ -423,13 +409,11 @@ public class HideAndSeekMode : AbstractGameMode
|
||||
deadPlayerCount = 0;
|
||||
ShipStatus.Instance.BreakEmergencyButton();
|
||||
PlayerControl.LocalPlayer.SetKillTimer(0.01f);
|
||||
if (HudManager.InstanceExists)
|
||||
{
|
||||
if (!HudManager.InstanceExists) return;
|
||||
HudManager.Instance.gameObject.AddComponent<HnsMusicHandler>();
|
||||
HudManager.Instance.gameObject.AddComponent<HideAndSeekHudHelper>();
|
||||
HudManager.Instance.gameObject.AddComponent<HnsDangerMeter>();
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override MapOptions GetMapOptions()
|
||||
@@ -484,30 +468,18 @@ public class HideAndSeekMode : AbstractGameMode
|
||||
}
|
||||
return PlayerBodyTypes.Normal;
|
||||
}
|
||||
else if (AprilFoolsMode.ShouldHorseAround())
|
||||
|
||||
if (AprilFoolsMode.ShouldHorseAround())
|
||||
{
|
||||
if (player.Data.Role.IsImpostor)
|
||||
return player.Data.Role.IsImpostor ? PlayerBodyTypes.Normal : PlayerBodyTypes.Horse;
|
||||
}
|
||||
|
||||
if (AprilFoolsMode.ShouldLongAround())
|
||||
{
|
||||
return PlayerBodyTypes.Normal;
|
||||
}
|
||||
return PlayerBodyTypes.Horse;
|
||||
}
|
||||
else if (AprilFoolsMode.ShouldLongAround())
|
||||
{
|
||||
if (player.Data.Role.IsImpostor)
|
||||
{
|
||||
return PlayerBodyTypes.LongSeeker;
|
||||
}
|
||||
return PlayerBodyTypes.Long;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (player.Data.Role.IsImpostor)
|
||||
{
|
||||
return PlayerBodyTypes.Seeker;
|
||||
}
|
||||
return PlayerBodyTypes.Normal;
|
||||
return player.Data.Role.IsImpostor ? PlayerBodyTypes.LongSeeker : PlayerBodyTypes.Long;
|
||||
}
|
||||
|
||||
return player.Data.Role.IsImpostor ? PlayerBodyTypes.Seeker : PlayerBodyTypes.Normal;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
@@ -516,11 +488,11 @@ public class HideAndSeekMode : AbstractGameMode
|
||||
instance.background.transform.localScale = (instance.taskText.textBounds.size.x > 0f)
|
||||
? new Vector3(instance.taskText.textBounds.size.x + 0.2f, instance.taskText.textBounds.size.y + 0.2f, 1f)
|
||||
: Vector3.zero;
|
||||
Vector3 vector = instance.background.sprite.bounds.extents;
|
||||
var vector = instance.background.sprite.bounds.extents;
|
||||
vector.y = -vector.y;
|
||||
vector = vector.Mul(instance.background.transform.localScale);
|
||||
instance.background.transform.localPosition = vector;
|
||||
Vector3 vector2 = instance.tab.sprite.bounds.extents;
|
||||
var vector2 = instance.tab.sprite.bounds.extents;
|
||||
vector2 = vector2.Mul(instance.tab.transform.localScale);
|
||||
vector2.y = -vector2.y;
|
||||
vector2.x += vector.x * 2f;
|
||||
|
||||
@@ -216,7 +216,7 @@ public static class ModdedOptionsManager
|
||||
internal static void HandleSyncOptions(NetData[] data)
|
||||
{
|
||||
// necessary to disable then re-enable this setting
|
||||
// we dont know how other plugins handle their configs
|
||||
// we don't know how other plugins handle their configs
|
||||
// this way, all the options are saved at once, instead of one by one
|
||||
var oldConfigSetting = new Dictionary<MiraPluginInfo, bool>();
|
||||
foreach (var plugin in MiraPluginManager.Instance.RegisteredPlugins)
|
||||
|
||||
@@ -13,7 +13,7 @@ public record struct OptionNotifConfiguration
|
||||
{
|
||||
[Obsolete("Default constructor is not supported. Please use the constructor that takes an AbstractOptionGroup parameter.")]
|
||||
[SuppressMessage("Info Code Smell", "S1133:Deprecated code should be removed", Justification = "Will not be removed, as this throws instead.")]
|
||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member (Justification: Read above.)
|
||||
public OptionNotifConfiguration()
|
||||
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ using Object = UnityEngine.Object;
|
||||
namespace MiraAPI.GameOptions.OptionTypes;
|
||||
|
||||
/// <summary>
|
||||
/// An option for selecting an ingame player. It returns an index of the values list, NOT A PLAYER ID. To get a player out of this, index the <see cref="Values"/> list.
|
||||
/// An option for selecting an in-game player. It returns an index of the values list, NOT A PLAYER ID. To get a player out of this, index the <see cref="Values"/> list.
|
||||
/// </summary>
|
||||
public class ModdedPlayerOption : ModdedOption<int>
|
||||
{
|
||||
|
||||
@@ -27,6 +27,7 @@ public sealed class HideAndSeekHudHelper(nint cppPtr) : MonoBehaviour(cppPtr)
|
||||
private AudioClip finalHideAlertSfx;
|
||||
private AudioClip finalHideCountdownSfx;
|
||||
[SuppressMessage("Style", "IDE0052:Remove unread private members", Justification = "Ignore for now; tentative code.")]
|
||||
// ReSharper disable once NotAccessedField.Local (Justification: Read above.)
|
||||
private AudioClip taskFinishedSound;
|
||||
|
||||
// private const int SECONDS_TO_BEEP = 10;
|
||||
@@ -38,7 +39,7 @@ public sealed class HideAndSeekHudHelper(nint cppPtr) : MonoBehaviour(cppPtr)
|
||||
private float currentFinalHideTime = float.MaxValue;
|
||||
|
||||
private float secondsSinceLastSetDirty;
|
||||
private Coroutine beepCoroutine;
|
||||
private Coroutine? beepCoroutine;
|
||||
private HideAndSeekTimerBar timerBar;
|
||||
private float taskDirtyTimer;
|
||||
|
||||
@@ -64,7 +65,7 @@ public sealed class HideAndSeekHudHelper(nint cppPtr) : MonoBehaviour(cppPtr)
|
||||
/// <returns>true if the player can use the admin ability.</returns>
|
||||
public bool SeekerAdminMapEnabled(PlayerControl player)
|
||||
{
|
||||
int item = Helpers.GetAlivePlayers().Count(x => !x.Data.Role.IsImpostor);
|
||||
var item = Helpers.GetAlivePlayers().Count(x => !x.Data.Role.IsImpostor);
|
||||
return !player.inVent && player.Data != null && player.Data.Role != null &&
|
||||
((!player.inVent && player.Data.Role.IsImpostor && IsFinalCountdown &&
|
||||
OptionGroupSingleton<HnsFinalHideOptions>.Instance.FinalHideSeekMap.Value) ||
|
||||
@@ -74,7 +75,7 @@ public sealed class HideAndSeekHudHelper(nint cppPtr) : MonoBehaviour(cppPtr)
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A event that is called when a task is completed.
|
||||
/// An event that is called when a task is completed.
|
||||
/// </summary>
|
||||
/// <param name="timeDeduction">The amount of time to deduct from the timer.</param>
|
||||
public void OnTaskComplete(float timeDeduction)
|
||||
@@ -93,8 +94,8 @@ public sealed class HideAndSeekHudHelper(nint cppPtr) : MonoBehaviour(cppPtr)
|
||||
/// <returns>The match duration in seconds.</returns>
|
||||
public static float GetTotalRoundTime()
|
||||
{
|
||||
float escapeTime = OptionGroupSingleton<HnsCrewmateOptions>.Instance.HidingTime.Value;
|
||||
float finalCountdownTime = OptionGroupSingleton<HnsFinalHideOptions>.Instance.FinalHideTime.Value;
|
||||
var escapeTime = OptionGroupSingleton<HnsCrewmateOptions>.Instance.HidingTime.Value;
|
||||
var finalCountdownTime = OptionGroupSingleton<HnsFinalHideOptions>.Instance.FinalHideTime.Value;
|
||||
return escapeTime + finalCountdownTime;
|
||||
}
|
||||
|
||||
@@ -156,21 +157,21 @@ public sealed class HideAndSeekHudHelper(nint cppPtr) : MonoBehaviour(cppPtr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (HideCountdown > 0f && taskDirtyTimer > 0.25f)
|
||||
{
|
||||
float num = taskDirtyTimer;
|
||||
|
||||
if (!(HideCountdown > 0f) || !(taskDirtyTimer > 0.25f)) return;
|
||||
var num = taskDirtyTimer;
|
||||
taskDirtyTimer = 0f;
|
||||
if (!PlayerControl.LocalPlayer)
|
||||
{
|
||||
HudManager.Instance.TaskPanel.SetTaskText(string.Empty);
|
||||
return;
|
||||
}
|
||||
NetworkedPlayerInfo data = PlayerControl.LocalPlayer.Data;
|
||||
var data = PlayerControl.LocalPlayer.Data;
|
||||
if (data == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
bool flag = data.Role != null && data.Role.IsImpostor;
|
||||
var flag = data.Role != null && data.Role.IsImpostor;
|
||||
HudManager.Instance.tasksString.Clear();
|
||||
if (PlayerControl.LocalPlayer.myTasks == null || PlayerControl.LocalPlayer.myTasks.Count == 0)
|
||||
{
|
||||
@@ -178,9 +179,9 @@ public sealed class HideAndSeekHudHelper(nint cppPtr) : MonoBehaviour(cppPtr)
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < PlayerControl.LocalPlayer.myTasks.Count; i++)
|
||||
for (var i = 0; i < PlayerControl.LocalPlayer.myTasks.Count; i++)
|
||||
{
|
||||
PlayerTask playerTask = PlayerControl.LocalPlayer.myTasks[i];
|
||||
var playerTask = PlayerControl.LocalPlayer.myTasks[i];
|
||||
if (playerTask)
|
||||
{
|
||||
if (playerTask.TaskType == TaskTypes.FixComms && !flag)
|
||||
@@ -205,7 +206,6 @@ public sealed class HideAndSeekHudHelper(nint cppPtr) : MonoBehaviour(cppPtr)
|
||||
}
|
||||
HudManager.Instance.TaskPanel.SetTaskText(HudManager.Instance.tasksString.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
@@ -230,7 +230,7 @@ public sealed class HideAndSeekHudHelper(nint cppPtr) : MonoBehaviour(cppPtr)
|
||||
|
||||
private void OnFinalCountdownTriggered()
|
||||
{
|
||||
foreach (PlayerControl playerControl in PlayerControl.AllPlayerControls)
|
||||
foreach (var playerControl in PlayerControl.AllPlayerControls)
|
||||
{
|
||||
if (!playerControl.Data.Role.IsImpostor && !playerControl.Data.IsDead)
|
||||
{
|
||||
@@ -242,7 +242,7 @@ public sealed class HideAndSeekHudHelper(nint cppPtr) : MonoBehaviour(cppPtr)
|
||||
|
||||
if (!PlayerControl.LocalPlayer.Data.IsDead && Minigame.Instance != null)
|
||||
{
|
||||
Minigame instance = Minigame.Instance;
|
||||
var instance = Minigame.Instance;
|
||||
if (instance != null)
|
||||
{
|
||||
instance.ForceClose();
|
||||
@@ -256,7 +256,7 @@ public sealed class HideAndSeekHudHelper(nint cppPtr) : MonoBehaviour(cppPtr)
|
||||
|
||||
private void AdjustEscapeTimer(float timeDeduction, bool forceDirty)
|
||||
{
|
||||
float num = currentHideTime;
|
||||
var num = currentHideTime;
|
||||
currentHideTime -= timeDeduction;
|
||||
currentHideTime = Mathf.Max(currentHideTime, 0f);
|
||||
if (currentHideTime <= 10f && beepCoroutine == null)
|
||||
@@ -281,8 +281,8 @@ public sealed class HideAndSeekHudHelper(nint cppPtr) : MonoBehaviour(cppPtr)
|
||||
{
|
||||
while (!IsFinalCountdown)
|
||||
{
|
||||
float num = currentHideTime / 10f;
|
||||
float pitch = 1.5f - num / 2f;
|
||||
var num = currentHideTime / 10f;
|
||||
var pitch = 1.5f - num / 2f;
|
||||
SoundManager.Instance.PlaySoundImmediate(finalHideCountdownSfx, false, 1f, pitch);
|
||||
yield return new WaitForSeconds(1f);
|
||||
}
|
||||
@@ -290,8 +290,8 @@ public sealed class HideAndSeekHudHelper(nint cppPtr) : MonoBehaviour(cppPtr)
|
||||
yield return Effects.Wait(currentFinalHideTime - 10f);
|
||||
while (currentFinalHideTime > 0f)
|
||||
{
|
||||
float num2 = currentFinalHideTime / 10f;
|
||||
float pitch2 = 1.5f - num2 / 2f;
|
||||
var num2 = currentFinalHideTime / 10f;
|
||||
var pitch2 = 1.5f - num2 / 2f;
|
||||
SoundManager.Instance.PlaySoundImmediate(finalHideCountdownSfx, false, 1f, pitch2);
|
||||
yield return new WaitForSeconds(1f);
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ public sealed class HnsDangerMeter(nint cppPtr) : MonoBehaviour(cppPtr)
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
PlayerControl localPlayer = PlayerControl.LocalPlayer;
|
||||
var localPlayer = PlayerControl.LocalPlayer;
|
||||
if (impostors == null || localPlayer == null)
|
||||
{
|
||||
return;
|
||||
@@ -56,12 +56,12 @@ public sealed class HnsDangerMeter(nint cppPtr) : MonoBehaviour(cppPtr)
|
||||
return;
|
||||
}
|
||||
|
||||
float num = float.MaxValue;
|
||||
foreach (PlayerControl playerControl in impostors)
|
||||
var num = float.MaxValue;
|
||||
foreach (var playerControl in impostors)
|
||||
{
|
||||
if (playerControl == null)
|
||||
continue;
|
||||
float sqrMagnitude = (playerControl.transform.position - localPlayer.transform.position).sqrMagnitude;
|
||||
var sqrMagnitude = (playerControl.transform.position - localPlayer.transform.position).sqrMagnitude;
|
||||
if (sqrMagnitude < scaryMusicDistance && num > sqrMagnitude)
|
||||
{
|
||||
num = sqrMagnitude;
|
||||
@@ -102,7 +102,7 @@ public sealed class HnsDangerMeter(nint cppPtr) : MonoBehaviour(cppPtr)
|
||||
|
||||
private void UpdateDangerMusic()
|
||||
{
|
||||
PlayerControl localPlayer = PlayerControl.LocalPlayer;
|
||||
var localPlayer = PlayerControl.LocalPlayer;
|
||||
if (localPlayer != null && localPlayer.Data != null && localPlayer.Data.IsDead)
|
||||
{
|
||||
HnsMusicHandler.Instance.SetTaskState(false);
|
||||
@@ -141,8 +141,8 @@ public sealed class HnsDangerMeter(nint cppPtr) : MonoBehaviour(cppPtr)
|
||||
scaryMusicDistance = 55f * baseSpeed;
|
||||
veryScaryMusicDistance = 15f * baseSpeed;
|
||||
if (scaryMusicDistance >= veryScaryMusicDistance) return;
|
||||
float num = veryScaryMusicDistance;
|
||||
float num2 = scaryMusicDistance;
|
||||
var num = veryScaryMusicDistance;
|
||||
var num2 = scaryMusicDistance;
|
||||
scaryMusicDistance = num;
|
||||
veryScaryMusicDistance = num2;
|
||||
}
|
||||
|
||||
@@ -144,9 +144,8 @@ public sealed class HnsMusicHandler(nint cppPtr) : MonoBehaviour(cppPtr)
|
||||
/// </summary>
|
||||
public void StartMusicWithIntro()
|
||||
{
|
||||
if (PlayerControl.LocalPlayer.Data.Role.IsImpostor)
|
||||
{
|
||||
AudioClip clip = OptionGroupSingleton<HnsCrewmateOptions>.Instance.HidingTime.Value <= 180f
|
||||
if (!PlayerControl.LocalPlayer.Data.Role.IsImpostor) return;
|
||||
var clip = OptionGroupSingleton<HnsCrewmateOptions>.Instance.HidingTime.Value <= 180f
|
||||
? musicCollection.ImpostorShortMusic
|
||||
: musicCollection.ImpostorLongMusic;
|
||||
if (AprilFoolsMode.ShouldHorseAround())
|
||||
@@ -156,15 +155,14 @@ public sealed class HnsMusicHandler(nint cppPtr) : MonoBehaviour(cppPtr)
|
||||
|
||||
SoundManager.Instance.PlaySound(clip, true, 1f, SoundManager.Instance.MusicChannel);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the current task state to alter music behaviour.
|
||||
/// </summary>
|
||||
/// <param name="isDoingTask">The new value of the state.</param>
|
||||
public void SetTaskState(bool isDoingTask)
|
||||
/// <param name="taskState">The new value of the state.</param>
|
||||
public void SetTaskState(bool taskState)
|
||||
{
|
||||
this.isDoingTask = isDoingTask;
|
||||
isDoingTask = taskState;
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
|
||||
@@ -8,6 +8,7 @@ namespace MiraAPI.HnsReimplemented.Options;
|
||||
/// <summary>
|
||||
/// Gets or sets the crewmate options for Hide and Seek.
|
||||
/// </summary>
|
||||
// ReSharper disable once ClassNeverInstantiated.Global (Justification: Instantiated via Activator.CreateInstance.)
|
||||
public class HnsCrewmateOptions : AbstractOptionGroup<HideAndSeekMode>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -8,6 +8,7 @@ namespace MiraAPI.HnsReimplemented.Options;
|
||||
/// <summary>
|
||||
/// Gets or sets the Final Hide options for Hide and Seek.
|
||||
/// </summary>
|
||||
// ReSharper disable once ClassNeverInstantiated.Global (Justification: Instantiated via Activator.CreateInstance.)
|
||||
public class HnsFinalHideOptions : AbstractOptionGroup<HideAndSeekMode>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -8,6 +8,7 @@ namespace MiraAPI.HnsReimplemented.Options;
|
||||
/// <summary>
|
||||
/// Gets or sets the seeker settings on Hide and Seek.
|
||||
/// </summary>
|
||||
// ReSharper disable once ClassNeverInstantiated.Global (Justification: Instantiated via Activator.CreateInstance.)
|
||||
public class HnsImpostorOptions : AbstractOptionGroup<HideAndSeekMode>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -8,6 +8,7 @@ namespace MiraAPI.HnsReimplemented.Options;
|
||||
/// <summary>
|
||||
/// Gets or sets the task options for Hide and Seek.
|
||||
/// </summary>
|
||||
// ReSharper disable once ClassNeverInstantiated.Global (Justification: Instantiated via Activator.CreateInstance.)
|
||||
public class HnsTaskOptions : AbstractOptionGroup<HideAndSeekMode>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -205,12 +205,10 @@ public abstract class CustomActionButton
|
||||
}
|
||||
}));
|
||||
|
||||
if (Keybind != null)
|
||||
{
|
||||
if (Keybind == null) return;
|
||||
Keybind.OnActivate(() =>
|
||||
{
|
||||
if (Enabled(PlayerControl.LocalPlayer.Data.Role))
|
||||
{
|
||||
if (!Enabled(PlayerControl.LocalPlayer.Data.Role)) return;
|
||||
// Invoke the generic button click event.
|
||||
var genericEvent = new MiraButtonClickEvent(this);
|
||||
MiraEventManager.InvokeEvent(genericEvent);
|
||||
@@ -244,7 +242,6 @@ public abstract class CustomActionButton
|
||||
ClickHandler();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
KeybindIcon =
|
||||
@@ -257,7 +254,6 @@ public abstract class CustomActionButton
|
||||
HudManagerPatches.ModdedKeybindIcons.Add(KeybindText);
|
||||
Button.usesRemainingSprite.transform.localPosition = new(-0.341f, 0.45f, -0.1f);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allows you to change the button's location.
|
||||
@@ -298,6 +294,8 @@ public abstract class CustomActionButton
|
||||
case ButtonLocation.BottomRight:
|
||||
Button.transform.SetParent(HudManagerPatches.BottomRight);
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(location), location, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,14 +21,12 @@ public static class CustomButtonManager
|
||||
/// <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>
|
||||
{ });
|
||||
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>
|
||||
{ });
|
||||
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 = [];
|
||||
|
||||
@@ -77,7 +77,7 @@ public class CustomPlayerMenu(IntPtr il2CppPtr) : Minigame(il2CppPtr)
|
||||
/// <inheritdoc />
|
||||
public override void Begin(PlayerTask task)
|
||||
{
|
||||
throw new NotImplementedException("Use the other Begin method.");
|
||||
throw new NotSupportedException("Use the other Begin method.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -31,8 +31,8 @@ internal sealed class MiraHudHelper(nint cppPtr) : MonoBehaviour(cppPtr)
|
||||
public static SpriteRenderer SubmergedFloorButtonRenderer;
|
||||
public static SpriteRenderer SubmergedFloorButtonRendererHover;
|
||||
|
||||
public static readonly Vector3 BelowOptionPos = new(0.435f, 1.25f, 0f);
|
||||
public static readonly Vector3 FullTopPos = new(0.435f, 0.475f, 0f);
|
||||
private static readonly Vector3 BelowOptionPos = new(0.435f, 1.25f, 0f);
|
||||
private static readonly Vector3 FullTopPos = new(0.435f, 0.475f, 0f);
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
@@ -71,7 +71,7 @@ internal sealed class MiraHudHelper(nint cppPtr) : MonoBehaviour(cppPtr)
|
||||
UpdateSubmergedButtons(instance);
|
||||
}
|
||||
|
||||
public static void CreateUiRow(HudManager instance)
|
||||
private static void CreateUiRow(HudManager instance)
|
||||
{
|
||||
if (!UiTopRight)
|
||||
{
|
||||
@@ -146,7 +146,7 @@ internal sealed class MiraHudHelper(nint cppPtr) : MonoBehaviour(cppPtr)
|
||||
}
|
||||
}
|
||||
|
||||
public static void UpdateSubmergedButtons(HudManager instance)
|
||||
private static void UpdateSubmergedButtons(HudManager instance)
|
||||
{
|
||||
if (!ModCompatibility.IsSubmerged() || SubmergedFloorButton || !ExtraUiTopRight || SubmergedFloorButton || !ExtraUiTopRight)
|
||||
return;
|
||||
@@ -166,7 +166,7 @@ internal sealed class MiraHudHelper(nint cppPtr) : MonoBehaviour(cppPtr)
|
||||
MiraApiSettings.SetUpButtonPositions();
|
||||
}
|
||||
|
||||
public static void AdjustModifierTab()
|
||||
private static void AdjustModifierTab()
|
||||
{
|
||||
if (ModifierDisplayObject || !UiTopRight || !ExtraUiTopRight || !ModifierDisplayComponent.Instance)
|
||||
return;
|
||||
@@ -185,7 +185,7 @@ internal sealed class MiraHudHelper(nint cppPtr) : MonoBehaviour(cppPtr)
|
||||
MiraApiSettings.SetUpButtonPositions();
|
||||
}
|
||||
|
||||
public static void CreateNewUiRow(HudManager instance)
|
||||
private static void CreateNewUiRow(HudManager instance)
|
||||
{
|
||||
if (ExtraUiTopRight || !UiTopRight)
|
||||
return;
|
||||
|
||||
@@ -70,8 +70,8 @@ public class BaseKeybind
|
||||
/// <param name="action">The <see cref="Action"/> to remove.</param>
|
||||
public void RemoveOnActivate(Action action)
|
||||
{
|
||||
#pragma warning disable CS8601 // Possible null reference assignment.
|
||||
#pragma warning disable CS8601 // Possible null reference assignment (Justification: Shut up.)
|
||||
Handler -= action;
|
||||
#pragma warning restore CS8601 // Possible null reference assignment.
|
||||
#pragma warning restore CS8601 // Possible null reference assignment
|
||||
}
|
||||
}
|
||||
@@ -64,10 +64,10 @@ public static class KeybindUtils
|
||||
/// </returns>
|
||||
public static KeyboardKeyCode FindAvailableKey(KeyboardKeyCode exclude)
|
||||
{
|
||||
foreach (KeyboardKeyCode key in Enum.GetValues<KeyboardKeyCode>())
|
||||
foreach (var key in Enum.GetValues<KeyboardKeyCode>())
|
||||
{
|
||||
if (key == exclude) continue;
|
||||
bool used = KeybindManager.Keybinds.Exists(e => e.DefaultKey == key);
|
||||
var used = KeybindManager.Keybinds.Exists(e => e.DefaultKey == key);
|
||||
if (!used) return key;
|
||||
}
|
||||
return KeyboardKeyCode.None;
|
||||
|
||||
@@ -10,10 +10,10 @@ namespace MiraAPI.LocalSettings.Attributes;
|
||||
/// <param name="description">The description of the setting. Defaults to entry description.</param>
|
||||
[AttributeUsage(AttributeTargets.Property)]
|
||||
public abstract class LocalSettingAttribute(
|
||||
#pragma warning disable CS9113 // Parameter is unread.
|
||||
#pragma warning disable CS9113 // Parameter is unread (Justification: No idea why they exist, but they probably do for a reason unknown to me.)
|
||||
string? name = null,
|
||||
string? description = null
|
||||
#pragma warning restore CS9113 // Parameter is unread.
|
||||
#pragma warning restore CS9113 // Parameter is unread
|
||||
) : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -29,7 +29,7 @@ public class LocalSettingsButton(string text, Action onClick)
|
||||
/// </summary>
|
||||
public LocalSettingsTab? Tab { get; internal set; }
|
||||
|
||||
private TextMeshPro _btnText { get; set; }
|
||||
private TextMeshPro _btnText;
|
||||
|
||||
internal GameObject CreateButton(ToggleButtonBehaviour toggle, Transform parent, ref float offset, ref int order, bool last)
|
||||
{
|
||||
|
||||
@@ -41,9 +41,8 @@ public class LocalEnumSetting(
|
||||
.Cast<Enum>()
|
||||
.Select(x => x.ToDisplayString())];
|
||||
|
||||
private SpriteRenderer _highlight { get; set; }
|
||||
|
||||
private TextMeshPro _btnText { get; set; }
|
||||
private SpriteRenderer _highlight;
|
||||
private TextMeshPro _btnText;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override GameObject CreateOption(ToggleButtonBehaviour toggle, SlideBar slider, Transform parent, ref float offset, ref int order, bool last)
|
||||
@@ -60,7 +59,7 @@ public class LocalEnumSetting(
|
||||
var highlight = button.transform.FindChild("ButtonHighlight")?.GetComponent<SpriteRenderer>();
|
||||
if (highlight != null)
|
||||
{
|
||||
_highlight = highlight;
|
||||
this._highlight = highlight;
|
||||
highlight.color = Tab!.TabAppearance.EnumHoverColor;
|
||||
highlight.gameObject.SetActive(false);
|
||||
}
|
||||
@@ -85,7 +84,7 @@ public class LocalEnumSetting(
|
||||
|
||||
button.OnClick.AddListener((UnityAction)(() =>
|
||||
{
|
||||
int value = GetValue();
|
||||
var value = GetValue();
|
||||
value++;
|
||||
if (value >= Values.Length)
|
||||
{
|
||||
|
||||
@@ -51,9 +51,8 @@ public class LocalNumberSetting(
|
||||
/// </summary>
|
||||
public MiraNumberSuffixes SuffixType { get; } = suffixType ?? MiraNumberSuffixes.None;
|
||||
|
||||
private SpriteRenderer _highlight { get; set; }
|
||||
|
||||
private TextMeshPro _btnText { get; set; }
|
||||
private SpriteRenderer _highlight;
|
||||
private TextMeshPro _btnText;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override GameObject CreateOption(ToggleButtonBehaviour toggle, SlideBar slider, Transform parent, ref float offset, ref int order, bool last)
|
||||
@@ -95,7 +94,7 @@ public class LocalNumberSetting(
|
||||
|
||||
button.OnClick.AddListener((UnityAction)(() =>
|
||||
{
|
||||
float value = GetValue();
|
||||
var value = GetValue();
|
||||
value += Increment;
|
||||
if (value > NumberRange.max)
|
||||
{
|
||||
|
||||
@@ -58,7 +58,7 @@ public class LocalSliderSetting(
|
||||
/// </summary>
|
||||
public MiraNumberSuffixes SuffixType { get; } = suffixType ?? MiraNumberSuffixes.None;
|
||||
|
||||
private SlideBar _slider { get; set; }
|
||||
private SlideBar _slider;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override GameObject CreateOption(ToggleButtonBehaviour toggle, SlideBar slider, Transform parent, ref float offset, ref int order, bool last)
|
||||
|
||||
@@ -23,7 +23,7 @@ public class LocalToggleSetting(
|
||||
string? description = null
|
||||
) : LocalSettingBase<bool>(tab, configEntry, name, description)
|
||||
{
|
||||
private ToggleButtonBehaviour _toggle { get; set; }
|
||||
private ToggleButtonBehaviour _toggle;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override GameObject CreateOption(ToggleButtonBehaviour toggle, SlideBar slider, Transform parent, ref float offset, ref int order, bool last)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Globalization;
|
||||
using Il2CppInterop.Runtime.Attributes;
|
||||
using MiraAPI.Utilities;
|
||||
using Reactor.Utilities.Attributes;
|
||||
using Reactor.Utilities.Extensions;
|
||||
using TMPro;
|
||||
@@ -31,12 +32,12 @@ public class MeetingAbilityBehaviour : MonoBehaviour
|
||||
public PassiveButton Button { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets he parent <see cref="PlayerVoteArea"/>.
|
||||
/// Gets the parent <see cref="PlayerVoteArea"/>.
|
||||
/// </summary>
|
||||
public PlayerVoteArea VoteArea { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets he button's <see cref="SpriteRenderer"/> component.
|
||||
/// Gets the button's <see cref="SpriteRenderer"/> component.
|
||||
/// </summary>
|
||||
public SpriteRenderer Renderer { get; internal set; }
|
||||
|
||||
@@ -102,13 +103,13 @@ public class MeetingAbilityBehaviour : MonoBehaviour
|
||||
if (!_init) return;
|
||||
if (_button.Timer < 0.01f)
|
||||
{
|
||||
Renderer.material.SetFloat("_Desat", 0.0f);
|
||||
Renderer.material.SetFloat(ShaderID.Desat, 0.0f);
|
||||
CooldownText.text = string.Empty;
|
||||
UsesText.text = _button.LimitedUses ? _button.UsesLeft.ToString(CultureInfo.InvariantCulture) : string.Empty;
|
||||
}
|
||||
else
|
||||
{
|
||||
Renderer.material.SetFloat("_Desat", 0.5f);
|
||||
Renderer.material.SetFloat(ShaderID.Desat, 0.5f);
|
||||
CooldownText.text = _button.Timer.ToString(_button.CooldownTimerFormatString, NumberFormatInfo.InvariantInfo);
|
||||
UsesText.text = string.Empty;
|
||||
}
|
||||
@@ -122,8 +123,8 @@ public class MeetingAbilityBehaviour : MonoBehaviour
|
||||
/// <param name="maxTimer">The maximum timer.</param>
|
||||
public void SetFillUp(float timer, float maxTimer)
|
||||
{
|
||||
float percentCool = Mathf.Clamp(timer / maxTimer, 0.001f, 1f);
|
||||
var percentCool = Mathf.Clamp(timer / maxTimer, 0.001f, 1f);
|
||||
if (percentCool <= 0) percentCool = 1f;
|
||||
Renderer.material.SetFloat("_Percent", percentCool);
|
||||
Renderer.material.SetFloat(ShaderID.Percent, percentCool);
|
||||
}
|
||||
}
|
||||
@@ -16,5 +16,11 @@
|
||||
<EmbeddedResource Include="Resources\**\*.*" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EditorConfigFiles Remove="GameModes\.editorconfig" />
|
||||
<EditorConfigFiles Remove="Patches\GameModes\.editorconfig" />
|
||||
<EditorConfigFiles Remove="Patches\.editorconfig" />
|
||||
</ItemGroup>
|
||||
|
||||
<Import Project="../AmongUs.props" />
|
||||
</Project>
|
||||
@@ -25,6 +25,7 @@ namespace MiraAPI;
|
||||
[BepInProcess("Among Us.exe")]
|
||||
[BepInDependency(ReactorPlugin.Id)]
|
||||
[ReactorModFlags(ModFlags.RequireOnAllClients)]
|
||||
// ReSharper disable once ClassNeverInstantiated.Global (Justification: Instantiated by BepInEx.)
|
||||
public partial class MiraApiPlugin : BasePlugin, IMiraPlugin
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -154,8 +154,7 @@ public class MiraApiSettings(ConfigFile config) : LocalSettingsTab(config)
|
||||
var extraAspect = MiraHudHelper.ExtraUiAspectPos;
|
||||
var extraGrid = MiraHudHelper.ExtraUiGrid;
|
||||
var extraUi = MiraHudHelper.ExtraUiTopRight;
|
||||
if (extraUi && extraAspect && extraGrid)
|
||||
{
|
||||
if (!extraUi || !extraAspect || !extraGrid) return;
|
||||
extraAspect.DistanceFromEdge = new Vector3(0.435f * scaleFactor, 1.25f * scaleFactor, 0f);
|
||||
|
||||
foreach (var button in extraUi.GetAllChildren())
|
||||
@@ -180,7 +179,6 @@ public class MiraApiSettings(ConfigFile config) : LocalSettingsTab(config)
|
||||
}
|
||||
extraAspect.AdjustPosition();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the scale of the ability buttons.
|
||||
|
||||
@@ -44,7 +44,7 @@ public static class ModCompatibility
|
||||
InitSubmerged();
|
||||
}
|
||||
|
||||
internal static void InitSubmerged()
|
||||
private static void InitSubmerged()
|
||||
{
|
||||
if (!IL2CPPChainloader.Instance.Plugins.TryGetValue(SubmergedId, out var plugin))
|
||||
{
|
||||
|
||||
@@ -99,8 +99,7 @@ public class ModifierDisplayComponent(nint cppPtr) : MonoBehaviour(cppPtr)
|
||||
IsOpen = false;
|
||||
_children.gameObject.SetActive(false);
|
||||
|
||||
if (LocalSettingsTabSingleton<MiraApiSettings>.Instance.ModifiersHudLeftSide.Value)
|
||||
{
|
||||
if (!LocalSettingsTabSingleton<MiraApiSettings>.Instance.ModifiersHudLeftSide.Value) return;
|
||||
var aspect = GetComponent<AspectPosition>();
|
||||
_toggleButton.transform.localPosition = new Vector3(-1f, 2.7f, 0f);
|
||||
_children.transform.localPosition = new Vector3(-0.2f, -0.05f, 0f);
|
||||
@@ -108,7 +107,6 @@ public class ModifierDisplayComponent(nint cppPtr) : MonoBehaviour(cppPtr)
|
||||
aspect.DistanceFromEdge = new Vector3(1.8f, 2.55f, -20f);
|
||||
aspect.AdjustPosition();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Use this to refresh the modifiers UI. Useful if you hide modifiers UIs based on options.
|
||||
|
||||
@@ -17,7 +17,7 @@ public static class ModifierUtils
|
||||
/// <returns>An <see cref="IEnumerable{T}"/> of <typeparamref name="T"/>s.</returns>
|
||||
public static IEnumerable<T> GetActiveModifiers<T>(Func<T, bool>? predicate = null) where T : BaseModifier
|
||||
{
|
||||
return PlayerControl.AllPlayerControls.ToArray().SelectMany(x => x.GetModifiers<T>(predicate)).OfType<T>();
|
||||
return PlayerControl.AllPlayerControls.ToArray().SelectMany(x => x.GetModifiers(predicate));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -28,6 +28,6 @@ public static class ModifierUtils
|
||||
/// <returns>An <see cref="IEnumerable{T}"/> of <see cref="PlayerControl"/>s with that <typeparamref name="T"/>.</returns>
|
||||
public static IEnumerable<PlayerControl> GetPlayersWithModifier<T>(Func<T, bool>? predicate = null) where T : BaseModifier
|
||||
{
|
||||
return PlayerControl.AllPlayerControls.ToArray().Where(x => x.HasModifier<T>(predicate));
|
||||
return PlayerControl.AllPlayerControls.ToArray().Where(x => x.HasModifier(predicate));
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ namespace MiraAPI.Networking;
|
||||
/// </summary>
|
||||
/// <inheritdoc />
|
||||
[RegisterCustomRpc((uint)MiraRpc.CustomGameOver)]
|
||||
// ReSharper disable once ClassNeverInstantiated.Global (Justification: Instantiated via Activator.CreateInstance.)
|
||||
public class CustomGameOverRpc(MiraApiPlugin plugin, uint id) : PlayerCustomRpc<MiraApiPlugin, GameOverData>(plugin, id)
|
||||
{
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace MiraAPI.Networking.Modifiers;
|
||||
/// <param name="plugin">Mira plugin.</param>
|
||||
/// <param name="id">RPC ID.</param>
|
||||
[RegisterCustomRpc((uint)MiraRpc.AddModifier)]
|
||||
// ReSharper disable once ClassNeverInstantiated.Global (Justification: Instantiated by Reactor.)
|
||||
public class AddModifierRpc(MiraApiPlugin plugin, uint id) : PlayerCustomRpc<MiraApiPlugin, ModifierData>(plugin, id)
|
||||
{
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace MiraAPI.Networking;
|
||||
|
||||
// METHOD RPC DOESN'T WORK WITH THE ARRAYS AND STUFF SO THIS IS HOW WE WILL DO IT FOR NOW
|
||||
[RegisterCustomRpc((uint)MiraRpc.SyncGameOptions)]
|
||||
// ReSharper disable once ClassNeverInstantiated.Global (Justification: Instantiated via Activator.CreateInstance.)
|
||||
internal sealed class SyncOptionsRpc(MiraApiPlugin plugin, uint id) : PlayerCustomRpc<MiraApiPlugin, NetData[]>(plugin, id)
|
||||
{
|
||||
public override RpcLocalHandling LocalHandling => RpcLocalHandling.None;
|
||||
|
||||
@@ -6,6 +6,7 @@ using Reactor.Networking.Rpc;
|
||||
namespace MiraAPI.Networking;
|
||||
|
||||
[RegisterCustomRpc((uint)MiraRpc.SyncRoleOptions)]
|
||||
// ReSharper disable once ClassNeverInstantiated.Global (Justification: Instantiated via Activator.CreateInstance.)
|
||||
internal sealed class SyncRoleOptionsRpc(MiraApiPlugin plugin, uint id) : PlayerCustomRpc<MiraApiPlugin, NetData[]>(plugin, id)
|
||||
{
|
||||
public override RpcLocalHandling LocalHandling => RpcLocalHandling.None;
|
||||
|
||||
@@ -9,6 +9,7 @@ namespace MiraAPI.Patches.Accessibility;
|
||||
|
||||
[HarmonyPatch]
|
||||
[SuppressMessage("Style", "IDE0074:Use compound assignment", Justification = "Using compound assignment bypasses Unity lifetime checks.")]
|
||||
// ReSharper disable ConvertIfStatementToNullCoalescingAssignment (Justification: Read above.)
|
||||
public static class HudManagerFlashPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(HudManager), nameof(HudManager.StartReactorFlash))]
|
||||
@@ -22,6 +23,7 @@ public static class HudManagerFlashPatches
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(HudManager), nameof(HudManager.StartOxyFlash))]
|
||||
[HarmonyPrefix]
|
||||
public static bool OxygenFlashPrefix(HudManager __instance)
|
||||
@@ -33,7 +35,8 @@ public static class HudManagerFlashPatches
|
||||
|
||||
return false;
|
||||
}
|
||||
public static IEnumerator CoReactorFlash()
|
||||
|
||||
private static IEnumerator CoReactorFlash()
|
||||
{
|
||||
if (!HudManager.InstanceExists)
|
||||
{
|
||||
|
||||
@@ -30,15 +30,11 @@ public static class CanUsePatches
|
||||
{
|
||||
canUse = couldUse = false;
|
||||
|
||||
IUsable usable = __instance.TryCast<IUsable>()!;
|
||||
if (usable != null)
|
||||
{
|
||||
var usable = __instance.TryCast<IUsable>();
|
||||
if (usable == null) return true;
|
||||
var @event = new PlayerCanUseEvent(usable);
|
||||
MiraEventManager.InvokeEvent(@event);
|
||||
|
||||
return !@event.IsCancelled;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -17,10 +17,8 @@ public static class FreeplayRoundStartPatch
|
||||
|
||||
public static void Postfix(ref bool __result)
|
||||
{
|
||||
if (!__result)
|
||||
{
|
||||
if (__result) return;
|
||||
MeetingButtonManager.OnGameStart();
|
||||
MiraEventManager.InvokeEvent(new RoundStartEvent(true));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ namespace MiraAPI.Patches.Events;
|
||||
[HarmonyPatch]
|
||||
public static class VentEventPatches
|
||||
{
|
||||
// necessary because Vent.Use is inlined in il2cpp.
|
||||
// necessary because Vent.Use is inlined in IL2Cpp.
|
||||
private static bool _showButtons;
|
||||
|
||||
[HarmonyPostfix]
|
||||
|
||||
@@ -82,7 +82,7 @@ public static class TaskAdderPatches
|
||||
// folders.Add("Neutrals", neutralFolder);
|
||||
Folders.Add(ModifiersName, modifiersFolder);
|
||||
|
||||
int folderIdx = 2;
|
||||
var folderIdx = 2;
|
||||
foreach (var plugin in MiraPluginManager.Instance.RegisteredPlugins)
|
||||
{
|
||||
var pluginFolders = new Dictionary<string, TaskFolder>();
|
||||
@@ -131,11 +131,11 @@ public static class TaskAdderPatches
|
||||
return false;
|
||||
}
|
||||
|
||||
TaskFolder crewFolder = folders["Crewmates"] =
|
||||
var crewFolder = folders["Crewmates"] =
|
||||
Object.Instantiate(__instance.RootFolderPrefab, __instance.transform);
|
||||
crewFolder.gameObject.SetActive(false);
|
||||
crewFolder.SetFolderColor(TaskFolder.FolderColor.Blue);
|
||||
TaskFolder impFolder = folders["Impostors"] =
|
||||
var impFolder = folders["Impostors"] =
|
||||
Object.Instantiate(__instance.RootFolderPrefab, __instance.transform);
|
||||
impFolder.gameObject.SetActive(false);
|
||||
impFolder.SetFolderColor(TaskFolder.FolderColor.Red);
|
||||
@@ -165,14 +165,15 @@ public static class TaskAdderPatches
|
||||
return false;
|
||||
}
|
||||
|
||||
// ReSharper disable once ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract (Justification: Nullable annotations of reference types do not survive compilation.)
|
||||
if (taskList == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach (NormalPlayerTask normalPlayerTask in taskList)
|
||||
foreach (var normalPlayerTask in taskList)
|
||||
{
|
||||
SystemTypes systemTypes = normalPlayerTask.StartAt;
|
||||
var systemTypes = normalPlayerTask.StartAt;
|
||||
if (normalPlayerTask is DivertPowerTask task)
|
||||
{
|
||||
systemTypes = task.TargetSystem;
|
||||
@@ -252,7 +253,7 @@ public static class TaskAdderPatches
|
||||
.Any(x => x.FolderName == child.FolderName);
|
||||
}
|
||||
|
||||
// yes it might be crazy patching the entire method, but i tried so many other methods and only this works :cry:
|
||||
// yes it might be crazy patching the entire method, but I tried so many other methods and only this works :cry:
|
||||
// true -chip
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(nameof(TaskAdderGame.ShowFolder))]
|
||||
@@ -273,12 +274,12 @@ public static class TaskAdderPatches
|
||||
__instance.ActiveItems.ToArray().Do(x => x.gameObject.DeepDestroy(false));
|
||||
__instance.ActiveItems.Clear();
|
||||
|
||||
float num = 0f;
|
||||
float num2 = 0f;
|
||||
float num3 = 0f;
|
||||
var num = 0f;
|
||||
var num2 = 0f;
|
||||
var num3 = 0f;
|
||||
foreach (var t in taskFolder.SubFolders)
|
||||
{
|
||||
TaskFolder taskFolder2 = Object.Instantiate(t, __instance.TaskParent);
|
||||
var taskFolder2 = Object.Instantiate(t, __instance.TaskParent);
|
||||
taskFolder2.gameObject.SetActive(true);
|
||||
taskFolder2.Parent = __instance;
|
||||
taskFolder2.transform.localPosition = new Vector3(num, num2, 0f);
|
||||
@@ -305,7 +306,7 @@ public static class TaskAdderPatches
|
||||
.ToArray();
|
||||
foreach (var task in list)
|
||||
{
|
||||
TaskAddButton taskAddButton = Object.Instantiate(__instance.TaskPrefab);
|
||||
var taskAddButton = Object.Instantiate(__instance.TaskPrefab);
|
||||
taskAddButton.MyTask = task;
|
||||
switch (task.TaskType)
|
||||
{
|
||||
@@ -342,7 +343,7 @@ public static class TaskAdderPatches
|
||||
.ToArray();
|
||||
foreach (var role in roleChildren)
|
||||
{
|
||||
TaskAddButton roleAddButton = Object.Instantiate(__instance.RoleButton);
|
||||
var roleAddButton = Object.Instantiate(__instance.RoleButton);
|
||||
roleAddButton.SafePositionWorld = __instance.SafePositionWorld;
|
||||
roleAddButton.Text.text = role.GetRoleName();
|
||||
roleAddButton.Role = role;
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
[*.cs]
|
||||
|
||||
# S125: Sections of code should not be commented out
|
||||
dotnet_diagnostic.S125.severity = none
|
||||
@@ -9,12 +9,8 @@ internal static class BodyTypePatch
|
||||
{
|
||||
public static bool Prefix(IntroCutscene __instance, ref Il2CppSystem.Collections.IEnumerator __result)
|
||||
{
|
||||
if (CustomGameModeManager.ActiveMode?.ShowGameModeIntroCutscene == true)
|
||||
{
|
||||
if (CustomGameModeManager.ActiveMode?.ShowGameModeIntroCutscene != true) return true;
|
||||
__result = CustomGameModeManager.ActiveMode.IntroCutscene(__instance).WrapToIl2Cpp();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ using MiraAPI.GameModes;
|
||||
namespace MiraAPI.Patches.GameModes;
|
||||
|
||||
/// <summary>
|
||||
/// Allow Impostors to kill each other if can kill is enabled in gamemode or friendly fire is toggled on.
|
||||
/// Allow Impostors to kill each other if CanKill is enabled in gamemode or friendly fire is toggled on.
|
||||
/// </summary>
|
||||
[HarmonyPatch(typeof(ImpostorRole), "IsValidTarget")]
|
||||
internal static class ImpostorTargetPatch
|
||||
|
||||
@@ -9,12 +9,8 @@ internal static class IntroCutscenePatch
|
||||
{
|
||||
public static bool Prefix(IntroCutscene __instance, ref Il2CppSystem.Collections.IEnumerator __result)
|
||||
{
|
||||
if (CustomGameModeManager.ActiveMode?.ShowGameModeIntroCutscene == true)
|
||||
{
|
||||
if (CustomGameModeManager.ActiveMode?.ShowGameModeIntroCutscene != true) return true;
|
||||
__result = CustomGameModeManager.ActiveMode.IntroCutscene(__instance).WrapToIl2Cpp();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -10,12 +10,8 @@ internal static class MapBehaviourPatch
|
||||
public static bool ShowSabotagePatch(MapBehaviour __instance)
|
||||
{
|
||||
var shouldShow = CustomGameModeManager.ActiveMode?.ShouldShowSabotageMap(__instance);
|
||||
if (shouldShow.HasValue && !shouldShow.Value)
|
||||
{
|
||||
if (!shouldShow.HasValue || shouldShow.Value) return true;
|
||||
__instance.ShowNormalMap();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -8,11 +8,8 @@ internal static class ProgressTrackerPatch
|
||||
{
|
||||
public static bool Prefix(ProgressTracker __instance)
|
||||
{
|
||||
if (CustomGameModeManager.ActiveMode != null && !CustomGameModeManager.ActiveMode.ShowTaskBar)
|
||||
{
|
||||
if (CustomGameModeManager.ActiveMode == null || CustomGameModeManager.ActiveMode.ShowTaskBar) return true;
|
||||
__instance.gameObject.SetActive(false);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -8,11 +8,8 @@ internal static class TaskPanelPatch
|
||||
{
|
||||
public static bool Prefix(TaskPanelBehaviour __instance)
|
||||
{
|
||||
if (__instance != Roles.HudManagerPatches.RoleTab && CustomGameModeManager.ActiveMode != null)
|
||||
{
|
||||
if (__instance == Roles.HudManagerPatches.RoleTab || CustomGameModeManager.ActiveMode == null) return true;
|
||||
CustomGameModeManager.ActiveMode.UpdateTaskPanel(__instance);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -87,8 +87,7 @@ public static class HudManagerPatches
|
||||
button.gameObject.SetActive(!button.isActiveAndEnabled);
|
||||
}
|
||||
|
||||
if (_storedButtonsParent)
|
||||
{
|
||||
if (!_storedButtonsParent) return;
|
||||
foreach (var arrange in _storedButtonsParent.GetComponentsInChildren<GridArrange>(true))
|
||||
{
|
||||
if (!arrange.gameObject || !arrange.transform)
|
||||
@@ -104,8 +103,7 @@ public static class HudManagerPatches
|
||||
arrange.gameObject.SetActive(!arrange.isActiveAndEnabled);
|
||||
arrange.CellSize = new Vector2(scaleFactor, scaleFactor);
|
||||
arrange.gameObject.SetActive(!arrange.isActiveAndEnabled);
|
||||
if (arrange.isActiveAndEnabled && arrange.gameObject.transform.childCount != 0)
|
||||
{
|
||||
if (!arrange.isActiveAndEnabled || arrange.gameObject.transform.childCount == 0) continue;
|
||||
try
|
||||
{
|
||||
arrange.ArrangeChilds();
|
||||
@@ -116,8 +114,6 @@ public static class HudManagerPatches
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
/// <summary>
|
||||
|
||||
@@ -7,8 +7,8 @@ namespace MiraAPI.Patches.Keybinds;
|
||||
[HarmonyPatch(typeof(OptionsMenuBehaviour))]
|
||||
public static class OptionsMenuBehaviourPatch
|
||||
{
|
||||
private static ButtonRolloverHandler? _remap_rollover;
|
||||
private static SpriteRenderer? _remap_background;
|
||||
private static ButtonRolloverHandler? _remapRollover;
|
||||
private static SpriteRenderer? _remapBackground;
|
||||
|
||||
private static bool Conflicts => KeybindManager.GetConflicts().Count > 0;
|
||||
|
||||
@@ -16,11 +16,11 @@ public static class OptionsMenuBehaviourPatch
|
||||
[HarmonyPatch(nameof(OptionsMenuBehaviour.Open))]
|
||||
private static void OpenPostfix()
|
||||
{
|
||||
_remap_rollover = GameObject.Find("Remap Controls")?.GetComponent<ButtonRolloverHandler>()!;
|
||||
_remapRollover = GameObject.Find("Remap Controls")?.GetComponent<ButtonRolloverHandler>()!;
|
||||
try
|
||||
{
|
||||
_remap_background = _remap_rollover.transform.FindChild("Background").GetComponent<SpriteRenderer>();
|
||||
_remap_background.color = Conflicts ? Color.red : Color.white;
|
||||
_remapBackground = _remapRollover.transform.FindChild("Background").GetComponent<SpriteRenderer>();
|
||||
_remapBackground.color = Conflicts ? Color.red : Color.white;
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -32,17 +32,17 @@ public static class OptionsMenuBehaviourPatch
|
||||
[HarmonyPatch(nameof(OptionsMenuBehaviour.Update))]
|
||||
private static void UpdatePostfix()
|
||||
{
|
||||
if (_remap_rollover == null)
|
||||
if (_remapRollover == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (_remap_background == null)
|
||||
if (_remapBackground == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_remap_rollover.OutColor = Conflicts ? Color.red : Color.white;
|
||||
_remap_rollover.UnselectedColor = Conflicts ? Color.red : Color.white;
|
||||
_remap_rollover.OverColor = Conflicts ? new Color32(255, 55, 55, 255) : Palette.AcceptedGreen;
|
||||
_remapRollover.OutColor = Conflicts ? Color.red : Color.white;
|
||||
_remapRollover.UnselectedColor = Conflicts ? Color.red : Color.white;
|
||||
_remapRollover.OverColor = Conflicts ? new Color32(255, 55, 55, 255) : Palette.AcceptedGreen;
|
||||
}
|
||||
}
|
||||
@@ -69,9 +69,9 @@ public static class OptionsMenuPatches
|
||||
currentPage = 1;
|
||||
TabButtons.Clear();
|
||||
float yOffset = 0;
|
||||
int i = 0;
|
||||
int tabIdx = 0;
|
||||
int page = 1;
|
||||
var i = 0;
|
||||
var tabIdx = 0;
|
||||
var page = 1;
|
||||
LocalSettingsTab.TabGroups.Clear();
|
||||
foreach (var settings in LocalSettingsManager.AvailableTabs)
|
||||
{
|
||||
|
||||
@@ -107,7 +107,7 @@ public static class HatsTabPatches
|
||||
var groupNameText = __instance.GetComponentInChildren<TextMeshPro>(false);
|
||||
var group = sortedHats.Where(x => x.Key == StoreNames[page]);
|
||||
|
||||
foreach ((string groupName, List<HatData> hats) in group)
|
||||
foreach (var (groupName, hats) in group)
|
||||
{
|
||||
var text = Object.Instantiate(groupNameText, __instance.scroller.Inner);
|
||||
text.enabled = true;
|
||||
@@ -120,12 +120,14 @@ public static class HatsTabPatches
|
||||
text.fontSizeMax = 5f;
|
||||
text.fontSizeMin = 0f;
|
||||
var xLerp = __instance.XRange.Lerp(0.5f);
|
||||
// ReSharper disable once PossibleLossOfFraction (Justification: Intended.)
|
||||
var yLerp = __instance.YStart - hatIndex / __instance.NumPerRow * __instance.YOffset;
|
||||
text.transform.localPosition = new Vector3(xLerp, yLerp, -1f);
|
||||
|
||||
hatIndex += 5;
|
||||
loadRoutine = Coroutines.Start(CoGenerateChips(__instance, hats));
|
||||
}
|
||||
// ReSharper disable once PossibleLossOfFraction (Justification: Intended.)
|
||||
__instance.scroller.ContentYBounds.max = -(__instance.YStart - (hatIndex + 1) / __instance.NumPerRow * __instance.YOffset) - 3f;
|
||||
__instance.currentHatIsEquipped = true;
|
||||
}
|
||||
@@ -141,6 +143,7 @@ public static class HatsTabPatches
|
||||
foreach (var hat in batch.OrderBy(HatManager.Instance.allHats.IndexOf))
|
||||
{
|
||||
var hatXPosition = __instance.XRange.Lerp(hatIndex % __instance.NumPerRow / (__instance.NumPerRow - 1f));
|
||||
// ReSharper disable once PossibleLossOfFraction (Justification: Intended.)
|
||||
var hatYPosition = __instance.YStart - hatIndex / __instance.NumPerRow * __instance.YOffset;
|
||||
GenerateColorChip(__instance, new Vector2(hatXPosition, hatYPosition), hat);
|
||||
hatIndex += 1;
|
||||
|
||||
@@ -88,7 +88,7 @@ public static class NameplatesTabPatches
|
||||
|
||||
var groupNameText = __instance.GetComponentInChildren<TextMeshPro>(false);
|
||||
|
||||
int hatIndex = 0;
|
||||
var hatIndex = 0;
|
||||
|
||||
var (groupName, nameplates) = SortedNameplates.ToArray()[page];
|
||||
var text = Object.Instantiate(groupNameText, __instance.scroller.Inner);
|
||||
@@ -101,15 +101,16 @@ public static class NameplatesTabPatches
|
||||
text.fontSize = 5f;
|
||||
text.fontSizeMax = 5f;
|
||||
text.fontSizeMin = 0f;
|
||||
float xLerp = __instance.XRange.Lerp(0.5f);
|
||||
float yLerp = __instance.YStart - hatIndex / __instance.NumPerRow * __instance.YOffset;
|
||||
var xLerp = __instance.XRange.Lerp(0.5f);
|
||||
var yLerp = __instance.YStart - __instance.YOffset;
|
||||
text.transform.localPosition = new Vector3(xLerp, yLerp, -1f);
|
||||
|
||||
hatIndex += 2;
|
||||
foreach (var visor in nameplates.OrderBy(HatManager.Instance.allNamePlates.IndexOf))
|
||||
{
|
||||
float hatXPosition = __instance.XRange.Lerp(hatIndex % __instance.NumPerRow / (__instance.NumPerRow - 1f));
|
||||
float hatYPosition = __instance.YStart - hatIndex / __instance.NumPerRow * __instance.YOffset;
|
||||
var hatXPosition = __instance.XRange.Lerp(hatIndex % __instance.NumPerRow / (__instance.NumPerRow - 1f));
|
||||
// ReSharper disable once PossibleLossOfFraction (Justification: Intended.)
|
||||
var hatYPosition = __instance.YStart - hatIndex / __instance.NumPerRow * __instance.YOffset;
|
||||
GenerateColorChip(__instance, new Vector2(hatXPosition, hatYPosition), visor);
|
||||
hatIndex += 1;
|
||||
}
|
||||
@@ -139,14 +140,16 @@ public static class NameplatesTabPatches
|
||||
colorChip.Button.ClickMask = __instance.scroller.Hitbox;
|
||||
colorChip.ProductId = namePlate.ProdId;
|
||||
|
||||
var x = (NamePlateViewData viewData) =>
|
||||
{
|
||||
colorChip.transform.GetChild(1).GetComponent<SpriteRenderer>().sprite = viewData?.Image;
|
||||
// (colorChip as NameplateChip).image.sprite = viewData?.Image;
|
||||
};
|
||||
__instance.StartCoroutine(AddressableAssetExtensions.CoLoadAssetAsync<NamePlateViewData>(__instance, namePlate.GetAssetReference(), x));
|
||||
__instance.StartCoroutine(__instance.CoLoadAssetAsync<NamePlateViewData>(namePlate.GetAssetReference(), (Action<NamePlateViewData>?)LoadNameplate));
|
||||
colorChip.transform.localPosition = new Vector3(position.x, position.y, -1f);
|
||||
colorChip.Tag = namePlate;
|
||||
__instance.ColorChips.Add(colorChip);
|
||||
return;
|
||||
|
||||
void LoadNameplate(NamePlateViewData viewData)
|
||||
{
|
||||
colorChip.transform.GetChild(1).GetComponent<SpriteRenderer>().sprite = viewData.Image;
|
||||
// (colorChip as NameplateChip).image.sprite = viewData?.Image;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -89,7 +89,7 @@ public static class SkinsTabPatches
|
||||
|
||||
var groupNameText = __instance.GetComponentInChildren<TextMeshPro>(false);
|
||||
|
||||
int hatIndex = 0;
|
||||
var hatIndex = 0;
|
||||
|
||||
var (groupName, skins) = sortedSkins.ToArray()[page];
|
||||
var text = Object.Instantiate(groupNameText, __instance.scroller.Inner);
|
||||
@@ -102,15 +102,16 @@ public static class SkinsTabPatches
|
||||
text.fontSize = 5f;
|
||||
text.fontSizeMax = 5f;
|
||||
text.fontSizeMin = 0f;
|
||||
float xLerp = __instance.XRange.Lerp(0.5f);
|
||||
float yLerp = __instance.YStart - hatIndex / __instance.NumPerRow * __instance.YOffset;
|
||||
var xLerp = __instance.XRange.Lerp(0.5f);
|
||||
var yLerp = __instance.YStart - __instance.YOffset;
|
||||
text.transform.localPosition = new Vector3(xLerp, yLerp, -1f);
|
||||
|
||||
hatIndex += 5;
|
||||
foreach (var skin in skins.OrderBy(HatManager.Instance.allSkins.IndexOf))
|
||||
{
|
||||
float hatXPosition = __instance.XRange.Lerp(hatIndex % __instance.NumPerRow / (__instance.NumPerRow - 1f));
|
||||
float hatYPosition = __instance.YStart - hatIndex / __instance.NumPerRow * __instance.YOffset;
|
||||
var hatXPosition = __instance.XRange.Lerp(hatIndex % __instance.NumPerRow / (__instance.NumPerRow - 1f));
|
||||
// ReSharper disable once PossibleLossOfFraction (Justification: Intended.)
|
||||
var hatYPosition = __instance.YStart - hatIndex / __instance.NumPerRow * __instance.YOffset;
|
||||
GenerateColorChip(__instance, new Vector2(hatXPosition, hatYPosition), skin);
|
||||
hatIndex += 1;
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ public static class VisorsTabPatches
|
||||
|
||||
var groupNameText = __instance.GetComponentInChildren<TextMeshPro>(false);
|
||||
|
||||
int hatIndex = 0;
|
||||
var hatIndex = 0;
|
||||
|
||||
var (groupName, visors) = SortedVisors.ToArray()[page];
|
||||
var text = Object.Instantiate(groupNameText, __instance.scroller.Inner);
|
||||
@@ -100,15 +100,16 @@ public static class VisorsTabPatches
|
||||
text.fontSize = 5f;
|
||||
text.fontSizeMax = 5f;
|
||||
text.fontSizeMin = 0f;
|
||||
float xLerp = __instance.XRange.Lerp(0.5f);
|
||||
float yLerp = __instance.YStart - hatIndex / __instance.NumPerRow * __instance.YOffset;
|
||||
var xLerp = __instance.XRange.Lerp(0.5f);
|
||||
var yLerp = __instance.YStart - __instance.YOffset;
|
||||
text.transform.localPosition = new Vector3(xLerp, yLerp, -1f);
|
||||
|
||||
hatIndex += 5;
|
||||
foreach (var visor in visors.OrderBy(HatManager.Instance.allVisors.IndexOf))
|
||||
{
|
||||
float hatXPosition = __instance.XRange.Lerp(hatIndex % __instance.NumPerRow / (__instance.NumPerRow - 1f));
|
||||
float hatYPosition = __instance.YStart - hatIndex / __instance.NumPerRow * __instance.YOffset;
|
||||
var hatXPosition = __instance.XRange.Lerp(hatIndex % __instance.NumPerRow / (__instance.NumPerRow - 1f));
|
||||
// ReSharper disable once PossibleLossOfFraction (Justification: Intended.)
|
||||
var hatYPosition = __instance.YStart - hatIndex / __instance.NumPerRow * __instance.YOffset;
|
||||
GenerateColorChip(__instance, new Vector2(hatXPosition, hatYPosition), visor);
|
||||
hatIndex += 1;
|
||||
}
|
||||
|
||||
@@ -8,12 +8,12 @@ namespace MiraAPI.Patches;
|
||||
[HarmonyPatch]
|
||||
public static class MinigameBeginErrorPatch
|
||||
{
|
||||
private static readonly Logger _logger = new(Logger.Category.Gameplay, "Minigame");
|
||||
private static readonly Logger Logger = new(Logger.Category.Gameplay, "Minigame");
|
||||
|
||||
[HarmonyPatch(typeof(Minigame), nameof(Minigame.Begin))]
|
||||
[HarmonyPrefix]
|
||||
public static void Prefix(Minigame __instance)
|
||||
{
|
||||
__instance.logger ??= _logger;
|
||||
__instance.logger ??= Logger;
|
||||
}
|
||||
}
|
||||
@@ -25,12 +25,12 @@ namespace MiraAPI.Patches.Options;
|
||||
[HarmonyPatch(typeof(GameOptionsMenu))]
|
||||
internal static class GameOptionsMenuPatch
|
||||
{
|
||||
private static readonly List<CategoryHeaderMasked> _vanillaHeaders = new();
|
||||
private static readonly List<OptionBehaviour> _vanillaOptions = new();
|
||||
private static readonly List<OptionBehaviour> _mainOptions = new();
|
||||
private static readonly System.Collections.Generic.Dictionary<AbstractGameMode, System.Collections.Generic.List<AbstractOptionGroup>> _gameModeGroups = [];
|
||||
private static readonly System.Collections.Generic.Dictionary<AbstractGameMode, System.Collections.Generic.List<OptionBehaviour>> _gameModeOptions = [];
|
||||
private static readonly System.Collections.Generic.Dictionary<AbstractGameMode, System.Collections.Generic.List<CategoryHeaderMasked>> _gameModeHeaders = [];
|
||||
private static readonly List<CategoryHeaderMasked> VanillaHeaders = new();
|
||||
private static readonly List<OptionBehaviour> VanillaOptions = new();
|
||||
private static readonly List<OptionBehaviour> MainOptions = new();
|
||||
private static readonly System.Collections.Generic.Dictionary<AbstractGameMode, System.Collections.Generic.List<AbstractOptionGroup>> GameModeGroups = [];
|
||||
private static readonly System.Collections.Generic.Dictionary<AbstractGameMode, System.Collections.Generic.List<OptionBehaviour>> GameModeOptions = [];
|
||||
private static readonly System.Collections.Generic.Dictionary<AbstractGameMode, System.Collections.Generic.List<CategoryHeaderMasked>> GameModeHeaders = [];
|
||||
private static TextMeshPro _gamemodeDescription = null!;
|
||||
private static SpriteRenderer _modIcon = null!;
|
||||
|
||||
@@ -39,7 +39,7 @@ internal static class GameOptionsMenuPatch
|
||||
// ReSharper disable once InconsistentNaming
|
||||
public static bool InitPatch(GameOptionsMenu __instance)
|
||||
{
|
||||
__instance.Children ??= new Il2CppSystem.Collections.Generic.List<OptionBehaviour>();
|
||||
__instance.Children ??= new List<OptionBehaviour>();
|
||||
__instance.Children.Clear();
|
||||
|
||||
if (MenuState.Instance.CurrentModIdx == 0)
|
||||
@@ -81,9 +81,9 @@ internal static class GameOptionsMenuPatch
|
||||
|
||||
internal static void ToggleGamemodeOptions(AbstractGameMode gameMode, GameOptionsMenu instance)
|
||||
{
|
||||
float num = -1.217f;
|
||||
var num = -1.217f;
|
||||
instance.Children.Clear();
|
||||
foreach (var opt in _mainOptions)
|
||||
foreach (var opt in MainOptions)
|
||||
{
|
||||
instance.Children.Add(opt);
|
||||
}
|
||||
@@ -117,12 +117,12 @@ internal static class GameOptionsMenuPatch
|
||||
_gamemodeDescription.text = MiraLocaleManager.Get(gameMode.Description);
|
||||
if (gameMode.ShowNormalGameSettings)
|
||||
{
|
||||
foreach (var opt in _vanillaHeaders)
|
||||
foreach (var opt in VanillaHeaders)
|
||||
{
|
||||
num -= 0.63f;
|
||||
opt.gameObject.SetActive(true);
|
||||
}
|
||||
foreach (var opt in _vanillaOptions)
|
||||
foreach (var opt in VanillaOptions)
|
||||
{
|
||||
opt.gameObject.SetActive(true);
|
||||
instance.Children.Add(opt);
|
||||
@@ -131,29 +131,29 @@ internal static class GameOptionsMenuPatch
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var opt in _vanillaHeaders)
|
||||
foreach (var opt in VanillaHeaders)
|
||||
{
|
||||
opt.gameObject.SetActive(false);
|
||||
}
|
||||
foreach (var opt in _vanillaOptions)
|
||||
foreach (var opt in VanillaOptions)
|
||||
{
|
||||
opt.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var pair in _gameModeGroups)
|
||||
foreach (var pair in GameModeGroups)
|
||||
{
|
||||
if (pair.Value.Count != 0)
|
||||
{
|
||||
if (gameMode == pair.Key)
|
||||
{
|
||||
foreach (var opt in _gameModeHeaders[gameMode])
|
||||
foreach (var opt in GameModeHeaders[gameMode])
|
||||
{
|
||||
num -= 0.63f;
|
||||
opt.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
foreach (var opt in _gameModeOptions[gameMode])
|
||||
foreach (var opt in GameModeOptions[gameMode])
|
||||
{
|
||||
opt.gameObject.SetActive(true);
|
||||
instance.Children.Add(opt);
|
||||
@@ -162,12 +162,12 @@ internal static class GameOptionsMenuPatch
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var opt in _gameModeHeaders[pair.Key])
|
||||
foreach (var opt in GameModeHeaders[pair.Key])
|
||||
{
|
||||
opt.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
foreach (var opt in _gameModeOptions[pair.Key])
|
||||
foreach (var opt in GameModeOptions[pair.Key])
|
||||
{
|
||||
opt.gameObject.SetActive(false);
|
||||
}
|
||||
@@ -188,15 +188,15 @@ internal static class GameOptionsMenuPatch
|
||||
|
||||
private static void CreateSettings(GameOptionsMenu instance, Transform container)
|
||||
{
|
||||
float num = 0.713f;
|
||||
_vanillaHeaders.Clear();
|
||||
_vanillaOptions.Clear();
|
||||
_mainOptions.Clear();
|
||||
_gameModeHeaders.Clear();
|
||||
_gameModeOptions.Clear();
|
||||
_gameModeGroups.Clear();
|
||||
var num = 0.713f;
|
||||
VanillaHeaders.Clear();
|
||||
VanillaOptions.Clear();
|
||||
MainOptions.Clear();
|
||||
GameModeHeaders.Clear();
|
||||
GameModeOptions.Clear();
|
||||
GameModeGroups.Clear();
|
||||
|
||||
CategoryHeaderMasked gmCategory = Object.Instantiate(instance.categoryHeaderOrigin, Vector3.zero, Quaternion.identity, container);
|
||||
var gmCategory = Object.Instantiate(instance.categoryHeaderOrigin, Vector3.zero, Quaternion.identity, container);
|
||||
gmCategory.SetHeader(GameModeOption.CustomName, 20);
|
||||
gmCategory.transform.localScale = Vector3.one * 0.63f;
|
||||
gmCategory.transform.localPosition = new Vector3(-0.903f, num, -2f);
|
||||
@@ -204,7 +204,7 @@ internal static class GameOptionsMenuPatch
|
||||
num -= 0.63f;
|
||||
GameModeOption.OptionBehaviour.transform.localPosition = new Vector3(0.952f, num, -2f);
|
||||
GameModeOption.OptionBehaviour.SetClickMask(instance.ButtonClickMask);
|
||||
StringGameSetting setting = ScriptableObject.CreateInstance<StringGameSetting>();
|
||||
var setting = ScriptableObject.CreateInstance<StringGameSetting>();
|
||||
setting.Type = OptionTypes.MultipleChoice;
|
||||
setting.Title = GameModeOption.GamemodeName;
|
||||
setting.Index = GameModeOption.LastValue;
|
||||
@@ -215,7 +215,7 @@ internal static class GameOptionsMenuPatch
|
||||
instance.Children.Add(GameModeOption.OptionBehaviour);
|
||||
foreach (var optionBehaviour in instance.Children)
|
||||
{
|
||||
_mainOptions.Add(optionBehaviour);
|
||||
MainOptions.Add(optionBehaviour);
|
||||
}
|
||||
for (var i = 1; i < GameModeOption.Values.Count; i++)
|
||||
{
|
||||
@@ -264,35 +264,25 @@ internal static class GameOptionsMenuPatch
|
||||
|
||||
num -= 1.3f;
|
||||
additionalVanillaScrollNum = 0f;
|
||||
foreach (RulesCategory rulesCategory in GameManager.Instance.GameSettingsList.AllCategories)
|
||||
foreach (var rulesCategory in GameManager.Instance.GameSettingsList.AllCategories)
|
||||
{
|
||||
var categoryHeaderMasked = Object.Instantiate(instance.categoryHeaderOrigin, container);
|
||||
categoryHeaderMasked.SetHeader(rulesCategory.CategoryName, 20);
|
||||
categoryHeaderMasked.transform.localScale = Vector3.one * 0.63f;
|
||||
categoryHeaderMasked.transform.localPosition = new Vector3(-0.903f, num, -2f);
|
||||
_vanillaHeaders.Add(categoryHeaderMasked);
|
||||
VanillaHeaders.Add(categoryHeaderMasked);
|
||||
num -= 0.63f;
|
||||
additionalVanillaScrollNum -= 0.63f;
|
||||
foreach (BaseGameSetting baseGameSetting in rulesCategory.AllGameSettings)
|
||||
foreach (var baseGameSetting in rulesCategory.AllGameSettings)
|
||||
{
|
||||
OptionBehaviour? optionBehaviour = null;
|
||||
|
||||
switch (baseGameSetting.Type)
|
||||
OptionBehaviour? optionBehaviour = baseGameSetting.Type switch
|
||||
{
|
||||
case OptionTypes.Checkbox:
|
||||
optionBehaviour = Object.Instantiate(instance.checkboxOrigin, container);
|
||||
break;
|
||||
case OptionTypes.String:
|
||||
optionBehaviour = Object.Instantiate(instance.stringOptionOrigin, container);
|
||||
break;
|
||||
case OptionTypes.Float:
|
||||
case OptionTypes.Int:
|
||||
optionBehaviour = Object.Instantiate(instance.numberOptionOrigin, container);
|
||||
break;
|
||||
case OptionTypes.Player:
|
||||
optionBehaviour = Object.Instantiate(instance.playerOptionOrigin, container);
|
||||
break;
|
||||
}
|
||||
OptionTypes.Checkbox => Object.Instantiate(instance.checkboxOrigin, container),
|
||||
OptionTypes.String => Object.Instantiate(instance.stringOptionOrigin, container),
|
||||
OptionTypes.Float or OptionTypes.Int => Object.Instantiate(instance.numberOptionOrigin, container),
|
||||
OptionTypes.Player => Object.Instantiate(instance.playerOptionOrigin, container),
|
||||
_ => null,
|
||||
};
|
||||
|
||||
if (!optionBehaviour)
|
||||
continue;
|
||||
@@ -300,13 +290,13 @@ internal static class GameOptionsMenuPatch
|
||||
optionBehaviour!.transform.localPosition = new Vector3(0.952f, num, -2f);
|
||||
optionBehaviour.SetClickMask(instance.ButtonClickMask);
|
||||
optionBehaviour.SetUpFromData(baseGameSetting, 20);
|
||||
_vanillaOptions.Add(optionBehaviour);
|
||||
VanillaOptions.Add(optionBehaviour);
|
||||
|
||||
num -= 0.45f;
|
||||
additionalVanillaScrollNum -= 0.45f;
|
||||
}
|
||||
}
|
||||
foreach (var optionBehaviour in _vanillaOptions)
|
||||
foreach (var optionBehaviour in VanillaOptions)
|
||||
{
|
||||
if (AmongUsClient.Instance && !AmongUsClient.Instance.AmHost)
|
||||
{
|
||||
@@ -324,8 +314,11 @@ internal static class GameOptionsMenuPatch
|
||||
{
|
||||
var filteredGroups =
|
||||
ModdedOptionsManager.GameModeOptionGroups
|
||||
.Where(x => x.Key == mode.GetType()).Select(y => y.Value).SelectMany(y => y) ?? [];
|
||||
_gameModeGroups.Add(mode, [.. filteredGroups]);
|
||||
.Where(x => x.Key == mode.GetType())
|
||||
.Select(y => y.Value)
|
||||
.SelectMany(y => y)
|
||||
.ToList();
|
||||
GameModeGroups.Add(mode, [.. filteredGroups]);
|
||||
|
||||
var optionBehaviours = new System.Collections.Generic.List<OptionBehaviour>();
|
||||
var categoryHeaders = new System.Collections.Generic.List<CategoryHeaderMasked>();
|
||||
@@ -335,8 +328,8 @@ internal static class GameOptionsMenuPatch
|
||||
CreateGroup(instance, group, container, ref newNum, ref optionBehaviours, ref categoryHeaders);
|
||||
group.Ready = true;
|
||||
}
|
||||
_gameModeHeaders.Add(mode, categoryHeaders);
|
||||
_gameModeOptions.Add(mode, optionBehaviours);
|
||||
GameModeHeaders.Add(mode, categoryHeaders);
|
||||
GameModeOptions.Add(mode, optionBehaviours);
|
||||
}
|
||||
|
||||
instance.ControllerSelectable.Clear();
|
||||
@@ -366,7 +359,7 @@ internal static class GameOptionsMenuPatch
|
||||
// ReSharper disable once InconsistentNaming
|
||||
public static void UpdatePatch(GameOptionsMenu __instance)
|
||||
{
|
||||
if (MenuState.Instance.CurrentModIdx == 0 && _gameModeGroups.Count <= 0)
|
||||
if (MenuState.Instance.CurrentModIdx == 0 && GameModeGroups.Count <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -393,7 +386,7 @@ internal static class GameOptionsMenuPatch
|
||||
var filteredGroups =
|
||||
MenuState.Instance.CurrentMod.InternalOptionGroups
|
||||
.Where(x => (x.OptionableType == null || CustomGameModeManager.ActiveMode!.GetType().IsAssignableTo(x.OptionableType)) &&
|
||||
x.ParentMenu == MenuCategory.Game) ?? [];
|
||||
x.ParentMenu == MenuCategory.Game);
|
||||
|
||||
foreach (var group in filteredGroups)
|
||||
{
|
||||
@@ -566,7 +559,7 @@ internal static class GameOptionsMenuPatch
|
||||
num += additionalVanillaScrollNum;
|
||||
}
|
||||
|
||||
if (!_gameModeGroups.TryGetValue(mode, out var groups) || groups.Count == 0)
|
||||
if (!GameModeGroups.TryGetValue(mode, out var groups) || groups.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -635,6 +628,7 @@ internal static class GameOptionsMenuPatch
|
||||
}
|
||||
|
||||
_creationCoroutine = GameSettingMenu.Instance.StartCoroutine(CreateGroups().WrapToIl2Cpp());
|
||||
return;
|
||||
|
||||
IEnumerator CreateGroups()
|
||||
{
|
||||
@@ -763,11 +757,16 @@ internal static class GameOptionsMenuPatch
|
||||
}
|
||||
|
||||
menu.Children.Add(newOpt);
|
||||
var resetBtn = new GameObject("ResetOption");
|
||||
resetBtn.transform.parent = newOpt.transform;
|
||||
resetBtn.transform.localScale = new(.5f, .5f, 1);
|
||||
resetBtn.layer = LayerMask.NameToLayer("UI");
|
||||
resetBtn.transform.localPosition = new Vector3(-3.1f, 0f, -2f);
|
||||
var resetBtn = new GameObject("ResetOption")
|
||||
{
|
||||
transform =
|
||||
{
|
||||
parent = newOpt.transform,
|
||||
localScale = new(.5f, .5f, 1),
|
||||
localPosition = new Vector3(-3.1f, 0f, -2f),
|
||||
},
|
||||
layer = LayerMask.NameToLayer("UI"),
|
||||
};
|
||||
var resetRend = resetBtn.AddComponent<SpriteRenderer>();
|
||||
resetRend.sprite = MiraAssets.ResetButton.LoadAsset();
|
||||
resetRend.maskInteraction = SpriteMaskInteraction.VisibleInsideMask;
|
||||
|
||||
@@ -220,16 +220,16 @@ public static class LobbyViewPanePatches
|
||||
{
|
||||
if (SelectedModIdx == 0)
|
||||
{
|
||||
float num = 0.95f;
|
||||
float num2 = -6.53f;
|
||||
CategoryHeaderMasked categoryHeaderMasked =
|
||||
var num = 0.95f;
|
||||
var num2 = -6.53f;
|
||||
var categoryHeaderMasked =
|
||||
Object.Instantiate(__instance.categoryHeaderOrigin, __instance.settingsContainer);
|
||||
categoryHeaderMasked.SetHeader(StringNames.RoleQuotaLabel, 61);
|
||||
categoryHeaderMasked.transform.localScale = Vector3.one;
|
||||
categoryHeaderMasked.transform.localPosition = new Vector3(-9.77f, 1.26f, -2f);
|
||||
__instance.settingsInfo.Add(categoryHeaderMasked.gameObject);
|
||||
var list = new List<RoleBehaviour>();
|
||||
for (int i = 0; i < 2; i++)
|
||||
for (var i = 0; i < 2; i++)
|
||||
{
|
||||
var categoryHeaderRoleVariant =
|
||||
Object.Instantiate(__instance.categoryHeaderRoleOrigin, __instance.settingsContainer);
|
||||
@@ -245,16 +245,16 @@ public static class LobbyViewPanePatches
|
||||
x.Role != RoleTypes.Impostor && ((i == 0 && x.TeamType is RoleTeamTypes.Crewmate) ||
|
||||
(i == 1 && x.TeamType is RoleTeamTypes.Impostor)) &&
|
||||
x.Role != RoleTypes.CrewmateGhost && x.Role != RoleTypes.ImpostorGhost).ToList();
|
||||
for (int j = 0; j < roles.Count; j++)
|
||||
for (var j = 0; j < roles.Count; j++)
|
||||
{
|
||||
var roleBehaviour = roles[j];
|
||||
int chancePerGame =
|
||||
var chancePerGame =
|
||||
GameOptionsManager.Instance.CurrentGameOptions.RoleOptions.GetChancePerGame(
|
||||
roleBehaviour.Role);
|
||||
int numPerGame =
|
||||
var numPerGame =
|
||||
GameOptionsManager.Instance.CurrentGameOptions.RoleOptions
|
||||
.GetNumPerGame(roleBehaviour.Role);
|
||||
bool flag = numPerGame == 0;
|
||||
var flag = numPerGame == 0;
|
||||
var viewSettingsInfoPanelRoleVariant =
|
||||
Object.Instantiate(
|
||||
__instance.infoPanelRoleOrigin,
|
||||
@@ -295,8 +295,8 @@ public static class LobbyViewPanePatches
|
||||
categoryHeaderMasked2.transform.localPosition = new Vector3(-9.77f, num, -2f);
|
||||
__instance.settingsInfo.Add(categoryHeaderMasked2.gameObject);
|
||||
num -= 2.1f;
|
||||
float num3 = 0f;
|
||||
for (int k = 0; k < list.Count; k++)
|
||||
var num3 = 0f;
|
||||
for (var k = 0; k < list.Count; k++)
|
||||
{
|
||||
float num4;
|
||||
if (k % 2 == 0)
|
||||
@@ -317,7 +317,7 @@ public static class LobbyViewPanePatches
|
||||
Object.Instantiate(__instance.advancedRolePanelOrigin, __instance.settingsContainer);
|
||||
advancedRoleViewPanel.transform.localScale = Vector3.one;
|
||||
advancedRoleViewPanel.transform.localPosition = new Vector3(num4, num, -2f);
|
||||
float num5 = advancedRoleViewPanel.SetUp(list[k], 0.85f, 61);
|
||||
var num5 = advancedRoleViewPanel.SetUp(list[k], 0.85f, 61);
|
||||
if (num5 > num3)
|
||||
{
|
||||
num3 = num5;
|
||||
@@ -431,7 +431,7 @@ public static class LobbyViewPanePatches
|
||||
}
|
||||
|
||||
var num = 0.95f;
|
||||
var num2 = -6.53f;
|
||||
const float num2 = -6.53f;
|
||||
var categoryHeaderMasked =
|
||||
Object.Instantiate(instance.categoryHeaderOrigin, instance.settingsContainer, true);
|
||||
categoryHeaderMasked.SetHeader(StringNames.RoleQuotaLabel, 61);
|
||||
|
||||
@@ -549,6 +549,7 @@ public static class RoleSettingMenuPatches
|
||||
var categoryHeaderMasked = __instance.AdvancedRolesSettings.transform.Find("CategoryHeaderMasked").GetComponent<CategoryHeaderMasked>();
|
||||
categoryHeaderMasked.Title.text = TranslationController.Instance.GetString(StringNames.RoleSettingsLabel);
|
||||
var labelBg = __instance.AdvancedRolesSettings.transform.FindChild("InfoLabelBackground");
|
||||
// ReSharper disable once StringLiteralTypo (Justification: Actual name in-game.)
|
||||
var imgBg = __instance.AdvancedRolesSettings.transform.FindChild("Imagebackground");
|
||||
imgBg.gameObject.SetActive(true);
|
||||
__instance.roleScreenshot.gameObject.SetActive(true);
|
||||
@@ -573,6 +574,7 @@ public static class RoleSettingMenuPatches
|
||||
__instance.roleDescriptionText.text = customRole.RoleMedDescription;
|
||||
__instance.roleTitleText.text = role.GetRoleName();
|
||||
|
||||
// ReSharper disable once StringLiteralTypo (Justification: Actual name in-game.)
|
||||
var imgBg = __instance.AdvancedRolesSettings.transform.FindChild("Imagebackground");
|
||||
var labelBg = __instance.AdvancedRolesSettings.transform.FindChild("InfoLabelBackground");
|
||||
if (role.RoleScreenshot == null)
|
||||
@@ -706,11 +708,16 @@ public static class RoleSettingMenuPatches
|
||||
|
||||
if (customRole.Configuration.Icon != null)
|
||||
{
|
||||
var roleIcon = new GameObject("RoleIcon");
|
||||
roleIcon.transform.parent = roleOptionSetting.transform;
|
||||
roleIcon.transform.localScale = new(.25f, .25f, 1);
|
||||
roleIcon.layer = LayerMask.NameToLayer("UI");
|
||||
roleIcon.transform.localPosition = new Vector3(-1.3f, -0.3f, -2f);
|
||||
var roleIcon = new GameObject("RoleIcon")
|
||||
{
|
||||
transform =
|
||||
{
|
||||
parent = roleOptionSetting.transform,
|
||||
localScale = new(.25f, .25f, 1),
|
||||
localPosition = new Vector3(-1.3f, -0.3f, -2f),
|
||||
},
|
||||
layer = LayerMask.NameToLayer("UI"),
|
||||
};
|
||||
var rend = roleIcon.AddComponent<SpriteRenderer>();
|
||||
rend.sprite = customRole.Configuration.Icon.LoadAsset();
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Globalization;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using HarmonyLib;
|
||||
using MiraAPI.GameOptions;
|
||||
@@ -23,6 +24,7 @@ public static class SettingPatches
|
||||
/// <returns><see langword="false"/> to skip original method.</returns>
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(FloatGameSetting), nameof(FloatGameSetting.GetValueString))]
|
||||
[SuppressMessage("Style", "IDE0045:Convert to conditional expression", Justification = "Warning cascades into forcing the entire tree to be ternary operators.")]
|
||||
public static bool ValueStringPatch(
|
||||
FloatGameSetting __instance,
|
||||
ref string __result,
|
||||
@@ -34,23 +36,19 @@ public static class SettingPatches
|
||||
var custom =
|
||||
ModdedOptionsManager.ModdedOptions.Values.FirstOrDefault(opt =>
|
||||
opt.OptionBehaviour != null && opt.OptionBehaviour.Data == __instance);
|
||||
result = custom is ModdedNumberOption moddedNumberOption
|
||||
? moddedNumberOption.NegativeWordValue != "#" && (int)value == -1
|
||||
? $"<b>{moddedNumberOption.NegativeWordValue}</b>"
|
||||
: moddedNumberOption.ZeroWordValue != "#" && Mathf.Abs(value) < 0.0001f
|
||||
? $"<b>{moddedNumberOption.ZeroWordValue}</b>"
|
||||
: suffix switch
|
||||
if (custom is ModdedNumberOption moddedNumberOption)
|
||||
{
|
||||
MiraNumberSuffixes.None => value.ToString(__instance.FormatString, NumberFormatInfo.InvariantInfo),
|
||||
MiraNumberSuffixes.Multiplier => value.ToString(__instance.FormatString, NumberFormatInfo.InvariantInfo) + "x",
|
||||
MiraNumberSuffixes.Percent => value.ToString(__instance.FormatString, NumberFormatInfo.InvariantInfo) + "%",
|
||||
_ => TranslationController.Instance.GetString(
|
||||
StringNames.GameSecondsAbbrev,
|
||||
(Il2CppSystem.Object[])[value.ToString(__instance.FormatString, CultureInfo.InvariantCulture)]),
|
||||
if (moddedNumberOption.NegativeWordValue != "#" && (int)value == -1)
|
||||
{
|
||||
result = $"<b>{moddedNumberOption.NegativeWordValue}</b>";
|
||||
}
|
||||
: __instance.ZeroIsInfinity && Mathf.Abs(value) < 0.0001f
|
||||
? "<b>∞</b>"
|
||||
: suffix switch
|
||||
else if (moddedNumberOption.ZeroWordValue != "#" && Mathf.Abs(value) < 0.0001f)
|
||||
{
|
||||
result = $"<b>{moddedNumberOption.ZeroWordValue}</b>";
|
||||
}
|
||||
else
|
||||
{
|
||||
result = suffix switch
|
||||
{
|
||||
MiraNumberSuffixes.None => value.ToString(__instance.FormatString, NumberFormatInfo.InvariantInfo),
|
||||
MiraNumberSuffixes.Multiplier => value.ToString(__instance.FormatString, NumberFormatInfo.InvariantInfo) + "x",
|
||||
@@ -59,6 +57,24 @@ public static class SettingPatches
|
||||
StringNames.GameSecondsAbbrev,
|
||||
(Il2CppSystem.Object[])[value.ToString(__instance.FormatString, CultureInfo.InvariantCulture)]),
|
||||
};
|
||||
}
|
||||
}
|
||||
else if (__instance.ZeroIsInfinity && Mathf.Abs(value) < 0.0001f)
|
||||
{
|
||||
result = "<b>∞</b>";
|
||||
}
|
||||
else
|
||||
{
|
||||
result = suffix switch
|
||||
{
|
||||
MiraNumberSuffixes.None => value.ToString(__instance.FormatString, NumberFormatInfo.InvariantInfo),
|
||||
MiraNumberSuffixes.Multiplier => value.ToString(__instance.FormatString, NumberFormatInfo.InvariantInfo) + "x",
|
||||
MiraNumberSuffixes.Percent => value.ToString(__instance.FormatString, NumberFormatInfo.InvariantInfo) + "%",
|
||||
_ => TranslationController.Instance.GetString(
|
||||
StringNames.GameSecondsAbbrev,
|
||||
(Il2CppSystem.Object[])[value.ToString(__instance.FormatString, CultureInfo.InvariantCulture)]),
|
||||
};
|
||||
}
|
||||
|
||||
__result = result;
|
||||
return false;
|
||||
|
||||
@@ -82,13 +82,13 @@ internal static class PlayerControlPatches
|
||||
|
||||
if (!target || __instance.Data.IsDead || !__instance.Data.Role.IsImpostor || __instance.Data.Disconnected)
|
||||
{
|
||||
int num = target ? target!.PlayerId : -1;
|
||||
var num = target ? target!.PlayerId : -1;
|
||||
__instance.logger.Warning($"Bad kill from {__instance.PlayerId} to {num}");
|
||||
__instance.RpcMurderPlayer(target, false);
|
||||
return;
|
||||
}
|
||||
|
||||
NetworkedPlayerInfo data = target!.Data;
|
||||
var data = target!.Data;
|
||||
if (data == null || data.IsDead || target.inVent || target.MyPhysics.Animations.IsPlayingEnterVentAnimation() ||
|
||||
target.MyPhysics.Animations.IsPlayingAnyLadderAnimation() || target.inMovingPlat)
|
||||
{
|
||||
|
||||
@@ -72,7 +72,7 @@ public static class RoleGuidePatches
|
||||
ConsoleJoystick.SetMode_MenuAdditive();
|
||||
}
|
||||
ControllerManager.Instance.OpenOverlayMenu("MatchInfoGuide", __instance.closeButton);
|
||||
bool enabled = ActiveInputManager.currentControlType == ActiveInputManager.InputType.Joystick;
|
||||
var enabled = ActiveInputManager.currentControlType == ActiveInputManager.InputType.Joystick;
|
||||
__instance.glyphL.enabled = enabled;
|
||||
__instance.glyphR.enabled = enabled;
|
||||
if (GameManager.Instance.TryCast<NormalGameManager>() != null)
|
||||
@@ -114,24 +114,24 @@ public static class RoleGuidePatches
|
||||
}
|
||||
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;
|
||||
var instance = ControllerManager.Instance;
|
||||
var currentUiState = ControllerManager.Instance.CurrentUiState;
|
||||
var controllerSelectable = __instance.ControllerSelectable;
|
||||
instance.SetUpSelectables(currentUiState, controllerSelectable[^1], __instance.ControllerSelectable);
|
||||
ControllerManager instance2 = ControllerManager.Instance;
|
||||
Il2CppSystem.Collections.Generic.List<UiElement> controllerSelectable2 = __instance.ControllerSelectable;
|
||||
var instance2 = ControllerManager.Instance;
|
||||
var controllerSelectable2 = __instance.ControllerSelectable;
|
||||
instance2.SetCurrentSelected(controllerSelectable2[^1]);
|
||||
__instance.SetActiveTab(0);
|
||||
return false;
|
||||
}
|
||||
|
||||
private static readonly Dictionary<RoleBehaviour, MatchInfoRolePanel> _rolePanels = [];
|
||||
private static readonly Dictionary<RoleBehaviour, MatchInfoRolePanel> RolePanels = [];
|
||||
|
||||
public static void DisplayNormalRoleSettings(MatchInfoGuide instance, bool reset)
|
||||
{
|
||||
if (reset)
|
||||
{
|
||||
_rolePanels.Clear();
|
||||
RolePanels.Clear();
|
||||
instance.CreateSettingsEntry(
|
||||
StringNames.GameNumImpostors,
|
||||
GameManager.Instance.AllGameSettingData[StringNames.GameNumImpostors]
|
||||
@@ -143,7 +143,7 @@ public static class RoleGuidePatches
|
||||
instance.CreateSettingsEntry(
|
||||
StringNames.GameEmergencyCooldown,
|
||||
GameManager.Instance.AllGameSettingData[StringNames.GameEmergencyCooldown]
|
||||
.GetValueString((float)GameManager.Instance.LogicOptions.GetEmergencyCooldown()));
|
||||
.GetValueString(GameManager.Instance.LogicOptions.GetEmergencyCooldown()));
|
||||
instance.CreateSettingsEntry(
|
||||
StringNames.GameVisualTasks,
|
||||
instance.GetBoolString(GameManager.Instance.LogicOptions.GetVisualTasks()));
|
||||
@@ -156,7 +156,7 @@ public static class RoleGuidePatches
|
||||
instance.CreateSettingsEntry(
|
||||
StringNames.GameTaskBarMode,
|
||||
GameManager.Instance.LogicOptions.GetTaskBarMode().ToString());
|
||||
foreach (RoleBehaviour roleBehaviour in RoleManager.Instance.AllRoles)
|
||||
foreach (var roleBehaviour in RoleManager.Instance.AllRoles)
|
||||
{
|
||||
if (roleBehaviour.Role is not RoleTypes.Crewmate and not RoleTypes.Impostor and
|
||||
not RoleTypes.CrewmateGhost and
|
||||
@@ -165,21 +165,19 @@ public static class RoleGuidePatches
|
||||
var panel = Object.Instantiate(
|
||||
instance.MatchInfoRolePanelPrefab,
|
||||
instance.settingsTabs[2].GetComponent<Scroller>().Inner);
|
||||
_rolePanels.Add(roleBehaviour, panel);
|
||||
RolePanels.Add(roleBehaviour, panel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int num = 0;
|
||||
foreach (var pair in _rolePanels)
|
||||
var num = 0;
|
||||
foreach (var (roleData, panel) in RolePanels)
|
||||
{
|
||||
var role = pair.Key;
|
||||
var panel = pair.Value;
|
||||
var amount = GameOptionsManager.Instance.CurrentGameOptions.RoleOptions.GetNumPerGame(role.Role);
|
||||
var chance = GameOptionsManager.Instance.CurrentGameOptions.RoleOptions.GetChancePerGame(role.Role);
|
||||
var forciblyShow = role is ICustomRole custom ? custom.ForceShowRoleOnWiki : null;
|
||||
if (amount == 0 || chance == 0 || (Enum.IsDefined(role.Role) && role.IsRoleBlacklisted()) ||
|
||||
(role is ICustomRole custom2 && ((!custom2.CanSpawnOnCurrentMode() && forciblyShow == null) ||
|
||||
var amount = GameOptionsManager.Instance.CurrentGameOptions.RoleOptions.GetNumPerGame(roleData.Role);
|
||||
var chance = GameOptionsManager.Instance.CurrentGameOptions.RoleOptions.GetChancePerGame(roleData.Role);
|
||||
var forciblyShow = roleData is ICustomRole custom ? custom.ForceShowRoleOnWiki : null;
|
||||
if (amount == 0 || chance == 0 || (Enum.IsDefined(roleData.Role) && roleData.IsRoleBlacklisted()) ||
|
||||
(roleData is ICustomRole custom2 && ((!custom2.CanSpawnOnCurrentMode() && forciblyShow == null) ||
|
||||
(forciblyShow.HasValue && !forciblyShow.Value))))
|
||||
{
|
||||
panel.gameObject.SetActive(false);
|
||||
@@ -188,7 +186,7 @@ public static class RoleGuidePatches
|
||||
|
||||
panel.gameObject.SetActive(true);
|
||||
panel.SetPanel(
|
||||
role,
|
||||
roleData,
|
||||
amount,
|
||||
chance);
|
||||
num++;
|
||||
@@ -199,7 +197,7 @@ public static class RoleGuidePatches
|
||||
instance.rolesEnabledMessage.SetActive(true);
|
||||
}
|
||||
|
||||
instance.MatchInfoRoleScroller.SetYBoundsMax(Mathf.Clamp(Mathf.Ceil((float)num / 2f) * 1.3f - 1.5f, 0f, 999f));
|
||||
instance.MatchInfoRoleScroller.SetYBoundsMax(Mathf.Clamp(Mathf.Ceil(num / 2f) * 1.3f - 1.5f, 0f, 999f));
|
||||
instance.MatchInfoRoleMaskArea.material.SetInt(PlayerMaterial.MaskLayer, 50);
|
||||
instance.matchInfoSettingsMaskArea.material.SetInt(PlayerMaterial.MaskLayer, 50);
|
||||
if (reset)
|
||||
@@ -214,10 +212,10 @@ public static class RoleGuidePatches
|
||||
private static bool CreatePlayerEntries(MatchInfoGuide __instance)
|
||||
{
|
||||
__instance.PlayerPool.ReclaimAll();
|
||||
int num = 51;
|
||||
foreach (NetworkedPlayerInfo networkedPlayerInfo in GameData.Instance.AllPlayers)
|
||||
var num = 51;
|
||||
foreach (var networkedPlayerInfo in GameData.Instance.AllPlayers)
|
||||
{
|
||||
PlayerIdentifierButton component =
|
||||
var component =
|
||||
__instance.PlayerPool.Get<PoolableBehavior>().GetComponent<PlayerIdentifierButton>();
|
||||
component.transform.localPosition = new Vector3(0f, 0f, -1f);
|
||||
component.Populate(networkedPlayerInfo);
|
||||
@@ -227,17 +225,19 @@ public static class RoleGuidePatches
|
||||
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) =>
|
||||
|
||||
__instance.StartCoroutine(
|
||||
__instance.CoLoadAssetAsync<NamePlateViewData>(
|
||||
namePlate.GetAssetReference(),
|
||||
(Action<NamePlateViewData>?)LoadNameplate));
|
||||
continue;
|
||||
|
||||
void LoadNameplate(NamePlateViewData viewdata)
|
||||
{
|
||||
component.buttonSprite.sprite = viewdata?.Image;
|
||||
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;
|
||||
|
||||
@@ -25,8 +25,8 @@ internal static class HowToPlayPatch
|
||||
{
|
||||
if (!role.IsSimpleRole && role.Role != RoleTypes.CrewmateGhost && role.Role != RoleTypes.ImpostorGhost)
|
||||
{
|
||||
HowToPlayRoleButton component = Object.Instantiate(__instance.roleButtonPrefab, __instance.roleButtonsParent).GetComponent<HowToPlayRoleButton>();
|
||||
Sprite roleIcon = __instance.rolesScenes.ToArray().First(r => r.role == role.Role).roleIcon;
|
||||
var component = Object.Instantiate(__instance.roleButtonPrefab, __instance.roleButtonsParent).GetComponent<HowToPlayRoleButton>();
|
||||
var roleIcon = __instance.rolesScenes.ToArray().First(r => r.role == role.Role).roleIcon;
|
||||
component.SetRoleInfo(role, roleIcon);
|
||||
component.SetButtonAction((Il2CppSystem.Action)(() =>
|
||||
{
|
||||
@@ -35,7 +35,7 @@ internal static class HowToPlayPatch
|
||||
__instance.controllerSelectables.Add(component.GetComponent<PassiveButton>());
|
||||
}
|
||||
}
|
||||
foreach (UiElement uiElement in __instance.controllerSelectables)
|
||||
foreach (var uiElement in __instance.controllerSelectables)
|
||||
{
|
||||
uiElement.ReceiveMouseOut();
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using AmongUs.GameOptions;
|
||||
using HarmonyLib;
|
||||
using Il2CppSystem.Collections.Generic;
|
||||
@@ -19,150 +20,91 @@ public static class LogicRoleSelectionHnsPatch
|
||||
int teamMax,
|
||||
Il2CppSystem.Nullable<RoleTypes> defaultRole)
|
||||
{
|
||||
Error($"MiraAPI.Patches.Roles.LogicRoleSelectionHnsPatch - AssignRolesForTeam: Team: {team}, Max: {teamMax}, Players: {players.Count}, DefaultRole: {defaultRole}");
|
||||
int num = 0;
|
||||
IRoleOptionsCollection roleOptions = opts.RoleOptions;
|
||||
Info($"MiraAPI.Patches.Roles.LogicRoleSelectionHnsPatch - AssignRolesForTeam: Team: {team}, Max: {teamMax}, Players: {players.Count}, DefaultRole: {defaultRole}");
|
||||
var num = 0;
|
||||
var roleOptions = opts.RoleOptions;
|
||||
|
||||
var source = RoleManager.Instance.AllRoles.ToArray()
|
||||
.Where(role => role.TeamType == team && !RoleManager.IsGhostRole(role.Role) &&
|
||||
CustomRoleUtils.CanSpawnOnCurrentMode(role));
|
||||
CustomRoleUtils.CanSpawnOnCurrentMode(role)).ToArray();
|
||||
|
||||
var assignmentData = source.Where(x => !x.IsDead).Select(role =>
|
||||
new RoleManager.RoleAssignmentData(
|
||||
role,
|
||||
roleOptions.GetNumPerGame(role.Role),
|
||||
roleOptions.GetChancePerGame(role.Role))).ToList();
|
||||
|
||||
var source2 = CustomRoleUtils.GetPossibleRoles(assignmentData, x => x.Chance == 100);
|
||||
var guaranteedRoles = source.Where(x => source2.Contains(((ushort)x.Role, 100)));
|
||||
var list = new List<RoleTypes>();
|
||||
if (team == RoleTeamTypes.Crewmate)
|
||||
{
|
||||
Error($"MiraAPI.Patches.Roles.LogicRoleSelectionHnsPatch - AssignRolesForTeam: Before Guaranteed Assignment");
|
||||
foreach (RoleManager.RoleAssignmentData roleAssignmentData in guaranteedRoles.Select((x) =>
|
||||
new RoleManager.RoleAssignmentData(x, roleOptions.GetNumPerGame(x.Role), 100)))
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
RoleManager.RoleAssignmentData roleAssignmentData2 = roleAssignmentData;
|
||||
int count = roleAssignmentData2.Count;
|
||||
roleAssignmentData2.Count = count - 1;
|
||||
if (count <= 0)
|
||||
|
||||
switch (team)
|
||||
{
|
||||
case RoleTeamTypes.Crewmate:
|
||||
Info($"MiraAPI.Patches.Roles.LogicRoleSelectionHnsPatch - AssignRolesForTeam: Before Guaranteed Assignment");
|
||||
AddGuaranteedRoles(guaranteedRoles, opts, list);
|
||||
Info($"MiraAPI.Patches.Roles.LogicRoleSelectionHnsPatch - AssignRolesForTeam: After Guaranteed Assignment");
|
||||
AssignRolesFromList(players, teamMax, list, ref num);
|
||||
|
||||
AddPotentialRoles(source, opts, list);
|
||||
Info($"MiraAPI.Patches.Roles.LogicRoleSelectionHnsPatch - AssignRolesForTeam: After Potential Assignment");
|
||||
AssignRolesFromList(players, teamMax, list, ref num);
|
||||
|
||||
const RoleTypes basicCrewRole = RoleTypes.Engineer;
|
||||
AddFallbackRoles(list, players.Count, teamMax, num, basicCrewRole);
|
||||
AssignRolesFromList(players, teamMax, list, ref num);
|
||||
Info($"MiraAPI.Patches.Roles.LogicRoleSelectionHnsPatch - AssignRolesForTeam: After Fallback Assignment");
|
||||
break;
|
||||
}
|
||||
|
||||
list.Add(roleAssignmentData.Role.Role);
|
||||
}
|
||||
}
|
||||
Error($"MiraAPI.Patches.Roles.LogicRoleSelectionHnsPatch - AssignRolesForTeam: After Guaranteed Assignment");
|
||||
AssignRolesFromList(players, teamMax, list, ref num);
|
||||
|
||||
var list2 = source.Where(x => !x.IsDead).Select(role =>
|
||||
new RoleManager.RoleAssignmentData(
|
||||
role,
|
||||
roleOptions.GetNumPerGame(role.Role),
|
||||
roleOptions.GetChancePerGame(role.Role))).ToList();
|
||||
|
||||
list.Clear();
|
||||
foreach (RoleManager.RoleAssignmentData roleAssignmentData3 in list2)
|
||||
{
|
||||
for (int i = 0; i < roleAssignmentData3.Count; i++)
|
||||
{
|
||||
if (HashRandom.Next(101) < roleAssignmentData3.Chance)
|
||||
{
|
||||
list.Add(roleAssignmentData3.Role.Role);
|
||||
}
|
||||
}
|
||||
}
|
||||
Error($"MiraAPI.Patches.Roles.LogicRoleSelectionHnsPatch - AssignRolesForTeam: After Potential Assignment");
|
||||
|
||||
AssignRolesFromList(players, teamMax, list, ref num);
|
||||
var basicRole = RoleTypes.Engineer;
|
||||
while (list.Count < players.Count && list.Count + num < teamMax)
|
||||
{
|
||||
list.Add(basicRole);
|
||||
}
|
||||
|
||||
AssignRolesFromList(players, teamMax, list, ref num);
|
||||
Error($"MiraAPI.Patches.Roles.LogicRoleSelectionHnsPatch - AssignRolesForTeam: After Fallback Assignment");
|
||||
}
|
||||
else if (team == RoleTeamTypes.Impostor)
|
||||
{
|
||||
Error($"MiraAPI.Patches.Roles.LogicRoleSelectionHnsPatch - AssignRolesForTeam: Before Guaranteed Assignment");
|
||||
case RoleTeamTypes.Impostor:
|
||||
Info($"MiraAPI.Patches.Roles.LogicRoleSelectionHnsPatch - AssignRolesForTeam: Before Guaranteed Assignment");
|
||||
var newImpostors = new List<NetworkedPlayerInfo>();
|
||||
|
||||
// Specified Seeker
|
||||
if (__instance.hnsManager.LogicOptionsHnS.HasImpostorPlayerID() &&
|
||||
__instance.hnsManager.LogicOptionsHnS.ValidateImpostorPlayerID(players) &&
|
||||
!AmongUsClient.Instance.IsGamePublic)
|
||||
{
|
||||
NetworkedPlayerInfo networkedPlayerInfo = players.ToArray()
|
||||
var networkedPlayerInfo = players.ToArray()
|
||||
.First(p => p.PlayerId == __instance.hnsManager.LogicOptionsHnS.ImpostorPlayerID());
|
||||
players.Remove(networkedPlayerInfo);
|
||||
newImpostors.Add(networkedPlayerInfo);
|
||||
Error($"MiraAPI.Patches.Roles.LogicRoleSelectionHnsPatch - AssignRolesForTeam: Seeker is {networkedPlayerInfo.PlayerName}, ID: {networkedPlayerInfo.PlayerId}");
|
||||
Info($"MiraAPI.Patches.Roles.LogicRoleSelectionHnsPatch - AssignRolesForTeam: Seeker is {networkedPlayerInfo.PlayerName}, ID: {networkedPlayerInfo.PlayerId}");
|
||||
}
|
||||
// Random Seeker
|
||||
else
|
||||
{
|
||||
int num2 = 0;
|
||||
var num2 = 0;
|
||||
while (num2 < teamMax && players.Count > 0)
|
||||
{
|
||||
var pseudoRandomList = new PseudoRandomList<NetworkedPlayerInfo>(AmongUsClient.Instance.GameId);
|
||||
players._items.Do(pseudoRandomList.Add);
|
||||
for (int i = 0; i < GameData.RoundsPlayedInSession; i++)
|
||||
for (var i = 0; i < GameData.RoundsPlayedInSession; i++)
|
||||
{
|
||||
pseudoRandomList.PickRandom();
|
||||
}
|
||||
NetworkedPlayerInfo networkedPlayerInfo = pseudoRandomList.PickRandom();
|
||||
var networkedPlayerInfo = pseudoRandomList.PickRandom();
|
||||
players.Remove(networkedPlayerInfo);
|
||||
newImpostors.Add(networkedPlayerInfo);
|
||||
num2++;
|
||||
Error($"MiraAPI.Patches.Roles.LogicRoleSelectionHnsPatch - AssignRolesForTeam: Seeker is {networkedPlayerInfo.PlayerName}, ID: {networkedPlayerInfo.PlayerId}");
|
||||
Info($"MiraAPI.Patches.Roles.LogicRoleSelectionHnsPatch - AssignRolesForTeam: Seeker is {networkedPlayerInfo.PlayerName}, ID: {networkedPlayerInfo.PlayerId}");
|
||||
}
|
||||
}
|
||||
Error($"MiraAPI.Patches.Roles.LogicRoleSelectionHnsPatch - AssignRolesForTeam: After Guaranteed Assignment");
|
||||
foreach (RoleManager.RoleAssignmentData roleAssignmentData in guaranteedRoles.Select((x) =>
|
||||
new RoleManager.RoleAssignmentData(x, roleOptions.GetNumPerGame(x.Role), 100)))
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
RoleManager.RoleAssignmentData roleAssignmentData2 = roleAssignmentData;
|
||||
int count = roleAssignmentData2.Count;
|
||||
roleAssignmentData2.Count = count - 1;
|
||||
if (count <= 0)
|
||||
{
|
||||
Info($"MiraAPI.Patches.Roles.LogicRoleSelectionHnsPatch - AssignRolesForTeam: After Guaranteed Assignment");
|
||||
|
||||
AddGuaranteedRoles(guaranteedRoles, opts, list);
|
||||
AssignRolesFromList(newImpostors, teamMax, list, ref num);
|
||||
|
||||
AddPotentialRoles(source, opts, list);
|
||||
AssignRolesFromList(newImpostors, teamMax, list, ref num);
|
||||
|
||||
const RoleTypes basicImpRole = RoleTypes.Impostor;
|
||||
AddFallbackRoles(list, newImpostors.Count, teamMax, num, basicImpRole);
|
||||
AssignRolesFromList(newImpostors, teamMax, list, ref num);
|
||||
break;
|
||||
}
|
||||
|
||||
list.Add(roleAssignmentData.Role.Role);
|
||||
}
|
||||
}
|
||||
AssignRolesFromList(newImpostors, teamMax, list, ref num);
|
||||
|
||||
var list2 = source.Where(x => !x.IsDead).Select(role =>
|
||||
new RoleManager.RoleAssignmentData(
|
||||
role,
|
||||
roleOptions.GetNumPerGame(role.Role),
|
||||
roleOptions.GetChancePerGame(role.Role))).ToList();
|
||||
|
||||
list.Clear();
|
||||
foreach (RoleManager.RoleAssignmentData roleAssignmentData3 in list2)
|
||||
{
|
||||
for (int i = 0; i < roleAssignmentData3.Count; i++)
|
||||
{
|
||||
if (HashRandom.Next(101) < roleAssignmentData3.Chance)
|
||||
{
|
||||
list.Add(roleAssignmentData3.Role.Role);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AssignRolesFromList(newImpostors, teamMax, list, ref num);
|
||||
var basicRole = RoleTypes.Impostor;
|
||||
while (list.Count < newImpostors.Count && list.Count + num < teamMax)
|
||||
{
|
||||
list.Add(basicRole);
|
||||
}
|
||||
|
||||
AssignRolesFromList(newImpostors, teamMax, list, ref num);
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(team), team, null);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -171,13 +113,61 @@ public static class LogicRoleSelectionHnsPatch
|
||||
{
|
||||
while (roleList.Count > 0 && players.Count > 0 && rolesAssigned < teamMax)
|
||||
{
|
||||
int index = HashRandom.FastNext(roleList.Count);
|
||||
RoleTypes roleType = roleList[index];
|
||||
var index = HashRandom.FastNext(roleList.Count);
|
||||
var roleType = roleList[index];
|
||||
roleList.RemoveAt(index);
|
||||
int index2 = HashRandom.FastNext(players.Count);
|
||||
var index2 = HashRandom.FastNext(players.Count);
|
||||
players[index2].Object.RpcSetRole(roleType);
|
||||
players.RemoveAt(index2);
|
||||
rolesAssigned++;
|
||||
}
|
||||
}
|
||||
|
||||
private static void AddGuaranteedRoles(
|
||||
System.Collections.Generic.IEnumerable<RoleBehaviour> guaranteedRoles,
|
||||
IGameOptions opts,
|
||||
List<RoleTypes> list)
|
||||
{
|
||||
var roleOptions = opts.RoleOptions;
|
||||
foreach (var roleAssignmentData in guaranteedRoles.Select(x =>
|
||||
new RoleManager.RoleAssignmentData(x, roleOptions.GetNumPerGame(x.Role), 100)))
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
var count = roleAssignmentData.Count;
|
||||
roleAssignmentData.Count = count - 1;
|
||||
if (count <= 0) break;
|
||||
list.Add(roleAssignmentData.Role.Role);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void AddPotentialRoles(System.Collections.Generic.IEnumerable<RoleBehaviour> source, IGameOptions opts, List<RoleTypes> list)
|
||||
{
|
||||
var roleOptions = opts.RoleOptions;
|
||||
var potentialRoles = source.Where(x => !x.IsDead).Select(role => new RoleManager.RoleAssignmentData(
|
||||
role,
|
||||
roleOptions.GetNumPerGame(role.Role),
|
||||
roleOptions.GetChancePerGame(role.Role))).ToList();
|
||||
|
||||
list.Clear();
|
||||
foreach (var roleData in potentialRoles)
|
||||
{
|
||||
for (var i = 0; i < roleData.Count; i++)
|
||||
{
|
||||
if (HashRandom.Next(101) < roleData.Chance)
|
||||
{
|
||||
list.Add(roleData.Role.Role);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void AddFallbackRoles(List<RoleTypes> list, int targetPlayerCount, int teamMax, int rolesAssigned, RoleTypes basicRole)
|
||||
{
|
||||
while (list.Count < targetPlayerCount && list.Count + rolesAssigned < teamMax)
|
||||
{
|
||||
list.Add(basicRole);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
using AmongUs.GameOptions;
|
||||
using HarmonyLib;
|
||||
using Il2CppSystem.Collections.Generic;
|
||||
using MiraAPI.Roles;
|
||||
|
||||
namespace MiraAPI.Patches.Roles;
|
||||
@@ -18,7 +17,7 @@ public static class RoleOptionsCollectionPatch
|
||||
[HarmonyPatch(nameof(RoleOptionsCollectionV11.AnyRolesEnabled))]
|
||||
public static bool AnyRolesEnabledPrefix(RoleOptionsCollectionV11 __instance)
|
||||
{
|
||||
foreach (KeyValuePair<RoleTypes, RoleDataV11> keyValuePair in __instance.roles)
|
||||
foreach (var keyValuePair in __instance.roles)
|
||||
{
|
||||
if (__instance.GetNumPerGame(keyValuePair.Key) > 0)
|
||||
{
|
||||
|
||||
@@ -47,15 +47,15 @@ public static class SelectRolesPatch
|
||||
.Where(c => c.Character != null && c.Character.Data != null && !c.Character.Data.Disconnected &&
|
||||
!c.Character.Data.IsDead).OrderBy(c => c.Id).Select(c => c.Character.Data)];
|
||||
|
||||
foreach (NetworkedPlayerInfo networkedPlayerInfo in GameData.Instance.AllPlayers)
|
||||
foreach (var networkedPlayerInfo in GameData.Instance.AllPlayers)
|
||||
{
|
||||
if (networkedPlayerInfo.Object != null && networkedPlayerInfo.Object.isDummy)
|
||||
{
|
||||
list2.Add(networkedPlayerInfo);
|
||||
}
|
||||
}
|
||||
IGameOptions currentGameOptions = GameOptionsManager.Instance.CurrentGameOptions;
|
||||
int adjustedNumImpostors = GameOptionsManager.Instance.CurrentGameOptions.GetAdjustedNumImpostors(list2.Count);
|
||||
var currentGameOptions = GameOptionsManager.Instance.CurrentGameOptions;
|
||||
var adjustedNumImpostors = GameOptionsManager.Instance.CurrentGameOptions.GetAdjustedNumImpostors(list2.Count);
|
||||
AssignRolesForTeam(list2, currentGameOptions, RoleTeamTypes.Impostor, adjustedNumImpostors, RoleTypes.Impostor);
|
||||
AssignRolesForTeam(list2, currentGameOptions, RoleTeamTypes.Crewmate, int.MaxValue, RoleTypes.Crewmate);
|
||||
return false;
|
||||
@@ -68,12 +68,13 @@ public static class SelectRolesPatch
|
||||
int teamMax,
|
||||
RoleTypes defaultRole)
|
||||
{
|
||||
int num = 0;
|
||||
var num = 0;
|
||||
var source = RoleManager.Instance.AllRoles.ToArray()
|
||||
.Where(role => role.TeamType == team && !RoleManager.IsGhostRole(role.Role) &&
|
||||
CustomRoleUtils.CanSpawnOnCurrentMode(role));
|
||||
CustomRoleUtils.CanSpawnOnCurrentMode(role))
|
||||
.ToArray();
|
||||
var list = new List<RoleTypes>();
|
||||
IRoleOptionsCollection roleOptions = opts.RoleOptions;
|
||||
var roleOptions = opts.RoleOptions;
|
||||
|
||||
// Assign guaranteed roles first, just like the vanilla selector. This is
|
||||
// important because the list of players is shared by both team passes.
|
||||
@@ -119,10 +120,10 @@ public static class SelectRolesPatch
|
||||
{
|
||||
while (roleList.Count > 0 && players.Count > 0 && rolesAssigned < teamMax)
|
||||
{
|
||||
int index = HashRandom.FastNext(roleList.Count);
|
||||
RoleTypes roleType = roleList[index];
|
||||
var index = HashRandom.FastNext(roleList.Count);
|
||||
var roleType = roleList[index];
|
||||
roleList.RemoveAt(index);
|
||||
int index2 = HashRandom.FastNext(players.Count);
|
||||
var index2 = HashRandom.FastNext(players.Count);
|
||||
players[index2].Object.RpcSetRole(roleType);
|
||||
players.RemoveAt(index2);
|
||||
rolesAssigned++;
|
||||
|
||||
@@ -9,7 +9,7 @@ internal static class TaskPanelPatch
|
||||
/// <summary>
|
||||
/// This patch is to override the automatic updating of the y position on the tab (which is in base game)
|
||||
/// because I can't change the custom tab y pos if it's being overridden every frame.
|
||||
/// Im sure there is an easier/better way, but this is the fix that worked for me.
|
||||
/// I'm sure there is an easier/better way, but this is the fix that worked for me.
|
||||
/// </summary>
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(nameof(TaskPanelBehaviour.Update))]
|
||||
|
||||
@@ -19,7 +19,7 @@ internal static class DummyBehaviourPatches
|
||||
[HarmonyPatch(nameof(DummyBehaviour.Update))]
|
||||
public static bool DummyUpdatePatch(DummyBehaviour __instance)
|
||||
{
|
||||
NetworkedPlayerInfo data = __instance.myPlayer.Data;
|
||||
var data = __instance.myPlayer.Data;
|
||||
if (data == null || data.IsDead) return false;
|
||||
|
||||
if (MeetingHud.Instance)
|
||||
@@ -65,7 +65,7 @@ internal static class DummyBehaviourPatches
|
||||
potentialSuspects.Add(253);
|
||||
}
|
||||
|
||||
if (CanVote(dummy))
|
||||
if (dummy.CanVote())
|
||||
{
|
||||
VotingUtils.RpcCastVote(PlayerControl.LocalPlayer, dummy.myPlayer.PlayerId, potentialSuspects.Random());
|
||||
}
|
||||
|
||||
@@ -44,8 +44,8 @@ internal static class MeetingHudPatches
|
||||
if (PlayerControl.LocalPlayer.Data.IsDead || __instance.AmDead || !__instance.Parent)
|
||||
return false;
|
||||
|
||||
JudgeRole? judgeRole = PlayerControl.LocalPlayer.Data.Role.TryCast<JudgeRole>();
|
||||
bool flag = judgeRole && PlayerControl.LocalPlayer.PlayerId != __instance.PlayerId;
|
||||
var judgeRole = PlayerControl.LocalPlayer.Data.Role.TryCast<JudgeRole>();
|
||||
var flag = judgeRole && PlayerControl.LocalPlayer.PlayerId != __instance.PlayerId;
|
||||
__instance.JudgeOverruleButton?.gameObject.SetActive(flag);
|
||||
|
||||
if (__instance.VoteComplete || !__instance.Parent.Select((byte)__instance.PlayerId))
|
||||
@@ -53,7 +53,7 @@ internal static class MeetingHudPatches
|
||||
|
||||
__instance.Buttons.SetActive(true);
|
||||
|
||||
float startPos = __instance.AnimateButtonsFromLeft ? 0.2f : 1.95f;
|
||||
var startPos = __instance.AnimateButtonsFromLeft ? 0.2f : 1.95f;
|
||||
|
||||
Il2CppSystem.Collections.Generic.List<UiElement> selectableElements = new();
|
||||
foreach (var btn in __instance.Buttons.GetComponentsInChildren<PassiveButton>())
|
||||
@@ -61,11 +61,11 @@ internal static class MeetingHudPatches
|
||||
selectableElements.Add(btn);
|
||||
}
|
||||
|
||||
for (int i = 0; i < selectableElements.Count; i++)
|
||||
for (var i = 0; i < selectableElements.Count; i++)
|
||||
{
|
||||
var button = selectableElements[i];
|
||||
float endPos = 1.3f - 0.65f * i;
|
||||
float duration = 0.25f + 0.1f * i;
|
||||
var endPos = 1.3f - 0.65f * i;
|
||||
var duration = 0.25f + 0.1f * i;
|
||||
__instance.StartCoroutine(Effects.All(Effects.Lerp(duration, (Action<float>)(t =>
|
||||
button.transform.localPosition = Vector2.Lerp(Vector2.right * startPos, Vector2.right * endPos, Effects.ExpOut(t))))));
|
||||
}
|
||||
|
||||
@@ -12,12 +12,12 @@ public interface IMiraPlugin
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether to display the plugin in the options menu.
|
||||
/// </summary>
|
||||
virtual bool DisplayOnOptionsMenu => true;
|
||||
bool DisplayOnOptionsMenu => true;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the localization id to use for anything registered under this mod.
|
||||
/// </summary>
|
||||
virtual string ParentLocaleId => GetType().Name.ToLower(CultureInfo.InvariantCulture);
|
||||
string ParentLocaleId => GetType().Name.ToLower(CultureInfo.InvariantCulture);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name to display on the options menu.
|
||||
@@ -28,7 +28,7 @@ public interface IMiraPlugin
|
||||
/// Gets the abbreviated name to display for other mods to pick up.
|
||||
/// </summary>
|
||||
/// <returns>The <see cref="string"/> text for the plugin.</returns>
|
||||
virtual string GetAbbreviatedModName()
|
||||
string GetAbbreviatedModName()
|
||||
{
|
||||
return new([.. OptionsTitleText.Where(c => !char.IsLower(c) && !char.IsWhiteSpace(c))]);
|
||||
}
|
||||
@@ -36,27 +36,27 @@ public interface IMiraPlugin
|
||||
/// <summary>
|
||||
/// Gets the name for the first custom category in the game options menu, if any.
|
||||
/// </summary>
|
||||
virtual string CustomOptionMenuNameOne => "Custom Category 1";
|
||||
string CustomOptionMenuNameOne => "Custom Category 1";
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name for the second custom category in the game options menu, if any.
|
||||
/// </summary>
|
||||
virtual string CustomOptionMenuNameTwo => "Custom Category 2";
|
||||
string CustomOptionMenuNameTwo => "Custom Category 2";
|
||||
|
||||
/// <summary>
|
||||
/// Gets the description for the second custom category in the game options menu, if any.
|
||||
/// </summary>
|
||||
virtual string ModifierMenuDescription => "Configure modifiers and their settings here!";
|
||||
string ModifierMenuDescription => "Configure modifiers and their settings here!";
|
||||
|
||||
/// <summary>
|
||||
/// Gets the description for the first custom category in the game options menu, if any.
|
||||
/// </summary>
|
||||
virtual string CustomOptionMenuOneDescription => "Apply game settings for this mod!";
|
||||
string CustomOptionMenuOneDescription => "Apply game settings for this mod!";
|
||||
|
||||
/// <summary>
|
||||
/// Gets the description for the second custom category in the game options menu, if any.
|
||||
/// </summary>
|
||||
virtual string CustomOptionMenuTwoDescription => "Apply game settings for this mod!";
|
||||
string CustomOptionMenuTwoDescription => "Apply game settings for this mod!";
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="ConfigFile"/> for the plugin.
|
||||
|
||||
@@ -72,11 +72,9 @@ public class OptionPreset(string name, MiraPluginInfo plugin, ConfigFile presetC
|
||||
{
|
||||
var selectedOpt = Plugin.InternalOptions.First(x => x.OptionBehaviour == baseOption);
|
||||
selectedOpt.LoadFromPreset(PresetConfig);
|
||||
#pragma warning disable S125 // Sections of code should not be commented out
|
||||
/*ModdedOptionsManager.SyncAllOptions();
|
||||
|
||||
CustomRoleManager.SyncAllRoleSettings();*/
|
||||
#pragma warning restore S125 // Sections of code should not be commented out
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -8,12 +8,13 @@ using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.UI;
|
||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
||||
|
||||
[RegisterInIl2Cpp]
|
||||
// TODO: Give proper reasoning
|
||||
[SuppressMessage("Design", "CA1050:Declare types in namespaces", Justification = "Reason pending.")]
|
||||
[SuppressMessage("Major Bug", "S3903:Types should be defined in named namespaces", Justification = "Reason pending.")]
|
||||
[SuppressMessage("Style", "IDE0051:Remove unused private members", Justification = "Unity Convention.")]
|
||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member (Justification: Unity fields; ignore.)
|
||||
public class SavePresetPopup(nint cppPtr) : Minigame(cppPtr)
|
||||
{
|
||||
private TextMeshPro textBoxText;
|
||||
@@ -22,7 +23,7 @@ public class SavePresetPopup(nint cppPtr) : Minigame(cppPtr)
|
||||
private Action<string> onSave;
|
||||
|
||||
// Cleanup holder object
|
||||
public void OnDestroy()
|
||||
private void OnDestroy()
|
||||
{
|
||||
transform.parent.gameObject.Destroy();
|
||||
}
|
||||
@@ -32,9 +33,7 @@ public class SavePresetPopup(nint cppPtr) : Minigame(cppPtr)
|
||||
// no-op
|
||||
}
|
||||
|
||||
#pragma warning disable IDE0051 // Remove unused private members
|
||||
private void Awake()
|
||||
#pragma warning restore IDE0051 // Remove unused private members
|
||||
{
|
||||
var textboxHolder = transform.GetChild(1).GetChild(1);
|
||||
var saveButton = transform.FindChild("SaveButton").GetComponent<PassiveButton>();
|
||||
|
||||
@@ -17,7 +17,7 @@ public record struct CustomRoleConfiguration
|
||||
{
|
||||
[Obsolete("Default constructor is not supported. Please use the constructor that takes an ICustomRole parameter.")]
|
||||
[SuppressMessage("Info Code Smell", "S1133:Deprecated code should be removed", Justification = "Will not be removed, as this throws instead.")]
|
||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member (Justification: Read above.)
|
||||
public CustomRoleConfiguration()
|
||||
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member
|
||||
{
|
||||
|
||||
@@ -277,7 +277,7 @@ public static class CustomRoleManager
|
||||
internal static void HandleSyncRoleOptions(NetData[] data)
|
||||
{
|
||||
// necessary to disable then re-enable this setting
|
||||
// we dont know how other plugins handle their configs
|
||||
// we don't know how other plugins handle their configs
|
||||
// this way, all the options are saved at once, instead of one by one
|
||||
var oldConfigSetting = new Dictionary<MiraPluginInfo, bool>();
|
||||
foreach (var plugin in MiraPluginManager.Instance.RegisteredPlugins)
|
||||
|
||||
@@ -27,7 +27,7 @@ public static class CustomRoleUtils
|
||||
? custom.CanSpawnOnCurrentMode() && custom.Configuration.AssociatedGameMode.IsInstanceOfType(CustomGameModeManager.ActiveMode)
|
||||
: (CustomGameModeManager.ActiveMode is HideAndSeekMode
|
||||
? role.Role is RoleTypes.Engineer or RoleTypes.Impostor
|
||||
: !Helpers.IsRoleBlacklisted(role));
|
||||
: !role.IsRoleBlacklisted());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -138,7 +138,7 @@ public interface ICustomRole : IOptionable
|
||||
/// Binds the configuration options for this role to the provided ConfigFile.
|
||||
/// </summary>
|
||||
/// <param name="config">The ConfigFile to bind the options to.</param>
|
||||
virtual void BindConfig(ConfigFile config)
|
||||
void BindConfig(ConfigFile config)
|
||||
{
|
||||
config.Bind(NumConfigDefinition, Configuration.DefaultRoleCount);
|
||||
config.Bind(ChanceConfigDefinition, Configuration.DefaultChance);
|
||||
@@ -149,7 +149,7 @@ public interface ICustomRole : IOptionable
|
||||
/// </summary>
|
||||
/// <param name="presetConfig">The <see cref="ConfigFile"/> to save the preset configuration to.</param>
|
||||
/// <param name="useDefault">Whether to use the default values for the configuration.</param>
|
||||
virtual void SaveToPreset(ConfigFile presetConfig, bool useDefault = false)
|
||||
void SaveToPreset(ConfigFile presetConfig, bool useDefault = false)
|
||||
{
|
||||
BindConfig(presetConfig);
|
||||
presetConfig[NumConfigDefinition].BoxedValue = useDefault ? Configuration.DefaultRoleCount : GetCount();
|
||||
@@ -160,7 +160,7 @@ public interface ICustomRole : IOptionable
|
||||
/// Loads the role's configuration from a preset <see cref="ConfigFile"/>.
|
||||
/// </summary>
|
||||
/// <param name="presetConfig">The <see cref="ConfigFile"/> containing the preset configuration.</param>
|
||||
virtual void LoadFromPreset(ConfigFile presetConfig)
|
||||
void LoadFromPreset(ConfigFile presetConfig)
|
||||
{
|
||||
if (presetConfig.TryGetEntry(NumConfigDefinition, out ConfigEntry<int> numEntry))
|
||||
{
|
||||
@@ -177,7 +177,7 @@ public interface ICustomRole : IOptionable
|
||||
/// Gets the role chance option.
|
||||
/// </summary>
|
||||
/// <returns>The role chance option.</returns>
|
||||
virtual int? GetChance()
|
||||
int? GetChance()
|
||||
{
|
||||
return !Configuration.CanModifyChance
|
||||
? Configuration.DefaultChance
|
||||
@@ -190,7 +190,7 @@ public interface ICustomRole : IOptionable
|
||||
/// Gets the role count option.
|
||||
/// </summary>
|
||||
/// <returns>The role count option.</returns>
|
||||
virtual int? GetCount()
|
||||
int? GetCount()
|
||||
{
|
||||
return ParentMod.PluginConfig.TryGetEntry(NumConfigDefinition, out ConfigEntry<int> entry)
|
||||
? Mathf.Clamp(entry.Value, 0, Configuration.MaxRoleCount)
|
||||
@@ -201,7 +201,7 @@ public interface ICustomRole : IOptionable
|
||||
/// Sets the role chance option.
|
||||
/// </summary>
|
||||
/// <param name="chance">The chance between 0 and 100.</param>
|
||||
virtual void SetChance(int chance)
|
||||
void SetChance(int chance)
|
||||
{
|
||||
if (!Configuration.CanModifyChance)
|
||||
{
|
||||
@@ -222,7 +222,7 @@ public interface ICustomRole : IOptionable
|
||||
/// Sets the role count option.
|
||||
/// </summary>
|
||||
/// <param name="count">The amount of this role between zero and its MaxRoleCount in the Configuration.</param>
|
||||
virtual void SetCount(int count)
|
||||
void SetCount(int count)
|
||||
{
|
||||
if (ParentMod.PluginConfig.TryGetEntry(NumConfigDefinition, out ConfigEntry<int> entry))
|
||||
{
|
||||
@@ -238,7 +238,7 @@ public interface ICustomRole : IOptionable
|
||||
/// </summary>
|
||||
/// <param name="player">The player with the role.</param>
|
||||
/// <returns>Whether they can see the role (name color) or not.</returns>
|
||||
virtual bool CanLocalPlayerSeeRole(PlayerControl player)
|
||||
bool CanLocalPlayerSeeRole(PlayerControl player)
|
||||
{
|
||||
return (PlayerControl.LocalPlayer.Data.Role.IsImpostor && player.Data.Role.IsImpostor) || PlayerControl.LocalPlayer.Data.IsDead;
|
||||
}
|
||||
@@ -249,7 +249,7 @@ public interface ICustomRole : IOptionable
|
||||
/// <param name="instance">The intro cutscene instance.</param>
|
||||
/// <param name="yourTeam">The reference to the list of player in the team.</param>
|
||||
/// <returns><see langword="true"/> to use the original team intro code, <see langword="false"/> to skip.</returns>
|
||||
virtual bool SetupIntroTeam(IntroCutscene instance, ref Il2CppSystem.Collections.Generic.List<PlayerControl> yourTeam)
|
||||
bool SetupIntroTeam(IntroCutscene instance, ref Il2CppSystem.Collections.Generic.List<PlayerControl> yourTeam)
|
||||
{
|
||||
if (Team == ModdedRoleTeams.Custom)
|
||||
{
|
||||
@@ -296,7 +296,7 @@ public interface ICustomRole : IOptionable
|
||||
/// Determines whether the role can spawn in general, accounting for gamemodes and everything else.
|
||||
/// </summary>
|
||||
/// <returns><see langword="true"/> if the role is able to spawn, otherwise <see langword="false"/>.</returns>
|
||||
virtual bool CanSpawnOnCurrentMode()
|
||||
bool CanSpawnOnCurrentMode()
|
||||
{
|
||||
return Configuration.AssociatedGameMode.IsInstanceOfType(CustomGameModeManager.ActiveMode);
|
||||
}
|
||||
@@ -305,10 +305,10 @@ public interface ICustomRole : IOptionable
|
||||
/// Gets whether the role is forcibly shown or disabled in the wiki screen.
|
||||
/// </summary>
|
||||
/// <returns><see langword="true"/> if the role is always displayed, otherwise <see langword="false"/> if it is never displayable, or <see langword="null"/> if it is dictated by amount and chance.</returns>
|
||||
virtual bool? ForceShowRoleOnWiki => null;
|
||||
bool? ForceShowRoleOnWiki => null;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the function that determines whether the role should be toggled on or off in the game settings.
|
||||
/// </summary>
|
||||
virtual Func<bool> VisibleInSettings => () => true;
|
||||
Func<bool> VisibleInSettings => () => true;
|
||||
}
|
||||
@@ -79,6 +79,7 @@ public enum MiraLanguage
|
||||
/// <summary>
|
||||
/// TChinese.
|
||||
/// </summary>
|
||||
// ReSharper disable once InconsistentNaming (Justification: Language name.)
|
||||
TChinese,
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
@@ -17,7 +18,7 @@ public static class MiraLocaleManager
|
||||
{
|
||||
private const string LangDirectory = "mira_languages";
|
||||
|
||||
// Language, Xml Name, then Value
|
||||
// Language, XML Name, then Value
|
||||
|
||||
/// <summary>
|
||||
/// Gets the dictionary containing all loaded localization strings, organized by language and XML name.
|
||||
@@ -153,15 +154,22 @@ public static class MiraLocaleManager
|
||||
/// <param name="key">The string id to find.</param>
|
||||
/// <param name="fallback">Fallback string to use if no translation is found.</param>
|
||||
/// <returns>A <see cref="string"/> based on the key provided.</returns>
|
||||
[SuppressMessage("Style", "IDE0046:Convert to conditional expression", Justification = "Warning cascades into forcing the entire tree to be ternary operators.")]
|
||||
public static string Get(MiraLanguage language, string key, string fallback = "")
|
||||
{
|
||||
return Locale.TryGetValue(language, out var translations) &&
|
||||
translations.TryGetValue(key, out var translation)
|
||||
? translation
|
||||
: Locale.TryGetValue(MiraLanguage.English, out var translationsEng) &&
|
||||
translationsEng.TryGetValue(key, out var translationEng)
|
||||
? translationEng
|
||||
: fallback;
|
||||
if (Locale.TryGetValue(language, out var translations) &&
|
||||
translations.TryGetValue(key, out var translation))
|
||||
{
|
||||
return translation;
|
||||
}
|
||||
|
||||
if (Locale.TryGetValue(MiraLanguage.English, out var translationsEng) &&
|
||||
translationsEng.TryGetValue(key, out var translationEng))
|
||||
{
|
||||
return translationEng;
|
||||
}
|
||||
|
||||
return fallback;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -325,7 +333,7 @@ public static class MiraLocaleManager
|
||||
}
|
||||
|
||||
using StreamReader reader = new(resourceStream);
|
||||
string xmlContent = reader.ReadToEnd();
|
||||
var xmlContent = reader.ReadToEnd();
|
||||
try
|
||||
{
|
||||
Locale.TryAdd(locale.Key, []);
|
||||
@@ -351,7 +359,7 @@ public static class MiraLocaleManager
|
||||
try
|
||||
{
|
||||
xmlDoc.LoadXml(xmlContent);
|
||||
XmlNodeList? stringNodes = xmlDoc.SelectNodes("/resources/string");
|
||||
var stringNodes = xmlDoc.SelectNodes("/resources/string");
|
||||
|
||||
if (stringNodes == null)
|
||||
{
|
||||
@@ -367,19 +375,19 @@ public static class MiraLocaleManager
|
||||
continue;
|
||||
}
|
||||
|
||||
string name = node.Attributes["name"]!.Value;
|
||||
string value = node.InnerText;
|
||||
var name = node.Attributes["name"]!.Value;
|
||||
var value = node.InnerText;
|
||||
|
||||
if (string.IsNullOrEmpty(name)) continue;
|
||||
|
||||
if (value.Contains('['))
|
||||
{
|
||||
value = value.Replace("[", "<");
|
||||
value = value.Replace('[', '<');
|
||||
}
|
||||
|
||||
if (value.Contains(']'))
|
||||
{
|
||||
value = value.Replace("]", ">");
|
||||
value = value.Replace(']', '>');
|
||||
}
|
||||
|
||||
value = value.Replace("<nl>", "\n").Replace("<and>", "&");
|
||||
|
||||
@@ -198,7 +198,7 @@ public static class AddressablesLoader
|
||||
private static T[] PrepareArray<T>(List<T> data, List<T> behaviours) where T : CosmeticData
|
||||
{
|
||||
var count = data.Count;
|
||||
for (int i = 0; i < behaviours.Count; i++)
|
||||
for (var i = 0; i < behaviours.Count; i++)
|
||||
{
|
||||
behaviours[i].displayOrder = count + i;
|
||||
data.Add(behaviours[i]);
|
||||
|
||||
@@ -52,12 +52,13 @@ public static class TmpSpriteUtils
|
||||
AssetHolder.fallbackSpriteAssets = new();
|
||||
}
|
||||
|
||||
TMP_SpriteAsset spriteAsset = ScriptableObject.CreateInstance<TMP_SpriteAsset>();
|
||||
var spriteAsset = ScriptableObject.CreateInstance<TMP_SpriteAsset>();
|
||||
spriteAsset.name = assetName;
|
||||
spriteAsset.spriteSheet = sourceTexture;
|
||||
|
||||
if (!_spriteShader)
|
||||
{
|
||||
// ReSharper disable once ShaderLabShaderReferenceNotResolved (Justification: Unnecessary.)
|
||||
_spriteShader = Shader.Find("TextMeshPro/Sprite");
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ public class CenteredGridArrange(IntPtr iPtr) : MonoBehaviour(iPtr)
|
||||
private void Start()
|
||||
{
|
||||
cells = [];
|
||||
GetChildsActive();
|
||||
GetChildrenActive();
|
||||
CheckCurrentChildren();
|
||||
}
|
||||
|
||||
@@ -42,16 +42,16 @@ public class CenteredGridArrange(IntPtr iPtr) : MonoBehaviour(iPtr)
|
||||
|
||||
private void CheckCurrentChildren()
|
||||
{
|
||||
GetChildsActive();
|
||||
GetChildrenActive();
|
||||
if (cells.SequenceEqual(CurrentChildren))
|
||||
return;
|
||||
cells.Clear();
|
||||
foreach (Transform currentChild in CurrentChildren)
|
||||
foreach (var currentChild in CurrentChildren)
|
||||
cells.Add(currentChild);
|
||||
ArrangeChilds();
|
||||
ArrangeChildren();
|
||||
}
|
||||
|
||||
private void GetChildsActive()
|
||||
private void GetChildrenActive()
|
||||
{
|
||||
CurrentChildren.Clear();
|
||||
foreach (var obj in transform)
|
||||
@@ -63,29 +63,29 @@ public class CenteredGridArrange(IntPtr iPtr) : MonoBehaviour(iPtr)
|
||||
}
|
||||
}
|
||||
|
||||
private void ArrangeChilds()
|
||||
private void ArrangeChildren()
|
||||
{
|
||||
if (cells.Count == 0)
|
||||
return;
|
||||
|
||||
int totalRows = Mathf.CeilToInt((float)cells.Count / MaxColumns);
|
||||
float totalHeight = (totalRows - 1) * CellSize.y;
|
||||
float startY = transform.position.y + totalHeight * 0.5f;
|
||||
var totalRows = Mathf.CeilToInt((float)cells.Count / MaxColumns);
|
||||
var totalHeight = (totalRows - 1) * CellSize.y;
|
||||
var startY = transform.position.y + totalHeight * 0.5f;
|
||||
|
||||
for (int index = 0; index < cells.Count; ++index)
|
||||
for (var index = 0; index < cells.Count; ++index)
|
||||
{
|
||||
int row = index / MaxColumns;
|
||||
int rowStartIndex = row * MaxColumns;
|
||||
int itemsInRow = Mathf.Min(MaxColumns, cells.Count - rowStartIndex);
|
||||
int col = index - rowStartIndex;
|
||||
var row = index / MaxColumns;
|
||||
var rowStartIndex = row * MaxColumns;
|
||||
var itemsInRow = Mathf.Min(MaxColumns, cells.Count - rowStartIndex);
|
||||
var col = index - rowStartIndex;
|
||||
|
||||
float rowWidth = (itemsInRow - 1) * CellSize.x;
|
||||
float startX = transform.position.x - rowWidth * 0.5f;
|
||||
var rowWidth = (itemsInRow - 1) * CellSize.x;
|
||||
var startX = transform.position.x - rowWidth * 0.5f;
|
||||
|
||||
float x = startX + col * CellSize.x;
|
||||
float y = startY - row * CellSize.y;
|
||||
var x = startX + col * CellSize.x;
|
||||
var y = startY - row * CellSize.y;
|
||||
|
||||
Transform cell = cells[index];
|
||||
var cell = cells[index];
|
||||
cell.position = new Vector3(x, y, cell.position.z);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,29 +7,25 @@ namespace MiraAPI.Utilities;
|
||||
|
||||
internal sealed class ControllableComparer<T>(T[] forcedToBottom, T[] forcedToTop, IComparer<T> fallbackComparer) : IComparer<T> where T : IComparable
|
||||
{
|
||||
private readonly T[] _forcedToBottom = forcedToBottom;
|
||||
private readonly T[] _forcedToTop = forcedToTop;
|
||||
private readonly IComparer<T> _fallbackComparer = fallbackComparer;
|
||||
|
||||
/// <inheritdoc/>
|
||||
[SuppressMessage("Style", "IDE0046:Convert to conditional expression", Justification = "Warning cascades into forcing the entire tree to be ternary operators.")]
|
||||
public int Compare(T? x, T? y)
|
||||
{
|
||||
if ((_forcedToBottom.Contains(x) && _forcedToBottom.Contains(y)) || (_forcedToTop.Contains(x) && _forcedToTop.Contains(y)))
|
||||
return _fallbackComparer.Compare(x, y);
|
||||
if ((forcedToBottom.Contains(x) && forcedToBottom.Contains(y)) || (forcedToTop.Contains(x) && forcedToTop.Contains(y)))
|
||||
return fallbackComparer.Compare(x, y);
|
||||
|
||||
if (_forcedToBottom.Contains(x))
|
||||
if (forcedToBottom.Contains(x))
|
||||
return 1;
|
||||
|
||||
if (_forcedToBottom.Contains(y))
|
||||
if (forcedToBottom.Contains(y))
|
||||
return -1;
|
||||
|
||||
if (_forcedToTop.Contains(x))
|
||||
if (forcedToTop.Contains(x))
|
||||
return -1;
|
||||
|
||||
if (_forcedToTop.Contains(y))
|
||||
if (forcedToTop.Contains(y))
|
||||
return 1;
|
||||
|
||||
return _fallbackComparer.Compare(x, y);
|
||||
return fallbackComparer.Compare(x, y);
|
||||
}
|
||||
}
|
||||
@@ -54,7 +54,6 @@ public static class Extensions
|
||||
/// <param name="self">The <see cref="Minigame"/>.</param>
|
||||
public static void BaseClose(this Minigame self)
|
||||
{
|
||||
bool isComplete;
|
||||
if (self.amClosing == Minigame.CloseState.Closing)
|
||||
{
|
||||
self.gameObject.Destroy();
|
||||
@@ -74,12 +73,12 @@ public static class Extensions
|
||||
}
|
||||
self.amClosing = Minigame.CloseState.Closing;
|
||||
self.logger.Info(string.Concat("Closing minigame ", self.GetType().Name));
|
||||
IAnalyticsReporter analytics = DebugAnalytics.Instance.Analytics;
|
||||
NetworkedPlayerInfo data = PlayerControl.LocalPlayer.Data;
|
||||
TaskTypes taskType = self.TaskType;
|
||||
float realtimeSinceStartup = Time.realtimeSinceStartup - self.timeOpened;
|
||||
PlayerTask myTask = self.MyTask;
|
||||
isComplete = myTask != null && myTask.IsComplete;
|
||||
var analytics = DebugAnalytics.Instance.Analytics;
|
||||
var data = PlayerControl.LocalPlayer.Data;
|
||||
var taskType = self.TaskType;
|
||||
var realtimeSinceStartup = Time.realtimeSinceStartup - self.timeOpened;
|
||||
var myTask = self.MyTask;
|
||||
var isComplete = myTask != null && myTask.IsComplete;
|
||||
analytics.MinigameClosed(data, taskType, realtimeSinceStartup, isComplete);
|
||||
self.StartCoroutine(self.CoDestroySelf());
|
||||
}
|
||||
@@ -193,6 +192,7 @@ public static class Extensions
|
||||
/// <returns>The converted list.</returns>
|
||||
public static Il2CppSystem.Collections.Generic.List<T> ToIl2CppList<T>(this List<T> systemList)
|
||||
{
|
||||
// ReSharper disable once InconsistentNaming (Justification: Acronym.)
|
||||
var il2cppList = new Il2CppSystem.Collections.Generic.List<T>();
|
||||
|
||||
foreach (var item in systemList)
|
||||
@@ -266,6 +266,8 @@ public static class Extensions
|
||||
// Left as is intentionally, did you guys mean to use it in DeepDestroy?
|
||||
[SuppressMessage("Style", "IDE0051:Remove unused private members", Justification = "Not known until intent it clear.")]
|
||||
[SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Unclear, but please shut up.")]
|
||||
// ReSharper disable once UnusedParameter.Local (Justification: Read above.)
|
||||
// ReSharper disable once UnusedMember.Local (Justification: Read above.)
|
||||
private static IEnumerator Nuke(GameObject? go, bool clearGc)
|
||||
{
|
||||
if (go == null)
|
||||
@@ -403,8 +405,8 @@ public static class Extensions
|
||||
return;
|
||||
}
|
||||
|
||||
float spriteWidth = sprite.sprite.rect.width;
|
||||
float spriteHeight = sprite.sprite.rect.height;
|
||||
var spriteWidth = sprite.sprite.rect.width;
|
||||
var spriteHeight = sprite.sprite.rect.height;
|
||||
|
||||
sprite.size = spriteWidth < spriteHeight
|
||||
? new Vector2(pixelSize * spriteWidth / spriteHeight, pixelSize)
|
||||
@@ -526,7 +528,7 @@ public static class Extensions
|
||||
/// <returns>A proper string for the <see cref="Enum"/>.</returns>
|
||||
public static string ToDisplayString(this Enum @enum)
|
||||
{
|
||||
var regex = new Regex(@"([^\^])([A-Z][a-z$])", default, default);
|
||||
var regex = new Regex(@"([^\^])([A-Z][a-z$])", default, Regex.InfiniteMatchTimeout);
|
||||
return regex.Replace(@enum.ToString(), m => $"{m.Groups[1].Value} {m.Groups[2].Value}");
|
||||
}
|
||||
|
||||
|
||||
@@ -137,18 +137,12 @@ public static class Helpers
|
||||
/// <returns><see langword="true"/> if the number falls in the range, <see langword="false"/> if not.</returns>
|
||||
public static bool CheckChance(int probability)
|
||||
{
|
||||
switch (probability)
|
||||
return probability switch
|
||||
{
|
||||
case 0:
|
||||
return false;
|
||||
case 100:
|
||||
return true;
|
||||
default:
|
||||
{
|
||||
var num = Random.RandomRangeInt(1, 101);
|
||||
return num <= probability;
|
||||
}
|
||||
}
|
||||
0 => false,
|
||||
100 => true,
|
||||
_ => Random.RandomRangeInt(1, 100) <= probability,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -198,12 +192,10 @@ public static class Helpers
|
||||
}
|
||||
|
||||
var sqrDistance = (obj.transform.position - position).sqrMagnitude;
|
||||
if (sqrDistance < closestDistanceSqr)
|
||||
{
|
||||
if (!(sqrDistance < closestDistanceSqr)) continue;
|
||||
closestDistanceSqr = sqrDistance;
|
||||
closest = obj;
|
||||
}
|
||||
}
|
||||
|
||||
return closest;
|
||||
}
|
||||
@@ -455,7 +447,7 @@ public static class Helpers
|
||||
/// Gets a <see cref="DeadBody"/> by its parent ID.
|
||||
/// </summary>
|
||||
/// <param name="id">The player ID.</param>
|
||||
/// <returns>A <see cref="DeadBody"/> or <see langword="null"/> if its not found.</returns>
|
||||
/// <returns>A <see cref="DeadBody"/> or <see langword="null"/> if it's not found.</returns>
|
||||
public static DeadBody? GetBodyById(byte id)
|
||||
{
|
||||
return Object.FindObjectsOfType<DeadBody>().FirstOrDefault(body => body.ParentId == id);
|
||||
|
||||
@@ -12,10 +12,12 @@ internal static class JudgeEvents
|
||||
MiraEventManager.RegisterEventHandler<ProcessVotesEvent>(ProcessVotesEventHandler, -1000);
|
||||
}
|
||||
|
||||
public static void ProcessVotesEventHandler(ProcessVotesEvent @event)
|
||||
{
|
||||
if (MeetingHud.Instance.TryGetWinningOverrule(out var judgeOverrule, out var networkedPlayerInfo, out var networkedPlayerInfo2))
|
||||
private static void ProcessVotesEventHandler(ProcessVotesEvent @event)
|
||||
{
|
||||
if (!MeetingHud.Instance.TryGetWinningOverrule(
|
||||
out var judgeOverrule,
|
||||
out var networkedPlayerInfo,
|
||||
out var networkedPlayerInfo2)) return;
|
||||
Error("Judge has overruled votes!");
|
||||
@event.OverruledVote = true;
|
||||
@event.OverruledNonce = judgeOverrule.OverruleNonce;
|
||||
@@ -25,4 +27,3 @@ internal static class JudgeEvents
|
||||
: networkedPlayerInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ internal static class UiResetEvents
|
||||
MiraEventManager.RegisterEventHandler<UiButtonPostResetEvent>(PlaceModifierUi, -700);
|
||||
}
|
||||
|
||||
public static void ResetButtonParents(UiButtonResetEvent _)
|
||||
private static void ResetButtonParents(UiButtonResetEvent _)
|
||||
{
|
||||
var wikiButton = MiraHudHelper.VanillaMatchInfoButton;
|
||||
var subButton = MiraHudHelper.SubmergedFloorButton;
|
||||
@@ -34,7 +34,7 @@ internal static class UiResetEvents
|
||||
}
|
||||
}
|
||||
|
||||
public static void PlaceWikiButton(UiButtonPostResetEvent @event)
|
||||
private static void PlaceWikiButton(UiButtonPostResetEvent @event)
|
||||
{
|
||||
var wikiButton = MiraHudHelper.VanillaMatchInfoButton;
|
||||
if (!wikiButton)
|
||||
@@ -47,7 +47,7 @@ internal static class UiResetEvents
|
||||
wikiButton.transform.SetParent(opts.WikiOnBottomRow.Value ? secondRow.transform : firstRow.transform);
|
||||
}
|
||||
|
||||
public static void PlaceSubmergedButton(UiButtonPostResetEvent @event)
|
||||
private static void PlaceSubmergedButton(UiButtonPostResetEvent @event)
|
||||
{
|
||||
var subButton = MiraHudHelper.SubmergedFloorButton;
|
||||
if (!subButton)
|
||||
@@ -58,7 +58,7 @@ internal static class UiResetEvents
|
||||
subButton.transform.SetParent(secondRow.transform);
|
||||
}
|
||||
|
||||
public static void PlaceModifierUi(UiButtonPostResetEvent @event)
|
||||
private static void PlaceModifierUi(UiButtonPostResetEvent @event)
|
||||
{
|
||||
var modDisplay = MiraHudHelper.ModifierDisplayOnRight ? MiraHudHelper.ModifierDisplayObject : null!;
|
||||
if (!modDisplay)
|
||||
|
||||
@@ -114,7 +114,7 @@ public static class VotingUtils
|
||||
/// 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="srcPlayerId">The id of the player who cast 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)]
|
||||
@@ -186,7 +186,7 @@ public static class VotingUtils
|
||||
/// Networks the casting of a vote. We replace the vanilla solution with a custom version that works for the use case.
|
||||
/// </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="srcPlayerId">The id of the player who cast the vote.</param>
|
||||
/// <param name="suspectPlayerId">The voted player's id.</param>
|
||||
[MethodRpc((uint)MiraRpc.CastVote)]
|
||||
[SuppressMessage(
|
||||
|
||||
Reference in new issue
Block a user