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 testmod v1.0.7
ReservedSprayPaintSlot.dll
Decompiled 2 years agousing System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using GameNetcodeStuff; using HarmonyLib; using ReservedItemSlotCore; using ReservedItemSlotCore.Networking; using ReservedItemSlotCore.Patches; using ReservedSprayPaintSlot.Config; 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("ReservedSprayPaintSlot")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("ReservedSprayPaintSlot")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("d5fcfd75-740b-418d-b185-a0bbdea6fa40")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] namespace ReservedSprayPaintSlot { [BepInPlugin("FlipMods.ReservedSprayPaintSlot", "ReservedSprayPaintSlot", "1.0.7")] [BepInDependency(/*Could not decode attribute arguments.*/)] internal class Plugin : BaseUnityPlugin { public static Plugin instance; private Harmony _harmony; public static ReservedItemInfo sprayPaintInfo; private void Awake() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown instance = this; ConfigSettings.BindConfigSettings(); _harmony = new Harmony("ReservedSprayPaintSlot"); _harmony.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"ReservedSprayPaintSlot loaded"); } public static void Log(string message) { ((BaseUnityPlugin)instance).Logger.LogInfo((object)message); } static Plugin() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown sprayPaintInfo = new ReservedItemInfo("페인트 스프레이", 30, true, true, false, false); } } public static class PluginInfo { public const string PLUGIN_GUID = "FlipMods.ReservedSprayPaintSlot"; public const string PLUGIN_NAME = "ReservedSprayPaintSlot"; public const string PLUGIN_VERSION = "1.0.7"; } } namespace ReservedSprayPaintSlot.Patches { [HarmonyPatch] internal static class Patcher { private static Vector3 playerWaistPositionOffset = new Vector3(0.26f, -0.05f, 0.2f); private static Vector3 playerWaistRotationOffset = new Vector3(-105f, 0f, 0f); public static PlayerControllerB localPlayerController => PlayerPatcher.localPlayerController; public static PlayerControllerB GetPreviousPlayerHeldBy(SprayPaintItem sprayPaintItem) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown return (PlayerControllerB)Traverse.Create((object)sprayPaintItem).Field("previousPlayerHeldBy").GetValue(); } public static SprayPaintItem GetMainSprayPaint(PlayerControllerB playerController) { return GetCurrentlySelectedSprayPaint(playerController) ?? GetReservedSprayPaint(playerController); } public static SprayPaintItem GetReservedSprayPaint(PlayerControllerB playerController) { ReservedPlayerData value; return (SprayPaintItem)((SyncManager.syncReservedItemsList.Contains(Plugin.sprayPaintInfo) && PlayerPatcher.allPlayerData.TryGetValue(playerController, out value)) ? /*isinst with value type is only supported in some contexts*/: null); } public static SprayPaintItem GetCurrentlySelectedSprayPaint(PlayerControllerB playerController) { return (SprayPaintItem)((playerController.currentItemSlot >= 0 && playerController.currentItemSlot < playerController.ItemSlots.Length) ? /*isinst with value type is only supported in some contexts*/: null); } [HarmonyPatch(typeof(SprayPaintItem), "PocketItem")] [HarmonyPostfix] public static void OnPocketSprayPaintLocal(SprayPaintItem __instance) { if ((Object)(object)((GrabbableObject)__instance).playerHeldBy == (Object)null) { return; } MeshRenderer[] componentsInChildren = ((Component)__instance).GetComponentsInChildren<MeshRenderer>(); foreach (MeshRenderer val in componentsInChildren) { if (!((Object)val).name.Contains("ScanNode") && !((Component)val).gameObject.CompareTag("DoNotSet") && !((Component)val).gameObject.CompareTag("InteractTrigger")) { ((Component)val).gameObject.layer = (((Object)(object)((GrabbableObject)__instance).playerHeldBy == (Object)(object)localPlayerController) ? 23 : 6); } } if ((Object)(object)__instance == (Object)(object)GetReservedSprayPaint(((GrabbableObject)__instance).playerHeldBy)) { ((GrabbableObject)__instance).parentObject = ((GrabbableObject)__instance).playerHeldBy.lowerSpine.parent; } } [HarmonyPatch(typeof(SprayPaintItem), "EquipItem")] [HarmonyPostfix] public static void OnEquipSprayPaint(SprayPaintItem __instance) { if ((Object)(object)((GrabbableObject)__instance).playerHeldBy == (Object)null) { return; } MeshRenderer[] componentsInChildren = ((Component)__instance).GetComponentsInChildren<MeshRenderer>(); foreach (MeshRenderer val in componentsInChildren) { if (!((Object)val).name.Contains("ScanNode") && !((Component)val).gameObject.CompareTag("DoNotSet") && !((Component)val).gameObject.CompareTag("InteractTrigger")) { ((Component)val).gameObject.layer = 6; } } ((GrabbableObject)__instance).parentObject = (((Object)(object)((GrabbableObject)__instance).playerHeldBy == (Object)(object)localPlayerController) ? ((GrabbableObject)__instance).playerHeldBy.localItemHolder : ((GrabbableObject)__instance).playerHeldBy.serverItemHolder); } [HarmonyPatch(typeof(SprayPaintItem), "DiscardItem")] [HarmonyPostfix] public static void ResetLayerAfterDiscard(SprayPaintItem __instance) { MeshRenderer[] componentsInChildren = ((Component)__instance).GetComponentsInChildren<MeshRenderer>(); foreach (MeshRenderer val in componentsInChildren) { if (!((Object)val).name.Contains("ScanNode") && !((Component)val).gameObject.CompareTag("DoNotSet") && !((Component)val).gameObject.CompareTag("InteractTrigger")) { ((Component)val).gameObject.layer = 6; } } } [HarmonyPatch(typeof(GrabbableObject), "LateUpdate")] [HarmonyPostfix] public static void SetPositionOffset(GrabbableObject __instance) { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) if (__instance is SprayPaintItem && (Object)(object)__instance.playerHeldBy != (Object)null && (Object)(object)__instance.parentObject != (Object)null && __instance.isPocketed && (Object)(object)__instance == (Object)(object)GetReservedSprayPaint(__instance.playerHeldBy) && (Object)(object)__instance != (Object)(object)GetCurrentlySelectedSprayPaint(__instance.playerHeldBy)) { Transform transform = ((Component)__instance.parentObject).transform; ((Component)__instance).transform.rotation = ((Component)__instance.parentObject).transform.rotation * Quaternion.Euler(playerWaistRotationOffset); ((Component)__instance).transform.position = transform.position + transform.rotation * playerWaistPositionOffset; } } [HarmonyPatch(typeof(GrabbableObject), "EnableItemMeshes")] [HarmonyPrefix] public static void OnEnableItemMeshes(ref bool enable, GrabbableObject __instance) { if (__instance is SprayPaintItem && (Object)(object)__instance.playerHeldBy != (Object)null && (Object)(object)__instance == (Object)(object)GetReservedSprayPaint(__instance.playerHeldBy) && !ConfigSettings.hideSprayPaintMeshWaist.Value && !ReservedItemPatcher.ReservedItemIsBeingGrabbed(__instance) && !ReservedItemPatcher.ReservedItemIsBeingGrabbed(__instance)) { enable = true; } } } [HarmonyPatch] public class SprayPaintTweaks { public static float GetSprayCanTankValue(SprayPaintItem sprayPaintItem) { return (float)Traverse.Create((object)sprayPaintItem).Field("sprayCanTank").GetValue(); } public static void SetSprayCanTankValue(SprayPaintItem sprayPaintItem, float value) { Traverse.Create((object)sprayPaintItem).Field("sprayCanTank").SetValue((object)value); } [HarmonyPatch(typeof(SprayPaintItem), "Start")] [HarmonyPrefix] public static void InitSprayPaint(SprayPaintItem __instance) { SetSprayCanTankValue(__instance, ConfigSettings.sprayPaintCapacityMultiplier.Value); } [HarmonyPatch(typeof(SprayPaintItem), "LoadItemSaveData")] [HarmonyPostfix] public static void OnLoadValues(int saveData, SprayPaintItem __instance) { float value = Mathf.Clamp(GetSprayCanTankValue(__instance) * ConfigSettings.sprayPaintCapacityMultiplier.Value, 0f, ConfigSettings.sprayPaintCapacityMultiplier.Value); SetSprayCanTankValue(__instance, value); Plugin.Log("Loading spraypaint save data. Remaining capacity: " + value); } [HarmonyPatch(typeof(SprayPaintItem), "GetItemDataToSave")] [HarmonyPostfix] public static void OnSaveValues(ref int __result, SprayPaintItem __instance) { __result = (int)Mathf.Clamp((float)__result / ConfigSettings.sprayPaintCapacityMultiplier.Value, 0f, 100f); } } } namespace ReservedSprayPaintSlot.Config { public static class ConfigSettings { public static ConfigEntry<bool> hideSprayPaintMeshWaist; public static ConfigEntry<float> sprayPaintCapacityMultiplier; public static void BindConfigSettings() { Plugin.Log("BindingConfigs"); hideSprayPaintMeshWaist = ((BaseUnityPlugin)Plugin.instance).Config.Bind<bool>("Client", "HideSprayPaintOnWaist", false, "Hides the spray paint mesh while on your waist."); sprayPaintCapacityMultiplier = ((BaseUnityPlugin)Plugin.instance).Config.Bind<float>("Client", "SprayPaintCapacityMultiplier", 10f, "Extends the max capacity of spraypaint cans by this multiplier. This setting will soon be host only, and will sync with all non-host clients."); sprayPaintCapacityMultiplier.Value = Mathf.Max(sprayPaintCapacityMultiplier.Value, 0f); } } }