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 BetterSpraycans v1.0.1
BepInEx/plugins/BetterSprayCans.dll
Decompiled 2 years agousing 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.Logging; using BetterSprayCans; using BetterSprayCansBase.Patches; using HarmonyLib; using LethalCompanyInputUtils.Api; using Unity.Netcode; using UnityEngine; using UnityEngine.InputSystem; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("BetterSprayCans")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("BetterSprayCans")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("1695274b-de79-44d3-b3c1-3561a77234c2")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace BetterSprayCans { public class SprayCanInputs : LcInputActions { [InputAction("<Keyboard>/minus", Name = "Previous Spray Color")] public InputAction PreviousSpray { get; set; } [InputAction("<Keyboard>/equals", Name = "Previous Spray Color")] public InputAction NextSpray { get; set; } } } namespace BetterSprayCansBase { [BepInPlugin("LCMOD.BetterSprayCans", "BetterSprayCans", "1.0.0")] public class BetterSprayCansBase : BaseUnityPlugin { public const string MODGUID = "LCMOD.BetterSprayCans"; public const string MODNAME = "BetterSprayCans"; public const string MODVERSION = "1.0.0"; private readonly Harmony harmony = new Harmony("LCMOD.BetterSprayCans"); public static ManualLogSource logger; public static BetterSprayCansBase Instance { get; private set; } private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } logger = ((BaseUnityPlugin)this).Logger; ((BaseUnityPlugin)this).Logger.LogInfo((object)"Mod LCMOD.BetterSprayCans is loaded!"); harmony.PatchAll(typeof(BetterSprayCansBase)); harmony.PatchAll(typeof(SprayPaintItemPatch)); harmony.PatchAll(typeof(ItemChargerPatch)); } } } namespace BetterSprayCansBase.Patches { [HarmonyPatch(typeof(ItemCharger))] internal class ItemChargerPatch { [HarmonyPatch("Update")] [HarmonyPrefix] private static bool ItemChargerUpdate(ItemCharger __instance, ref float ___updateInterval, ref InteractTrigger ___triggerScript) { if ((Object)(object)NetworkManager.Singleton == (Object)null || (Object)(object)__instance == (Object)null || (Object)(object)___triggerScript == (Object)null) { return false; } if (___updateInterval > 1f) { ___updateInterval = 0f; if ((Object)(object)GameNetworkManager.Instance != (Object)null && (Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)null) { GrabbableObject currentlyHeldObjectServer = GameNetworkManager.Instance.localPlayerController.currentlyHeldObjectServer; if ((Object)(object)currentlyHeldObjectServer != (Object)null && ((object)currentlyHeldObjectServer).GetType() == typeof(SprayPaintItem)) { ___triggerScript.interactable = true; ___triggerScript.hoverTip = "Fillup SprayCan : [LMB]"; } else if ((Object)(object)currentlyHeldObjectServer != (Object)null && ((object)currentlyHeldObjectServer).GetType() != typeof(SprayPaintItem) && currentlyHeldObjectServer.itemProperties.requiresBattery) { ___triggerScript.interactable = true; ___triggerScript.hoverTip = "Charge item : [LMB]"; } else { ___triggerScript.interactable = false; } } } ___updateInterval += Time.deltaTime; return false; } [HarmonyPatch("ChargeItem")] [HarmonyPostfix] private static void ItemChargerCharge(ItemCharger __instance) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown GrabbableObject currentlyHeldObjectServer = GameNetworkManager.Instance.localPlayerController.currentlyHeldObjectServer; if ((Object)(object)currentlyHeldObjectServer != (Object)null && ((object)currentlyHeldObjectServer).GetType() == typeof(SprayPaintItem)) { SprayPaintItem val = (SprayPaintItem)currentlyHeldObjectServer; SprayPaintItemPatch.fillSprayCan = true; } } } [HarmonyPatch(typeof(SprayPaintItem))] internal class SprayPaintItemPatch { public static bool fillSprayCan = false; private static int colorIndex = 0; internal static SprayCanInputs sprayCanInputs = new SprayCanInputs(); [HarmonyPatch("LateUpdate")] [HarmonyPostfix] private static void ChangeSprayColor(SprayPaintItem __instance, ref int ___sprayCanMatsIndex, ref float ___sprayCanTank) { if (fillSprayCan && playerIsHolding(__instance)) { ___sprayCanTank = 1f; fillSprayCan = false; BetterSprayCansBase.logger.LogInfo((object)$"ID{((Object)__instance).GetInstanceID()} Spraycan Filled"); } if (sprayCanInputs.PreviousSpray.triggered && playerIsHolding(__instance)) { colorIndex--; if (colorIndex < 0 || colorIndex == __instance.particleMats.Length) { colorIndex = __instance.particleMats.Length; HUDManager.Instance.DisplayTip("Spray Color Changed", "Color changed to RAINBOWS", false, false, "LC_Tip1"); } else { ___sprayCanMatsIndex = colorIndex; BetterSprayCansBase.logger.LogInfo((object)$"Pressed Previous key to index {___sprayCanMatsIndex} for {((Object)__instance.particleMats[___sprayCanMatsIndex]).name.Substring(18)}"); setSprayColor(__instance, ___sprayCanMatsIndex); } } if (sprayCanInputs.NextSpray.triggered && playerIsHolding(__instance)) { colorIndex++; if (colorIndex == __instance.particleMats.Length) { HUDManager.Instance.DisplayTip("Spray Color Changed", "Color changed to RAINBOWS", false, false, "LC_Tip1"); } else { if (colorIndex > __instance.particleMats.Length) { colorIndex = 0; } ___sprayCanMatsIndex = colorIndex; BetterSprayCansBase.logger.LogInfo((object)$"Pressed Next key index {___sprayCanMatsIndex} for {((Object)__instance.particleMats[___sprayCanMatsIndex]).name.Substring(18)}"); setSprayColor(__instance, ___sprayCanMatsIndex); } } if (colorIndex == __instance.particleMats.Length && playerIsHolding(__instance)) { ___sprayCanMatsIndex++; if (___sprayCanMatsIndex >= __instance.particleMats.Length) { ___sprayCanMatsIndex = 0; } setSprayColor(__instance, ___sprayCanMatsIndex); } else if (___sprayCanMatsIndex != colorIndex && playerIsHolding(__instance)) { ___sprayCanMatsIndex = colorIndex; setSprayColor(__instance, ___sprayCanMatsIndex); } } private static void setSprayColor(SprayPaintItem instance, int sprayCanMatsIndex) { ((Renderer)((Component)instance.sprayParticle).GetComponent<ParticleSystemRenderer>()).material = instance.particleMats[sprayCanMatsIndex]; ((Renderer)((Component)instance.sprayCanNeedsShakingParticle).GetComponent<ParticleSystemRenderer>()).material = instance.particleMats[sprayCanMatsIndex]; if (colorIndex != instance.particleMats.Length) { HUDManager.Instance.DisplayTip("Spray Color Changed", $"Color changed to color #{sprayCanMatsIndex + 1} {((Object)instance.particleMats[sprayCanMatsIndex]).name.Substring(18)}", false, false, "LC_Tip1"); } } private static bool playerIsHolding(SprayPaintItem instance) { return (Object)(object)((GrabbableObject)instance).playerHeldBy == (Object)(object)GameNetworkManager.Instance.localPlayerController; } } }