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 QuotaDependentSpeed v1.0.0
Tomatobird.QuotaDependentSpeed.dll
Decompiled 4 hours agousing System; 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 BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using Unity.Netcode; 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("Tomatobird.QuotaDependentSpeed")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+1970b5f00ee622973ec84f73c1f0aeb34cf8101a")] [assembly: AssemblyProduct("QuotaDependentSpeed")] [assembly: AssemblyTitle("Tomatobird.QuotaDependentSpeed")] [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 QuotaDependentSpeed { [BepInPlugin("Tomatobird.QuotaDependentSpeed", "QuotaDependentSpeed", "1.0.0")] public class QuotaDependentSpeed : BaseUnityPlugin { public static ConfigEntry<int> quotaBaseValue; public static ConfigEntry<float> quotaEffectScaler; public static ConfigEntry<float> minSpeedMultiplier; public static ConfigEntry<float> maxSpeedMultiplier; public static QuotaDependentSpeed Instance { get; private set; } internal static ManualLogSource Logger { get; private set; } internal static Harmony? Harmony { get; set; } private void Awake() { Logger = ((BaseUnityPlugin)this).Logger; Instance = this; quotaBaseValue = ((BaseUnityPlugin)this).Config.Bind<int>("General", "QuotaBaseValue", 1000, "The value of quota"); quotaEffectScaler = ((BaseUnityPlugin)this).Config.Bind<float>("General", "QuotaEffectScaler", 0.5f, "How strongly the difference from QuotaBaseValue affects player speed."); minSpeedMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("General", "MinSpeedMultiplier", 0.01f, "How slow should the player be at slowest?"); maxSpeedMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("General", "MaxSpeedMultiplier", 999f, "How fast should the player be at fastest?"); Patch(); Logger.LogInfo((object)"Tomatobird.QuotaDependentSpeed v1.0.0 has loaded!"); } internal static void Patch() { //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_0018: Expected O, but got Unknown if (Harmony == null) { Harmony = new Harmony("Tomatobird.QuotaDependentSpeed"); } Logger.LogDebug((object)"Patching..."); Harmony.PatchAll(); Logger.LogDebug((object)"Finished patching!"); } internal static void Unpatch() { Logger.LogDebug((object)"Unpatching..."); Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } Logger.LogDebug((object)"Finished unpatching!"); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "Tomatobird.QuotaDependentSpeed"; public const string PLUGIN_NAME = "QuotaDependentSpeed"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace QuotaDependentSpeed.Patches { [HarmonyPatch(typeof(NetworkManager))] internal class RegisterNetworkPrefabPatch { private static readonly string MOD_GUID = "Tomatobird.QuotaDependentSpeed"; [HarmonyPatch("SetSingleton")] [HarmonyPostfix] private static void RegisterPrefab() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_0018: 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) GameObject val = new GameObject(MOD_GUID + " Prefab"); ((Object)val).hideFlags = (HideFlags)(((Object)val).hideFlags | 0x3D); Object.DontDestroyOnLoad((Object)(object)val); NetworkObject obj = val.AddComponent<NetworkObject>(); FieldInfo field = typeof(NetworkObject).GetField("GlobalObjectIdHash", BindingFlags.Instance | BindingFlags.NonPublic); field.SetValue(obj, GetHash(MOD_GUID)); NetworkManager.Singleton.PrefabHandler.AddNetworkPrefab(val); static uint GetHash(string value) { return value?.Aggregate(17u, (uint current, char c) => (current * 31) ^ c) ?? 0; } } } [HarmonyPatch] internal class SprintSpeedPatch { private static float value = 1f; private static float previousSpeed; [HarmonyPatch(typeof(TimeOfDay), "UpdateProfitQuotaCurrentTime")] [HarmonyPostfix] private static void UpdateValue() { value = CalculateSpeed(); } [HarmonyPatch(typeof(PlayerControllerB), "Update")] [HarmonyPrefix] private static void UpdatePrefix(ref bool ___isPlayerControlled, ref float ___movementSpeed) { if (___isPlayerControlled && !StartOfRound.Instance.isChallengeFile) { previousSpeed = ___movementSpeed; ___movementSpeed *= value; } } [HarmonyPatch(typeof(PlayerControllerB), "Update")] [HarmonyPostfix] private static void UpdatePostfix(ref bool ___isPlayerControlled, ref float ___movementSpeed) { if (___isPlayerControlled && !StartOfRound.Instance.isChallengeFile) { ___movementSpeed = previousSpeed; } } private static float CalculateSpeed() { float num = (float)TimeOfDay.Instance.profitQuota / (float)QuotaDependentSpeed.quotaBaseValue.Value; QuotaDependentSpeed.Logger.LogDebug((object)num); QuotaDependentSpeed.Logger.LogDebug((object)"pow:"); QuotaDependentSpeed.Logger.LogDebug((object)Mathf.Pow(num, QuotaDependentSpeed.quotaEffectScaler.Value)); QuotaDependentSpeed.Logger.LogDebug((object)("result: " + Mathf.Clamp(Mathf.Pow(num, QuotaDependentSpeed.quotaEffectScaler.Value), QuotaDependentSpeed.minSpeedMultiplier.Value, QuotaDependentSpeed.maxSpeedMultiplier.Value))); return Mathf.Clamp(Mathf.Pow(num, QuotaDependentSpeed.quotaEffectScaler.Value), QuotaDependentSpeed.minSpeedMultiplier.Value, QuotaDependentSpeed.maxSpeedMultiplier.Value); } } }