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 SpeedyCart v1.1.0
plugins/SpeedyCart.dll
Decompiled 10 months agousing System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security.Permissions; using System.Text.RegularExpressions; using BepInEx; using HarmonyLib; using Jotunn; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("JotunnModStub")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("JotunnModStub")] [assembly: AssemblyCopyright("Copyright © 2021")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")] [assembly: AssemblyFileVersion("1.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] namespace SpeedyCart; [BepInPlugin("org.slesar.speedycart", "SpeedyCart", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] internal class SpeedyCart : BaseUnityPlugin { [HarmonyPatch(typeof(Vagon), "AttachTo")] public class Vagon_AttachTo_Patch { private static void Postfix(Vagon __instance, GameObject go) { //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) Logger.LogInfo((object)go); PlayerController component = go.GetComponent<PlayerController>(); if ((Object)(object)component == (Object)null) { Logger.LogWarning((object)"PlayerController not found on attached GameObject."); return; } Character component2 = ((Component)component).GetComponent<Character>(); if ((Object)(object)component2 == (Object)null) { Logger.LogWarning((object)"Character not found on PlayerController."); } else if (!component2.m_seman.HaveStatusEffect(CartSpeeds[0].StatusEffect.m_nameHash)) { component2.m_seman.AddStatusEffect(CartSpeeds[0].StatusEffect, false, 0, 0f); __instance.m_breakForce = float.PositiveInfinity; ((Joint)__instance.m_attachJoin).breakTorque = float.PositiveInfinity; __instance.m_detachDistance = 3f; __instance.m_itemWeightMassFactor = 0f; SoftJointLimit linearLimit = default(SoftJointLimit); ((SoftJointLimit)(ref linearLimit)).limit = 0.01f; ((SoftJointLimit)(ref linearLimit)).bounciness = 1f; __instance.m_attachJoin.linearLimit = linearLimit; SoftJointLimit angularZLimit = default(SoftJointLimit); ((SoftJointLimit)(ref angularZLimit)).limit = 5f; ((SoftJointLimit)(ref angularZLimit)).bounciness = 1f; __instance.m_attachJoin.angularZLimit = angularZLimit; } } } [HarmonyPatch(typeof(Vagon), "CanAttach")] public class Vagon_CanAttach_Patch { private static bool Prefix(Vagon __instance, GameObject go, ref bool __result) { if ((Object)(object)__instance.m_attachedObject != (Object)null && (Object)(object)__instance.m_attachedObject == (Object)(object)go) { __result = true; return false; } return true; } } [HarmonyPatch(typeof(Vagon), "Detach")] public class Vagon_Detach_Patch { private static void Prefix(Vagon __instance) { if ((Object)(object)__instance.m_attachedObject == (Object)null) { return; } PlayerController component = __instance.m_attachedObject.GetComponent<PlayerController>(); if ((Object)(object)component == (Object)null) { Logger.LogWarning((object)"PlayerController not found on attached GameObject."); return; } Character component2 = ((Component)component).GetComponent<Character>(); if ((Object)(object)component2 == (Object)null) { Logger.LogWarning((object)"Character not found on PlayerController."); return; } CustomStatusEffect val = detectEffect(component2.m_seman); if (val != null) { component2.m_seman.RemoveStatusEffect(val.StatusEffect.m_nameHash, false); } } } [HarmonyPatch(typeof(WearNTear), "Damage")] public class Cart_Indestructible_Patch { private static bool Prefix(WearNTear __instance, ref HitData hit) { if ((Object)(object)((Component)__instance).gameObject.GetComponent<Vagon>() != (Object)null) { return false; } return true; } } public class InfiniteStaminaCommand : ConsoleCommand { public override string Name => "nostamina"; public override string Help => "You don't need stamina, bro"; public override bool IsCheat => true; public override void Run(string[] args) { if (!((Character)Player.m_localPlayer).m_seman.HaveStatusEffect(InfiniteStaminaEffect.StatusEffect.m_nameHash)) { ((Character)Player.m_localPlayer).m_seman.AddStatusEffect(InfiniteStaminaEffect.StatusEffect, false, 0, 0f); } else { ((Character)Player.m_localPlayer).m_seman.RemoveStatusEffect(InfiniteStaminaEffect.StatusEffect.m_nameHash, false); } } } [HarmonyPatch(typeof(Player), "UseStamina")] public static class Patch_UseStamina { public static bool Prefix(Player __instance, ref float v) { if (((Character)__instance).m_seman.HaveStatusEffect(InfiniteStaminaEffect.StatusEffect.m_nameHash)) { v = 0f; return false; } return true; } } [HarmonyPatch(typeof(Piece), "Awake")] public static class Patch_DestroyCart { private static void Postfix(Piece __instance) { if (Object.op_Implicit((Object)(object)((Component)__instance).GetComponentInChildren<Vagon>())) { __instance.m_canBeRemoved = true; } } } public const string PluginGUID = "org.slesar.speedycart"; public const string PluginName = "SpeedyCart"; public const string PluginVersion = "1.0.0"; private const int CartGears = 5; private readonly Harmony HarmonyInstance = new Harmony("org.slesar.speedycart"); private AssetBundle EmbeddedResourceBunlde; private Sprite SpeedIcon; private Sprite StaminaIcon; private static List<CustomStatusEffect> CartSpeeds = new List<CustomStatusEffect>(); private static CustomStatusEffect InfiniteStaminaEffect; private ButtonConfig SwitchGearsButton; private void Awake() { LoadAssets(); AddStatusEffects(); AddInputs(); CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new InfiniteStaminaCommand()); Assembly executingAssembly = Assembly.GetExecutingAssembly(); HarmonyInstance.PatchAll(executingAssembly); } private void LoadAssets() { EmbeddedResourceBunlde = AssetUtils.LoadAssetBundleFromResources("speedicon"); SpeedIcon = EmbeddedResourceBunlde.LoadAsset<Sprite>("SpeedIcon"); if ((Object)(object)SpeedIcon == (Object)null) { Logger.LogError((object)"Failed to load SpeedIcon from AssetBundle"); } StaminaIcon = EmbeddedResourceBunlde.LoadAsset<Sprite>("StaminaIcon"); if ((Object)(object)StaminaIcon == (Object)null) { Logger.LogError((object)"Failed to load StaminaIcon from AssetBundle"); } } private void AddStatusEffects() { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_007d: 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_00a7: Expected O, but got Unknown //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Expected O, but got Unknown for (int i = 0; i < 5; i++) { SE_Stats obj = ScriptableObject.CreateInstance<SE_Stats>(); ((Object)obj).name = $"CartSpeedEffect{i}"; ((StatusEffect)obj).m_name = $"Cart Speed {i}"; ((StatusEffect)obj).m_tooltip = "Dragging a cart is really fast!"; ((StatusEffect)obj).m_icon = SpeedIcon; ((StatusEffect)obj).m_startMessageType = (MessageType)2; ((StatusEffect)obj).m_startMessage = string.Concat("You are ", string.Concat(Enumerable.Repeat("really ", i)), "fast"); ((StatusEffect)obj).m_stopMessageType = (MessageType)2; ((StatusEffect)obj).m_stopMessage = "You are slow :("; obj.m_speedModifier = i; ((StatusEffect)obj).m_ttl = 0f; CustomStatusEffect val = new CustomStatusEffect((StatusEffect)(object)obj, false); CartSpeeds.Add(val); ItemManager.Instance.AddStatusEffect(val); } StatusEffect obj2 = ScriptableObject.CreateInstance<StatusEffect>(); ((Object)obj2).name = "InfiniteStaminaEffect"; obj2.m_name = "Infinite Stamina Effect"; obj2.m_tooltip = "You won't need stamina where we are going."; obj2.m_icon = StaminaIcon; obj2.m_startMessageType = (MessageType)2; obj2.m_startMessage = "Stamina disabled"; obj2.m_stopMessageType = (MessageType)2; obj2.m_stopMessage = "Stamina enabled"; InfiniteStaminaEffect = new CustomStatusEffect(obj2, false); ItemManager.Instance.AddStatusEffect(InfiniteStaminaEffect); } private void AddInputs() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown SwitchGearsButton = new ButtonConfig { Name = "SwitchGears", Key = (KeyCode)103 }; InputManager.Instance.AddButton("org.slesar.speedycart", SwitchGearsButton); } private void Update() { if (ZInput.instance != null && ZInput.GetButtonDown(SwitchGearsButton.Name)) { CustomStatusEffect val = detectEffect(((Character)Player.m_localPlayer).m_seman); if (val != null) { int gearFromString = getGearFromString(((Object)val.StatusEffect).name); ((Character)Player.m_localPlayer).m_seman.RemoveStatusEffect(val.StatusEffect.m_nameHash, false); ((Character)Player.m_localPlayer).m_seman.AddStatusEffect(CartSpeeds[(gearFromString + 1) % 5].StatusEffect, false, 0, 0f); } } } private static CustomStatusEffect detectEffect(SEMan m_seman) { foreach (CustomStatusEffect cartSpeed in CartSpeeds) { if (((Character)Player.m_localPlayer).m_seman.HaveStatusEffect(cartSpeed.StatusEffect.m_nameHash)) { return cartSpeed; } } return null; } private static int getGearFromString(string name) { return int.Parse(Regex.Match(name, "(\\d+)$").Value); } } public static class StringHashExtensions { public static int GetStableHashCode(this string str) { int num = 352654597; int num2 = num; for (int i = 0; i < str.Length; i += 2) { num = ((num << 5) + num) ^ str[i]; if (i == str.Length - 1) { break; } num2 = ((num2 << 5) + num2) ^ str[i + 1]; } return num + num2 * 1566083941; } }