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 Vanaheim v1.0.0
Vanaheim.dll
Decompiled 16 hours agousing System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; 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("Vanaheim")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("HP")] [assembly: AssemblyProduct("Vanaheim")] [assembly: AssemblyCopyright("Copyright © HP 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("75197ad0-6f9f-4b64-9c56-795ccdd26874")] [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 Vanaheim; public class Class1 { } internal class Class2 { } [BepInPlugin("vanaheim.havstormr", "Vanaheim - Havstormr", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class VanaheimPlugin : BaseUnityPlugin { private const string PluginGuid = "vanaheim.havstormr"; private const string PluginName = "Vanaheim - Havstormr"; private const string PluginVersion = "1.0.0"; private void Awake() { PrefabManager.OnVanillaPrefabsAvailable += CreatePrefabs; } private void LoadDeadSerpentRock() { //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Expected O, but got Unknown string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location); string text = Path.Combine(directoryName, "deadserpentbundle"); ((BaseUnityPlugin)this).Logger.LogInfo((object)("Looking for bundle at: " + text)); AssetBundle val = AssetBundle.LoadFromFile(text); if ((Object)(object)val == (Object)null) { ((BaseUnityPlugin)this).Logger.LogError((object)"Failed to load deadserpentbundle."); return; } ((BaseUnityPlugin)this).Logger.LogInfo((object)"Loaded deadserpentbundle."); GameObject val2 = val.LoadAsset<GameObject>("DeadSerpent_Rock"); if ((Object)(object)val2 == (Object)null) { ((BaseUnityPlugin)this).Logger.LogError((object)"Failed to load prefab named DeadSerpent_Rock from bundle."); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Assets inside bundle:"); string[] allAssetNames = val.GetAllAssetNames(); foreach (string text2 in allAssetNames) { ((BaseUnityPlugin)this).Logger.LogInfo((object)text2); } } else { ((Object)val2).name = "DeadSerpent_Rock"; CustomPrefab val3 = new CustomPrefab(val2, false); PrefabManager.Instance.AddPrefab(val3); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Registered prefab: DeadSerpent_Rock"); } } private void CreatePrefabs() { CreateHavstormrTrophy(); CreateStormpiercerBow(); CreateHavstormr(); CreateStormDrake(); CreateStormSerpent(); LoadDeadSerpentRock(); PrefabManager.OnVanillaPrefabsAvailable -= CreatePrefabs; } private void CreateHavstormr() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) GameObject val = PrefabManager.Instance.CreateClonedPrefab("Havstormr", "Dragon"); val.transform.localScale = Vector3.one * 1.5f; Character component = val.GetComponent<Character>(); if ((Object)(object)component != (Object)null) { component.m_name = "Havstormr, the Abyssal Tyrant"; component.m_health = 10000f; component.m_defeatSetGlobalKey = ""; component.m_defeatSetGlobalKey = null; component.m_bossEvent = ""; ConfigureResistances(component); } TintObject(val, new Color(0.05f, 0.12f, 0.35f, 1f)); ConfigureHavstormrDrops(val); HavstormrController havstormrController = val.AddComponent<HavstormrController>(); havstormrController.StormEnvironment = "ThunderStorm"; havstormrController.DrakeAddPrefab = "Havstormr_Drake"; havstormrController.SerpentAddPrefab = "Havstormr_Serpent"; PrefabManager.Instance.AddPrefab(val); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Created Havstormr prefab."); } private void CreateStormDrake() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) GameObject val = PrefabManager.Instance.CreateClonedPrefab("Havstormr_Drake", "Hatchling"); val.transform.localScale = Vector3.one * 1.1f; Character component = val.GetComponent<Character>(); if ((Object)(object)component != (Object)null) { component.m_name = "Storm Drake"; component.m_health = 325f; } TintObject(val, new Color(0.1f, 0.25f, 0.65f, 1f)); PrefabManager.Instance.AddPrefab(val); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Created Havstormr_Drake prefab."); } private void CreateStormSerpent() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) GameObject val = PrefabManager.Instance.CreateClonedPrefab("Havstormr_Serpent", "Serpent"); val.transform.localScale = Vector3.one * 0.8f; Character component = val.GetComponent<Character>(); if ((Object)(object)component != (Object)null) { component.m_name = "Abyssal Serpent"; component.m_health = 650f; } TintObject(val, new Color(0.02f, 0.08f, 0.22f, 1f)); PrefabManager.Instance.AddPrefab(val); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Created Havstormr_Serpent prefab."); } private void CreateHavstormrTrophy() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown //IL_004b: Unknown result type (might be due to invalid IL or missing references) ItemConfig val = new ItemConfig { Name = "Havstormr Trophy", Description = "A storm-darkened trophy torn from Havstormr, the Abyssal Tyrant." }; CustomItem val2 = new CustomItem("Havstormr_Trophy", "TrophyDragonQueen", val); TintObject(val2.ItemPrefab, new Color(0.05f, 0.12f, 0.35f, 1f)); ItemManager.Instance.AddItem(val2); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Created Havstormr_Trophy item."); } private void CreateStormpiercerBow() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown ItemConfig val = new ItemConfig { Name = "Stormpiercer", Description = "A bow carved from stormbone and abyssal scale. Its arrows crackle with thunder and freezing sea-wind." }; CustomItem val2 = new CustomItem("Havstormr_Bow", "BowDraugrFang", val); ItemDrop component = val2.ItemPrefab.GetComponent<ItemDrop>(); if ((Object)(object)component != (Object)null) { component.m_itemData.m_shared.m_name = "Stormpiercer"; component.m_itemData.m_shared.m_description = "A bow carved from stormbone and abyssal scale. Its arrows crackle with thunder and freezing sea-wind."; component.m_itemData.m_shared.m_damages.m_pierce = 85f; component.m_itemData.m_shared.m_damages.m_frost = 12f; component.m_itemData.m_shared.m_damages.m_lightning = 18f; component.m_itemData.m_shared.m_damages.m_poison = 0f; component.m_itemData.m_shared.m_damages.m_spirit = 0f; component.m_itemData.m_shared.m_attackForce = 25f; component.m_itemData.m_shared.m_maxDurability = 250f; component.m_itemData.m_shared.m_useDurabilityDrain = 1f; component.m_itemData.m_shared.m_movementModifier = -0.05f; } TintStormpiercer(val2.ItemPrefab); ItemManager.Instance.AddItem(val2); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Created Havstormr_Bow item."); } private void ConfigureResistances(Character character) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0013: 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) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) DamageModifiers damageModifiers = character.m_damageModifiers; damageModifiers.m_frost = (DamageModifier)3; damageModifiers.m_lightning = (DamageModifier)3; damageModifiers.m_pierce = (DamageModifier)2; character.m_damageModifiers = damageModifiers; } private void ConfigureHavstormrDrops(GameObject boss) { CharacterDrop val = boss.GetComponent<CharacterDrop>(); if ((Object)(object)val == (Object)null) { val = boss.AddComponent<CharacterDrop>(); } val.m_drops.Clear(); AddDrop(val, "Havstormr_Trophy", 1, 1, 1f); AddDrop(val, "Havstormr_Bow", 1, 1, 0.25f); AddDrop(val, "SerpentScale", 8, 16, 1f); AddDrop(val, "Coins", 100, 250, 1f); } private void AddDrop(CharacterDrop drops, string prefabName, int min, int max, float chance) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Expected O, but got Unknown GameObject prefab = PrefabManager.Instance.GetPrefab(prefabName); if ((Object)(object)prefab == (Object)null) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Drop prefab not found: " + prefabName)); return; } drops.m_drops.Add(new Drop { m_prefab = prefab, m_amountMin = min, m_amountMax = max, m_chance = chance, m_levelMultiplier = false, m_onePerPlayer = false }); } private void TintObject(GameObject obj, Color tint) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) Renderer[] componentsInChildren = obj.GetComponentsInChildren<Renderer>(true); Renderer[] array = componentsInChildren; foreach (Renderer val in array) { Material[] materials = val.materials; foreach (Material val2 in materials) { val2.color = tint; } } } private void TintStormpiercer(GameObject bow) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) Renderer[] componentsInChildren = bow.GetComponentsInChildren<Renderer>(true); Renderer[] array = componentsInChildren; foreach (Renderer val in array) { Material[] materials = val.materials; foreach (Material val2 in materials) { val2.color = new Color(0.03f, 0.12f, 0.38f, 1f); if (val2.HasProperty("_EmissionColor")) { val2.EnableKeyword("_EMISSION"); val2.SetColor("_EmissionColor", new Color(0.05f, 0.25f, 0.75f, 1f)); } } } } } public class HavstormrController : MonoBehaviour { public string StormEnvironment = "ThunderStorm"; public string DrakeAddPrefab = "Havstormr_Drake"; public string SerpentAddPrefab = "Havstormr_Serpent"; private Character character; private float drakeTimer = 50f; private float serpentTimer = 115f; private bool deathHandled = false; private bool stormStarted = false; private void Awake() { character = ((Component)this).GetComponent<Character>(); } private void Start() { ForceStorm(); stormStarted = true; if ((Object)(object)MessageHud.instance != (Object)null) { MessageHud.instance.ShowMessage((MessageType)2, "The sea blackens beneath Havstormr's wings...", 0, (Sprite)null, false); } } private void Update() { if ((Object)(object)character == (Object)null) { return; } if (character.IsDead()) { if (!deathHandled) { deathHandled = true; ResetStorm(); if ((Object)(object)MessageHud.instance != (Object)null) { MessageHud.instance.ShowMessage((MessageType)2, "Havstormr falls. The eternal storm begins to break.", 0, (Sprite)null, false); } } return; } ForceStorm(); if (IsServer()) { drakeTimer -= Time.deltaTime; serpentTimer -= Time.deltaTime; if (drakeTimer <= 0f) { SpawnDrakes(); drakeTimer = Random.Range(45f, 60f); } if (serpentTimer <= 0f) { SpawnSerpent(); serpentTimer = Random.Range(100f, 130f); } } } private void OnDestroy() { if (stormStarted && !deathHandled) { ResetStorm(); } } private bool IsServer() { return (Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsServer(); } private void ForceStorm() { if ((Object)(object)EnvMan.instance != (Object)null) { EnvMan.instance.m_debugEnv = StormEnvironment; } } private void ResetStorm() { if ((Object)(object)EnvMan.instance != (Object)null) { EnvMan.instance.m_debugEnv = ""; } } private void SpawnDrakes() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) int num = Random.Range(1, 3); for (int i = 0; i < num; i++) { Vector3 val = Random.insideUnitSphere * 14f; val.y = Random.Range(4f, 8f); SpawnPrefab(DrakeAddPrefab, ((Component)this).transform.position + val, Quaternion.identity); } if ((Object)(object)MessageHud.instance != (Object)null) { MessageHud.instance.ShowMessage((MessageType)1, "Storm drakes descend from the clouds.", 0, (Sprite)null, false); } } private void SpawnSerpent() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Random.insideUnitSphere * 22f; val.y = 0f; SpawnPrefab(SerpentAddPrefab, ((Component)this).transform.position + val, Quaternion.identity); if ((Object)(object)MessageHud.instance != (Object)null) { MessageHud.instance.ShowMessage((MessageType)1, "Something coils beneath the waves...", 0, (Sprite)null, false); } } private void SpawnPrefab(string prefabName, Vector3 position, Quaternion rotation) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)ZNetScene.instance == (Object)null)) { GameObject prefab = ZNetScene.instance.GetPrefab(prefabName); if ((Object)(object)prefab == (Object)null) { Debug.LogError((object)("Could not find prefab: " + prefabName)); } else { Object.Instantiate<GameObject>(prefab, position, rotation); } } } }