Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Random TP v1.1.1
Random_TP.dll
Decompiled 5 months agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Photon.Pun; using UnityEngine; using UnityEngine.Networking; using config; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("Random_TP")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("HP")] [assembly: AssemblyProduct("Random_TP")] [assembly: AssemblyCopyright("Copyright © HP 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("b61299c4-e630-4ce9-b767-145d52732b87")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] [BepInPlugin("miko.repo.random_tp", "Random TP", "1.0.0")] public class Random_TP : BaseUnityPlugin { [CompilerGenerated] private sealed class <Load>d__7 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public string path; public Random_TP <>4__this; private UnityWebRequest <www>5__1; private AudioClip <clip>5__2; private Exception <e>5__3; private Exception <e>5__4; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <Load>d__7(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <www>5__1 = null; <clip>5__2 = null; <e>5__3 = null; <e>5__4 = null; <>1__state = -2; } private bool MoveNext() { //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Invalid comparison between Unknown and I4 switch (<>1__state) { default: return false; case 0: <>1__state = -1; <www>5__1 = null; try { <www>5__1 = UnityWebRequestMultimedia.GetAudioClip("file:///" + path.Replace("\\", "/"), (AudioType)14); } catch (Exception ex) { <e>5__3 = ex; Debug.LogError((object)("[ModAudio INIT ERROR] " + <e>5__3)); return false; } <>2__current = <www>5__1.SendWebRequest(); <>1__state = 1; return true; case 1: <>1__state = -1; if ((int)<www>5__1.result != 1) { Debug.LogError((object)("[ModAudio REQUEST ERROR] " + <www>5__1.error)); return false; } try { <clip>5__2 = DownloadHandlerAudioClip.GetContent(<www>5__1); } catch (Exception ex) { <e>5__4 = ex; Debug.LogError((object)("[ModAudio CLIP ERROR] " + <e>5__4)); return false; } if (path.Contains("Leave")) { tpSoundLeave = <clip>5__2; } else if (path.Contains("Arrive")) { tpSoundArrive = <clip>5__2; } Debug.Log((object)("Load with success : " + path)); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private Harmony harmony; public static AudioClip tpSoundLeave; public static AudioClip tpSoundArrive; public string modFolderPath; private void Awake() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown harmony = new Harmony("miko.repo.random_tp"); harmony.PatchAll(); modFolderPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); PhysGrabber_StartGrabbing_Patch.random_tp = this; string path = Path.Combine(modFolderPath, "Enderman_TP_Leave.ogg"); ((MonoBehaviour)this).StartCoroutine(Load(path)); string path2 = Path.Combine(modFolderPath, "Enderman_TP_Arrive.ogg"); ((MonoBehaviour)this).StartCoroutine(Load(path2)); ConfigManager.Initialize(((BaseUnityPlugin)this).Config); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Random TP has loaded !"); } public void PlayTPSoundLeaveNetworked(Vector3 pos) { //IL_004c: 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) if (PhotonNetwork.InRoom) { PhotonView val = PhotonView.Get(((Component)PlayerController.instance).gameObject); val.RPC("RPC_PlayTPSoundLeave", (RpcTarget)0, new object[1] { pos }); } else { TP_SoundHandler component = ((Component)PlayerController.instance).gameObject.GetComponent<TP_SoundHandler>(); component.RPC_PlayTPSoundLeave(pos); } } public void PlayTPSoundArriveNetworked(Vector3 pos) { //IL_004c: 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) if (PhotonNetwork.InRoom) { PhotonView val = PhotonView.Get(((Component)PlayerController.instance).gameObject); val.RPC("RPC_PlayTPSoundArrive", (RpcTarget)0, new object[1] { pos }); } else { TP_SoundHandler component = ((Component)PlayerController.instance).gameObject.GetComponent<TP_SoundHandler>(); component.RPC_PlayTPSoundArrive(pos); } } [IteratorStateMachine(typeof(<Load>d__7))] private IEnumerator Load(string path) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <Load>d__7(0) { <>4__this = this, path = path }; } public Vector3 GetRandomPosition(bool isForce = false) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) Vector3 zero = Vector3.zero; if (!ConfigManager.UseMinDistWithOtherPlayer.Value || isForce) { List<LevelPoint> list = SemiFunc.LevelPointsGetAll(); int index = Random.Range(0, list.Count); return ((Component)list[index]).transform.position; } return ((Component)SemiFunc.LevelPointGetFurthestFromPlayer(((Component)PlayerController.instance).transform.position, (float)ConfigManager.MinDist.Value)).transform.position; } } [HarmonyPatch(typeof(PhysGrabber))] [HarmonyPatch("StartGrabbingPhysObject")] public class PhysGrabber_StartGrabbing_Patch { public static Random_TP random_tp; private static void Postfix(RaycastHit hit, PhysGrabObject _physGrabObject, PhysGrabber __instance) { //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: 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_0086: 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_00ef: 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_010e: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) if (!((ConfigEntryBase)ConfigManager.IsEnable).BoxedValue.Equals(true) || !((Object)(object)_physGrabObject != (Object)null)) { return; } ValuableObject componentInParent = ((Component)_physGrabObject).GetComponentInParent<ValuableObject>(); if (!((Object)(object)componentInParent != (Object)null)) { return; } int num = Random.Range(1, 101); if (num > ConfigManager.Proba.Value) { return; } Vector3 position = ((Component)PlayerController.instance).transform.position; Vector3 randomPosition = random_tp.GetRandomPosition(); bool flag = false; while (!flag) { Enemy val = SemiFunc.EnemyGetNearest(randomPosition, (float)ConfigManager.DistanceFromEnemy.Value, true); if ((Object)(object)val == (Object)null) { flag = true; } else { randomPosition = random_tp.GetRandomPosition(isForce: true); } } __instance.ReleaseObject(__instance.photonView.ViewID, 0.1f); random_tp.PlayTPSoundLeaveNetworked(position); ((Component)PlayerController.instance).GetComponent<Rigidbody>().position = randomPosition; random_tp.PlayTPSoundArriveNetworked(randomPosition); } } [HarmonyPatch] public class PlayerController_Awake_Patch { private static MethodBase TargetMethod() { return AccessTools.Method(typeof(PlayerController), "Awake", (Type[])null, (Type[])null); } private static void Postfix(PlayerController __instance) { if (!((Object)(object)__instance == (Object)null)) { TP_SoundHandler component = ((Component)__instance).gameObject.GetComponent<TP_SoundHandler>(); if ((Object)(object)component == (Object)null) { component = ((Component)__instance).gameObject.AddComponent<TP_SoundHandler>(); component.tpSoundLeave = Random_TP.tpSoundLeave; component.tpSoundArrive = Random_TP.tpSoundArrive; } } } } public class TP_SoundHandler : MonoBehaviourPun { public AudioClip tpSoundLeave = null; public AudioClip tpSoundArrive = null; [PunRPC] public void RPC_PlayTPSoundLeave(Vector3 position) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) if (ConfigManager.EnableTPSound.Value) { if ((Object)(object)tpSoundLeave == (Object)null) { Debug.LogError((object)"leave sound not set"); } else { AudioSource.PlayClipAtPoint(tpSoundLeave, position); } } } [PunRPC] public void RPC_PlayTPSoundArrive(Vector3 position) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) if (ConfigManager.EnableTPSound.Value) { if ((Object)(object)tpSoundArrive == (Object)null) { Debug.LogError((object)"arrive sound not set"); } else { AudioSource.PlayClipAtPoint(tpSoundArrive, position); } } } } namespace config; internal static class ConfigManager { public static ConfigFile ConfigFile { get; private set; } public static ConfigEntry<bool> IsEnable { get; private set; } public static ConfigEntry<int> Proba { get; private set; } public static ConfigEntry<bool> UseMinDistWithOtherPlayer { get; private set; } public static ConfigEntry<int> MinDist { get; private set; } public static ConfigEntry<bool> EnableTPSound { get; private set; } public static ConfigEntry<int> DistanceFromEnemy { get; private set; } public static void Initialize(ConfigFile configFile) { ConfigFile = configFile; BindConfigs(); } private static void BindConfigs() { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Expected O, but got Unknown //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Expected O, but got Unknown IsEnable = ConfigFile.Bind<bool>("General", "Enable", true, "Enable random tp."); Proba = ConfigFile.Bind<int>("General", "Probability of random tp", 1, new ConfigDescription("Probability to tp when you grap an object", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); UseMinDistWithOtherPlayer = ConfigFile.Bind<bool>("General", "Use minimum distance from other player when tp", false, "Use minimum distance from other player when tp."); MinDist = ConfigFile.Bind<int>("General", "Min dist", 14, new ConfigDescription("Min distance", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); EnableTPSound = ConfigFile.Bind<bool>("General", "Enable TP Sound", true, "Enable tp sound."); DistanceFromEnemy = ConfigFile.Bind<int>("General", "Distance from enemy", 5, new ConfigDescription("Distance from enemy when tp.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 25), Array.Empty<object>())); } }