using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using BetterCaves.Patches;
using DunGen;
using GameNetcodeStuff;
using HarmonyLib;
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(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("BetterCaves")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Fixes Caves")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0")]
[assembly: AssemblyProduct("BetterCaves")]
[assembly: AssemblyTitle("BetterCaves")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.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;
}
}
}
namespace BetterCaves
{
[BepInPlugin("dev.oki.bettercavewater", "BetterCaveWater", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
public const string modGUID = "dev.oki.bettercavewater";
public const string modName = "BetterCaveWater";
public const string modVersion = "1.0.0";
private static Harmony _harmony = new Harmony("dev.oki.bettercavewater");
internal static ManualLogSource mls = Logger.CreateLogSource("dev.oki.bettercavewater");
private void Awake()
{
mls.LogInfo((object)"BetterCaveWater is loaded!");
ApplyPatches();
}
private static void ApplyPatches()
{
_harmony.PatchAll(typeof(DungeonPatch));
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "BetterCaves";
public const string PLUGIN_NAME = "BetterCaves";
public const string PLUGIN_VERSION = "0.1.0";
}
}
namespace BetterCaves.Patches
{
[HarmonyPatch(typeof(Dungeon))]
internal class DungeonPatch
{
[HarmonyPatch(typeof(Dungeon), "PostGenerateDungeon")]
[HarmonyPostfix]
private static void PostGenerateDungeon(Dungeon __instance)
{
//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
//IL_010e: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
if (!(((Object)__instance.DungeonFlow).name == "Level3Flow"))
{
return;
}
foreach (Tile allTile in __instance.allTiles)
{
if (!((Object)allTile).name.Contains("CaveWaterTile(Clone)") && !((Object)allTile).name.Contains("CaveWaterTile"))
{
continue;
}
Transform[] componentsInChildren = ((Component)((Component)allTile).GetComponentInChildren<Transform>()).GetComponentsInChildren<Transform>();
if (componentsInChildren == null)
{
continue;
}
Transform[] array = componentsInChildren;
foreach (Transform val in array)
{
if (((Object)val).name.Contains("Water (1)") || ((Object)val).name.Contains("WaterTrigger"))
{
if (((Object)val).name.Contains("Water (1)"))
{
((Component)val).transform.SetPositionAndRotation(new Vector3(val.position.x, val.position.y - 1.125f, val.position.z), val.rotation);
}
else
{
((Component)val).gameObject.SetActive(false);
}
}
}
}
}
}
[HarmonyPatch(typeof(PlayerControllerB))]
internal class PlayerControllerBPatch
{
[HarmonyPatch("Update")]
[HarmonyPostfix]
private static void UpdatePatch(PlayerControllerB __instance)
{
__instance.grabDistance = 100f;
}
[HarmonyPatch("DamagePlayer")]
[HarmonyPrefix]
private static bool DamagePlayerPrefix()
{
HUDManager.Instance.DisplayTip("Saved", "You have been saved from damage!", true, false, "LC_Tip1");
return true;
}
}
}