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 Abort Teleport By Emoting v1.0.0
BepInEx/plugins/AbortTeleportByEmoting.dll
Decompiled 5 months agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using AbortTeleportByEmoting; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using LethalConfig; using LethalConfig.ConfigItems; using LethalNetworkAPI; using LethalNetworkAPI.Utils; using Microsoft.CodeAnalysis; using Unity.Netcode; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("AbortTeleportByEmoting")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Aborts teleport by emoting")] [assembly: AssemblyFileVersion("0.0.1.0")] [assembly: AssemblyInformationalVersion("0.0.1+e5cbd81f0600a57dc495868fb6d22c52fdca8366")] [assembly: AssemblyProduct("AbortTeleportByEmoting")] [assembly: AssemblyTitle("AbortTeleportByEmoting")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.1.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.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } internal static class LethalConfigCompat { [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] internal static void Register(ConfigEntry<bool> boolConfigEntry) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown LethalConfigManager.SkipAutoGenFor((ConfigEntryBase)(object)boolConfigEntry); LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(boolConfigEntry, false)); } } internal static class NotifyPlayers { internal static void OnAbortClient(Plugin.AbortPayload msg) { if (!Utility.IsNullOrWhiteSpace(msg.AbortingPlayerName)) { HUDManager.Instance.DisplayTip("TELEPORT ABORTED", "<line-height=45%>\n</line-height><line-height=100%>" + msg.AbortingPlayerName.Trim() + " aborted the teleport.</line-height>", false, false, "LC_Tip1"); } } public static void NotifyShipOfAbortedTeleport(PlayerControllerB abortingPlayer) { //IL_0048: 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_009b: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.IsHost() || (Object)(object)abortingPlayer == (Object)null) { return; } StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance == (Object)null || (Object)(object)instance.shipInnerRoomBounds == (Object)null) { return; } Bounds bounds = instance.shipInnerRoomBounds.bounds; List<ulong> list = new List<ulong>(); foreach (PlayerControllerB item in instance.allPlayerScripts.Where((PlayerControllerB p) => (Object)(object)p != (Object)null && p.isPlayerControlled && !p.isPlayerDead && p.actualClientId != abortingPlayer.actualClientId)) { if (((Bounds)(ref bounds)).Contains(((Component)item).transform.position)) { list.Add(item.actualClientId); } } if (list.Count > 0 && ConfigSettings.NotifyShipOnAbort) { Plugin.AbortMessage.SendClients(new Plugin.AbortPayload { AbortingPlayerName = abortingPlayer.playerUsername }, list.ToArray()); } } } [HarmonyPatch(typeof(ShipTeleporter), "SetPlayerTeleporterId")] internal static class SetPlayerTeleporterId_Patch { [CompilerGenerated] private sealed class <AbortTeleportIfEmoting>d__1 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public PlayerControllerB pc; public ShipTeleporter tp; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <AbortTeleportIfEmoting>d__1(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(2.95f); <>1__state = 1; return true; case 1: { <>1__state = -1; if (!IsEmoting(pc)) { return false; } FieldInfo fieldInfo = AccessTools.Field(typeof(ShipTeleporter), "beamUpPlayerCoroutine"); Coroutine val = (Coroutine)fieldInfo.GetValue(tp); if (val != null) { ((MonoBehaviour)tp).StopCoroutine(val); fieldInfo.SetValue(tp, null); } pc.shipTeleporterId = -1; if ((Object)(object)pc.deadBody == (Object)null) { ParticleSystem beamUpParticle = pc.beamUpParticle; if (beamUpParticle != null) { beamUpParticle.Stop(); } AudioSource movementAudio = pc.movementAudio; if (movementAudio != null) { movementAudio.Stop(); } } NotifyPlayers.NotifyShipOfAbortedTeleport(pc); 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 void Prefix(ShipTeleporter __instance, PlayerControllerB playerScript, int teleporterId) { if (!__instance.isInverseTeleporter && teleporterId == 1) { if (Plugin.StopEmoteVar?.Value ?? ConfigSettings.StopEmoteWhenTeleportStarts) { StopEmote(playerScript); } ((MonoBehaviour)__instance).StartCoroutine(AbortTeleportIfEmoting(__instance, playerScript)); } } [IteratorStateMachine(typeof(<AbortTeleportIfEmoting>d__1))] private static IEnumerator AbortTeleportIfEmoting(ShipTeleporter tp, PlayerControllerB pc) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <AbortTeleportIfEmoting>d__1(0) { tp = tp, pc = pc }; } private static bool IsEmoting(PlayerControllerB p) { if ((Object)(object)p != (Object)null) { return p.performingEmote; } return false; } private static void StopEmote(PlayerControllerB pc) { //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Invalid comparison between Unknown and I4 //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Invalid comparison between Unknown and I4 if ((Object)(object)pc == (Object)null || !pc.performingEmote || (InvokeIfExists(pc, "StopPerformingEmoteServerRpc") | InvokeIfExists(pc, "StopPerformingEmoteClientRpc")) || InvokeIfExists(pc, "StopPerformingEmote") || InvokeIfExists(pc, "StopEmote")) { return; } pc.performingEmote = false; try { Animator val = (((Object)(object)pc.playerBodyAnimator != (Object)null) ? pc.playerBodyAnimator : ((Component)pc).GetComponentInChildren<Animator>()); if (!((Object)(object)val != (Object)null)) { return; } AnimatorControllerParameter[] parameters = val.parameters; foreach (AnimatorControllerParameter val2 in parameters) { if (val2.name.IndexOf("emote", StringComparison.OrdinalIgnoreCase) >= 0) { if ((int)val2.type == 4) { val.SetBool(val2.name, false); } else if ((int)val2.type == 9) { val.ResetTrigger(val2.name); } } } } catch { } } private static bool InvokeIfExists(object target, string methodName) { MethodInfo methodInfo = AccessTools.Method(target.GetType(), methodName, Array.Empty<Type>(), (Type[])null); if (methodInfo == null) { return false; } methodInfo.Invoke(target, null); return true; } } namespace AbortTeleportByEmoting { internal static class ConfigSettings { private static ConfigEntry<bool> _notifyShipOnAbort; private static ConfigEntry<bool> _stopEmoteWhenTeleportStarts; internal static bool NotifyShipOnAbort = true; internal static bool StopEmoteWhenTeleportStarts = true; internal static void Init(BaseUnityPlugin plugin) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown ConfigFile config = plugin.Config; _notifyShipOnAbort = config.Bind<bool>("General", "NotifyShipOnAbort", true, new ConfigDescription("When enabled, players in the ship are notified when a teleport is aborted.", (AcceptableValueBase)null, Array.Empty<object>())); _stopEmoteWhenTeleportStarts = config.Bind<bool>("General", "StopEmoteWhenTeleportStarts", true, new ConfigDescription("When enabled, players will stop emoting when they start being teleported.", (AcceptableValueBase)null, Array.Empty<object>())); _notifyShipOnAbort.SettingChanged += OnNotifyShipOnAbortSettingChanged; _stopEmoteWhenTeleportStarts.SettingChanged += OnStopEmoteWhenTeleportStartsSettingChanged; UpdateNotifyShipOnAbort(); UpdateStopEmoteWhenTeleportStarts(); } private static void OnNotifyShipOnAbortSettingChanged(object sender, EventArgs e) { UpdateNotifyShipOnAbort(); } private static void OnStopEmoteWhenTeleportStartsSettingChanged(object sender, EventArgs e) { UpdateStopEmoteWhenTeleportStarts(); } private static void UpdateNotifyShipOnAbort() { NotifyShipOnAbort = _notifyShipOnAbort?.Value ?? true; } private static void UpdateStopEmoteWhenTeleportStarts() { StopEmoteWhenTeleportStarts = _stopEmoteWhenTeleportStarts?.Value ?? true; if (Plugin.IsHost() && Plugin.StopEmoteVar != null) { Plugin.StopEmoteVar.Value = StopEmoteWhenTeleportStarts; } } internal static void RegisterWithLethalConfigIfPresent() { if (Chainloader.PluginInfos.ContainsKey("ainavt.lc.lethalconfig")) { LethalConfigCompat.Register(_notifyShipOnAbort); LethalConfigCompat.Register(_stopEmoteWhenTeleportStarts); } } } [BepInPlugin("Azx.AbortTeleportByEmoting", "Abort Teleport By Emoting", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { [Serializable] public struct AbortPayload { public string AbortingPlayerName; } public const string PluginGuid = "Azx.AbortTeleportByEmoting"; public const string PluginName = "Abort Teleport By Emoting"; public const string PluginVersion = "1.0.0"; internal static ManualLogSource Log; internal static Harmony Harmony; internal static Plugin Instance; internal static string AbortingPlayerName; internal static LNetworkMessage<AbortPayload> AbortMessage; internal static LNetworkVariable<bool> StopEmoteVar; private void Awake() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown Instance = this; Log = ((BaseUnityPlugin)this).Logger; Harmony = new Harmony("Azx.AbortTeleportByEmoting"); ConfigSettings.Init((BaseUnityPlugin)(object)this); AbortMessage = LNetworkMessage<AbortPayload>.Connect("Azx.AbortTeleportByEmoting", (Action<AbortPayload, ulong>)null, (Action<AbortPayload>)NotifyPlayers.OnAbortClient, (Action<AbortPayload, ulong>)null); StopEmoteVar = LNetworkVariable<bool>.Connect("Azx.AbortTeleportByEmoting.StopEmoteWhenTeleportStarts", ConfigSettings.StopEmoteWhenTeleportStarts, (LNetworkVariableWritePerms)0, (Action<bool, bool>)delegate(bool oldV, bool newV) { Log.LogDebug((object)$"StopEmote sync: {oldV} -> {newV}"); }); LNetworkUtils.OnNetworkStart += delegate(bool isServer) { if (isServer && StopEmoteVar != null) { StopEmoteVar.Value = ConfigSettings.StopEmoteWhenTeleportStarts; } }; ConfigSettings.RegisterWithLethalConfigIfPresent(); Harmony.PatchAll(); Log.LogInfo((object)"Abort Teleport By Emoting 1.0.0 loaded."); } internal static bool IsHost() { if (Object.op_Implicit((Object)(object)NetworkManager.Singleton)) { if (!NetworkManager.Singleton.IsServer) { return NetworkManager.Singleton.IsHost; } return true; } return false; } } public static class PluginInfo { public const string PLUGIN_GUID = "AbortTeleportByEmoting"; public const string PLUGIN_NAME = "AbortTeleportByEmoting"; public const string PLUGIN_VERSION = "0.0.1"; } }