Please disclose if your mod was created primarily 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 OdinIsFroggyB v1.0.4
BepInEx/plugins/OdinIsFroggyB/OdinIsFroggyB.dll
Decompiled 10 months agousing System; using System.Collections; 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 Jotunn.Managers; 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(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("OdinIsFroggyB")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("OdinIsFroggyB")] [assembly: AssemblyTitle("OdinIsFroggyB")] [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.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } [BepInPlugin("com.TA.odinreplacer", "Odin is Froggy B", "1.0.5")] public class OdinReplacer : BaseUnityPlugin { private AssetBundle myBundle; private GameObject froggyModel; private void Awake() { PrefabManager.OnVanillaPrefabsAvailable += delegate { LoadAssets(); ((MonoBehaviour)this).StartCoroutine(WaitAndReplaceOdin()); }; ((BaseUnityPlugin)this).Logger.LogInfo((object)"OdinReplacer initialized with prefab patching!"); } private void LoadAssets() { try { string text = Path.Combine(Paths.PluginPath, "ExtinctPandas-OdinIsFroggyB", "OdinIsFroggyB", "froggyb"); ((BaseUnityPlugin)this).Logger.LogInfo((object)("Attempting to load AssetBundle from: " + text)); myBundle = AssetBundle.LoadFromFile(text); if ((Object)(object)myBundle == (Object)null) { ((BaseUnityPlugin)this).Logger.LogError((object)"Failed to load AssetBundle."); return; } froggyModel = myBundle.LoadAsset<GameObject>("assets/froggy_b.fbx"); if ((Object)(object)froggyModel == (Object)null) { ((BaseUnityPlugin)this).Logger.LogError((object)"Failed to load 'froggy_b.fbx' from AssetBundle."); myBundle.Unload(false); } else { ((BaseUnityPlugin)this).Logger.LogInfo((object)"Froggy model loaded successfully!"); } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Error loading assets: " + ex.Message)); } } private IEnumerator WaitAndReplaceOdin() { while ((Object)(object)ZNetScene.instance == (Object)null) { yield return null; } ReplaceOdinPrefab(); } private void ReplaceOdinPrefab() { //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)froggyModel == (Object)null) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"Froggy model not loaded; cannot replace Odin."); return; } GameObject prefab = ZNetScene.instance.GetPrefab("odin"); if ((Object)(object)prefab == (Object)null) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"Odin prefab not found in ZNetScene."); return; } Transform val = FindVisualTransform(prefab.transform); if ((Object)(object)val != (Object)null) { ((BaseUnityPlugin)this).Logger.LogInfo((object)"Replacing Odin's visual in prefab..."); Object.DestroyImmediate((Object)(object)((Component)val).gameObject); GameObject val2 = Object.Instantiate<GameObject>(froggyModel); ((Object)val2).name = "Visual"; val2.transform.SetParent(prefab.transform, false); val2.transform.localPosition = new Vector3(0f, 1f, 0f); val2.transform.localRotation = Quaternion.identity; val2.transform.localScale = Vector3.one * 500f; val2.SetActive(true); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Odin prefab successfully replaced with Froggy!"); } else { ((BaseUnityPlugin)this).Logger.LogWarning((object)"Could not find original visual to replace in Odin prefab."); } } private Transform FindVisualTransform(Transform parent) { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Expected O, but got Unknown Transform val = parent.Find("Visual") ?? parent.Find("visual"); if ((Object)(object)val != (Object)null) { return val; } val = parent.Find("Model") ?? parent.Find("model"); if ((Object)(object)val != (Object)null) { return val; } foreach (Transform item in parent) { Transform val2 = item; if ((Object)(object)((Component)val2).GetComponent<Renderer>() != (Object)null) { return val2; } } return null; } private void OnDestroy() { if ((Object)(object)myBundle != (Object)null) { myBundle.Unload(true); } } }