Merge branch 'master' into dev

This commit is contained in:
XtraCube committed 2024-09-10 09:46:44 -04:00
commit 30d2edfd9c
2 files changed
+45 -27

No files matched your search

-27
View File
@@ -1,27 +0,0 @@
using HarmonyLib;
using MiraAPI.Roles;
using MiraAPI.Utilities;
using UnityEngine;
namespace MiraAPI.Patches.Roles;
/// <summary>
/// Set vent outline color based on the player's role.
/// </summary>
[HarmonyPatch(typeof(Vent), nameof(Vent.SetOutline))]
public static class VentOutlinePatch
{
public static void Postfix(Vent __instance, bool on, bool mainTarget)
{
if (PlayerControl.LocalPlayer.Data.Role is not ICustomRole customRole)
{
return;
}
var color = customRole.RoleColor;
__instance.myRend.material.SetFloat(ShaderID.Outline, on ? 1 : 0);
__instance.myRend.material.SetColor(ShaderID.OutlineColor, color);
__instance.myRend.material.SetColor(ShaderID.AddColor, mainTarget ? color : Color.clear);
}
}
+45
View File
@@ -0,0 +1,45 @@
using HarmonyLib;
using MiraAPI.Roles;
using MiraAPI.Utilities;
using UnityEngine;
namespace MiraAPI.Patches.Roles;
/// <summary>
/// Vent patches for Roles.
/// </summary>
[HarmonyPatch(typeof(Vent))]
public static class VentPatches
{
/// <summary>
/// Set CanVent of player to customRole CanUseVent because the original one isnt a property :(.
/// </summary>
[HarmonyPrefix]
[HarmonyPatch(nameof(Vent.CanUse))]
public static void CanUsePrefix(Vent __instance, NetworkedPlayerInfo pc)
{
if (pc.Role is ICustomRole customRole)
{
pc.Role.CanVent = customRole.CanUseVent;
}
}
/// <summary>
/// Set outline to player's custom role color.
/// </summary>
[HarmonyPostfix]
[HarmonyPatch(nameof(Vent.SetOutline))]
public static void SetOutlinePostfix(Vent __instance, bool on, bool mainTarget)
{
if (PlayerControl.LocalPlayer.Data.Role is not ICustomRole customRole)
{
return;
}
var color = customRole.RoleColor;
__instance.myRend.material.SetFloat(ShaderID.Outline, on ? 1 : 0);
__instance.myRend.material.SetColor(ShaderID.OutlineColor, color);
__instance.myRend.material.SetColor(ShaderID.AddColor, mainTarget ? color : Color.clear);
}
}