mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-10-19 15:51:48 +00:00
Merge branch 'master' into dev
This commit is contained in:
commit
30d2edfd9c
2 files changed
+45
-27
No files matched your search
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user