-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix neutral killing issues and rename some properties in ICustomRole …
…to clear confusion
- Loading branch information
Showing
6 changed files
with
107 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using MiraAPI.Roles; | ||
using UnityEngine; | ||
|
||
namespace MiraAPI.Example.Roles; | ||
|
||
[RegisterCustomRole] | ||
public class NeutralKillerRole : ImpostorRole, ICustomRole | ||
{ | ||
public string RoleName => "Neutral Killer"; | ||
public string RoleDescription => "Neutral who can kill."; | ||
public string RoleLongDescription => RoleDescription; | ||
public Color RoleColor => Color.magenta; | ||
public ModdedRoleTeams Team => ModdedRoleTeams.Neutral; | ||
public bool CanUseKill => true; | ||
public bool CanGetKilled => true; | ||
public bool CanUseVent => true; | ||
|
||
public override void SpawnTaskHeader(PlayerControl playerControl) | ||
{ | ||
// remove existing task header. | ||
} | ||
|
||
public override bool DidWin(GameOverReason gameOverReason) | ||
{ | ||
return GameManager.Instance.DidHumansWin(gameOverReason); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
using HarmonyLib; | ||
using Il2CppSystem; | ||
using MiraAPI.Networking; | ||
using MiraAPI.Roles; | ||
using UnityEngine; | ||
|
||
namespace MiraAPI.Patches.Roles; | ||
|
||
/// <summary> | ||
/// Fix kill button issues for neutral killers. | ||
/// </summary> | ||
[HarmonyPatch(typeof(KillButton))] | ||
public static class KillButtonPatches | ||
{ | ||
[HarmonyPrefix] | ||
[HarmonyPatch(nameof(KillButton.SetTarget))] | ||
public static bool SetTargetPrefix(KillButton __instance, PlayerControl target) | ||
{ | ||
if (!PlayerControl.LocalPlayer || PlayerControl.LocalPlayer.Data == null || !PlayerControl.LocalPlayer.Data.Role) | ||
{ | ||
return false; | ||
} | ||
|
||
if (PlayerControl.LocalPlayer.Data.Role is not ICustomRole customRole) | ||
{ | ||
return true; | ||
} | ||
|
||
if (__instance.currentTarget && __instance.currentTarget != target) | ||
{ | ||
__instance.currentTarget.cosmetics.SetOutline(false, new Nullable<Color>(Color.clear)); | ||
} | ||
__instance.currentTarget = target; | ||
if (__instance.currentTarget) | ||
{ | ||
__instance.currentTarget.cosmetics.SetOutline(true, new Nullable<Color>(customRole.RoleColor)); | ||
__instance.SetEnabled(); | ||
return false; | ||
} | ||
__instance.SetDisabled(); | ||
|
||
return false; | ||
} | ||
|
||
[HarmonyPrefix] | ||
[HarmonyPatch(nameof(KillButton.DoClick))] | ||
public static bool DoClickPrefix(KillButton __instance) | ||
{ | ||
if (PlayerControl.LocalPlayer.Data.Role is not ICustomRole) | ||
{ | ||
return true; | ||
} | ||
|
||
if (!__instance.isActiveAndEnabled || !__instance.currentTarget || __instance.isCoolingDown || | ||
PlayerControl.LocalPlayer.Data.IsDead || !PlayerControl.LocalPlayer.CanMove) | ||
{ | ||
return false; | ||
} | ||
|
||
PlayerControl.LocalPlayer.RpcCustomMurder(__instance.currentTarget); | ||
__instance.SetTarget(null); | ||
|
||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters