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 Teleporter v0.1.0
Teleporter.dll
Decompiled 4 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.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using REPOLib; using REPOLib.Modules; using REPOLib.Objects.Sdk; using Teleporter; using UnityEngine; using UnityEngine.AI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("")] [assembly: AssemblyCompany("yzch")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("Teleporter")] [assembly: AssemblyTitle("Teleporter")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] 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; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } public class ItemUpgradeTeleporter : MonoBehaviour { private ItemToggle itemToggle; private PhotonView photonView; private void Start() { itemToggle = ((Component)this).GetComponent<ItemToggle>(); photonView = ((Component)this).GetComponent<PhotonView>(); } public void Upgrade() { UpgradePlayersTeleportModule(SemiFunc.PlayerGetSteamID(SemiFunc.PlayerAvatarGetFromPhotonID(itemToggle.playerTogglePhotonID))); } public void UpgradePlayersTeleportModule(string _steamID) { if (GameManager.Multiplayer()) { photonView.RPC("UpgradeTeleportModuleNowRPC", (RpcTarget)0, Array.Empty<object>()); } else { UpgradeTeleportModuleNowRPC(); } } [PunRPC] private void UpgradeTeleportModuleNowRPC() { foreach (PlayerAvatar player in GameDirector.instance.PlayerList) { GetStatsDictionary()[player.steamID] = 1; } if (!GameManager.Multiplayer() || PhotonNetwork.IsMasterClient) { BuildTeleporterModule(); } } private void BuildTeleporterModule() { //IL_0028: 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_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) GameObject val = ((GameManager.instance.gameMode != 0) ? PhotonNetwork.InstantiateRoomObject("Teleporter", Vector3.zero, Quaternion.identity, (byte)0, (object[])null) : Object.Instantiate<GameObject>(global::Teleporter.Teleporter.pref_teleportModule, Vector3.zero, Quaternion.identity)); } private Dictionary<string, int> GetStatsDictionary() { return StatsManager.instance.dictionaryOfDictionaries["playerTeleporter"]; } } public class TeleporterModule : MonoBehaviour { public PhotonView photonView; public ParticleSystem particleSystem; public Transform activationCheckPoint; public float activationCheckDistance; public GameObject spin1; public GameObject spin2; public ParticleSystem particleSystem_teleport; public Sound activationSound; public Sound teleportSound; private AudioSource activationSoundSource; private bool someoneStandingOnIt = false; private bool rotating = false; private float charge = 0f; private float cooldown = 0f; private MainModule particleSystem_mm; private EmissionModule particleSystem_em; private ShapeModule particleSystem_sm; private ExtractionPoint[] extractionPoints; private List<Vector3> possiblePoints; private void Start() { //IL_0055: 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_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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) if (GameManager.Multiplayer()) { photonView.RPC("BuildTeleporterModuleRPC", (RpcTarget)0, Array.Empty<object>()); } else { BuildTeleporterModuleRPC(); } if (LevelGenerator.Instance.Level.HasEnemies) { photonView = ((Component)this).GetComponent<PhotonView>(); particleSystem_mm = particleSystem.main; particleSystem_em = particleSystem.emission; particleSystem_sm = particleSystem.shape; ((MonoBehaviour)this).InvokeRepeating("Update100ms", 0.1f, 0.1f); ((MonoBehaviour)this).InvokeRepeating("Update300ms", 0.3f, 0.3f); } } [PunRPC] private void BuildTeleporterModuleRPC() { //IL_0074: 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) StartRoom val = Object.FindObjectOfType<StartRoom>(); if (Object.op_Implicit((Object)(object)val)) { Transform val2 = ((Component)val).transform.Find("Truck Run"); if ((Object)(object)val2 == (Object)null) { val2 = ((Component)val).transform.Find("Truck Shop"); } if (!((Object)(object)val2 == (Object)null)) { ((Component)this).transform.SetParent(val2); ((Component)this).transform.localPosition = new Vector3(-21.824f, 0.66f, -1.357f); ((Component)this).transform.localEulerAngles = Vector3.zero; } } } private void Update() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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_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_004d: 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_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0071: 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) Transform transform = spin1.transform; transform.localEulerAngles += Vector3.up * charge * 4000f * Time.deltaTime; Transform transform2 = spin2.transform; transform2.localEulerAngles += Vector3.up * charge * 2000f * Time.deltaTime; } private void Update100ms() { //IL_0034: 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_0109: 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_0113: Unknown result type (might be due to invalid IL or missing references) if (!LevelGenerator.Instance.Generated || possiblePoints == null) { return; } ((EmissionModule)(ref particleSystem_em)).rateOverTime = MinMaxCurve.op_Implicit(charge * 30f); ((MainModule)(ref particleSystem_mm)).simulationSpeed = 1f + charge * 8f; ((ShapeModule)(ref particleSystem_sm)).arcSpeed = MinMaxCurve.op_Implicit(charge * 0.7f); if (!someoneStandingOnIt) { charge -= 0.02f; charge = Mathf.Clamp01(charge); } if (cooldown > 0f) { cooldown -= 0.1f; return; } if (someoneStandingOnIt) { charge += 0.02f; charge = Mathf.Clamp01(charge); SemiFunc.CameraShakeDistance(activationCheckPoint.position + Vector3.up, charge * 8f, 0.3f, 0f, 4f); } if (!rotating && someoneStandingOnIt) { OnActivation(); } else if (rotating && !someoneStandingOnIt) { OnDeactivation(); } if (charge > 0.9999f && !IsClient()) { TeleportPlayersInside(); } } private void Update300ms() { //IL_0076: 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_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) if (!LevelGenerator.Instance.Generated) { return; } someoneStandingOnIt = SomeoneIsStandingOnIt(); if (IsClient()) { return; } extractionPoints = Object.FindObjectsOfType<ExtractionPoint>(); if (possiblePoints != null) { return; } possiblePoints = new List<Vector3>(); DirtFinderMapFloor[] array = Object.FindObjectsOfType<DirtFinderMapFloor>(); DirtFinderMapFloor[] array2 = array; foreach (DirtFinderMapFloor val in array2) { bool flag = true; if (Vector3.Distance(Vector3.zero, ((Component)val).transform.position) <= 40f) { flag = false; } ExtractionPoint[] array3 = extractionPoints; foreach (ExtractionPoint val2 in array3) { if (Vector3.Distance(((Component)val2).transform.position, ((Component)val).transform.position) <= 10f) { flag = false; } } if (flag) { possiblePoints.Add(((Component)val).gameObject.transform.position); } } } private bool SomeoneIsStandingOnIt() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) foreach (PlayerAvatar player in GameDirector.instance.PlayerList) { if (Vector3.Distance(((Component)player).transform.position, activationCheckPoint.position) <= activationCheckDistance) { return true; } } return false; } private void OnActivation() { //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) rotating = true; if (!Object.op_Implicit((Object)(object)activationSoundSource)) { activationSoundSource = activationSound.Play(activationCheckPoint.position, 1f, 1f, 1f, 1f); return; } Object.Destroy((Object)(object)((Component)activationSoundSource).gameObject); activationSoundSource = activationSound.Play(activationCheckPoint.position, 1f, 1f, 1f, 1f); activationSoundSource.time = charge * 5f; } private void OnDeactivation() { rotating = false; if (Object.op_Implicit((Object)(object)activationSoundSource)) { activationSoundSource.time = 10f - charge * 5f; } } private void TeleportPlayersInside() { //IL_004f: 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_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) someoneStandingOnIt = false; cooldown = 4f; if (possiblePoints.Count == 0) { return; } foreach (PlayerAvatar player in GameDirector.instance.PlayerList) { if (Vector3.Distance(((Component)player).transform.position, activationCheckPoint.position) <= activationCheckDistance) { if (GameManager.Multiplayer()) { photonView.RPC("TeleportPlayerRPC", (RpcTarget)0, new object[2] { player.steamID, GetRandomMapPos() }); } else { TeleportPlayerRPC(player.steamID, GetRandomMapPos()); } } } } [PunRPC] private void TeleportPlayerRPC(string steamID, Vector3 randomPoint) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: 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_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0097: 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_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: 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_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: 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_010d: Unknown result type (might be due to invalid IL or missing references) someoneStandingOnIt = false; cooldown = 4f; Object.Destroy((Object)(object)Object.Instantiate<GameObject>(((Component)particleSystem_teleport).gameObject, activationCheckPoint.position + Vector3.up, Quaternion.identity), 3f); teleportSound.Play(activationCheckPoint.position, 1f, 1f, 1f, 1f); if (PlayerController.instance.playerSteamID == steamID) { Object.Destroy((Object)(object)Object.Instantiate<GameObject>(((Component)particleSystem_teleport).gameObject, randomPoint + Vector3.up, Quaternion.identity), 3f); teleportSound.Play(randomPoint, 1f, 1f, 1f, 1f); PlayerAvatar.instance.Spawn(randomPoint, Quaternion.Euler(-Vector3.up)); ((Component)PlayerAvatar.instance).GetComponent<Rigidbody>().MovePosition(randomPoint); ((Component)PlayerController.instance).GetComponent<Rigidbody>().MovePosition(randomPoint); PlayerController instance = PlayerController.instance; instance.SetCrawl(); } } private Vector3 GetRandomMapPos() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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_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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) Vector3 val = possiblePoints[Random.Range(0, possiblePoints.Count)]; NavMeshHit val2 = default(NavMeshHit); if (NavMesh.SamplePosition(val, ref val2, 999f, -1)) { return ((NavMeshHit)(ref val2)).position; } return Vector3.zero; } private bool IsClient() { return GameManager.Multiplayer() && !PhotonNetwork.IsMasterClient; } } namespace Teleporter { [HarmonyPatch(typeof(PlayerController))] internal static class ExamplePlayerControllerPatch { [HarmonyPatch(typeof(LevelGenerator), "Generate")] private class LevelGeneratorCoroutinePatch { [CompilerGenerated] private sealed class <WrapCoroutine>d__1 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public IEnumerator original; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <WrapCoroutine>d__1(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; break; case 1: <>1__state = -1; break; } if (original.MoveNext()) { <>2__current = original.Current; <>1__state = 1; return true; } Teleporter.Logger.LogInfo((object)("Teleporter Upgrades: " + playerTeleporter[PlayerAvatar.instance.steamID])); if (playerTeleporter[PlayerAvatar.instance.steamID] >= 1 && (!GameManager.Multiplayer() || PhotonNetwork.IsMasterClient)) { BuildTeleporterModule(); } 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 static IEnumerator Postfix(IEnumerator result) { return WrapCoroutine(result); } [IteratorStateMachine(typeof(<WrapCoroutine>d__1))] private static IEnumerator WrapCoroutine(IEnumerator original) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <WrapCoroutine>d__1(0) { original = original }; } private static void BuildTeleporterModule() { //IL_0028: 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_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) GameObject val = ((GameManager.instance.gameMode != 0) ? PhotonNetwork.InstantiateRoomObject("Teleporter", Vector3.zero, Quaternion.identity, (byte)0, (object[])null) : Object.Instantiate<GameObject>(Teleporter.pref_teleportModule, Vector3.zero, Quaternion.identity)); } } public static Dictionary<string, int> playerTeleporter; [HarmonyPrefix] [HarmonyPatch("Start")] private static void Start_Prefix(StatsManager __instance) { Teleporter.Logger.LogDebug((object)$"{__instance} Start Prefix"); } [HarmonyPostfix] [HarmonyPatch("Start")] private static void Start_Postfix(StatsManager __instance) { Teleporter.Logger.LogDebug((object)$"{__instance} Start Postfix"); if (!StatsManager.instance.dictionaryOfDictionaries.ContainsKey("playerTeleporter")) { playerTeleporter = new Dictionary<string, int>(); StatsManager.instance.dictionaryOfDictionaries.Add("playerTeleporter", playerTeleporter); StatsManager.instance.stripTheseDictionaries.Add("playerTeleporter"); } } } [BepInPlugin("yzch.Teleporter", "Teleporter", "0.1.0")] public class Teleporter : BaseUnityPlugin { internal static GameObject pref_teleportModule; internal static string modFolder; internal static Teleporter Instance { get; private set; } internal static ManualLogSource Logger => Instance._logger; private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger; internal Harmony? Harmony { get; set; } private void Awake() { Instance = this; modFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string text = Path.Combine(modFolder, "teleporter"); Logger.LogInfo((object)("Moon_Enemy Path: " + text)); if (!File.Exists(text)) { Logger.LogError((object)"Bundle file doesn't exist!"); return; } BundleLoader.LoadBundle(text, (Action<AssetBundle>)delegate(AssetBundle assetBundle) { ItemContent val = assetBundle.LoadAsset<ItemContent>("ItemContent_Teleporter"); Items.RegisterItem(val); pref_teleportModule = assetBundle.LoadAsset<GameObject>("Teleporter"); NetworkPrefabs.RegisterNetworkPrefab(pref_teleportModule); }, false); ((Component)this).gameObject.transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; Patch(); Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!"); } internal void Patch() { //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_0021: Expected O, but got Unknown //IL_0026: Expected O, but got Unknown if (Harmony == null) { Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID); Harmony val2 = val; Harmony = val; } Harmony.PatchAll(); } internal void Unpatch() { Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } } private void Update() { } } }