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 WaterWalkingPotion v1.0.0
WaterWalkingPotion/JotunnModStub.dll
Decompiled 2 years agousing System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security.Permissions; using BepInEx; using HarmonyLib; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; 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("WaterWalkingPotion")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("WaterWalkingPotion")] [assembly: AssemblyCopyright("Copyright © 2021")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")] [assembly: AssemblyFileVersion("0.0.1.0")] [assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.1.0")] namespace WaterWalkingPotion; [BepInPlugin("TeamEdward.Mastersimrad.WaterWalkingPotion", "WaterWalkingPotion", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] internal class WaterWalkingPotion : BaseUnityPlugin { public const string PluginGUID = "TeamEdward.Mastersimrad.WaterWalkingPotion"; public const string PluginName = "WaterWalkingPotion"; public const string PluginVersion = "1.0.0"; private CustomStatusEffect WaterWalkingEffect; private Harmony _harmony; private string WWIconPath; private void Awake() { AddStatusEffects(); PrefabManager.OnVanillaPrefabsAvailable += AddClonedItems; _harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "TeamEdward.Mastersimrad.WaterWalkingPotion"); } private void AddClonedItems() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Expected O, but got Unknown //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown ItemConfig val = new ItemConfig(); val.Name = "Water Walking Potion"; val.Description = "Allows the user to walk across the surface of water for 10 seconds by concentrating the natural water resistance found in necks"; val.CraftingStation = "opalchemy"; val.AddRequirement(new RequirementConfig("TrophyNeck", 1, 0, false)); val.AddRequirement(new RequirementConfig("MushroomYellow", 1, 0, false)); CustomItem val2 = new CustomItem("WaterWalkingPotion", "MeadEitrMinor", val); ItemManager.Instance.AddItem(val2); val2.ItemDrop.m_itemData.m_shared.m_consumeStatusEffect = WaterWalkingEffect.StatusEffect; PrefabManager.OnVanillaPrefabsAvailable -= AddClonedItems; } private void AddStatusEffects() { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Expected O, but got Unknown StatusEffect val = (StatusEffect)(object)ScriptableObject.CreateInstance<SE_WaterWalking>(); ((Object)val).name = "Water Walking"; val.m_name = "Water Walking"; WWIconPath = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "Assets/WaterWalking.png"); val.m_icon = AssetUtils.LoadSpriteFromFile(WWIconPath); val.m_startMessageType = (MessageType)2; val.m_startMessage = "Jesus"; val.m_stopMessageType = (MessageType)2; val.m_stopMessage = "Judas"; val.m_ttl = 10f; val.m_flashIcon = true; WaterWalkingEffect = new CustomStatusEffect(val, false); ItemManager.Instance.AddStatusEffect(WaterWalkingEffect); } } public class SE_WaterWalking : StatusEffect { public override void Setup(Character character) { WaterWalking.isWaterWalking = true; WaterWalking.isOnWater = false; ((StatusEffect)this).Setup(character); } public override void Stop() { WaterWalking.isWaterWalking = false; WaterWalking.isOnWater = false; ((StatusEffect)this).Stop(); } } public static class WaterWalking { [HarmonyPatch(typeof(Character), "IsSwimming")] public static class Character_IsSwimming_Patch { public static bool Prefix(Character __instance, ref bool __result) { if (__instance.IsPlayer() && isWaterWalking) { __result = false; return false; } return true; } } [HarmonyPatch(typeof(Character), "IsOnGround")] public static class Character_IsOnGround_Patch { public static bool Prefix(Character __instance, ref bool __result) { if (__instance.IsPlayer() && isWaterWalking && isOnWater) { __result = true; return false; } return true; } } [HarmonyPatch(typeof(Character), "UpdateGroundContact")] public static class Character_UpdateGroundContact_Patch { public static void Prefix(Character __instance) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) if (__instance.IsPlayer() && isWaterWalking && isOnWater) { Player val = (Player)(object)((__instance is Player) ? __instance : null); if (val != null) { SetPositionToWaterLevel(__instance); __instance.m_body.velocity = Vector3.zero; } } } } [HarmonyPatch(typeof(Character), "ApplyGroundForce")] public static class Character_ApplyGroundForce_Patch { public static bool Prefix(Character __instance, ref Vector3 vel) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) isOnWater = false; if (__instance.IsPlayer()) { Player val = (Player)(object)((__instance is Player) ? __instance : null); if (val != null) { if (__instance.m_body.position.y > 4500f) { isOnWater = false; return true; } float waterLevel = __instance.m_waterLevel; isOnWater = waterLevel > __instance.m_body.position.y; if (isWaterWalking && isOnWater) { vel.y = Mathf.Max(0f, vel.y); if (vel.y <= 0f) { SetPositionToWaterLevel(__instance); } __instance.m_maxAirAltitude = -1000f; __instance.ResetGroundContact(); } return !isOnWater || !isWaterWalking; } } return true; } } [HarmonyPatch(typeof(Character), "ApplySlide")] public static class Character_ApplySlide_Patch { public static bool Prefix(Character __instance) { if (__instance.IsPlayer() && isWaterWalking) { __instance.m_sliding = false; __instance.m_slippage = 0f; return false; } return true; } } public static bool isWaterWalking; public static bool isOnWater; public static void SetPositionToWaterLevel(Character __instance) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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) __instance.m_body.position = new Vector3(__instance.m_body.position.x, __instance.m_waterLevel, __instance.m_body.position.z); } }