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 Mining Caves v0.3.0
Plugins/VentureValheim.MiningCaves.dll
Decompiled 5 days agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("VentureValheim.MiningCaves")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("VentureValheim.MiningCaves")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("291F2F3D-B629-453D-AF1A-1A7C815758DE")] [assembly: AssemblyFileVersion("0.3.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.3.0.0")] [module: UnverifiableCode] 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; } } } public class VV_VariableLiquidVolume : WaterVolume { public LiquidType VariableLiquidType; public EffectList RandomEffectList = new EffectList(); public float RandomEffectInterval = 3f; private float randomEffectTimer; private float randomEffectIntervalInternal; public float Width = 10f; public float Length = 10f; public float Scale = 1f; private void Update() { UpdateEffects(Time.deltaTime); } private void UpdateEffects(float dt) { //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) if (RandomEffectList.HasEffects() && !(RandomEffectInterval <= 0f) && !(base.m_forceDepth < 0.2f)) { randomEffectTimer += dt; if (!(randomEffectTimer < randomEffectIntervalInternal)) { randomEffectIntervalInternal = Random.Range(RandomEffectInterval * 0.5f, RandomEffectInterval); randomEffectTimer = 0f; float num = Width / 2f; float num2 = Length / 2f; Vector3 val = new Vector3(Random.Range(0f - num, num), 0f, Random.Range(0f - num2, num2)) + ((Component)this).transform.position; float waterSurface = ((WaterVolume)this).GetWaterSurface(val, 1f); val.y = waterSurface; RandomEffectList.Create(val, Quaternion.identity, (Transform)null, 1f, -1); } } } } namespace VentureValheim.MiningCaves { [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("com.orianaventure.mod.MiningCaves", "MiningCaves", "0.3.0")] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public class MiningCavesPlugin : BaseUnityPlugin { private const string ModName = "MiningCaves"; private const string ModVersion = "0.3.0"; private const string Author = "com.orianaventure.mod"; private const string ModGUID = "com.orianaventure.mod.MiningCaves"; private readonly Harmony HarmonyInstance = new Harmony("com.orianaventure.mod.MiningCaves"); public static readonly ManualLogSource MiningCavesLogger = Logger.CreateLogSource("MiningCaves"); private static string ConfigFileName = "com.orianaventure.mod.MiningCaves.cfg"; private static string ConfigFileFullPath; public static GameObject Root; public static ConfigEntry<bool> CE_AdminBypass; public static ConfigEntry<bool> CE_LockTerrain; public static ConfigEntry<string> CE_LockTerrainIgnoreItems; public static ConfigEntry<bool> CE_RemoveSilverWishbonePing; internal static AssetBundle CavesBundle; private readonly ConfigurationManagerAttributes AdminConfig = new ConfigurationManagerAttributes { IsAdminOnly = true }; private readonly ConfigurationManagerAttributes ClientConfig = new ConfigurationManagerAttributes { IsAdminOnly = false }; private DateTime _lastReloadTime; private const long RELOAD_DELAY = 10000000L; public static bool GetLockTerrain() { if (CE_AdminBypass.Value && SynchronizationManager.Instance.PlayerIsAdmin) { return false; } return CE_LockTerrain.Value; } public static string GetLockTerrainIgnoreItems() { return CE_LockTerrainIgnoreItems.Value; } public static bool GetRemoveSilverWishbonePing() { return CE_RemoveSilverWishbonePing.Value; } private void AddConfig<T>(string key, string section, string description, bool synced, T value, ref ConfigEntry<T> configEntry) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown string extendedDescription = GetExtendedDescription(description, synced); configEntry = ((BaseUnityPlugin)this).Config.Bind<T>(section, key, value, new ConfigDescription(extendedDescription, (AcceptableValueBase)null, new object[1] { synced ? AdminConfig : ClientConfig })); } public string GetExtendedDescription(string description, bool synchronizedSetting) { return description + (synchronizedSetting ? " [Synced with Server]" : " [Not Synced with Server]"); } public void Awake() { //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected O, but got Unknown AddConfig("AdminBypass", "General", "True to allow admins to bypass settings (boolean)", synced: true, value: false, ref CE_AdminBypass); AddConfig("LockTerrain", "General", "True to restrict actions that would alter the terrain such as mining or flattening (boolean)", synced: true, value: false, ref CE_LockTerrain); AddConfig("LockTerrainIgnoreItems", "General", "Prefab names of items to ignore for the terrain locking feature (comma-separated)", synced: true, "", ref CE_LockTerrainIgnoreItems); AddConfig("RemoveSilverWishbonePing", "General", "True to always remove the wishbone ping from silver veins (boolean)", synced: true, value: false, ref CE_RemoveSilverWishbonePing); ZoneManager.OnVanillaLocationsAvailable += CaveManager.AddMiningCaves; PrefabManager.OnVanillaPrefabsAvailable += CaveManager.AddPrefabs; Root = new GameObject("MiningCavesRoot"); Root.SetActive(false); Object.DontDestroyOnLoad((Object)(object)Root); MiningCavesLogger.LogInfo((object)"So you're mining stuff to craft with and crafting stuff to mine with?"); Assembly executingAssembly = Assembly.GetExecutingAssembly(); HarmonyInstance.PatchAll(executingAssembly); SetupWatcher(); CavesBundle = AssetUtils.LoadAssetBundleFromResources("vv_miningcaves", Assembly.GetExecutingAssembly()); } private void OnDestroy() { ((BaseUnityPlugin)this).Config.Save(); } private void SetupWatcher() { FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(Paths.ConfigPath, ConfigFileName); fileSystemWatcher.Changed += ReadConfigValues; fileSystemWatcher.Created += ReadConfigValues; fileSystemWatcher.Renamed += ReadConfigValues; fileSystemWatcher.IncludeSubdirectories = true; fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject; fileSystemWatcher.EnableRaisingEvents = true; } private void ReadConfigValues(object sender, FileSystemEventArgs e) { DateTime now = DateTime.Now; long num = now.Ticks - _lastReloadTime.Ticks; if (File.Exists(ConfigFileFullPath) && num >= 10000000) { try { MiningCavesLogger.LogInfo((object)"Attempting to reload configuration..."); ((BaseUnityPlugin)this).Config.Reload(); } catch { MiningCavesLogger.LogError((object)("There was an issue loading " + ConfigFileName)); } _lastReloadTime = now; if ((Object)(object)ZNet.instance != (Object)null && !ZNet.instance.IsDedicated()) { TerrainManager.ApplyTerrainLocking(); } } } static MiningCavesPlugin() { string configPath = Paths.ConfigPath; char directorySeparatorChar = Path.DirectorySeparatorChar; ConfigFileFullPath = configPath + directorySeparatorChar + ConfigFileName; CE_AdminBypass = null; CE_LockTerrain = null; CE_LockTerrainIgnoreItems = null; CE_RemoveSilverWishbonePing = null; } } public class CaveManager { public static void AddPrefabs() { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected O, but got Unknown //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Expected O, but got Unknown GameObject prefab = PrefabManager.Instance.GetPrefab("rock4_copper_frac"); if ((Object)(object)prefab != (Object)null) { TerrainModifier[] componentsInChildren = prefab.gameObject.GetComponentsInChildren<TerrainModifier>(); for (int i = 0; i < componentsInChildren.Length; i++) { ((Behaviour)componentsInChildren[i]).enabled = false; } } PrefabManager.Instance.AddPrefab(new CustomPrefab(MiningCavesPlugin.CavesBundle, "VV_rock4_copper", true)); PrefabManager.Instance.AddPrefab(new CustomPrefab(MiningCavesPlugin.CavesBundle, "VV_MineRock_Copper", true)); PrefabManager.Instance.AddPrefab(new CustomPrefab(MiningCavesPlugin.CavesBundle, "VV_MineRock_Tin", true)); PrefabManager.Instance.AddPrefab(new CustomPrefab(MiningCavesPlugin.CavesBundle, "VV_MineRock_Iron", true)); PrefabManager.OnVanillaPrefabsAvailable -= AddPrefabs; } public static void AddMiningCaves() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Expected O, but got Unknown //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Expected O, but got Unknown //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Expected O, but got Unknown string text = "VV_CopperTinCave"; GameObject obj = ZoneManager.Instance.CreateLocationContainer(MiningCavesPlugin.CavesBundle, text); LocationConfig val = new LocationConfig(); val.Biome = (Biome)8; val.Quantity = 50; val.ExteriorRadius = 12f; val.HasInterior = true; val.InteriorRadius = 35f; val.MinAltitude = 3f; val.MaxAltitude = 1000f; val.Priotized = true; CustomLocation val2 = new CustomLocation(obj, true, val); ZoneManager.Instance.AddCustomLocation(val2); string text2 = "VV_SilverCave"; GameObject obj2 = ZoneManager.Instance.CreateLocationContainer(MiningCavesPlugin.CavesBundle, text2); LocationConfig val3 = new LocationConfig(); val3.Biome = (Biome)4; val3.Quantity = 50; val3.ExteriorRadius = 16f; val3.HasInterior = true; val3.InteriorRadius = 40f; val3.MinAltitude = 90f; val3.MaxAltitude = 2000f; val3.Priotized = true; val3.ClearArea = true; CustomLocation val4 = new CustomLocation(obj2, true, val3); ZoneManager.Instance.AddCustomLocation(val4); string text3 = "VV_TarCave"; GameObject obj3 = ZoneManager.Instance.CreateLocationContainer(MiningCavesPlugin.CavesBundle, text3); LocationConfig val5 = new LocationConfig(); val5.Biome = (Biome)16; val5.Quantity = 50; val5.ExteriorRadius = 25f; val5.HasInterior = true; val5.InteriorRadius = 50f; val5.MinAltitude = 10f; val5.MaxAltitude = 2000f; val5.Priotized = true; val5.MinDistanceFromSimilar = 300f; val5.ClearArea = true; CustomLocation val6 = new CustomLocation(obj3, true, val5); ZoneManager.Instance.AddCustomLocation(val6); ZoneManager.OnVanillaLocationsAvailable -= AddMiningCaves; } } public class TerrainManager { protected struct OriginalTerrainComp { public string Name; public GameObject SpawnOnHit; public List<GameObject> Pieces; public OriginalTerrainComp(string name, GameObject spawnOnHit, List<GameObject> pieces) { Name = name; SpawnOnHit = spawnOnHit; Pieces = pieces; } } [HarmonyPatch(typeof(ObjectDB), "Awake")] public static class Patch_ObjectDB_Awake { private static void Postfix() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) Scene activeScene = SceneManager.GetActiveScene(); if (((Scene)(ref activeScene)).name.Equals("main")) { _objectDBReady = true; ApplyTerrainLocking(); } else { _objectDBReady = false; } } } private const string SUFFIX = "_VVMC"; private static bool _objectDBReady = false; private static List<OriginalTerrainComp> _originalTerrainCompList = new List<OriginalTerrainComp>(); public static HashSet<string> StringToSet(string str) { HashSet<string> hashSet = new HashSet<string>(); if (!Utility.IsNullOrWhiteSpace(str)) { List<string> list = str.Split(new char[1] { ',' }).ToList(); for (int i = 0; i < list.Count; i++) { hashSet.Add(list[i].Trim()); } } return hashSet; } public static bool GetItemDrop(string name, out ItemDrop item) { item = null; if (!Utility.IsNullOrWhiteSpace(name)) { GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(StringExtensionMethods.GetStableHashCode(name)); if ((Object)(object)itemPrefab == (Object)null) { itemPrefab = ObjectDB.instance.GetItemPrefab(name); } if ((Object)(object)itemPrefab != (Object)null) { item = itemPrefab.GetComponent<ItemDrop>(); if ((Object)(object)item != (Object)null) { return true; } } } return false; } private static void RestoreOriginalValues() { foreach (OriginalTerrainComp originalTerrainComp in _originalTerrainCompList) { if (GetItemDrop(originalTerrainComp.Name, out ItemDrop item)) { item.m_itemData.m_shared.m_spawnOnHitTerrain = originalTerrainComp.SpawnOnHit; if ((Object)(object)item.m_itemData.m_shared.m_buildPieces != (Object)null) { item.m_itemData.m_shared.m_buildPieces.m_pieces = originalTerrainComp.Pieces; } } } _originalTerrainCompList = new List<OriginalTerrainComp>(); } private static bool RemoveHitTerrainFromTable(ref ItemDrop itemDrop, out List<GameObject> OriginalPieces) { bool flag = false; OriginalPieces = null; PieceTable buildPieces = itemDrop.m_itemData.m_shared.m_buildPieces; if ((Object)(object)buildPieces != (Object)null) { OriginalPieces = buildPieces.m_pieces; List<GameObject> list = new List<GameObject>(); foreach (GameObject piece in buildPieces.m_pieces) { TerrainOp component = piece.GetComponent<TerrainOp>(); if ((Object)(object)component != (Object)null) { if (component.m_settings.m_level || component.m_settings.m_smooth) { GameObject val = Object.Instantiate<GameObject>(piece, MiningCavesPlugin.Root.transform, false); ((Object)val).name = Utils.GetPrefabName(val) + "_VVMC"; TerrainOp component2 = val.GetComponent<TerrainOp>(); component2.m_settings.m_level = false; component2.m_settings.m_smooth = false; itemDrop.m_itemData.m_shared.m_spawnOnHitTerrain = val; list.Add(val); flag = true; continue; } if (component.m_settings.m_raise) { flag = true; continue; } } list.Add(piece); } if (flag) { itemDrop.m_itemData.m_shared.m_buildPieces.m_pieces = list; } } return flag; } private static bool RemoveHitTerrain(ref ItemDrop itemDrop, out GameObject original) { original = itemDrop.m_itemData.m_shared.m_spawnOnHitTerrain; if ((Object)(object)original != (Object)null) { TerrainOp component = original.GetComponent<TerrainOp>(); if ((Object)(object)component != (Object)null && (component.m_settings.m_raise || (Object)(object)component.m_spawnOnPlaced != (Object)null)) { GameObject val = Object.Instantiate<GameObject>(original, MiningCavesPlugin.Root.transform, false); ((Object)val).name = Utils.GetPrefabName(val) + "_VVMC"; TerrainOp component2 = val.GetComponent<TerrainOp>(); component2.m_settings.m_raise = false; component2.m_spawnOnPlaced = null; itemDrop.m_itemData.m_shared.m_spawnOnHitTerrain = val; return true; } } return false; } public static void ApplyTerrainLocking() { if (_objectDBReady) { RestoreOriginalValues(); if (MiningCavesPlugin.GetLockTerrain()) { RemoveToolTerrainChanges(); } if (MiningCavesPlugin.GetRemoveSilverWishbonePing() || (MiningCavesPlugin.GetLockTerrain() && Utility.IsNullOrWhiteSpace(MiningCavesPlugin.GetLockTerrainIgnoreItems()))) { RemoveWishbonePing(); } } } private static void RemoveToolTerrainChanges() { HashSet<string> hashSet = StringToSet(MiningCavesPlugin.GetLockTerrainIgnoreItems()); foreach (GameObject item in ObjectDB.instance.m_items) { if (hashSet.Contains(((Object)item).name)) { continue; } ItemDrop itemDrop = item.GetComponent<ItemDrop>(); if (!((Object)(object)itemDrop == (Object)null)) { GameObject original = null; List<GameObject> OriginalPieces = null; if (RemoveHitTerrainFromTable(ref itemDrop, out OriginalPieces) || RemoveHitTerrain(ref itemDrop, out original)) { _originalTerrainCompList.Add(new OriginalTerrainComp(((Object)item).name, original, OriginalPieces)); } } } MiningCavesPlugin.MiningCavesLogger.LogInfo((object)"Done removing terrain operations from tools."); } private static void RemoveWishbonePing() { GameObject prefab = ZNetScene.instance.GetPrefab("silvervein"); if ((Object)(object)prefab != (Object)null) { Beacon componentInChildren = prefab.GetComponentInChildren<Beacon>(); if ((Object)(object)componentInChildren != (Object)null) { Object.Destroy((Object)(object)componentInChildren); MiningCavesPlugin.MiningCavesLogger.LogInfo((object)"Done removing silver wishbone ping."); } else { MiningCavesPlugin.MiningCavesLogger.LogDebug((object)"Issue finding silvervein beacon, could not remove."); } } else { MiningCavesPlugin.MiningCavesLogger.LogDebug((object)"Issue finding silvervein. Could not remove beacon."); } } } public class WaterVolumePatches { [HarmonyPatch(typeof(WaterVolume))] private static class WaterVolumeTranspilers { [HarmonyPostfix] [HarmonyPatch("GetLiquidType")] private static void GetLiquidTypePostfix(WaterVolume __instance, ref LiquidType __result) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected I4, but got Unknown if ((Object)(object)__instance != (Object)null && __instance is VV_VariableLiquidVolume) { __result = (LiquidType)(int)(__instance as VV_VariableLiquidVolume).VariableLiquidType; } } [HarmonyTranspiler] [HarmonyPatch("OnTriggerEnter")] private static IEnumerable<CodeInstruction> OnTriggerEnterTranspiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Expected O, but got Unknown return new CodeMatcher(instructions, generator).Start().MatchStartForward((CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Ldc_I4_0, (object)null, (string)null) }).ThrowIfInvalid("Could not patch WaterVolume.OnTriggerEnter()!") .RemoveInstruction() .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[2] { new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Callvirt, (object)AccessTools.Method(typeof(WaterVolume), "GetLiquidType", (Type[])null, (Type[])null)) }) .InstructionEnumeration(); } [HarmonyTranspiler] [HarmonyPatch("UpdateFloaters")] private static IEnumerable<CodeInstruction> UpdateFloatersTranspiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Expected O, but got Unknown return new CodeMatcher(instructions, generator).Start().MatchStartForward((CodeMatch[])(object)new CodeMatch[3] { new CodeMatch((OpCode?)OpCodes.Ldc_I4_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(IWaterInteractable), "SetLiquidLevel", (Type[])null, (Type[])null), (string)null) }).ThrowIfInvalid("Could not patch WaterVolume.UpdateFloaters()!") .RemoveInstruction() .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[2] { new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Callvirt, (object)AccessTools.Method(typeof(WaterVolume), "GetLiquidType", (Type[])null, (Type[])null)) }) .InstructionEnumeration(); } [HarmonyTranspiler] [HarmonyPatch("OnTriggerExit")] private static IEnumerable<CodeInstruction> OnTriggerExitTranspiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected O, but got Unknown //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Expected O, but got Unknown //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Expected O, but got Unknown //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Expected O, but got Unknown //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Expected O, but got Unknown //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Expected O, but got Unknown //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Expected O, but got Unknown return new CodeMatcher(instructions, generator).Start().MatchStartForward((CodeMatch[])(object)new CodeMatch[2] { new CodeMatch((OpCode?)OpCodes.Ldc_I4_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(IWaterInteractable), "Decrement", (Type[])null, (Type[])null), (string)null) }).ThrowIfInvalid("Could not patch WaterVolume.OnTriggerExit()!") .RemoveInstruction() .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[2] { new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Callvirt, (object)AccessTools.Method(typeof(WaterVolume), "GetLiquidType", (Type[])null, (Type[])null)) }) .Start() .MatchStartForward((CodeMatch[])(object)new CodeMatch[3] { new CodeMatch((OpCode?)OpCodes.Ldc_I4_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(IWaterInteractable), "SetLiquidLevel", (Type[])null, (Type[])null), (string)null) }) .ThrowIfInvalid("Could not patch WaterVolume.OnTriggerExit()!") .RemoveInstruction() .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[2] { new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Callvirt, (object)AccessTools.Method(typeof(WaterVolume), "GetLiquidType", (Type[])null, (Type[])null)) }) .InstructionEnumeration(); } [HarmonyTranspiler] [HarmonyPatch("OnDestroy")] private static IEnumerable<CodeInstruction> OnDestroyTranspiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected O, but got Unknown //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Expected O, but got Unknown //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Expected O, but got Unknown //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Expected O, but got Unknown //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Expected O, but got Unknown //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Expected O, but got Unknown //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Expected O, but got Unknown return new CodeMatcher(instructions, generator).Start().MatchStartForward((CodeMatch[])(object)new CodeMatch[2] { new CodeMatch((OpCode?)OpCodes.Ldc_I4_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(IWaterInteractable), "Decrement", (Type[])null, (Type[])null), (string)null) }).ThrowIfInvalid("Could not patch WaterVolume.OnDestroy()!") .RemoveInstruction() .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[2] { new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Callvirt, (object)AccessTools.Method(typeof(WaterVolume), "GetLiquidType", (Type[])null, (Type[])null)) }) .Start() .MatchStartForward((CodeMatch[])(object)new CodeMatch[3] { new CodeMatch((OpCode?)OpCodes.Ldc_I4_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(IWaterInteractable), "SetLiquidLevel", (Type[])null, (Type[])null), (string)null) }) .ThrowIfInvalid("Could not patch WaterVolume.OnDestroy()!") .RemoveInstruction() .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[2] { new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Callvirt, (object)AccessTools.Method(typeof(WaterVolume), "GetLiquidType", (Type[])null, (Type[])null)) }) .InstructionEnumeration(); } } } }