From cb943c2173fa2ea8bfb93e391e881ab0e086d1bc Mon Sep 17 00:00:00 2001
From: XtraCube <72575280+XtraCube@users.noreply.github.com>
Date: Mon, 2 Sep 2024 13:37:45 -0400
Subject: [PATCH] CanKill -> UseVanillaKillButton ICustomRole changes to clear
up confusion Add KillButtonOutlineColor to ICustomRole
---
MiraAPI.Example/Roles/NeutralKillerRole.cs | 2 +-
MiraAPI/Patches/Roles/KillButtonPatches.cs | 8 ++++-
MiraAPI/Roles/CustomRoleManager.cs | 2 +-
MiraAPI/Roles/ICustomRole.cs | 36 ++++++++++++++--------
4 files changed, 32 insertions(+), 16 deletions(-)
diff --git a/MiraAPI.Example/Roles/NeutralKillerRole.cs b/MiraAPI.Example/Roles/NeutralKillerRole.cs
index 0cbc6fd..820c334 100644
--- a/MiraAPI.Example/Roles/NeutralKillerRole.cs
+++ b/MiraAPI.Example/Roles/NeutralKillerRole.cs
@@ -11,7 +11,7 @@ public class NeutralKillerRole : ImpostorRole, ICustomRole
public string RoleLongDescription => RoleDescription;
public Color RoleColor => Color.magenta;
public ModdedRoleTeams Team => ModdedRoleTeams.Neutral;
- public bool CanUseKill => true;
+ public bool UseVanillaKillButton => true;
public bool CanGetKilled => true;
public bool CanUseVent => true;
diff --git a/MiraAPI/Patches/Roles/KillButtonPatches.cs b/MiraAPI/Patches/Roles/KillButtonPatches.cs
index 52b5cba..7b7010a 100644
--- a/MiraAPI/Patches/Roles/KillButtonPatches.cs
+++ b/MiraAPI/Patches/Roles/KillButtonPatches.cs
@@ -12,6 +12,9 @@ namespace MiraAPI.Patches.Roles;
[HarmonyPatch(typeof(KillButton))]
public static class KillButtonPatches
{
+ ///
+ /// SetTarget for custom roles.
+ ///
[HarmonyPrefix]
[HarmonyPatch(nameof(KillButton.SetTarget))]
public static bool SetTargetPrefix(KillButton __instance, PlayerControl target)
@@ -33,7 +36,7 @@ public static class KillButtonPatches
__instance.currentTarget = target;
if (__instance.currentTarget)
{
- __instance.currentTarget.cosmetics.SetOutline(true, new Nullable(customRole.RoleColor));
+ __instance.currentTarget.cosmetics.SetOutline(true, new Nullable(customRole.KillButtonOutlineColor));
__instance.SetEnabled();
return false;
}
@@ -42,6 +45,9 @@ public static class KillButtonPatches
return false;
}
+ ///
+ /// Use Custom Murder if player is custom role.
+ ///
[HarmonyPrefix]
[HarmonyPatch(nameof(KillButton.DoClick))]
public static bool DoClickPrefix(KillButton __instance)
diff --git a/MiraAPI/Roles/CustomRoleManager.cs b/MiraAPI/Roles/CustomRoleManager.cs
index 7fad146..f63a5c8 100644
--- a/MiraAPI/Roles/CustomRoleManager.cs
+++ b/MiraAPI/Roles/CustomRoleManager.cs
@@ -86,7 +86,7 @@ public static class CustomRoleManager
roleBehaviour.BlurbNameLong = CustomStringName.CreateAndRegister(customRole.RoleLongDescription);
roleBehaviour.AffectedByLightAffectors = customRole.AffectedByLightOnAirship;
roleBehaviour.CanBeKilled = customRole.CanGetKilled;
- roleBehaviour.CanUseKillButton = customRole.CanUseKill;
+ roleBehaviour.CanUseKillButton = customRole.UseVanillaKillButton;
roleBehaviour.TasksCountTowardProgress = customRole.TasksCountForProgress;
roleBehaviour.CanVent = customRole.CanUseVent;
roleBehaviour.DefaultGhostRole = customRole.GhostRole;
diff --git a/MiraAPI/Roles/ICustomRole.cs b/MiraAPI/Roles/ICustomRole.cs
index 0ac41bb..3087dbe 100644
--- a/MiraAPI/Roles/ICustomRole.cs
+++ b/MiraAPI/Roles/ICustomRole.cs
@@ -57,30 +57,20 @@ public interface ICustomRole
[HideFromIl2Cpp]
LoadableAsset Icon => MiraAssets.Empty;
- ///
- /// Gets the BepInEx ConfigDefinition for the amount of players that can have this role.
- ///
- ConfigDefinition NumConfigDefinition => new("Roles", $"Num {GetType().FullName}");
-
- ///
- /// Gets the BepInEx ConfigDefinition for the chance of this role being selected.
- ///
- ConfigDefinition ChanceConfigDefinition => new("Roles", $"Chance {GetType().FullName}");
-
///
/// Gets a value indicating whether the role is affected by light affectors on Airship.
///
bool AffectedByLightOnAirship => Team == ModdedRoleTeams.Crewmate;
///
- /// Gets a value indicating whether the role can be killed by others.
+ /// Gets a value indicating whether the role can be killed by vanilla murder system.
///
bool CanGetKilled => Team == ModdedRoleTeams.Crewmate;
///
- /// Gets a value indicating whether the role can kill others.
+ /// Gets a value indicating whether the role should use the vanilla kill button.
///
- bool CanUseKill => Team == ModdedRoleTeams.Impostor;
+ bool UseVanillaKillButton => Team == ModdedRoleTeams.Impostor;
///
/// Gets a value indicating whether the role can use vents.
@@ -102,6 +92,16 @@ public interface ICustomRole
///
bool HideSettings => IsGhostRole;
+ ///
+ /// Gets the outline color for the KillButton if is true.
+ ///
+ Color KillButtonOutlineColor => Team switch
+ {
+ ModdedRoleTeams.Impostor => Palette.ImpostorRed,
+ ModdedRoleTeams.Crewmate => Palette.CrewmateBlue,
+ _ => RoleColor,
+ };
+
///
/// Gets the role hint style. See enum for all options.
///
@@ -112,6 +112,16 @@ public interface ICustomRole
///
RoleTypes GhostRole => Team == ModdedRoleTeams.Impostor ? RoleTypes.ImpostorGhost : RoleTypes.CrewmateGhost;
+ ///
+ /// Gets the BepInEx ConfigDefinition for the amount of players that can have this role.
+ ///
+ ConfigDefinition NumConfigDefinition => new("Roles", $"Num {GetType().FullName}");
+
+ ///
+ /// Gets the BepInEx ConfigDefinition for the chance of this role being selected.
+ ///
+ ConfigDefinition ChanceConfigDefinition => new("Roles", $"Chance {GetType().FullName}");
+
///
/// Gets the parent mod of this role.
///