using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using MelonLoader;
using Microsoft.CodeAnalysis;
using TeleportoMouse;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(TeleportoMouseMod), "TeleportoMouse", "1.0.0", "Zooks", null)]
[assembly: MelonGame("Boneloaf", "Gang Beasts")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("TeleportToMouse_New")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("TeleportToMouse_New")]
[assembly: AssemblyTitle("TeleportToMouse_New")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
}
namespace TeleportoMouse
{
public class TeleportoMouseMod : MelonMod
{
private struct POINT
{
public int X;
public int Y;
}
private const int VK_T = 84;
private const int VK_F = 70;
private Transform? selectedPlayer;
private int selectedPlayerID = -1;
private Rigidbody[]? cachedPlayerRigidbodies;
private Camera? mainCamera;
private bool isTeleporting;
private Vector3 teleportTarget = Vector3.zero;
private int enforceFramesRemaining;
private const int ENFORCE_FRAME_COUNT = 40;
private bool wasTPressed;
private bool wasFPressed;
private Dictionary<int, Vector3> bodyPartOffsets = new Dictionary<int, Vector3>();
private Dictionary<int, Quaternion> bodyPartRotations = new Dictionary<int, Quaternion>();
[DllImport("user32.dll")]
private static extern short GetAsyncKeyState(int vKey);
[DllImport("user32.dll")]
private static extern bool GetCursorPos(out POINT lpPoint);
[DllImport("user32.dll")]
private static extern bool ScreenToClient(IntPtr hWnd, ref POINT lpPoint);
[DllImport("user32.dll")]
private static extern IntPtr GetActiveWindow();
public override void OnInitializeMelon()
{
MelonLogger.Msg("===================================");
MelonLogger.Msg(" TeleportoMouse Mod v3.0");
MelonLogger.Msg(" Made by Zooks");
MelonLogger.Msg("===================================");
MelonLogger.Msg(" F = Select player nearest to mouse");
MelonLogger.Msg(" T = Teleport to mouse cursor");
MelonLogger.Msg("===================================");
}
private bool IsTKeyJustPressed()
{
bool flag = (GetAsyncKeyState(84) & 0x8000) != 0;
bool result = flag && !wasTPressed;
wasTPressed = flag;
return result;
}
private bool IsFKeyJustPressed()
{
bool flag = (GetAsyncKeyState(70) & 0x8000) != 0;
bool result = flag && !wasFPressed;
wasFPressed = flag;
return result;
}
private Vector3 GetScreenMousePosition()
{
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
GetCursorPos(out var lpPoint);
ScreenToClient(GetActiveWindow(), ref lpPoint);
return new Vector3((float)lpPoint.X, (float)(Screen.height - lpPoint.Y), 0f);
}
private void FindMainCamera()
{
if ((Object)(object)mainCamera != (Object)null && ((Component)mainCamera).gameObject.activeInHierarchy && ((Behaviour)mainCamera).enabled)
{
return;
}
mainCamera = null;
try
{
mainCamera = Camera.main;
}
catch
{
}
if (!((Object)(object)mainCamera == (Object)null))
{
return;
}
try
{
Camera[] array = Il2CppArrayBase<Camera>.op_Implicit(Object.FindObjectsOfType<Camera>());
if (array == null)
{
return;
}
Camera[] array2 = array;
foreach (Camera val in array2)
{
if ((Object)(object)val != (Object)null && ((Component)val).gameObject.activeInHierarchy && ((Behaviour)val).enabled)
{
mainCamera = val;
break;
}
}
}
catch
{
}
}
private List<Transform> FindAllCharacterCandidates()
{
List<Transform> list = new List<Transform>();
HashSet<int> hashSet = new HashSet<int>();
try
{
Rigidbody[] array = Il2CppArrayBase<Rigidbody>.op_Implicit(Object.FindObjectsOfType<Rigidbody>());
if (array == null)
{
return list;
}
Dictionary<int, List<Rigidbody>> dictionary = new Dictionary<int, List<Rigidbody>>();
Rigidbody[] array2 = array;
foreach (Rigidbody val in array2)
{
if ((Object)(object)val == (Object)null)
{
continue;
}
Transform val2 = FindCharacterRoot(((Component)val).transform);
if (!((Object)(object)val2 == (Object)null))
{
int instanceID = ((Object)((Component)val2).gameObject).GetInstanceID();
if (!dictionary.ContainsKey(instanceID))
{
dictionary[instanceID] = new List<Rigidbody>();
}
dictionary[instanceID].Add(val);
}
}
foreach (KeyValuePair<int, List<Rigidbody>> item in dictionary)
{
int count = item.Value.Count;
if (count < 6 || count > 30)
{
continue;
}
Transform transform = ((Component)item.Value[0]).transform;
Transform val3 = FindCharacterRoot(transform);
if ((Object)(object)val3 == (Object)null)
{
continue;
}
int instanceID2 = ((Object)((Component)val3).gameObject).GetInstanceID();
if (!hashSet.Contains(instanceID2))
{
hashSet.Add(instanceID2);
string text = ((Object)val3).name.ToLower();
if (!text.Contains("stage") && !text.Contains("level") && !text.Contains("environment") && !text.Contains("camera") && !text.Contains("manager") && !text.Contains("system") && !text.Contains("canvas") && !text.Contains("ui") && !text.Contains("light") && !text.Contains("audio") && !text.Contains("event") && !text.Contains("spawn"))
{
list.Add(val3);
}
}
}
}
catch (Exception ex)
{
MelonLogger.Error("Find candidates error: " + ex.Message);
}
return list;
}
private Transform? FindCharacterRoot(Transform start)
{
if ((Object)(object)start == (Object)null)
{
return null;
}
Transform val = start;
Transform val2 = start;
while ((Object)(object)val2.parent != (Object)null)
{
Transform parent = val2.parent;
Rigidbody[] array = Il2CppArrayBase<Rigidbody>.op_Implicit(((Component)parent).GetComponentsInChildren<Rigidbody>());
int num = ((array != null) ? array.Length : 0);
if (num > 35)
{
break;
}
if (num >= 6 && num <= 30)
{
val = parent;
}
val2 = parent;
}
Rigidbody[] array2 = Il2CppArrayBase<Rigidbody>.op_Implicit(((Component)val).GetComponentsInChildren<Rigidbody>());
if (array2 == null || array2.Length < 6)
{
return null;
}
return val;
}
private void SelectPlayerNearMouse()
{
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
//IL_0108: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_012c: Unknown result type (might be due to invalid IL or missing references)
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_0136: Unknown result type (might be due to invalid IL or missing references)
//IL_013b: Unknown result type (might be due to invalid IL or missing references)
//IL_013d: Unknown result type (might be due to invalid IL or missing references)
//IL_014b: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
//IL_0157: Unknown result type (might be due to invalid IL or missing references)
//IL_015c: Unknown result type (might be due to invalid IL or missing references)
//IL_0163: Unknown result type (might be due to invalid IL or missing references)
//IL_016a: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)mainCamera == (Object)null)
{
MelonLogger.Warning("No camera found!");
return;
}
List<Transform> list = FindAllCharacterCandidates();
if (list.Count == 0)
{
MelonLogger.Warning("No character candidates found in scene!");
return;
}
MelonLogger.Msg($"Found {list.Count} character candidate(s):");
foreach (Transform item in list)
{
Rigidbody[] array = Il2CppArrayBase<Rigidbody>.op_Implicit(((Component)item).GetComponentsInChildren<Rigidbody>());
MelonLogger.Msg($" - {((Object)item).name} ({((array != null) ? array.Length : 0)} rigidbodies)");
}
Vector3 screenMousePosition = GetScreenMousePosition();
Transform val = null;
float num = float.MaxValue;
foreach (Transform item2 in list)
{
Vector3 centerOf = GetCenterOf(item2);
Vector3 val2 = mainCamera.WorldToScreenPoint(centerOf);
if (!(val2.z < 0f))
{
float num2 = Vector2.Distance(new Vector2(screenMousePosition.x, screenMousePosition.y), new Vector2(val2.x, val2.y));
if (num2 < num)
{
num = num2;
val = item2;
}
}
}
if ((Object)(object)val == (Object)null)
{
MelonLogger.Warning("Could not find any character near mouse!");
return;
}
selectedPlayer = val;
selectedPlayerID = ((Object)((Component)val).gameObject).GetInstanceID();
cachedPlayerRigidbodies = Il2CppArrayBase<Rigidbody>.op_Implicit(((Component)val).GetComponentsInChildren<Rigidbody>());
MelonLogger.Msg("========== PLAYER SELECTED ==========");
MelonLogger.Msg(" Name: " + ((Object)val).name);
MelonLogger.Msg($" ID: {selectedPlayerID}");
MelonLogger.Msg($" Rigidbodies: {((cachedPlayerRigidbodies != null) ? cachedPlayerRigidbodies.Length : 0)}");
MelonLogger.Msg(" Press T to teleport! - Made by Zooks");
MelonLogger.Msg("======================================");
}
private Vector3 GetCenterOf(Transform t)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
Rigidbody[] array = Il2CppArrayBase<Rigidbody>.op_Implicit(((Component)t).GetComponentsInChildren<Rigidbody>());
if (array == null || array.Length == 0)
{
return t.position;
}
Vector3 val = Vector3.zero;
int num = 0;
Rigidbody[] array2 = array;
foreach (Rigidbody val2 in array2)
{
if (!((Object)(object)val2 == (Object)null))
{
val += val2.position;
num++;
}
}
if (num > 0)
{
return val / (float)num;
}
return t.position;
}
private bool IsPlayerValid()
{
if ((Object)(object)selectedPlayer == (Object)null)
{
return false;
}
try
{
if ((Object)(object)((Component)selectedPlayer).gameObject == (Object)null)
{
return false;
}
if (!((Component)selectedPlayer).gameObject.activeInHierarchy)
{
return false;
}
if (((Object)((Component)selectedPlayer).gameObject).GetInstanceID() != selectedPlayerID)
{
return false;
}
return true;
}
catch
{
return false;
}
}
private void RefreshCachedRigidbodies()
{
if (!((Object)(object)selectedPlayer == (Object)null))
{
cachedPlayerRigidbodies = Il2CppArrayBase<Rigidbody>.op_Implicit(((Component)selectedPlayer).GetComponentsInChildren<Rigidbody>());
}
}
public override void OnUpdate()
{
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
FindMainCamera();
if (!IsPlayerValid() && (Object)(object)selectedPlayer != (Object)null)
{
MelonLogger.Warning("Player lost! Press F to re-select");
selectedPlayer = null;
selectedPlayerID = -1;
cachedPlayerRigidbodies = null;
isTeleporting = false;
}
if (IsFKeyJustPressed())
{
SelectPlayerNearMouse();
}
if (IsTKeyJustPressed())
{
if (!IsPlayerValid())
{
MelonLogger.Warning("No player selected! Press F first");
return;
}
Vector3? mouseWorldPosition = GetMouseWorldPosition();
if (mouseWorldPosition.HasValue)
{
teleportTarget = mouseWorldPosition.Value;
PerformTeleport(teleportTarget);
}
}
if (isTeleporting && IsPlayerValid())
{
EnforcePosition(teleportTarget);
enforceFramesRemaining--;
if (enforceFramesRemaining <= 0)
{
isTeleporting = false;
RestorePhysics();
MelonLogger.Msg("Teleport stable - Made by Zooks");
}
}
}
public override void OnLateUpdate()
{
if (isTeleporting && IsPlayerValid() && (Object)(object)mainCamera != (Object)null)
{
ForceCameraFollow();
}
}
public override void OnFixedUpdate()
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
if (isTeleporting && IsPlayerValid())
{
EnforcePosition(teleportTarget);
}
}
private Vector3? GetMouseWorldPosition()
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_018b: Unknown result type (might be due to invalid IL or missing references)
//IL_0192: Unknown result type (might be due to invalid IL or missing references)
//IL_019c: Unknown result type (might be due to invalid IL or missing references)
//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0101: Unknown result type (might be due to invalid IL or missing references)
//IL_0106: Unknown result type (might be due to invalid IL or missing references)
//IL_0108: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: Unknown result type (might be due to invalid IL or missing references)
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_0119: Unknown result type (might be due to invalid IL or missing references)
//IL_011e: Unknown result type (might be due to invalid IL or missing references)
//IL_0138: Unknown result type (might be due to invalid IL or missing references)
//IL_014f: Unknown result type (might be due to invalid IL or missing references)
//IL_0154: Unknown result type (might be due to invalid IL or missing references)
//IL_017f: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)mainCamera == (Object)null)
{
return null;
}
try
{
Vector3 screenMousePosition = GetScreenMousePosition();
Ray val = mainCamera.ScreenPointToRay(screenMousePosition);
RaycastHit[] array = Il2CppArrayBase<RaycastHit>.op_Implicit((Il2CppArrayBase<RaycastHit>)(object)Physics.RaycastAll(val, 500f));
if (array != null && array.Length != 0)
{
RaycastHit? val2 = null;
float num = float.MaxValue;
RaycastHit[] array2 = array;
for (int i = 0; i < array2.Length; i++)
{
RaycastHit value = array2[i];
Collider collider = ((RaycastHit)(ref value)).collider;
if (!((Object)(object)collider == (Object)null) && !collider.isTrigger && !IsPartOfSelectedPlayer(((RaycastHit)(ref value)).transform) && ((RaycastHit)(ref value)).distance < num)
{
num = ((RaycastHit)(ref value)).distance;
val2 = value;
}
}
if (val2.HasValue)
{
RaycastHit value2 = val2.Value;
Vector3 point = ((RaycastHit)(ref value2)).point;
value2 = val2.Value;
Vector3 normal = ((RaycastHit)(ref value2)).normal;
point += normal * 1f;
point += Vector3.up * 0.5f;
DefaultInterpolatedStringHandler defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(20, 2);
defaultInterpolatedStringHandler.AppendLiteral("Target: ");
defaultInterpolatedStringHandler.AppendFormatted<Vector3>(point);
defaultInterpolatedStringHandler.AppendLiteral(" (surface: ");
value2 = val2.Value;
defaultInterpolatedStringHandler.AppendFormatted(((Object)((RaycastHit)(ref value2)).transform).name);
defaultInterpolatedStringHandler.AppendLiteral(")");
MelonLogger.Msg(defaultInterpolatedStringHandler.ToStringAndClear());
return point;
}
}
return ((Ray)(ref val)).origin + ((Ray)(ref val)).direction * 15f;
}
catch (Exception ex)
{
MelonLogger.Error("Mouse error: " + ex.Message);
return null;
}
}
private bool IsPartOfSelectedPlayer(Transform t)
{
if ((Object)(object)selectedPlayer == (Object)null || (Object)(object)t == (Object)null)
{
return false;
}
Transform val = t;
while ((Object)(object)val != (Object)null)
{
if (((Object)((Component)val).gameObject).GetInstanceID() == selectedPlayerID)
{
return true;
}
val = val.parent;
}
return false;
}
private void SaveBodyPose()
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
bodyPartOffsets.Clear();
bodyPartRotations.Clear();
if (cachedPlayerRigidbodies == null)
{
return;
}
Vector3 playerCenter = GetPlayerCenter();
Rigidbody[] array = cachedPlayerRigidbodies;
foreach (Rigidbody val in array)
{
if (!((Object)(object)val == (Object)null))
{
int instanceID = ((Object)((Component)val).gameObject).GetInstanceID();
bodyPartOffsets[instanceID] = val.position - playerCenter;
bodyPartRotations[instanceID] = val.rotation;
}
}
}
private void PerformTeleport(Vector3 targetPosition)
{
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: Unknown result type (might be due to invalid IL or missing references)
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_0126: Unknown result type (might be due to invalid IL or missing references)
//IL_012f: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
//IL_0102: Unknown result type (might be due to invalid IL or missing references)
//IL_0154: Unknown result type (might be due to invalid IL or missing references)
//IL_0168: Unknown result type (might be due to invalid IL or missing references)
if (!IsPlayerValid())
{
return;
}
try
{
RefreshCachedRigidbodies();
if (cachedPlayerRigidbodies == null || cachedPlayerRigidbodies.Length == 0)
{
MelonLogger.Error("No rigidbodies!");
return;
}
SaveBodyPose();
Rigidbody[] array = cachedPlayerRigidbodies;
foreach (Rigidbody val in array)
{
if (!((Object)(object)val == (Object)null))
{
val.velocity = Vector3.zero;
val.angularVelocity = Vector3.zero;
val.isKinematic = true;
}
}
Vector3 playerCenter = GetPlayerCenter();
Vector3 val2 = targetPosition - playerCenter;
Transform? obj = selectedPlayer;
obj.position += val2;
array = cachedPlayerRigidbodies;
foreach (Rigidbody val3 in array)
{
if (!((Object)(object)val3 == (Object)null))
{
int instanceID = ((Object)((Component)val3).gameObject).GetInstanceID();
if (bodyPartOffsets.ContainsKey(instanceID))
{
Vector3 position = targetPosition + bodyPartOffsets[instanceID];
((Component)val3).transform.position = position;
val3.position = position;
}
else
{
Vector3 position2 = ((Component)val3).transform.position + val2;
((Component)val3).transform.position = position2;
val3.position = position2;
}
if (bodyPartRotations.ContainsKey(instanceID))
{
((Component)val3).transform.rotation = bodyPartRotations[instanceID];
val3.rotation = bodyPartRotations[instanceID];
}
}
}
isTeleporting = true;
enforceFramesRemaining = 40;
MelonLogger.Msg("=== TELEPORTED '" + ((Object)selectedPlayer).name + "' - Made by Zooks ===");
}
catch (Exception ex)
{
MelonLogger.Error("Teleport error: " + ex.Message);
RestorePhysics();
isTeleporting = false;
}
}
private void RestorePhysics()
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
if (cachedPlayerRigidbodies == null)
{
return;
}
Rigidbody[] array = cachedPlayerRigidbodies;
foreach (Rigidbody val in array)
{
if (!((Object)(object)val == (Object)null))
{
val.isKinematic = false;
val.velocity = Vector3.zero;
val.angularVelocity = Vector3.zero;
}
}
}
private Vector3 GetPlayerCenter()
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)selectedPlayer == (Object)null)
{
return Vector3.zero;
}
if (cachedPlayerRigidbodies == null || cachedPlayerRigidbodies.Length == 0)
{
return selectedPlayer.position;
}
Vector3 val = Vector3.zero;
int num = 0;
Rigidbody[] array = cachedPlayerRigidbodies;
foreach (Rigidbody val2 in array)
{
if (!((Object)(object)val2 == (Object)null))
{
val += val2.position;
num++;
}
}
if (num > 0)
{
return val / (float)num;
}
return selectedPlayer.position;
}
private void EnforcePosition(Vector3 targetPosition)
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0120: Unknown result type (might be due to invalid IL or missing references)
//IL_0125: Unknown result type (might be due to invalid IL or missing references)
//IL_0126: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_0102: Unknown result type (might be due to invalid IL or missing references)
if (!IsPlayerValid() || cachedPlayerRigidbodies == null)
{
return;
}
try
{
Vector3 playerCenter = GetPlayerCenter();
if (!(Vector3.Distance(playerCenter, targetPosition) > 0.5f))
{
return;
}
Vector3 val = targetPosition - playerCenter;
Rigidbody[] array = cachedPlayerRigidbodies;
foreach (Rigidbody val2 in array)
{
if (!((Object)(object)val2 == (Object)null))
{
val2.isKinematic = true;
int instanceID = ((Object)((Component)val2).gameObject).GetInstanceID();
if (bodyPartOffsets.ContainsKey(instanceID))
{
Vector3 position = targetPosition + bodyPartOffsets[instanceID];
((Component)val2).transform.position = position;
val2.position = position;
}
else
{
Transform transform = ((Component)val2).transform;
transform.position += val;
val2.position = ((Component)val2).transform.position;
}
if (bodyPartRotations.ContainsKey(instanceID))
{
((Component)val2).transform.rotation = bodyPartRotations[instanceID];
val2.rotation = bodyPartRotations[instanceID];
}
}
}
Transform? obj = selectedPlayer;
obj.position += val;
}
catch (Exception ex)
{
MelonLogger.Error("Enforce error: " + ex.Message);
RestorePhysics();
isTeleporting = false;
}
}
private void ForceCameraFollow()
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
//IL_0109: Unknown result type (might be due to invalid IL or missing references)
//IL_010f: Unknown result type (might be due to invalid IL or missing references)
if (!IsPlayerValid() || (Object)(object)mainCamera == (Object)null)
{
return;
}
try
{
Vector3 playerCenter = GetPlayerCenter();
float num = Vector3.Distance(((Component)mainCamera).transform.position, playerCenter);
if (num > 30f)
{
Vector3 val = playerCenter - ((Component)mainCamera).transform.forward * 12f + Vector3.up * 6f;
((Component)mainCamera).transform.position = Vector3.Lerp(((Component)mainCamera).transform.position, val, 0.8f);
((Component)mainCamera).transform.LookAt(playerCenter);
}
else if (num > 15f)
{
Vector3 val2 = playerCenter - ((Component)mainCamera).transform.forward * 12f + Vector3.up * 6f;
((Component)mainCamera).transform.position = Vector3.Lerp(((Component)mainCamera).transform.position, val2, 0.3f);
}
}
catch
{
}
}
public override void OnSceneWasLoaded(int buildIndex, string sceneName)
{
selectedPlayer = null;
selectedPlayerID = -1;
cachedPlayerRigidbodies = null;
mainCamera = null;
isTeleporting = false;
enforceFramesRemaining = 0;
wasTPressed = false;
wasFPressed = false;
bodyPartOffsets.Clear();
bodyPartRotations.Clear();
MelonLogger.Msg("======================================");
MelonLogger.Msg(" Scene: " + sceneName);
MelonLogger.Msg(" F = Select | T = Teleport");
MelonLogger.Msg(" Made by Zooks");
MelonLogger.Msg("======================================");
}
}
}