mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-10-20 21:35:49 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a72fefe235 |
No files matched your search
@@ -99,11 +99,6 @@ public static class PlayerControlPatches
|
|||||||
[HarmonyPatch(nameof(PlayerControl.FixedUpdate))]
|
[HarmonyPatch(nameof(PlayerControl.FixedUpdate))]
|
||||||
public static void PlayerControlFixedUpdatePostfix(PlayerControl __instance)
|
public static void PlayerControlFixedUpdatePostfix(PlayerControl __instance)
|
||||||
{
|
{
|
||||||
if (__instance.Data?.Role is ICustomRole customRole)
|
|
||||||
{
|
|
||||||
customRole.PlayerControlFixedUpdate(__instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!__instance.AmOwner)
|
if (!__instance.AmOwner)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -5,29 +5,15 @@ using Reactor.Utilities.Extensions;
|
|||||||
|
|
||||||
namespace MiraAPI.Patches.Roles;
|
namespace MiraAPI.Patches.Roles;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// HudManager patches for roles.
|
|
||||||
/// </summary>
|
|
||||||
[HarmonyPatch(typeof(HudManager))]
|
[HarmonyPatch(typeof(HudManager))]
|
||||||
public static class HudManagerPatches
|
internal static class HudManagerPatches
|
||||||
{
|
{
|
||||||
// Custom role tab.
|
|
||||||
private static TaskPanelBehaviour? _roleTab;
|
private static TaskPanelBehaviour? _roleTab;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Fixes Kill Button not showing for Neutral killing role.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="__instance">HudManager instance.</param>
|
|
||||||
/// <param name="localPlayer">The local PlayerControl.</param>
|
|
||||||
/// <param name="role">The player's RoleBehaviour.</param>
|
|
||||||
/// <param name="isActive">Whether the Hud should be set active or not.</param>
|
|
||||||
[HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
[HarmonyPatch(nameof(HudManager.SetHudActive), typeof(PlayerControl), typeof(RoleBehaviour), typeof(bool))]
|
[HarmonyPatch(nameof(HudManager.SetHudActive), typeof(PlayerControl), typeof(RoleBehaviour), typeof(bool))]
|
||||||
public static void SetHudActivePostfix(
|
// ReSharper disable once InconsistentNaming
|
||||||
HudManager __instance,
|
public static void SetHudActivePostfix(HudManager __instance, PlayerControl localPlayer, RoleBehaviour role, bool isActive)
|
||||||
PlayerControl localPlayer,
|
|
||||||
RoleBehaviour role,
|
|
||||||
bool isActive)
|
|
||||||
{
|
{
|
||||||
var flag = localPlayer.Data != null && localPlayer.Data.IsDead;
|
var flag = localPlayer.Data != null && localPlayer.Data.IsDead;
|
||||||
|
|
||||||
@@ -44,11 +30,9 @@ public static class HudManagerPatches
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Update custom role tab and custom role hud elements.
|
|
||||||
/// </summary>
|
|
||||||
[HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
[HarmonyPatch(nameof(HudManager.Update))]
|
[HarmonyPatch(nameof(HudManager.Update))]
|
||||||
|
// ReSharper disable once InconsistentNaming
|
||||||
public static void UpdatePostfix(HudManager __instance)
|
public static void UpdatePostfix(HudManager __instance)
|
||||||
{
|
{
|
||||||
var local = PlayerControl.LocalPlayer;
|
var local = PlayerControl.LocalPlayer;
|
||||||
@@ -62,8 +46,6 @@ public static class HudManagerPatches
|
|||||||
|
|
||||||
if (role is ICustomRole { Configuration.RoleHintType: RoleHintType.RoleTab } customRole)
|
if (role is ICustomRole { Configuration.RoleHintType: RoleHintType.RoleTab } customRole)
|
||||||
{
|
{
|
||||||
customRole.HudUpdate(__instance);
|
|
||||||
|
|
||||||
if (_roleTab == null)
|
if (_roleTab == null)
|
||||||
{
|
{
|
||||||
_roleTab = CustomRoleManager.CreateRoleTab(customRole);
|
_roleTab = CustomRoleManager.CreateRoleTab(customRole);
|
||||||
@@ -71,9 +53,9 @@ public static class HudManagerPatches
|
|||||||
|
|
||||||
CustomRoleManager.UpdateRoleTab(_roleTab, customRole);
|
CustomRoleManager.UpdateRoleTab(_roleTab, customRole);
|
||||||
}
|
}
|
||||||
else if (_roleTab)
|
else if (_roleTab != null)
|
||||||
{
|
{
|
||||||
_roleTab?.gameObject.Destroy();
|
_roleTab.gameObject.Destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -74,14 +74,6 @@ public interface ICustomRole : IOptionable
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
MiraPluginInfo ParentMod => CustomRoleManager.FindParentMod(this);
|
MiraPluginInfo ParentMod => CustomRoleManager.FindParentMod(this);
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This method runs on the PlayerControl.FixedUpdate method for ALL players with this role.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="playerControl">The PlayerControl that has this role.</param>
|
|
||||||
void PlayerControlFixedUpdate(PlayerControl playerControl)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
internal ConfigDefinition NumConfigDefinition => new("Roles", $"Num {GetType().FullName}");
|
internal ConfigDefinition NumConfigDefinition => new("Roles", $"Num {GetType().FullName}");
|
||||||
internal ConfigDefinition ChanceConfigDefinition => new("Roles", $"Chance {GetType().FullName}");
|
internal ConfigDefinition ChanceConfigDefinition => new("Roles", $"Chance {GetType().FullName}");
|
||||||
|
|
||||||
@@ -184,14 +176,6 @@ public interface ICustomRole : IOptionable
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This method runs on the HudManager.Update method ONLY when the LOCAL player has this role.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="hudManager">Reference to HudManager instance.</param>
|
|
||||||
void HudUpdate(HudManager hudManager)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a custom ejection message for the role. Return null to use the default message.
|
/// Gets a custom ejection message for the role. Return null to use the default message.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in new issue
Block a user