Decompiled source of Unbound Terrain v1.0.1

UnboundTerrain.dll

Decompiled 5 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
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 HarmonyLib;
using Landfall.TABS;
using Landfall.TABS.GameMode;
using LevelCreator;
using TFBGames;
using UnityEngine;
using UnityEngine.Rendering.PostProcessing;
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: AssemblyTitle("UnboundTerrain")]
[assembly: AssemblyDescription("UnboundTerrain")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("GeeztJeez")]
[assembly: AssemblyProduct("UnboundTerrain")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("7acfaef0-7669-4401-8bff-5a9a02e18c75")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.0")]
[module: UnverifiableCode]
namespace UnboundTerrain;

[BepInPlugin("GeeztJeez.UnboundTerrain", "UnboundTerrain", "1.0.1")]
internal class Loader : BaseUnityPlugin
{
	private Transform camTransform;

	public GameObject baseBrickObject;

	public AssetBundle assetsBundle;

	public static ConfigEntry<float> multiplyMapSize;

	private bool buildMode;

	private float currentScale = 5f;

	private readonly float minScale = 5f;

	private readonly float maxScale = 100f;

	private GameObject indicationInstance;

	public GameObject indicationObject;

	public static ConfigEntry<float> waterLevel;

	public PostProcessProfile waterPostProcessProfile;

	private SoundPlayer SoundPlayer => ServiceLocator.GetService<SoundPlayer>();

	public static float GetMultiplyMapSize => multiplyMapSize.Value;

	public static float GetWaterLevel => waterLevel.Value;

	public static event Action<float> OnMultiplyMapSizeChanged;

	public static event Action<float> OnWaterLevelChanged;

	private void Awake()
	{
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: 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_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Expected O, but got Unknown
		assetsBundle = GetBundle("unboundterrainbundle");
		baseBrickObject = (GameObject)assetsBundle.LoadAsset("DestructibleBrick");
		baseBrickObject.AddComponent<DestructibleObjectUnbound>();
		indicationObject = (GameObject)assetsBundle.LoadAsset("IndicationBrick");
		waterPostProcessProfile = (PostProcessProfile)assetsBundle.LoadAsset("WaterPostDefault");
		ApplyHarmony();
		((MonoBehaviour)this).StartCoroutine(Call());
	}

	private IEnumerator Call()
	{
		yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)Object.FindObjectOfType<ServiceLocator>() != (Object)null));
		yield return (object)new WaitUntil((Func<bool>)(() => ServiceLocator.GetService<ISaveLoaderService>() != null));
		CreateSettings();
		yield return ((MonoBehaviour)this).StartCoroutine(GenerateSettings());
		Debug.Log((object)"[UnboundTerrain] Loading...");
		SLMALoader.GetInstance();
		new Harmony("UnboundTerrain").PatchAll();
		SceneManager.sceneLoaded += SceneLoaded;
		Debug.Log((object)"[UnboundTerrain] Loaded Successfully!");
	}

	private void SceneLoaded(Scene scene, LoadSceneMode loadSceneMode)
	{
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: 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_00d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_016f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0176: Unknown result type (might be due to invalid IL or missing references)
		//IL_0181: Unknown result type (might be due to invalid IL or missing references)
		//IL_0186: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
		float num = 100000f;
		if (((Scene)(ref scene)).name == "Editor Scene")
		{
			MeshCollider[] array = Object.FindObjectsOfType<MeshCollider>();
			foreach (MeshCollider val in array)
			{
				if (((Object)((Component)val).gameObject).name == "Water")
				{
					Transform transform = ((Component)val).transform;
					transform.localScale = new Vector3(num, transform.localScale.y, num);
					Debug.Log((object)"[UnboundTerrain] Scaled Water MeshCollider");
				}
			}
		}
		if (!(((Scene)(ref scene)).name == "LevelScene"))
		{
			return;
		}
		float getMultiplyMapSize = GetMultiplyMapSize;
		GameObject val2 = GameObject.Find("WeatherEffects");
		if ((Object)(object)val2 != (Object)null)
		{
			ParticleSystemRenderer[] componentsInChildren = val2.GetComponentsInChildren<ParticleSystemRenderer>(true);
			foreach (ParticleSystemRenderer val3 in componentsInChildren)
			{
				if ((Object)(object)val3 != (Object)null)
				{
					Transform transform2 = ((Component)val3).transform;
					transform2.localScale *= getMultiplyMapSize;
				}
			}
		}
		else
		{
			Debug.LogWarning((object)"[UnboundTerrain] WeatherEffects not found.");
		}
		PostProcessVolume val4 = Object.FindObjectOfType<PostProcessVolume>();
		if ((Object)(object)val4 != (Object)null)
		{
			if ((Object)(object)((Component)val4).gameObject.GetComponent<UnboundWaterPost>() == (Object)null)
			{
				((Component)val4).gameObject.AddComponent<UnboundWaterPost>().waterPost = waterPostProcessProfile;
			}
		}
		else
		{
			Debug.LogWarning((object)"[UnboundTerrain] PostProcessVolume not found.");
		}
		WaterPost val5 = Object.FindObjectOfType<WaterPost>();
		if ((Object)(object)val5 != (Object)null)
		{
			Object.Destroy((Object)(object)val5);
		}
		SpawnLevel val6 = Object.FindObjectOfType<SpawnLevel>();
		if ((Object)(object)val6 != (Object)null)
		{
			Transform transform3 = ((Component)val6).transform;
			transform3.localScale *= getMultiplyMapSize;
			Vector3 position = transform3.position;
			position.x *= getMultiplyMapSize;
			position.y = -10f * getMultiplyMapSize;
			position.z *= getMultiplyMapSize;
			transform3.position = position;
		}
		else
		{
			Debug.LogWarning((object)"[UnboundTerrain] SpawnLevel not found.");
		}
		Water val7 = Object.FindObjectOfType<Water>();
		if ((Object)(object)val7 != (Object)null)
		{
			Transform transform4 = ((Component)val7).transform;
			transform4.localScale = new Vector3(num, transform4.localScale.y, num);
			Transform parent = transform4.parent;
			if ((Object)(object)parent != (Object)null && (Object)(object)((Component)parent).GetComponent<GoToYBehaviour>() == (Object)null)
			{
				((Component)parent).gameObject.AddComponent<GoToYBehaviour>();
			}
		}
		else
		{
			Debug.LogWarning((object)"[UnboundTerrain] Water not found.");
		}
	}

	private void OnDestroy()
	{
		SceneManager.sceneLoaded -= SceneLoaded;
	}

	public Transform GetCamera()
	{
		if ((Object)(object)camTransform != (Object)null)
		{
			return camTransform;
		}
		PlayerCamerasManager service = ServiceLocator.GetService<PlayerCamerasManager>();
		MainCam val = ((service != null) ? service.GetMainCam((Player)0) : null);
		camTransform = (((Object)(object)val != (Object)null) ? ((Component)val).transform : null);
		return camTransform;
	}

	public void SpawnBrick(GameObject prefab, float scale, Vector3 position, Quaternion rotation)
	{
		//IL_002a: 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_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_013d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0143: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)prefab == (Object)null)
		{
			Debug.LogError((object)"[UnboundTerrain] PREFAB is null.");
			return;
		}
		SoundPlayer.PlaySoundEffect("UI/Unit Placed", 1f, GetCamera().position, (MaterialType)0, (Transform)null, 3f);
		GameObject val = Object.Instantiate<GameObject>(prefab, position, rotation);
		Rigidbody[] componentsInChildren = val.GetComponentsInChildren<Rigidbody>(true);
		foreach (Rigidbody obj in componentsInChildren)
		{
			obj.mass *= scale;
			obj.drag *= scale;
			obj.angularDrag *= scale;
		}
		DestructibleObjectUnbound componentInChildren = val.GetComponentInChildren<DestructibleObjectUnbound>();
		componentInChildren.scaleMultiplier = scale;
		componentInChildren.damageThreshold *= scale;
		Material val2 = CreateDarkenedMaterialHSV(((Renderer)val.GetComponentInChildren<MeshRenderer>()).material, 0.1f, 0.6f);
		ParticleSystemRenderer[] componentsInChildren2 = val.GetComponentsInChildren<ParticleSystemRenderer>(true);
		foreach (ParticleSystemRenderer obj2 in componentsInChildren2)
		{
			((Renderer)obj2).material = val2;
			((Renderer)obj2).materials[0] = val2;
			((Renderer)obj2).sharedMaterial = val2;
			((Renderer)obj2).sharedMaterials[0] = val2;
		}
		MeshRenderer[] componentsInChildren3 = val.GetComponentsInChildren<MeshRenderer>(true);
		foreach (MeshRenderer obj3 in componentsInChildren3)
		{
			((Renderer)obj3).material = val2;
			((Renderer)obj3).materials[0] = val2;
		}
		val.transform.localScale = Vector3.one * scale;
		DestructibleObject component = val.GetComponent<DestructibleObject>();
		if ((Object)(object)component == (Object)null)
		{
			Debug.LogError((object)"No DestructibleObject found on this GameObject!");
			return;
		}
		Type typeFromHandle = typeof(DestructibleObject);
		componentInChildren.objectsToActivate = GetField<GameObject[]>(typeFromHandle, component, "m_objectsToActivate");
		componentInChildren.objectsToDisable = GetField<GameObject[]>(typeFromHandle, component, "m_objectsToDisable");
		Object.Destroy((Object)(object)val.GetComponent<DestructibleObject>());
		Debug.Log((object)("[UnboundTerrain] Spawned brick at " + position));
	}

	public void DestroyBrick(GameObject go)
	{
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		if (Object.op_Implicit((Object)(object)go) && (Object)(object)((Component)go.transform.root).GetComponentInChildren<DestructibleObjectUnbound>() != (Object)null)
		{
			SoundPlayer.PlaySoundEffect("UI/Unit Removed", 1f, GetCamera().position, (MaterialType)0, (Transform)null, 3f);
			Object.Destroy((Object)(object)((Component)go.transform.root).gameObject);
			Debug.Log((object)"[UnboundTerrain] Brick destroyed.");
		}
	}

	private void Update()
	{
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Invalid comparison between Unknown and I4
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bf: 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_01cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01df: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0200: Unknown result type (might be due to invalid IL or missing references)
		//IL_0205: Unknown result type (might be due to invalid IL or missing references)
		//IL_021f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0231: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_0102: Unknown result type (might be due to invalid IL or missing references)
		//IL_010d: Unknown result type (might be due to invalid IL or missing references)
		//IL_024d: Unknown result type (might be due to invalid IL or missing references)
		//IL_024f: Unknown result type (might be due to invalid IL or missing references)
		//IL_025f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0265: Unknown result type (might be due to invalid IL or missing references)
		if (Object.op_Implicit((Object)(object)MapSettings.Instance) && MapSettings.Instance.m_mapRadius != float.MaxValue)
		{
			MapSettings.Instance.m_mapRadius = float.MaxValue;
			Debug.Log((object)"Set Map Settings to infinite.");
		}
		GameModeService service = ServiceLocator.GetService<GameModeService>();
		if ((Object)(object)service == (Object)null || service.CurrentGameMode == null || service.CurrentGameMode.GameStateManager == null || (int)service.CurrentGameMode.GameStateManager.GameState > 0)
		{
			return;
		}
		Transform camera = GetCamera();
		if (!Object.op_Implicit((Object)(object)camera))
		{
			return;
		}
		if (Input.GetKeyDown((KeyCode)109))
		{
			SoundPlayer.PlaySoundEffect("UI/Click", 1f, GetCamera().position, (MaterialType)0, (Transform)null, 3f);
			buildMode = !buildMode;
			if (buildMode)
			{
				if ((Object)(object)indicationInstance == (Object)null && (Object)(object)indicationObject != (Object)null)
				{
					indicationInstance = Object.Instantiate<GameObject>(indicationObject);
					indicationInstance.transform.localScale = Vector3.one * currentScale;
				}
			}
			else if (Object.op_Implicit((Object)(object)indicationInstance))
			{
				Object.Destroy((Object)(object)indicationInstance);
				indicationInstance = null;
			}
		}
		else
		{
			if (!buildMode)
			{
				return;
			}
			float axis = Input.GetAxis("Mouse ScrollWheel");
			if (Mathf.Abs(axis) > 0.01f)
			{
				currentScale += axis * 10f;
				currentScale = Mathf.Clamp(currentScale, minScale, maxScale);
				if (Object.op_Implicit((Object)(object)indicationInstance))
				{
					indicationInstance.transform.localScale = Vector3.one * currentScale;
				}
			}
			float num = currentScale;
			Vector3 position = camera.position + camera.forward * 2f * num * 0.25f;
			Quaternion rotation = Quaternion.Euler(0f, camera.eulerAngles.y, 0f);
			if (Object.op_Implicit((Object)(object)indicationInstance))
			{
				indicationInstance.transform.position = position;
				indicationInstance.transform.rotation = rotation;
			}
			if (Input.GetMouseButtonDown(0))
			{
				SpawnBrick(baseBrickObject, currentScale, position, rotation);
			}
			RaycastHit val = default(RaycastHit);
			if (Input.GetMouseButtonDown(1) && Physics.Raycast(camera.position, camera.forward, ref val, 9999f))
			{
				DestroyBrick(((Component)((RaycastHit)(ref val)).collider).gameObject);
			}
		}
	}

	public static AssetBundle GetBundle(string assetBundleName)
	{
		Stream manifestResourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(assetBundleName);
		if (manifestResourceStream == null)
		{
			Debug.LogError((object)("[LoadBundle] Failed to find resource: " + assetBundleName));
			return null;
		}
		if (!manifestResourceStream.CanRead)
		{
			Debug.LogError((object)("[LoadBundle] Resource stream is not readable: " + assetBundleName));
			return null;
		}
		return AssetBundle.LoadFromStream(manifestResourceStream);
	}

	private void ApplyHarmony()
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			new Harmony("UnboundTerrain").PatchAll(Assembly.GetExecutingAssembly());
			Debug.Log((object)"[UnboundTerrain] Harmony patched successfully!");
		}
		catch (Exception ex)
		{
			Debug.LogError((object)("[UnboundTerrain] Harmony patch failed: " + ex));
			Debug.Log((object)"Please contact Geezt Jeez or try reloading the game for proper installation...");
		}
	}

	private T GetField<T>(Type t, object obj, string fieldName)
	{
		FieldInfo field = t.GetField(fieldName, BindingFlags.Instance | BindingFlags.NonPublic);
		if (field == null)
		{
			Debug.LogError((object)("Field not found: " + fieldName));
			return default(T);
		}
		return (T)field.GetValue(obj);
	}

	public static Material CreateDarkenedMaterialHSV(Material baseMat, float minOffset, float maxOffset)
	{
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Expected O, but got Unknown
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: 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)
		if ((Object)(object)baseMat == (Object)null)
		{
			return null;
		}
		Material val = new Material(baseMat);
		float num = Random.Range(minOffset, maxOffset);
		bool flag = false;
		bool flag2 = false;
		Color val2;
		if (val.HasProperty("_Color"))
		{
			val2 = val.color;
			flag = true;
		}
		else if (val.HasProperty("_BaseColor"))
		{
			val2 = val.GetColor("_BaseColor");
			flag2 = true;
		}
		else
		{
			val2 = Color.white;
		}
		float num2 = default(float);
		float num3 = default(float);
		float num4 = default(float);
		Color.RGBToHSV(val2, ref num2, ref num3, ref num4);
		num4 *= 1f - num;
		val2 = Color.HSVToRGB(num2, num3, num4);
		if (flag)
		{
			val.color = val2;
		}
		if (flag2)
		{
			val.SetColor("_BaseColor", val2);
		}
		return val;
	}

	private void CreateSettings()
	{
		multiplyMapSize = ((BaseUnityPlugin)this).Config.Bind<float>("UnboundTerrain", "Multiply Map Size", 5f, "Amount of scale the custom map getting multiplied.");
		AttachFloatSettingChangedHandler(multiplyMapSize, Loader.OnMultiplyMapSizeChanged);
		waterLevel = ((BaseUnityPlugin)this).Config.Bind<float>("UnboundTerrain", "WaterSize", 0f, "Amount of height the water would be on custom map.");
		AttachFloatSettingChangedHandler(waterLevel, Loader.OnWaterLevelChanged);
	}

	private void AttachFloatSettingChangedHandler(ConfigEntry<float> entry, Action<float> targetEvent)
	{
		entry.SettingChanged += delegate
		{
			targetEvent?.Invoke(entry.Value);
		};
	}

	private IEnumerator GenerateSettings()
	{
		GlobalSettingsHandler service = null;
		yield return (object)new WaitUntil((Func<bool>)(() => Object.op_Implicit((Object)(object)(service = ServiceLocator.GetService<GlobalSettingsHandler>()))));
		List<SettingsInstance> list = service.GameplaySettings.ToList();
		list.Add(CreateSliderSettingInstance(multiplyMapSize, "Multiply Map Size", "Amount of scale the custom map getting multiplied", 1f, 30f, (float)((ConfigEntryBase)multiplyMapSize).DefaultValue));
		list.Add(CreateSliderSettingInstance(waterLevel, "Water Level", "Amount of height the water would be on custom map", -60f, 600f, (float)((ConfigEntryBase)waterLevel).DefaultValue));
		((object)service).GetType().GetField("m_gameplaySettings", (BindingFlags)(-1)).SetValue(service, list.ToArray());
	}

	private SettingsInstance CreateSliderSettingInstance(ConfigEntry<float> configEntry, string key, string toolTip, float min, float max, float defaultValue)
	{
		//IL_000d: 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_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: 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_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Expected O, but got Unknown
		SettingsInstance val2 = new SettingsInstance
		{
			settingsType = (SettingsType)1,
			currentSliderValue = configEntry.Value,
			defaultSliderValue = defaultValue,
			min = min,
			max = max,
			m_settingsKey = key,
			toolTip = toolTip
		};
		val2.OnSliderValueChanged += delegate(float val)
		{
			configEntry.Value = val;
		};
		return val2;
	}
}
public class DestructibleObjectUnbound : Damagable
{
	public float damageThreshold = 200f;

