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 Sluggle v1.0.0
Sluggle.dll
Decompiled a year agousing System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using HarmonyLib; 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(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("Sluggle")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("Sluggle")] [assembly: AssemblyTitle("Sluggle")] [assembly: AssemblyVersion("1.0.0.0")] namespace Sluggle; [BepInPlugin("Ginja.Sluggle", "Sluggle", "1.0.0")] public class SluggleLoader : BaseUnityPlugin { private readonly Harmony harmony = new Harmony("Ginja.Sluggle"); internal static SluggleLoader instance; internal static GameObject SluggleModel; private void Awake() { ((BaseUnityPlugin)this).Logger.LogInfo((object)"Loading Sluggle Model"); if ((Object)(object)instance == (Object)null) { instance = this; harmony.PatchAll(); string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location); string text = Path.Combine(directoryName, "slugglemodel"); AssetBundle val = AssetBundle.LoadFromFile(text); if ((Object)(object)val == (Object)null) { ((BaseUnityPlugin)this).Logger.LogError((object)"Failed to load asset bundle!"); return; } SluggleModel = val.LoadAsset<GameObject>("Sluggle"); if ((Object)(object)SluggleModel == (Object)null) { ((BaseUnityPlugin)this).Logger.LogError((object)"Failed to load replacement models!"); } else { ((BaseUnityPlugin)this).Logger.LogInfo((object)"Successfully loaded Sluggle Model"); } } else { Object.Destroy((Object)(object)((Component)this).gameObject); } } } [HarmonyPatch(typeof(ValuableObject))] internal class SlugglePatch { private static readonly ManualLogSource Logger = Logger.CreateLogSource("SluggleLoader"); [HarmonyPatch("Start")] [HarmonyPostfix] private static void ReplaceSluggle(ValuableObject __instance) { Logger.LogInfo((object)"Starting Loading Proccess"); if ((Object)(object)SluggleLoader.SluggleModel == (Object)null) { Logger.LogError((object)"Sluggle Model Missing. Using Original Model"); return; } Transform val = FindDeepChild(((Component)__instance).transform, "Ocarina"); if ((Object)(object)val == (Object)null) { Logger.LogWarning((object)"Ocarina Model Not Found"); return; } ReplaceOcarina(val, SluggleLoader.SluggleModel, __instance); Logger.LogInfo((object)"Model Replaced"); } private static Transform FindDeepChild(Transform parent, string name) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown foreach (Transform item in parent) { Transform val = item; if (((Object)val).name == name) { return val; } Transform val2 = FindDeepChild(val, name); if ((Object)(object)val2 != (Object)null) { return val2; } } return null; } private static void ReplaceOcarina(Transform oldmodel, GameObject newModelPrefab, ValuableObject visuals) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) GameObject val = Object.Instantiate<GameObject>(newModelPrefab, oldmodel.parent); val.transform.SetPositionAndRotation(oldmodel.position, oldmodel.rotation); val.layer = ((Component)oldmodel).gameObject.layer; Object.Destroy((Object)(object)((Component)oldmodel).gameObject); } }