Decompiled source of BluranceTerrainFix v1.0.1

Tomatobird.BluranceTerrainFix.dll

Decompiled 3 months ago
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.Configuration;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.SceneManagement;

[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("Tomatobird.BluranceTerrainFix")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+6ee5f539450dbb2d80b50516912f9ab8590b2f37")]
[assembly: AssemblyProduct("BluranceTerrainFix")]
[assembly: AssemblyTitle("Tomatobird.BluranceTerrainFix")]
[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.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;
		}
	}
	[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 BluranceTerrainFix
{
	[BepInPlugin("Tomatobird.BluranceTerrainFix", "BluranceTerrainFix", "1.0.0")]
	public class BluranceTerrainFix : BaseUnityPlugin
	{
		public static ConfigEntry<bool> drawInstanced;

		public static BluranceTerrainFix Instance { get; private set; }

		internal static ManualLogSource Logger { get; private set; }

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			drawInstanced = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "DrawInstanced", true, "Whether the terrain should be drawn instanced. False allows the game's post processing to affect terrain rendering but makes quicksand barely visible. True keeps the terrain's old look.");
			Logger.LogInfo((object)"Tomatobird.BluranceTerrainFix v1.0.0 has loaded!");
			SceneManager.sceneLoaded += OnSceneLoaded;
		}

		private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Expected O, but got Unknown
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Expected O, but got Unknown
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_028d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
			if (!(((Scene)(ref scene)).name != "blurance"))
			{
				Terrain componentInChildren = ((Scene)(ref scene)).GetRootGameObjects()[1].GetComponentInChildren<Terrain>();
				((Component)componentInChildren).gameObject.tag = "Gravel";
				((Component)componentInChildren).gameObject.layer = LayerMask.NameToLayer("Room");
				componentInChildren.drawInstanced = drawInstanced.Value;
				GameObject[] array = BluranceTerrainFix.CreateArray<GameObject>(3);
				GameObject[] array2 = array;
				foreach (GameObject val in array2)
				{
					val.layer = LayerMask.NameToLayer("NavigationSurface");
					GameObject val2 = new GameObject();
					((Object)val2).name = "A";
					val2.transform.parent = val.transform;
					GameObject val3 = new GameObject();
					((Object)val3).name = "B";
					val3.transform.parent = val.transform;
					OffMeshLink val4 = val.AddComponent<OffMeshLink>();
					val4.costOverride = -1f;
					val4.area = 4;
					val4.startTransform = val3.transform;
					val4.endTransform = val2.transform;
				}
				((Object)array[0]).name = "ShipLadderRight";
				((Object)array[1]).name = "ShipLadderFront";
				((Object)array[2]).name = "ShipLadderBack";
				array[0].transform.position = new Vector3(-6.2389f, 1.0254f, -9.4513f);
				array[0].transform.Find("A").position = new Vector3(-6.2389f, -0.5f, -7.0943f);
				array[0].transform.Find("B").position = new Vector3(-6.2389f, 0.2614f, -9.6813f);
				array[1].transform.position = new Vector3(-8.5289f, 1.0254f, -13.6413f);
				array[1].transform.Find("A").position = new Vector3(-10.6689f, -0.2f, -14.2013f);
				array[1].transform.Find("B").position = new Vector3(-8.0479f, 0.2614f, -13.8713f);
				array[2].transform.position = new Vector3(7.4088f, 0.4519f, -8.1851f);
				array[2].transform.Find("A").position = new Vector3(7.4364f, -1.2f, -6.7258f);
				array[2].transform.Find("B").position = new Vector3(7.428f, 0.2614f, -9.1096f);
				GameObject[] array3 = array;
				foreach (GameObject val5 in array3)
				{
					Object.Instantiate<GameObject>(val5);
				}
			}
		}

		public static T[] CreateArray<T>(int count) where T : new()
		{
			T[] array = new T[count];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = new T();
			}
			return array;
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "Tomatobird.BluranceTerrainFix";

		public const string PLUGIN_NAME = "BluranceTerrainFix";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}