Please disclose if your mod was created primarily 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 Need For Speed v0.2.3
Plugins/VentureValheim.NeedForSpeed.dll
Decompiled a year agousing System; using System.Collections; using System.Diagnostics; using System.IO; 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 HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("VentureValheim.NeedForSpeed")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("VentureValheim.NeedForSpeed")] [assembly: AssemblyCopyright("Copyright © 2022")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("FED6F81E-23E5-46DC-B89B-0F87894CC18A")] [assembly: AssemblyFileVersion("0.2.3")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.2.3.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 VentureValheim.NeedForSpeed { [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("com.orianaventure.mod.NeedForSpeed", "NeedForSpeed", "0.2.3")] public class NeedForSpeedPlugin : BaseUnityPlugin { private static readonly NeedForSpeedPlugin _instance; private const string ModName = "NeedForSpeed"; private const string ModVersion = "0.2.3"; private const string Author = "com.orianaventure.mod"; private const string ModGUID = "com.orianaventure.mod.NeedForSpeed"; private static string ConfigFileName; private static string ConfigFileFullPath; private readonly Harmony HarmonyInstance = new Harmony("com.orianaventure.mod.NeedForSpeed"); public static readonly ManualLogSource NeedForSpeedLogger; internal static ConfigEntry<float> CE_JogSpeedMultiplier; internal static ConfigEntry<float> CE_RunSpeedMultiplier; private readonly ConfigurationManagerAttributes AdminConfig = new ConfigurationManagerAttributes { IsAdminOnly = true }; private readonly ConfigurationManagerAttributes ClientConfig = new ConfigurationManagerAttributes { IsAdminOnly = false }; public static NeedForSpeedPlugin Instance => _instance; static NeedForSpeedPlugin() { _instance = new NeedForSpeedPlugin(); ConfigFileName = "com.orianaventure.mod.NeedForSpeed.cfg"; string configPath = Paths.ConfigPath; char directorySeparatorChar = Path.DirectorySeparatorChar; ConfigFileFullPath = configPath + directorySeparatorChar + ConfigFileName; NeedForSpeedLogger = Logger.CreateLogSource("NeedForSpeed"); CE_JogSpeedMultiplier = null; CE_RunSpeedMultiplier = null; } private NeedForSpeedPlugin() { }//IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_0023: 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) //IL_0034: Expected O, but got Unknown public float GetJogSpeedMultiplier() { return CE_JogSpeedMultiplier.Value; } public float GetRunSpeedMultiplier() { return CE_RunSpeedMultiplier.Value; } private void AddConfig<T>(string key, string section, string description, bool synced, T value, ref ConfigEntry<T> configEntry) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown string extendedDescription = GetExtendedDescription(description, synced); configEntry = ((BaseUnityPlugin)this).Config.Bind<T>(section, key, value, new ConfigDescription(extendedDescription, (AcceptableValueBase)null, new object[1] { synced ? AdminConfig : ClientConfig })); } public string GetExtendedDescription(string description, bool synchronizedSetting) { return description + (synchronizedSetting ? " [Synced with Server]" : " [Not Synced with Server]"); } public void Awake() { AddConfig("JogSpeedMultiplier", "General", "Jog Speed Multiplier, 1.3 is 30% faster (float).", synced: true, 1.3f, ref CE_JogSpeedMultiplier); AddConfig("RunSpeedMultiplier", "General", "Run Speed Multiplier, 1.3 is 30% faster (float).", synced: true, 1.3f, ref CE_RunSpeedMultiplier); NeedForSpeedLogger.LogInfo((object)"Somebody got the zoomies? Get ready to go fast!"); Assembly executingAssembly = Assembly.GetExecutingAssembly(); HarmonyInstance.PatchAll(executingAssembly); SetupWatcher(); } private void OnDestroy() { ((BaseUnityPlugin)this).Config.Save(); } private void SetupWatcher() { FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(Paths.ConfigPath, ConfigFileName); fileSystemWatcher.Changed += ReadConfigValues; fileSystemWatcher.Created += ReadConfigValues; fileSystemWatcher.Renamed += ReadConfigValues; fileSystemWatcher.IncludeSubdirectories = true; fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject; fileSystemWatcher.EnableRaisingEvents = true; } private void ReadConfigValues(object sender, FileSystemEventArgs e) { if (!File.Exists(ConfigFileFullPath)) { return; } try { NeedForSpeedLogger.LogDebug((object)"Attempting to reload configuration..."); ((BaseUnityPlugin)this).Config.Reload(); } catch { NeedForSpeedLogger.LogError((object)("There was an issue loading " + ConfigFileName)); } } } public class NeedForSpeed { [HarmonyPatch(typeof(Player), "SetLocalPlayer")] public static class Patch_Player_SetLocalPlayer { private static void Postfix(Player __instance) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) Scene activeScene = SceneManager.GetActiveScene(); if (((Scene)(ref activeScene)).name.Equals("main")) { Instance._resetCoroutine = Instance.WatchGround(); ((MonoBehaviour)__instance).StartCoroutine(Instance._resetCoroutine); } else if (Instance._resetCoroutine != null) { ((MonoBehaviour)__instance).StopCoroutine(Instance._resetCoroutine); } } } [HarmonyPatch(typeof(Player), "GetJogSpeedFactor")] public static class Patch_Character_GetJogSpeedFactor { private static void Postfix(ref float __result) { __result *= Instance._jogSpeedMultiplier; } } [HarmonyPatch(typeof(Player), "GetRunSpeedFactor")] public static class Patch_Character_GetRunSpeedFactor { private static void Postfix(ref float __result) { __result *= Instance._runSpeedMultiplier; } } private static readonly NeedForSpeed _instance = new NeedForSpeed(); private float _runSpeedMultiplier = 1f; private float _jogSpeedMultiplier = 1f; private IEnumerator _resetCoroutine; public static NeedForSpeed Instance => _instance; private NeedForSpeed() { } public IEnumerator WatchGround() { while (true) { yield return (object)new WaitForSeconds(0.25f); if (!((Object)(object)Player.m_localPlayer == (Object)null)) { UpdateMultiplier(); continue; } break; } } public void UpdateMultiplier() { if (OnPath()) { _runSpeedMultiplier = NeedForSpeedPlugin.Instance.GetRunSpeedMultiplier(); _jogSpeedMultiplier = NeedForSpeedPlugin.Instance.GetJogSpeedMultiplier(); } else { _runSpeedMultiplier = 1f; _jogSpeedMultiplier = 1f; } } public bool OnPath() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) Collider lastGroundCollider = ((Character)Player.m_localPlayer).m_lastGroundCollider; if ((Object)(object)lastGroundCollider == (Object)null) { return false; } Heightmap component = ((Component)lastGroundCollider).GetComponent<Heightmap>(); if ((Object)(object)component != (Object)null && component.IsCleared(((Component)Player.m_localPlayer).transform.position)) { return true; } return false; } } }