	public float forceExplosion = 200f;

	public float currentDamage;

	public float scaleMultiplier = 1f;

	public GameObject[] objectsToActivate;

	public GameObject[] objectsToDisable;

	public override void TakeDamage(float damage, Vector3 direction, Unit unit, DamageType damageType = 0)
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: Invalid comparison between Unknown and I4
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		((Component)this).GetComponentInChildren<ParticleSystem>().Play();
		if ((int)damageType != 3)
		{
			currentDamage += damage;
			if (currentDamage >= damageThreshold)
			{
				Destruct(direction * forceExplosion);
			}
		}
	}

	private void Destruct(Vector3 force)
	{
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: Unknown result type (might be due to invalid IL or missing references)
		Object.Destroy((Object)(object)((Component)this).GetComponent<Rigidbody>());
		((Component)this).GetComponentInChildren<ParticleSystem>().Play();
		for (int i = 0; i < objectsToActivate.Length; i++)
		{
			objectsToActivate[i].SetActive(true);
			Rigidbody[] componentsInChildren = objectsToActivate[i].GetComponentsInChildren<Rigidbody>(true);
			if (componentsInChildren != null)
			{
				for (int j = 0; j < componentsInChildren.Length; j++)
				{
					Vector3 val = force * Random.Range(-1f, 1f) / scaleMultiplier;
					componentsInChildren[j].AddForce(val, (ForceMode)1);
					RemoveAfterSeconds obj = ((Component)componentsInChildren[j]).gameObject.AddComponent<RemoveAfterSeconds>();
					obj.shrink = true;
					obj.seconds = Random.Range(5f, 8f);
				}
			}
		}
		RemoveAfterSeconds obj2 = ((Component)this).gameObject.AddComponent<RemoveAfterSeconds>();
		obj2.shrink = true;
		obj2.seconds = 10f;
		for (int k = 0; k < objectsToDisable.Length; k++)
		{
			objectsToDisable[k].SetActive(false);
		}
	}
}
[HarmonyPatch(typeof(CameraMovement), "Start")]
internal class Patch_CameraMovementStart
{
	private static void Postfix(CameraMovement __instance)
	{
		((object)__instance).GetType().GetField("m_mapRadius", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(__instance, 99999f);
		((object)__instance).GetType().GetField("m_mapRadiusSqr", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(__instance, 9.9998E+09f);
	}
}
public class UnboundWaterPost : MonoBehaviour
{
	public PostProcessProfile waterPost;

	private PostProcessProfile defaultPost;

	private PostProcessVolume volume;

	private Transform mainCamTransform;

	private PostProcessProfile defaultPostProfile;

	private void Start()
	{
		volume = ((Component)this).GetComponent<PostProcessVolume>();
		defaultPost = volume.sharedProfile;
		defaultPostProfile = volume.profile;
		GetMainCamera();
	}

	private void GetMainCamera()
	{
		PlayerCamerasManager service = ServiceLocator.GetService<PlayerCamerasManager>();
		MainCam val = ((service != null) ? service.GetMainCam((Player)0) : null);
		mainCamTransform = (((Object)(object)val != (Object)null) ? ((Component)val).transform : null);
	}

	private void Update()
	{
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)mainCamTransform == (Object)null)
		{
			GetMainCamera();
			return;
		}
		float getWaterLevel = Loader.GetWaterLevel;
		if (mainCamTransform.position.y < getWaterLevel)
		{
			volume.profile = waterPost;
			volume.sharedProfile = waterPost;
		}
		else
		{
			volume.profile = defaultPostProfile;
			volume.sharedProfile = defaultPost;
		}
	}
}
public class GoToYBehaviour : MonoBehaviour
{
	private Transform mainCamTransform;

	private void Update()
	{
		//IL_0006: 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)
		float y = ((Component)this).transform.position.y;
		float getWaterLevel = Loader.GetWaterLevel;
		if (y != getWaterLevel)
		{
			((Component)this).transform.position = new Vector3(0f, getWaterLevel, 0f);
		}
	}
}