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 ThereAreDogs v1.0.5
ThereAreDogs.dll
Decompiled 11 months agousing System; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using HarmonyLib; 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: IgnoresAccessChecksTo("")] [assembly: AssemblyCompany("Vegetius-s")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+5ba893ccfaa57dd36d1aca4b51d41819546840ee")] [assembly: AssemblyProduct("ThereAreDogs")] [assembly: AssemblyTitle("ThereAreDogs")] [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 ThereAreDogs { [HarmonyPatch(typeof(PlayerController))] internal static class TADPatch { internal static bool ShopIsCurrentLevel; [HarmonyPostfix] [HarmonyPatch("Start")] private static void Start_Postfix(PlayerController __instance) { ShopIsCurrentLevel = IsShopLevel(); if (ShopIsCurrentLevel) { InsertDogs(); } } public static void InsertDogs() { //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: 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_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) if (!ShopIsCurrentLevel) { ThereAreDogs.Logger.LogWarning((object)"Tried to insert dog but current level is not shop"); return; } string directoryName = Path.GetDirectoryName(typeof(ThereAreDogs).Assembly.Location); string[] files = new string[3] { "good_boy.png", "confession.jpg", "meekodrip.png" }; Vector3[] positions = (Vector3[])(object)new Vector3[3] { new Vector3(-20f, 1f, 0f), new Vector3(20f, 3.5f, 3f), new Vector3(0f, 1.9f, 20f) }; float[] rotations = new float[3] { 90f, 90f, 0f }; Vector3[] scales = (Vector3[])(object)new Vector3[3] { new Vector3(1f, 1f, 1f), new Vector3(1f, 1f, 1f), new Vector3(0.25f, 0.25f, 0.25f) }; try { InsertObjects(directoryName, files, positions, rotations, scales); ThereAreDogs.Logger.LogInfo((object)"Dogs have been inserted."); } catch (Exception ex) { ThereAreDogs.Logger.LogError((object)ex.Message); } } private static void InsertObjects(string folder, string[] files, Vector3[] positions, float[] rotations, Vector3[] scales) { //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Expected O, but got Unknown //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) if (positions.Length == 0 || files.Length == 0 || positions.Length == 0 || scales.Length == 0) { throw new Exception("One or more arrays are empty."); } if (positions.Length < files.Length || rotations.Length < files.Length || scales.Length < files.Length) { throw new Exception("Array sizes do not match."); } for (int i = 0; i < files.Length; i++) { string text = Path.Combine(folder, files[i]); if (!File.Exists(text)) { ThereAreDogs.Logger.LogWarning((object)("Failed to load file: " + text)); continue; } Sprite val = LoadSpriteFromFile(text); if (!((Object)(object)val == (Object)null)) { GameObject val2 = new GameObject(files[i]); SpriteRenderer val3 = val2.AddComponent<SpriteRenderer>(); val3.sprite = val; val2.transform.position = positions[i]; val2.transform.rotation = Quaternion.Euler(0f, rotations[i], 0f); val2.transform.localScale = scales[i]; ThereAreDogs.Logger.LogInfo((object)("The dog: " + text + " was successfully inserted.")); } } } private static Sprite? LoadSpriteFromFile(string path) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) if (!File.Exists(path)) { ThereAreDogs.Logger.LogWarning((object)(path + "doesn't exist.")); return null; } byte[] array = File.ReadAllBytes(path); Texture2D val = new Texture2D(2, 2); if (!ImageConversion.LoadImage(val, array)) { ThereAreDogs.Logger.LogWarning((object)("Failed to load image data from: " + path)); return null; } return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f)); } private static bool IsShopLevel() { GameObject val = GameObject.Find("Run Manager"); if ((Object)(object)val == (Object)null) { ThereAreDogs.Logger.LogWarning((object)"Run Manager GameObject not found."); return false; } Type type = ((object)val.GetComponent<MonoBehaviour>())?.GetType(); if (type == null) { ThereAreDogs.Logger.LogWarning((object)"Run Manager component not found."); return false; } Component component = val.GetComponent(type); object obj = type.GetField("levelCurrent", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(component); if (obj == null) { ThereAreDogs.Logger.LogWarning((object)"levelCurrent field is null."); return false; } Type type2 = obj.GetType(); string text = null; FieldInfo field = type2.GetField("NarrativeName", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { text = field.GetValue(obj) as string; } if (string.IsNullOrEmpty(text)) { PropertyInfo property = type2.GetProperty("NarrativeName", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (property != null) { text = property.GetValue(obj) as string; } } ThereAreDogs.Logger.LogInfo((object)("Current level narrativeName: '" + text + "'")); if (text == "Service Station") { return true; } return false; } } [BepInPlugin("ThereAreDogs", "There Are Dogs", "1.0.5")] public class ThereAreDogs : BaseUnityPlugin { internal static ThereAreDogs Instance { get; private set; } internal static ManualLogSource Logger => Instance._logger; private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger; internal Harmony? Harmony { get; set; } private void Awake() { Instance = this; ((Component)this).gameObject.transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; Patch(); Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!"); } internal void Patch() { //IL_001a: 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) //IL_0021: Expected O, but got Unknown //IL_0026: Expected O, but got Unknown if (Harmony == null) { Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID); Harmony val2 = val; Harmony = val; } Harmony.PatchAll(typeof(TADPatch)); } internal void Unpatch() { Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } } } }