diff --git a/TheOtherRoles/Objects/Trap.cs b/TheOtherRoles/Objects/Trap.cs index 76bdde7e4..e47ef1d6b 100644 --- a/TheOtherRoles/Objects/Trap.cs +++ b/TheOtherRoles/Objects/Trap.cs @@ -7,6 +7,11 @@ using UnityEngine; namespace TheOtherRoles.Objects { + record TrapInfo { + public PlayerControl player; + public string roleWhenInTrap; + } + class Trap { public static List traps = new List(); public static Dictionary trapPlayerIdMap = new Dictionary(); @@ -18,7 +23,7 @@ class Trap { public bool triggerable = false; private int usedCount = 0; private int neededCount = Trapper.trapCountToReveal; - public List trappedPlayer = new List(); + public List trappedPlayer = new List(); private Arrow arrow = new Arrow(Color.blue); private static Sprite trapSprite; @@ -95,11 +100,12 @@ public static void triggerTrap(byte playerId, byte trapId) { } }))); - if (t.usedCount == t.neededCount) { + if (t.usedCount == t.neededCount) + { t.revealed = true; } - - t.trappedPlayer.Add(player); + + t.trappedPlayer.Add(new TrapInfo { player = player, roleWhenInTrap = RoleInfo.GetRolesString(player, false, false, true)}); t.triggerable = true; } @@ -115,7 +121,7 @@ public static void Update() { Trap target = null; foreach (Trap trap in traps) { if (trap.arrow.arrow.active) trap.arrow.Update(); - if (trap.revealed || !trap.triggerable || trap.trappedPlayer.Contains(player.PlayerControl)) continue; + if (trap.revealed || !trap.triggerable || trap.trappedPlayer.Any(tp => tp.player == player.PlayerControl)) continue; if (player.PlayerControl.inVent || !player.PlayerControl.CanMove) continue; float distance = Vector2.Distance(trap.trap.transform.position, player.PlayerControl.GetTruePosition()); if (distance <= ud && distance < closestDistance) { diff --git a/TheOtherRoles/Patches/MeetingPatch.cs b/TheOtherRoles/Patches/MeetingPatch.cs index 30cc11da8..f84d78428 100644 --- a/TheOtherRoles/Patches/MeetingPatch.cs +++ b/TheOtherRoles/Patches/MeetingPatch.cs @@ -717,8 +717,10 @@ public static void Prefix(PlayerControl __instance, [HarmonyArgument(0)]GameData if (!trap.revealed) continue; string message = $"Trap {trap.instanceId}: \n"; trap.trappedPlayer = trap.trappedPlayer.OrderBy(x => rnd.Next()).ToList(); - foreach (PlayerControl p in trap.trappedPlayer) { - if (Trapper.infoType == 0) message += RoleInfo.GetRolesString(p, false, false, true) + "\n"; + foreach (TrapInfo trapInfo in trap.trappedPlayer) + { + PlayerControl p = trapInfo.player; + if (Trapper.infoType == 0) message += trapInfo.roleWhenInTrap + "\n"; else if (Trapper.infoType == 1) { if (Helpers.isNeutral(p) || p.Data.Role.IsImpostor) message += "Evil Role \n"; else message += "Good Role \n";