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 PlayerSpeedConfig v1.0.0
PlayerSpeedConfig.dll
Decompiled 4 months agousing System; using System.Collections; 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 BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using ExitGames.Client.Photon; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using Photon.Realtime; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("PlayerSpeedConfig")] [assembly: AssemblyDescription("Mod for configuring the R.E.P.O. Players Speed! Developed by Jettcodey.")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Jettcodey")] [assembly: AssemblyProduct("PlayerSpeedConfig")] [assembly: AssemblyCopyright("Copyright © Jettcodey 2026")] [assembly: ComVisible(false)] [assembly: Guid("fedde841-8cf7-4484-a152-6a98305805dd")] [assembly: AssemblyFileVersion("1.0.0")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [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; } } } namespace PlayerSpeedConfig { public class ConfigManager { private ConfigEntry<float> _walkSpeedMultiplier; private ConfigEntry<float> _sprintSpeedMultiplier; private ConfigEntry<float> _crouchSpeedMultiplier; public static ConfigManager Instance { get; private set; } public float WalkMult => _walkSpeedMultiplier.Value; public float SprintMult => _sprintSpeedMultiplier.Value; public float CrouchMult => _crouchSpeedMultiplier.Value; public event Action OnConfigChanged; public void Initialize(ConfigFile config) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Expected O, but got Unknown //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Expected O, but got Unknown Instance = this; _walkSpeedMultiplier = config.Bind<float>("Movement", "WalkSpeedMultiplier", 1f, new ConfigDescription("Multiplier for base walking speed.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>())); _sprintSpeedMultiplier = config.Bind<float>("Movement", "SprintSpeedMultiplier", 1f, new ConfigDescription("Multiplier for sprinting speed.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>())); _crouchSpeedMultiplier = config.Bind<float>("Movement", "CrouchSpeedMultiplier", 1f, new ConfigDescription("Multiplier for crouching speed.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>())); _walkSpeedMultiplier.SettingChanged += delegate { this.OnConfigChanged?.Invoke(); }; _sprintSpeedMultiplier.SettingChanged += delegate { this.OnConfigChanged?.Invoke(); }; _crouchSpeedMultiplier.SettingChanged += delegate { this.OnConfigChanged?.Invoke(); }; } } public static class MultiplayerHandler { public const string ModCheckKey = "Jettcodey_PlayerSpeedConfig"; public static bool IsModEnabled() { if (!SemiFunc.IsMultiplayer()) { return true; } if (PhotonNetwork.CurrentRoom == null) { return false; } if (PhotonNetwork.IsMasterClient) { return true; } if (((Dictionary<object, object>)(object)((RoomInfo)PhotonNetwork.CurrentRoom).CustomProperties).TryGetValue((object)"Jettcodey_PlayerSpeedConfig", out object value)) { return (bool)value; } return false; } public static void SetModActive() { //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_002e: Expected O, but got Unknown //IL_0030: Expected O, but got Unknown if (PhotonNetwork.IsMasterClient && PhotonNetwork.CurrentRoom != null) { Hashtable val = new Hashtable(); ((Dictionary<object, object>)val).Add((object)"Jettcodey_PlayerSpeedConfig", (object)true); Hashtable val2 = val; PhotonNetwork.CurrentRoom.SetCustomProperties(val2, (Hashtable)null, (WebFlags)null); Plugin.Logger.LogInfo((object)"[Host Mode] Mod presence announced to room."); } } } public static class MyPluginInfo { public const string PLUGIN_GUID = "Jettcodey.PlayerSpeedConfig"; public const string PLUGIN_NAME = "PlayerSpeedConfig"; public const string PLUGIN_VERSION = "1.0.0"; } [BepInPlugin("Jettcodey.PlayerSpeedConfig", "PlayerSpeedConfig", "1.0.0")] public class Plugin : BaseUnityPlugin { private Harmony _harmony; public static Plugin Instance { get; private set; } internal static ManualLogSource? Logger { get; private set; } private void Awake() { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown Instance = this; Logger = ((BaseUnityPlugin)this).Logger; new ConfigManager().Initialize(((BaseUnityPlugin)this).Config); ((Component)this).gameObject.transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); _harmony = new Harmony("Jettcodey.PlayerSpeedConfig"); _harmony.PatchAll(); Logger.LogInfo((object)"Plugin PlayerSpeedConfig v1.0.0 loaded successfully."); } private void OnDestroy() { Harmony.UnpatchID("Jettcodey.PlayerSpeedConfig"); } } } namespace PlayerSpeedConfig.Patches { [HarmonyPatch(typeof(PlayerController))] public class PlayerControllerPatches { [CompilerGenerated] private sealed class <ClientCheckRoutine>d__5 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; private int <retries>5__1; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <ClientCheckRoutine>d__5(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <retries>5__1 = 5; break; case 1: <>1__state = -1; <retries>5__1--; break; } if (<retries>5__1 > 0) { if (MultiplayerHandler.IsModEnabled()) { Plugin.Logger.LogInfo((object)"[Client Mode] Host Mod Detected! Mod is active."); return false; } <>2__current = (object)new WaitForSeconds(1.5f); <>1__state = 1; return true; } Plugin.Logger.LogWarning((object)"[Client Mode] Host does NOT have the mod (or high latency). Mod is disabled."); 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 float? _baseWalk; private static float? _baseSprint; private static float? _baseCrouch; private static PlayerController _localController; [HarmonyPatch("Awake")] [HarmonyPrefix] private static void AwakePrefix(PlayerController __instance) { _baseWalk = null; _baseSprint = null; _baseCrouch = null; _localController = __instance; ConfigManager.Instance.OnConfigChanged -= OnConfigChanged; ConfigManager.Instance.OnConfigChanged += OnConfigChanged; if (SemiFunc.IsMultiplayer() && !SemiFunc.IsMasterClient()) { ((MonoBehaviour)Plugin.Instance).StartCoroutine(ClientCheckRoutine()); } } [IteratorStateMachine(typeof(<ClientCheckRoutine>d__5))] private static IEnumerator ClientCheckRoutine() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <ClientCheckRoutine>d__5(0); } [HarmonyPatch("FixedUpdate")] [HarmonyPrefix] private static void FixedUpdatePrefix(PlayerController __instance) { if (!_baseWalk.HasValue && !(__instance.playerOriginalMoveSpeed <= 0f) && MultiplayerHandler.IsModEnabled()) { _baseWalk = __instance.playerOriginalMoveSpeed; _baseSprint = __instance.playerOriginalSprintSpeed; _baseCrouch = __instance.playerOriginalCrouchSpeed; ApplyMovementStats(__instance); } } private static void OnConfigChanged() { if ((Object)(object)_localController != (Object)null && _baseWalk.HasValue) { ApplyMovementStats(_localController); } } private static void ApplyMovementStats(PlayerController pc) { if (MultiplayerHandler.IsModEnabled()) { ConfigManager instance = ConfigManager.Instance; float num = _baseWalk.Value * instance.WalkMult; float num2 = _baseSprint.Value * instance.SprintMult; float num3 = _baseCrouch.Value * instance.CrouchMult; pc.MoveSpeed = num; pc.SprintSpeed = num2; pc.CrouchSpeed = num3; pc.playerOriginalMoveSpeed = num; pc.playerOriginalSprintSpeed = num2; pc.playerOriginalCrouchSpeed = num3; Plugin.Logger.LogInfo((object)$"Walk: {num} | Sprint: {num2} | Crouch: {num3}"); } } } [HarmonyPatch(typeof(PunManager))] public class PunManagerPatches { [HarmonyPatch("Start")] [HarmonyPostfix] private static void StartPostfix() { if (SemiFunc.IsMultiplayer() && PhotonNetwork.IsMasterClient) { MultiplayerHandler.SetModActive(); } } } }