mirror of
https://github.com/ApeMV/AmongUsRevamped.git
synced 2026-10-19 15:51:59 +00:00
That was not a fun surpirse
This commit is contained in:
1 parent
81c20d4706
commit
71461583b3
2 files changed
+76
-58
No files matched your search
@@ -547,4 +547,26 @@ public static class Utils
|
||||
PlayerControl.LocalPlayer.CmdReportDeadBody(null);
|
||||
MeetingHud.Instance.RpcClose();
|
||||
}
|
||||
|
||||
public static MethodBase GetStateMachineMoveNext<T>(string methodName)
|
||||
{
|
||||
var typeName = typeof(T).FullName;
|
||||
var stateMachine = typeof(T).GetNestedTypes().FirstOrDefault(x => x.Name.Contains(methodName));
|
||||
|
||||
if (stateMachine == null)
|
||||
{
|
||||
Logger.Error($"Failed to find {methodName} state machine for {typeName}", "GetStateMachineMoveNext");
|
||||
return null;
|
||||
}
|
||||
|
||||
var moveNext = AccessTools.Method(stateMachine, "MoveNext");
|
||||
if (moveNext == null)
|
||||
{
|
||||
Logger.Error($"Failed to find MoveNext method for {typeName}.{methodName}", "GetStateMachineMoveNext");
|
||||
return null;
|
||||
}
|
||||
|
||||
Logger.Info($"Found {methodName}.MoveNext", "GetStateMachineMoveNext");
|
||||
return moveNext;
|
||||
}
|
||||
}
|
||||
+54
-58
@@ -1,78 +1,74 @@
|
||||
using System.Reflection;
|
||||
using Il2CppInterop.Runtime.InteropTypes;
|
||||
|
||||
namespace AmongUsRevamped;
|
||||
|
||||
[HarmonyPatch]
|
||||
class ExileControllerWrapUpPatch
|
||||
{
|
||||
[HarmonyPatch(typeof(ExileController), nameof(ExileController.WrapUp))]
|
||||
class ExileControllerPatch
|
||||
public static MethodBase TargetMethod()
|
||||
{
|
||||
public static void Postfix(ExileController __instance)
|
||||
return AccessTools.Method(typeof(ExileController), nameof(ExileController.WrapUp));
|
||||
}
|
||||
|
||||
public static void Postfix(ExileController __instance)
|
||||
{
|
||||
AfterExile(__instance.initData.networkedPlayer);
|
||||
}
|
||||
|
||||
public static void AfterExile(NetworkedPlayerInfo ejectedPlayer)
|
||||
{
|
||||
if (!AmongUsClient.Instance.AmHost) return;
|
||||
if (ejectedPlayer == null) return;
|
||||
|
||||
PlayerControl pc = null;
|
||||
PlayerControl exiledPlayer = ejectedPlayer.Object;
|
||||
foreach (var p in PlayerControl.AllPlayerControls)
|
||||
{
|
||||
AfterExile(__instance.initData.networkedPlayer);
|
||||
}
|
||||
|
||||
public static void AfterExile(NetworkedPlayerInfo ejectedPlayer)
|
||||
{
|
||||
if (!AmongUsClient.Instance.AmHost) return;
|
||||
|
||||
if (ejectedPlayer == null) return;
|
||||
|
||||
PlayerControl pc = null;
|
||||
PlayerControl exiledPlayer = ejectedPlayer.Object;
|
||||
foreach (var p in PlayerControl.AllPlayerControls)
|
||||
if (p.PlayerId == ejectedPlayer.PlayerId)
|
||||
{
|
||||
if (p.PlayerId == ejectedPlayer.PlayerId)
|
||||
{
|
||||
pc = p;
|
||||
}
|
||||
|
||||
if (ejectedPlayer == PlayerControl.LocalPlayer.Data && !Main.DisableInfoWhenDead.Value)
|
||||
{
|
||||
if (p.Data.Role.IsImpostor)
|
||||
{
|
||||
p.cosmetics.nameText.text = $"{p.Data.PlayerName}<color=red><size=90%>({MurderPlayerPatch.killCount[p.Data.PlayerId]}†)";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!PlayerControlCompleteTaskPatch.playerTasksCompleted.ContainsKey(p))
|
||||
{
|
||||
PlayerControlCompleteTaskPatch.playerTasksCompleted[p] = 0;
|
||||
}
|
||||
p.cosmetics.nameText.text = $"{p.Data.PlayerName}<color=green><size=90%>({PlayerControlCompleteTaskPatch.playerTasksCompleted[p]}/{PlayerControlCompleteTaskPatch.tasksPerPlayer[p]})";
|
||||
}
|
||||
}
|
||||
pc = p;
|
||||
}
|
||||
|
||||
Logger.Info($" {ejectedPlayer.PlayerName} was ejected", "ExileController");
|
||||
|
||||
if (PlayerControlSetRolePatch.Jesters.Contains(exiledPlayer))
|
||||
if (ejectedPlayer == PlayerControl.LocalPlayer.Data && !Main.DisableInfoWhenDead.Value)
|
||||
{
|
||||
Logger.Info($"Jester {ejectedPlayer.PlayerName} wins", "ExilePatch");
|
||||
Utils.CustomWinnerEndGame(exiledPlayer, 1);
|
||||
NormalGameEndChecker.CheckWinnerText("Jester");
|
||||
return;
|
||||
if (p.Data.Role.IsImpostor)
|
||||
{
|
||||
p.cosmetics.nameText.text = $"{p.Data.PlayerName}<color=red><size=90%>({MurderPlayerPatch.killCount[p.Data.PlayerId]}†)";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!PlayerControlCompleteTaskPatch.playerTasksCompleted.ContainsKey(p))
|
||||
{
|
||||
PlayerControlCompleteTaskPatch.playerTasksCompleted[p] = 0;
|
||||
}
|
||||
p.cosmetics.nameText.text = $"{p.Data.PlayerName}<color=green><size=90%>({PlayerControlCompleteTaskPatch.playerTasksCompleted[p]}/{PlayerControlCompleteTaskPatch.tasksPerPlayer[p]})";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Logger.Info($" {ejectedPlayer.PlayerName} was ejected", "ExileController");
|
||||
|
||||
if (PlayerControlSetRolePatch.Jesters.Contains(exiledPlayer))
|
||||
{
|
||||
Logger.Info($"Jester {ejectedPlayer.PlayerName} wins", "ExilePatch");
|
||||
Utils.CustomWinnerEndGame(exiledPlayer, 1);
|
||||
NormalGameEndChecker.CheckWinnerText("Jester");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
#if ANDROID
|
||||
[HarmonyPatch(typeof(AirshipExileController), nameof(AirshipExileController.WrapUpAndSpawn))]
|
||||
class AirshipExileControllerPatchAndroid
|
||||
[HarmonyPatch]
|
||||
class AirshipExileControllerPatch
|
||||
{
|
||||
public static void Postfix(AirshipExileController __instance)
|
||||
public static MethodBase TargetMethod()
|
||||
{
|
||||
ExileControllerPatch.AfterExile(__instance.initData.networkedPlayer);
|
||||
return Utils.GetStateMachineMoveNext<AirshipExileController>(nameof(AirshipExileController.WrapUpAndSpawn));
|
||||
}
|
||||
|
||||
public static void Postfix(AirshipExileController._WrapUpAndSpawn_d__11 __instance)
|
||||
{
|
||||
ExileControllerWrapUpPatch.AfterExile(__instance.__4__this.initData.networkedPlayer);
|
||||
}
|
||||
}
|
||||
#else
|
||||
[HarmonyPatch(typeof(AirshipExileController._WrapUpAndSpawn_d__11), nameof(AirshipExileController._WrapUpAndSpawn_d__11.MoveNext))]
|
||||
class AirshipExileControllerPatchPC
|
||||
{
|
||||
public static void Postfix(AirshipExileController._WrapUpAndSpawn_d__11 __instance, ref bool __result)
|
||||
{
|
||||
var instance = __instance.__4__this;
|
||||
ExileControllerPatch.AfterExile(instance.initData.networkedPlayer);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
Reference in new issue
Block a user