mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-10-19 15:51:48 +00:00
Some changes to role visibility name text
This commit is contained in:
1 parent
c7d16f7fc9
commit
4db7605d27
5 files changed
+50
-26
No files matched your search
@@ -18,4 +18,9 @@ public class TeleporterRole : CrewmateRole, ICustomRole
|
|||||||
DefaultChance = 73,
|
DefaultChance = 73,
|
||||||
DefaultRoleCount = 4,
|
DefaultRoleCount = 4,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public bool CanLocalPlayerSeeRole(PlayerControl player)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
using HarmonyLib;
|
||||||
|
using MiraAPI.Roles;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace MiraAPI.Patches.Roles;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Patches the haunt menu to show the actual role name rather then team.
|
||||||
|
/// </summary>
|
||||||
|
[HarmonyPatch(typeof(HauntMenuMinigame), nameof(HauntMenuMinigame.SetFilterText))]
|
||||||
|
public static class HauntMenuMinigamePatch
|
||||||
|
{
|
||||||
|
public static void Postfix(HauntMenuMinigame __instance)
|
||||||
|
{
|
||||||
|
if (__instance.HauntTarget.Data.IsDead)
|
||||||
|
{
|
||||||
|
__instance.FilterText.color = Color.white;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var role = __instance.HauntTarget.Data.Role;
|
||||||
|
var color = role is ICustomRole custom ? custom.RoleColor : role.TeamColor;
|
||||||
|
|
||||||
|
__instance.FilterText.text = role.NiceName;
|
||||||
|
__instance.FilterText.color = color;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,10 +1,11 @@
|
|||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
|
using MiraAPI.Roles;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace MiraAPI.Patches.Roles;
|
namespace MiraAPI.Patches.Roles;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set nametag color depending on option
|
/// Set nametag color depending on visibility.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[HarmonyPatch(typeof(PlayerNameColor))]
|
[HarmonyPatch(typeof(PlayerNameColor))]
|
||||||
public static class NameTagPatch
|
public static class NameTagPatch
|
||||||
@@ -13,6 +14,12 @@ public static class NameTagPatch
|
|||||||
[HarmonyPatch(nameof(PlayerNameColor.Get), typeof(RoleBehaviour))]
|
[HarmonyPatch(nameof(PlayerNameColor.Get), typeof(RoleBehaviour))]
|
||||||
public static bool GetPatch([HarmonyArgument(0)] RoleBehaviour otherPlayerRole, ref Color __result)
|
public static bool GetPatch([HarmonyArgument(0)] RoleBehaviour otherPlayerRole, ref Color __result)
|
||||||
{
|
{
|
||||||
|
if (otherPlayerRole is ICustomRole customRole && customRole.CanLocalPlayerSeeRole(otherPlayerRole.Player))
|
||||||
|
{
|
||||||
|
__result = customRole.RoleColor;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (PlayerControl.LocalPlayer.Data.Role.IsImpostor && otherPlayerRole.IsImpostor)
|
if (PlayerControl.LocalPlayer.Data.Role.IsImpostor && otherPlayerRole.IsImpostor)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -1,25 +0,0 @@
|
|||||||
using HarmonyLib;
|
|
||||||
using MiraAPI.Roles;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace MiraAPI.Patches.Roles;
|
|
||||||
|
|
||||||
[HarmonyPatch(typeof(RoleBehaviour))]
|
|
||||||
public static class RoleBehaviourPatches
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Update TeamColor text for Launchpad roles
|
|
||||||
/// </summary>
|
|
||||||
[HarmonyPrefix]
|
|
||||||
[HarmonyPatch(nameof(RoleBehaviour.TeamColor), MethodType.Getter)]
|
|
||||||
public static bool PrefixTeamColorGetter(RoleBehaviour __instance, ref Color __result)
|
|
||||||
{
|
|
||||||
if (__instance is not ICustomRole behaviour)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
__result = behaviour.RoleColor;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -128,6 +128,16 @@ public interface ICustomRole
|
|||||||
Logger<MiraApiPlugin>.Error($"Error getting count configuration for role: {RoleName}");
|
Logger<MiraApiPlugin>.Error($"Error getting count configuration for role: {RoleName}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether the local player can see this role.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="player">The player with the role.</param>
|
||||||
|
/// <returns>Whether they can see the role (name color) or not.</returns>
|
||||||
|
public virtual bool CanLocalPlayerSeeRole(PlayerControl player)
|
||||||
|
{
|
||||||
|
return (Team == ModdedRoleTeams.Impostor && player.Data.Role.IsImpostor) || PlayerControl.LocalPlayer.Data.IsDead;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This method runs on the HudManager.Update method ONLY when the LOCAL player has this role.
|
/// This method runs on the HudManager.Update method ONLY when the LOCAL player has this role.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in new issue
Block a user