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 AFK Manager v1.0.0
EmpressAFKMod.dll
Decompiled 3 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using Microsoft.CodeAnalysis; using Photon.Pun; using UnityEngine; [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: AssemblyCompany("Omniscye")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("EmpressAFKMod")] [assembly: AssemblyTitle("EmpressAFKMod")] [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 RepoMods { [BepInPlugin("com.empress.afkmod", "AFK Manager", "1.1.0")] public class AFKMod : BaseUnityPlugin { private class PlayerAFKData { public Vector3 LastPosition; public Quaternion LastRotation; public float AfkTimer; public bool Teleported; } public static ManualLogSource Log; private ConfigEntry<float> ConfigTeleportTime; private ConfigEntry<float> ConfigKillTime; private const float MOVEMENT_THRESHOLD = 0.5f; private Dictionary<int, PlayerAFKData> _playerData = new Dictionary<int, PlayerAFKData>(); private float _checkInterval = 1f; private float _timer; public static bool PhotonReady => PhotonNetwork.IsConnected && PhotonNetwork.InRoom && !SemiFunc.RunIsLobby() && !SemiFunc.RunIsLobbyMenu() && !SemiFunc.IsMainMenu() && !SemiFunc.IsSplashScreen(); private void Awake() { ((Component)this).gameObject.transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); Log = ((BaseUnityPlugin)this).Logger; ConfigTeleportTime = ((BaseUnityPlugin)this).Config.Bind<float>("General", "TeleportTime", 120f, "Time in seconds before teleporting to truck (Max 600)"); ConfigKillTime = ((BaseUnityPlugin)this).Config.Bind<float>("General", "KillTime", 300f, "Time in seconds before killing player (Max 600)"); if (ConfigTeleportTime.Value > 600f) { ConfigTeleportTime.Value = 600f; } if (ConfigKillTime.Value > 600f) { ConfigKillTime.Value = 600f; } } private void Update() { if (!PhotonReady || !PhotonNetwork.IsMasterClient) { _playerData.Clear(); return; } _timer += Time.deltaTime; if (_timer >= _checkInterval) { CheckPlayers(); _timer = 0f; } } private void CheckPlayers() { //IL_00e1: 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_00fa: 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_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_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_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014a: 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) if ((Object)(object)GameDirector.instance == (Object)null) { return; } foreach (PlayerAvatar player in GameDirector.instance.PlayerList) { if ((Object)(object)player == (Object)null || (Object)(object)player.photonView == (Object)null || player.isDisabled || player.deadSet) { continue; } int viewID = player.photonView.ViewID; if (!_playerData.ContainsKey(viewID)) { _playerData[viewID] = new PlayerAFKData { LastPosition = ((Component)player).transform.position, LastRotation = ((Component)player).transform.rotation, AfkTimer = 0f }; continue; } PlayerAFKData playerAFKData = _playerData[viewID]; float num = Vector3.Distance(((Component)player).transform.position, playerAFKData.LastPosition); float num2 = Quaternion.Angle(((Component)player).transform.rotation, playerAFKData.LastRotation); if (num > 0.5f || num2 > 10f) { playerAFKData.AfkTimer = 0f; playerAFKData.Teleported = false; playerAFKData.LastPosition = ((Component)player).transform.position; playerAFKData.LastRotation = ((Component)player).transform.rotation; continue; } playerAFKData.AfkTimer += _checkInterval; if (playerAFKData.AfkTimer >= ConfigTeleportTime.Value && !playerAFKData.Teleported && Object.op_Implicit((Object)(object)player.RoomVolumeCheck) && !player.RoomVolumeCheck.inTruck) { TeleportPlayerToTruck(player); playerAFKData.Teleported = true; } if (playerAFKData.AfkTimer >= ConfigKillTime.Value) { KillPlayer(player); playerAFKData.AfkTimer = 0f; } } } private void TeleportPlayerToTruck(PlayerAvatar player) { //IL_001d: 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) if (!((Object)(object)TruckSafetySpawnPoint.instance == (Object)null)) { player.Spawn(((Component)TruckSafetySpawnPoint.instance).transform.position, ((Component)TruckSafetySpawnPoint.instance).transform.rotation); if ((Object)(object)ChatManager.instance != (Object)null) { ChatManager.instance.ForceSendMessage("[AFK] Teleporting " + player.playerName + " to truck."); } } } private void KillPlayer(PlayerAvatar player) { player.PlayerDeath(-1); if ((Object)(object)ChatManager.instance != (Object)null) { ChatManager.instance.ForceSendMessage("[AFK] " + player.playerName + " removed for inactivity."); } } } }