mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-10-20 01:46:15 +00:00
Merge branch 'dev' into feat-addressables-2
This commit is contained in:
commit
54d85a6996
2 files changed
+14
-5
No files matched your search
@@ -1,5 +1,6 @@
|
||||
using AmongUs.GameOptions;
|
||||
using MiraAPI.Roles;
|
||||
using Reactor.Utilities;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -19,6 +20,12 @@ public class ChameloenRole : CrewmateRole, ICustomRole
|
||||
IntroSound = CustomRoleUtils.GetIntroSound(RoleTypes.Shapeshifter),
|
||||
};
|
||||
|
||||
public override void Initialize(PlayerControl player)
|
||||
{
|
||||
Player = player;
|
||||
Logger<ExamplePlugin>.Error("Initializing ChamelonRole for player: " + player.PlayerId);
|
||||
}
|
||||
|
||||
public void PlayerControlFixedUpdate(PlayerControl playerControl)
|
||||
{
|
||||
if (playerControl.MyPhysics.Velocity.magnitude > 0)
|
||||
|
||||
@@ -12,19 +12,19 @@ namespace MiraAPI.Patches.Roles;
|
||||
[HarmonyPatch(typeof(RoleManager))]
|
||||
public static class RoleManagerPatches
|
||||
{
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(nameof(RoleManager.SetRole))]
|
||||
public static void SetRolePatch(RoleManager __instance, PlayerControl targetPlayer, RoleTypes roleType)
|
||||
public static bool SetRolePatch(RoleManager __instance, PlayerControl targetPlayer, RoleTypes roleType)
|
||||
{
|
||||
if (!targetPlayer)
|
||||
{
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
var data = targetPlayer.Data;
|
||||
if (data == null)
|
||||
{
|
||||
Debug.LogError("It shouldn't be possible, but " + targetPlayer.name + " still doesn't have PlayerData during role selection.");
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
if (data.Role)
|
||||
{
|
||||
@@ -47,7 +47,7 @@ public static class RoleManagerPatches
|
||||
{
|
||||
case true when !targetPlayer.Data.IsDead:
|
||||
targetPlayer.Die(DeathReason.Kill, false);
|
||||
return;
|
||||
return false;
|
||||
case false when targetPlayer.Data.IsDead:
|
||||
targetPlayer.Revive();
|
||||
break;
|
||||
@@ -55,6 +55,8 @@ public static class RoleManagerPatches
|
||||
|
||||
var @event = new SetRoleEvent(targetPlayer, roleType);
|
||||
MiraEventManager.InvokeEvent(@event);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
|
||||
Reference in new issue
Block a user