@@ -8,16 +8,33 @@ namespace MalumMenu;
8
8
[ HarmonyPatch ( typeof ( PlayerPhysics ) , nameof ( PlayerPhysics . LateUpdate ) ) ]
9
9
public static class TeleportCursor_PlayerPhysics_LateUpdate_Postfix
10
10
{
11
- // Postfix patch of PlayerPhysics.LateUpdate to teleport to cursor position on right-click
11
+ private static bool previousTeleportMeCursorState = false ;
12
+ private static bool previousTeleportAllCursorState = false ;
13
+
14
+ // Postfix patch of PlayerPhysics.LateUpdate to teleport players to cursor position on right-click
12
15
public static void Postfix ( PlayerPhysics __instance )
13
16
{
14
- if ( Input . GetMouseButtonDown ( 1 ) )
17
+ //Code to make sure only one of these cheats is enabled at a time
18
+ if ( CheatToggles . teleportMeCursor && ! previousTeleportMeCursorState )
19
+ {
20
+ CheatToggles . teleportAllCursor = false ;
21
+ previousTeleportMeCursorState = true ;
22
+ previousTeleportAllCursorState = false ;
23
+ }
24
+ else if ( CheatToggles . teleportAllCursor && ! previousTeleportAllCursorState )
15
25
{
16
- if ( CheatToggles . teleportMeCursor )
26
+ CheatToggles . teleportMeCursor = false ;
27
+ previousTeleportAllCursorState = true ;
28
+ previousTeleportMeCursorState = false ;
29
+ }
30
+
31
+ if ( Input . GetMouseButtonDown ( 1 ) ) //Register right-click
32
+ {
33
+ if ( CheatToggles . teleportMeCursor ) //Teleport LocalPlayer to cursor position
17
34
{
18
35
Utils . TeleportPlayer ( PlayerControl . LocalPlayer , Camera . main . ScreenToWorldPoint ( Input . mousePosition ) ) ;
19
36
}
20
- else if ( CheatToggles . teleportAllCursor )
37
+ else if ( CheatToggles . teleportAllCursor ) //Teleport all players to cursor position
21
38
{
22
39
foreach ( var item in PlayerControl . AllPlayerControls )
23
40
{
@@ -80,7 +97,7 @@ public static void Postfix(PlayerPhysics __instance){
80
97
[ HarmonyPatch ( typeof ( PlayerPhysics ) , nameof ( PlayerPhysics . LateUpdate ) ) ]
81
98
public static class TeleportAllPlayer_PlayerPhysics_LateUpdate_Postfix
82
99
{
83
- //Postfix patch of PlayerPhysics.LateUpdate to open player pick menu to teleport to player
100
+ //Postfix patch of PlayerPhysics.LateUpdate to open player pick menu to teleport all players to one player
84
101
public static bool isActive ;
85
102
public static void Postfix ( PlayerPhysics __instance ) {
86
103
if ( CheatToggles . teleportAllPlayer ) {
@@ -104,7 +121,9 @@ public static void Postfix(PlayerPhysics __instance){
104
121
Utils_PlayerPickMenu . openPlayerPickMenu ( playerList , ( Action ) ( ( ) =>
105
122
{
106
123
foreach ( var item in PlayerControl . AllPlayerControls ) {
107
- Utils . TeleportPlayer ( item , Utils_PlayerPickMenu . targetPlayer . transform . position ) ;
124
+ if ( item . PlayerId != Utils_PlayerPickMenu . targetPlayer . PlayerId ) {
125
+ Utils . TeleportPlayer ( item , Utils_PlayerPickMenu . targetPlayer . transform . position ) ;
126
+ }
108
127
}
109
128
110
129
} ) ) ;
0 commit comments