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 SprayModV v1.0.1
BepInEx/plugins/SprayMod/SprayMod.dll
Decompiled 2 years agousing System; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using Microsoft.CodeAnalysis; 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("IvitoDev")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.1.0")] [assembly: AssemblyInformationalVersion("1.0.1")] [assembly: AssemblyProduct("GraffitiMod")] [assembly: AssemblyTitle("GraffitiMod")] [assembly: AssemblyVersion("1.0.1.0")] [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 SprayMod { [BepInPlugin("IvitoDev.SprayMod", "Spray Mod", "1.0.0")] public class SprayMod : BaseUnityPlugin { private Texture2D sprayTexture = null; private string selectedImageName = string.Empty; private ConfigEntry<string> sprayImageEntry = null; private ConfigEntry<bool> openFolderFlag = null; private ConfigEntry<bool> refreshFlag = null; private string imagesFolderPath = null; private string[] availableImages = Array.Empty<string>(); private void Awake() { imagesFolderPath = Path.Combine(Paths.PluginPath, "SprayMod", "Images"); Directory.CreateDirectory(imagesFolderPath); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Spray Mod loaded. Press T to place spray. Use config toggles to open folder or refresh."); UpdateImageList(); InitConfigEntries(); } private void InitConfigEntries() { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown string text = availableImages.FirstOrDefault() ?? ""; sprayImageEntry = ((BaseUnityPlugin)this).Config.Bind<string>("Spray", "Image", text, new ConfigDescription("Select the spray image (PNG or JPG).", (AcceptableValueBase)(object)new AcceptableValueList<string>(availableImages), Array.Empty<object>())); sprayImageEntry.SettingChanged += delegate { LoadSelectedSpray(); }; openFolderFlag = ((BaseUnityPlugin)this).Config.Bind<bool>("Spray", "Open Spray Folder", false, "Turn ON to open the spray folder. It will turn OFF automatically."); refreshFlag = ((BaseUnityPlugin)this).Config.Bind<bool>("Spray", "Refresh Spray List", false, "Turn ON to refresh image list. Then close and reopen this menu to update the dropdown."); selectedImageName = sprayImageEntry.Value; LoadSelectedSpray(); } private void Update() { if (Input.GetKeyDown((KeyCode)116) && (Object)(object)sprayTexture != (Object)null) { TryPlaceSpray(); } if (Input.GetKeyDown((KeyCode)288)) { RefreshImagesManually(); } if (openFolderFlag.Value) { OpenImagesFolder(); openFolderFlag.Value = false; } if (refreshFlag.Value) { RefreshImagesManually(); refreshFlag.Value = false; } } private void OpenImagesFolder() { ((BaseUnityPlugin)this).Logger.LogInfo((object)"Opening spray image folder..."); try { Process.Start(new ProcessStartInfo { FileName = imagesFolderPath, UseShellExecute = true }); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Could not open folder: " + ex.Message)); } } private void RefreshImagesManually() { ((BaseUnityPlugin)this).Logger.LogInfo((object)"Refreshing spray image list..."); UpdateImageList(); UpdateSprayConfigEntry(); } private void UpdateImageList() { try { availableImages = (from f in Directory.GetFiles(imagesFolderPath) where f.EndsWith(".png") || f.EndsWith(".jpg") select f).Select(Path.GetFileName).ToArray(); ((BaseUnityPlugin)this).Logger.LogInfo((object)$"Found {availableImages.Length} spray image(s)."); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Error reading spray folder: " + ex.Message)); } } private void UpdateSprayConfigEntry() { //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Expected O, but got Unknown string text = sprayImageEntry.Value; string text2 = availableImages.FirstOrDefault() ?? ""; if (!availableImages.Contains(text)) { text = text2; } ConfigDefinition definition = ((ConfigEntryBase)sprayImageEntry).Definition; ((BaseUnityPlugin)this).Config.Remove(definition); sprayImageEntry = ((BaseUnityPlugin)this).Config.Bind<string>(definition.Section, definition.Key, text, new ConfigDescription("Select the spray image (PNG or JPG).", (AcceptableValueBase)(object)new AcceptableValueList<string>(availableImages), Array.Empty<object>())); sprayImageEntry.SettingChanged += delegate { LoadSelectedSpray(); }; selectedImageName = sprayImageEntry.Value; LoadSelectedSpray(); } private void LoadSelectedSpray() { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown try { string path = Path.Combine(imagesFolderPath, sprayImageEntry.Value); if (!File.Exists(path)) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Spray image not found: " + sprayImageEntry.Value)); return; } byte[] array = File.ReadAllBytes(path); sprayTexture = new Texture2D(2, 2); if (!ImageConversion.LoadImage(sprayTexture, array)) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"Failed to load image data."); } else { ((BaseUnityPlugin)this).Logger.LogInfo((object)("Spray image loaded: " + sprayImageEntry.Value)); } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Failed to load spray texture: " + ex.Message)); } } private void TryPlaceSpray() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Expected O, but got Unknown Camera main = Camera.main; if (!((Object)(object)main == (Object)null)) { Ray val = main.ViewportPointToRay(new Vector3(0.5f, 0.5f)); RaycastHit val2 = default(RaycastHit); if (Physics.Raycast(val, ref val2, 3f)) { GameObject val3 = GameObject.CreatePrimitive((PrimitiveType)5); val3.transform.position = ((RaycastHit)(ref val2)).point + ((RaycastHit)(ref val2)).normal * 0.01f; val3.transform.rotation = Quaternion.LookRotation(-((RaycastHit)(ref val2)).normal, Vector3.up); val3.transform.localScale = new Vector3(1.2f, 1.2f, 1f); Object.Destroy((Object)(object)val3.GetComponent<Collider>()); Shader val4 = Shader.Find("Sprites/Default"); Material material = new Material(val4) { mainTexture = (Texture)(object)sprayTexture }; val3.GetComponent<Renderer>().material = material; Object.Destroy((Object)(object)val3, 5f); ((BaseUnityPlugin)this).Logger.LogInfo((object)("Spray placed: " + selectedImageName)); } else { ((BaseUnityPlugin)this).Logger.LogWarning((object)"No valid surface found to place spray."); } } } } }