Decompiled source of LowGravity v0.1.0

LowGravity.dll

Decompiled an hour ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;
using WeatherRegistry;
using WeatherRegistry.Enums;
using WeatherRegistry.Modules;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("LowGravity")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0+69f4843bcb7740f5324a96ce4fbb7d5477ef857b")]
[assembly: AssemblyProduct("LowGravity")]
[assembly: AssemblyTitle("LowGravity")]
[assembly: AssemblyVersion("0.1.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 LowGravity
{
	internal static class Drift
	{
		private class Flight
		{
			public GrabbableObject Item;

			public Vector3 From;

			public Vector3 To;

			public float Height;

			public float T;

			public Vector3 Spin;
		}

		[CompilerGenerated]
		private static class <>O
		{
			public static HandleNamedMessageDelegate <0>__OnDrift;
		}

		internal const string Msg = "DanielLC.LowGravity.Drift";

		private const float Duration = 2.6f;

		private static readonly List<Flight> Flights = new List<Flight>();

		private static CustomMessagingManager _registeredOn;

		private static float _next;

		internal static int Started;

		internal static int Landed;

		internal static void EnsureRegistered()
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Expected O, but got Unknown
			NetworkManager singleton = NetworkManager.Singleton;
			CustomMessagingManager val = (((Object)(object)singleton != (Object)null && singleton.IsListening) ? singleton.CustomMessagingManager : null);
			if (val != null && val != _registeredOn)
			{
				object obj = <>O.<0>__OnDrift;
				if (obj == null)
				{
					HandleNamedMessageDelegate val2 = OnDrift;
					<>O.<0>__OnDrift = val2;
					obj = (object)val2;
				}
				val.RegisterNamedMessageHandler("DanielLC.LowGravity.Drift", (HandleNamedMessageDelegate)obj);
				_registeredOn = val;
			}
		}

		internal static void HostTick()
		{
			NetworkManager singleton = NetworkManager.Singleton;
			if (!Gravity.Active || !Plugin.ItemDrift.Value || (Object)(object)singleton == (Object)null || !singleton.IsServer)
			{
				_next = Time.time + 5f;
			}
			else if (!(Time.time < _next))
			{
				_next = Time.time + Mathf.Max(3f, Plugin.ItemDriftInterval.Value) * Random.Range(0.7f, 1.3f);
				TryDriftOne();
			}
		}

		internal static bool TryDriftOne()
		{
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: 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)
			List<GrabbableObject> list = new List<GrabbableObject>();
			GrabbableObject[] array = Object.FindObjectsOfType<GrabbableObject>();
			foreach (GrabbableObject val in array)
			{
				if (Eligible(val))
				{
					list.Add(val);
				}
			}
			for (int j = 0; j < 6; j++)
			{
				if (list.Count <= 0)
				{
					break;
				}
				int index = Random.Range(0, list.Count);
				GrabbableObject val2 = list[index];
				list.RemoveAt(index);
				if (PickLanding(val2, out var from, out var to))
				{
					float h = Random.Range(0.7f, 1.4f);
					Send(((NetworkBehaviour)val2).NetworkObjectId, from, to, h);
					Begin(val2, from, to, h);
					return true;
				}
			}
			return false;
		}

		private static bool Eligible(GrabbableObject it)
		{
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: 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_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)it == (Object)null || it.isHeld || it.isHeldByEnemy || it.isPocketed || (Object)(object)it.parentObject != (Object)null || !it.grabbable || it.deactivated)
			{
				return false;
			}
			if (!(it is RagdollGrabbableObject))
			{
				LungProp val = (LungProp)(object)((it is LungProp) ? it : null);
				if (val == null || !val.isLungDocked)
				{
					if (it.isInShipRoom || it.isInElevator || it.isInFactory || it.fallTime < 1f || !it.reachedFloorTarget || (Object)(object)it.itemProperties == (Object)null)
					{
						return false;
					}
					if ((Object)(object)((NetworkBehaviour)it).NetworkObject == (Object)null || !((NetworkBehaviour)it).NetworkObject.IsSpawned || IsFlying(it))
					{
						return false;
					}
					if (it.itemProperties.weight > 1.5f)
					{
						return false;
					}
					StartOfRound instance = StartOfRound.Instance;
					Vector3 position = ((Component)it).transform.position;
					if ((Object)(object)instance != (Object)null && (Object)(object)instance.shipInnerRoomBounds != (Object)null)
					{
						Bounds bounds = instance.shipInnerRoomBounds.bounds;
						if (((Bounds)(ref bounds)).Contains(position))
						{
							return false;
						}
					}
					return true;
				}
			}
			return false;
		}

		private static bool PickLanding(GrabbableObject it, out Vector3 from, out Vector3 to)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: 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_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: 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_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: 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_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			from = ((Component)it).transform.position;
			to = from;
			int num = (((Object)(object)StartOfRound.Instance != (Object)null) ? StartOfRound.Instance.collidersAndRoomMaskAndDefault : 1107298561);
			float verticalOffset = it.itemProperties.verticalOffset;
			StartOfRound instance = StartOfRound.Instance;
			RaycastHit val3 = default(RaycastHit);
			for (int i = 0; i < 5; i++)
			{
				Vector2 insideUnitCircle = Random.insideUnitCircle;
				Vector2 val = ((Vector2)(ref insideUnitCircle)).normalized * Random.Range(1f, 2.2f);
				Vector3 val2 = from + new Vector3(val.x, 0f, val.y);
				if (Physics.Linecast(from + Vector3.up * 0.6f, val2 + Vector3.up * 0.6f, num, (QueryTriggerInteraction)1) || !Physics.Raycast(val2 + Vector3.up * 1.5f, Vector3.down, ref val3, 4f, num, (QueryTriggerInteraction)1) || Mathf.Abs(((RaycastHit)(ref val3)).point.y + verticalOffset - from.y) > 1.2f)
				{
					continue;
				}
				Vector3 val4 = ((RaycastHit)(ref val3)).point + Vector3.up * verticalOffset;
				if ((Object)(object)instance != (Object)null && (Object)(object)instance.shipInnerRoomBounds != (Object)null)
				{
					Bounds bounds = instance.shipInnerRoomBounds.bounds;
					if (((Bounds)(ref bounds)).Contains(val4 + Vector3.up * 0.3f))
					{
						continue;
					}
				}
				to = val4;
				return true;
			}
			return false;
		}

		private static void Send(ulong id, Vector3 from, Vector3 to, float h)
		{
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager singleton = NetworkManager.Singleton;
			List<ulong> list = new List<ulong>();
			foreach (ulong connectedClientsId in singleton.ConnectedClientsIds)
			{
				if (connectedClientsId != 0L)
				{
					list.Add(connectedClientsId);
				}
			}
			if (list.Count == 0)
			{
				return;
			}
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(64, (Allocator)2, -1);
			try
			{
				((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref id, default(ForPrimitives));
				((FastBufferWriter)(ref val)).WriteValueSafe(ref from);
				((FastBufferWriter)(ref val)).WriteValueSafe(ref to);
				((FastBufferWriter)(ref val)).WriteValueSafe<float>(ref h, default(ForPrimitives));
				singleton.CustomMessagingManager.SendNamedMessage("DanielLC.LowGravity.Drift", (IReadOnlyList<ulong>)list, val, (NetworkDelivery)2);
			}
			finally
			{
				((FastBufferWriter)(ref val)).Dispose();
			}
		}

		private static void OnDrift(ulong sender, FastBufferReader r)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			if (sender != 0L)
			{
				return;
			}
			ulong key = default(ulong);
			((FastBufferReader)(ref r)).ReadValueSafe<ulong>(ref key, default(ForPrimitives));
			Vector3 val = default(Vector3);
			((FastBufferReader)(ref r)).ReadValueSafe(ref val);
			Vector3 to = default(Vector3);
			((FastBufferReader)(ref r)).ReadValueSafe(ref to);
			float h = default(float);
			((FastBufferReader)(ref r)).ReadValueSafe<float>(ref h, default(ForPrimitives));
			NetworkManager singleton = NetworkManager.Singleton;
			if (!((Object)(object)singleton == (Object)null) && singleton.SpawnManager.SpawnedObjects.TryGetValue(key, out var value))
			{
				GrabbableObject componentInChildren = ((Component)value).GetComponentInChildren<GrabbableObject>();
				if ((Object)(object)componentInChildren != (Object)null && !IsFlying(componentInChildren))
				{
					Begin(componentInChildren, val, to, h);
				}
			}
		}

		private static void Begin(GrabbableObject it, Vector3 from, Vector3 to, float h)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: 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_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			Flights.Add(new Flight
			{
				Item = it,
				From = from,
				To = to,
				Height = h,
				Spin = Random.onUnitSphere * Random.Range(40f, 120f)
			});
			Started++;
		}

		internal static bool IsFlying(GrabbableObject it)
		{
			foreach (Flight flight in Flights)
			{
				if ((Object)(object)flight.Item == (Object)(object)it)
				{
					return true;
				}
			}
			return false;
		}

		internal static void Tick()
		{
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: 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_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			if (Flights.Count == 0)
			{
				return;
			}
			float deltaTime = Time.deltaTime;
			for (int num = Flights.Count - 1; num >= 0; num--)
			{
				Flight flight = Flights[num];
				GrabbableObject item = flight.Item;
				if ((Object)(object)item == (Object)null || item.isHeld || item.isHeldByEnemy || (Object)(object)item.parentObject != (Object)null)
				{
					Flights.RemoveAt(num);
				}
				else
				{
					flight.T += deltaTime / 2.6f;
					float num2 = Mathf.Clamp01(flight.T);
					float num3 = num2 * num2 * (3f - 2f * num2);
					Vector3 val = Vector3.Lerp(flight.From, flight.To, num3) + Vector3.up * (4f * flight.Height * num2 * (1f - num2));
					Vector3 val2 = (((Object)(object)((Component)item).transform.parent != (Object)null) ? ((Component)item).transform.parent.InverseTransformPoint(val) : val);
					item.fallTime = 1f;
					item.startFallingPosition = val2;
					item.targetFloorPosition = val2;
					((Component)item).transform.position = val;
					if (num2 < 1f)
					{
						item.reachedFloorTarget = true;
						item.hasHitGround = true;
						((Component)item).transform.Rotate(flight.Spin * deltaTime, (Space)0);
					}
					else
					{
						item.floorYRot = -1;
						item.reachedFloorTarget = false;
						item.hasHitGround = false;
						Flights.RemoveAt(num);
						Landed++;
					}
				}
			}
		}

		internal static void Reset()
		{
			Flights.Clear();
		}
	}
	[HarmonyPatch(typeof(StartOfRound), "SetPlanetsWeather")]
	internal static class EveryDay
	{
		[HarmonyPostfix]
		[HarmonyAfter(new string[] { "mrov.WeatherRegistry" })]
		private static void After(StartOfRound __instance)
		{
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			if (!Plugin.EveryDay.Value || (Object)(object)__instance == (Object)null || !((NetworkBehaviour)__instance).IsHost || !WeatherManager.IsSetupFinished || !WeatherHook.TryGetType(out var t))
			{
				return;
			}
			Dictionary<SelectableLevel, LevelWeatherType> dictionary = new Dictionary<SelectableLevel, LevelWeatherType>();
			SelectableLevel[] levels = __instance.levels;
			foreach (SelectableLevel val in levels)
			{
				if ((Object)(object)val != (Object)null && val.planetHasTime)
				{
					dictionary[val] = t;
				}
			}
			WeatherManager.CurrentWeathers.SetWeathers(dictionary);
			Plugin.Log.LogInfo((object)$"[Testing] EveryDay: Low Gravity on all {dictionary.Count} moons today.");
		}
	}
	internal static class Gravity
	{
		internal const float VanillaGravity = 38f;

		private static Vector3 _savedPhysicsGravity;

		private static bool _physicsSet;

		private static PlayerControllerB _jumpPlayer;

		private static float _savedJump;

		internal static bool Active { get; private set; }

		internal static float Scale
		{
			get
			{
				if (!Active)
				{
					return 1f;
				}
				return Mathf.Clamp(Plugin.GravityScale.Value, 0.1f, 1f);
			}
		}

		internal static void Tick()
		{
			bool flag = WeatherHook.TodayHere();
			if (flag != Active)
			{
				if (flag)
				{
					Begin();
				}
				else
				{
					End();
				}
			}
			if (Active)
			{
				KeepJump();
			}
		}

		private static void Begin()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			Active = true;
			_savedPhysicsGravity = Physics.gravity;
			Physics.gravity = _savedPhysicsGravity * Scale;
			_physicsSet = true;
			KeepJump();
			Plugin.Log.LogInfo((object)$"Low Gravity day: gravity x{Scale:F2}, jump {Plugin.JumpForce.Value:F1}, scrap falls x{Plugin.ItemFallSpeed.Value:F2}.");
		}

		internal static void End()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			Active = false;
			if (_physicsSet)
			{
				Physics.gravity = _savedPhysicsGravity;
				_physicsSet = false;
			}
			RestoreJump();
			Plugin.Log.LogInfo((object)"Low Gravity: back to normal gravity.");
		}

		private static void KeepJump()
		{
			PlayerControllerB val = (((Object)(object)GameNetworkManager.Instance != (Object)null) ? GameNetworkManager.Instance.localPlayerController : null);
			if ((Object)(object)val != (Object)(object)_jumpPlayer)
			{
				RestoreJump();
			}
			if (!((Object)(object)val == (Object)null))
			{
				if ((Object)(object)_jumpPlayer == (Object)null)
				{
					_jumpPlayer = val;
					_savedJump = val.jumpForce;
				}
				val.jumpForce = Plugin.JumpForce.Value;
			}
		}

		private static void RestoreJump()
		{
			if ((Object)(object)_jumpPlayer != (Object)null)
			{
				_jumpPlayer.jumpForce = _savedJump;
			}
			_jumpPlayer = null;
		}

		internal static bool IsLocal(PlayerControllerB p)
		{
			if ((Object)(object)p != (Object)null && (Object)(object)GameNetworkManager.Instance != (Object)null)
			{
				return (Object)(object)p == (Object)(object)GameNetworkManager.Instance.localPlayerController;
			}
			return false;
		}
	}
	[HarmonyPatch]
	internal static class PlayerPatches
	{
		private static float _savedFall;

		private static float _savedUncapped;

		private static bool _scaled;

		[HarmonyPatch(typeof(PlayerControllerB), "Update")]
		[HarmonyPostfix]
		private static void AfterUpdate(PlayerControllerB __instance)
		{
			if (!Gravity.Active || !Gravity.IsLocal(__instance) || (Object)(object)__instance.thisController == (Object)null)
			{
				return;
			}
			if (!__instance.thisController.isGrounded && !__instance.jetpackControls && !__instance.isClimbingLadder && !__instance.isUnderwater && !__instance.isPlayerDead && (!__instance.inSpecialInteractAnimation || __instance.inShockingMinigame))
			{
				float gravity;
				float num = (ShockwaveLink.InFlight(out gravity) ? (gravity * (1f - Gravity.Scale)) : (1f - Gravity.Scale));
				float num2 = 38f * num * Time.deltaTime;
				__instance.fallValue = Mathf.Min(__instance.fallValue + num2, __instance.jumpForce);
				if (Mathf.Abs(__instance.externalForceAutoFade.y) - Mathf.Abs(__instance.fallValue) < 5f)
				{
					__instance.fallValueUncapped += num2;
				}
				if (Plugin.FallDamage.Value == FallDamageMode.VanillaHeights && __instance.fallValueUncapped / Mathf.Sqrt(Gravity.Scale) < -35f)
				{
					__instance.takingFallDamage = true;
				}
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB), "PlayerHitGroundEffects")]
		[HarmonyPrefix]
		private static void BeforeHitGround(PlayerControllerB __instance)
		{
			_scaled = false;
			if (Gravity.Active && Gravity.IsLocal(__instance))
			{
				switch (Plugin.FallDamage.Value)
				{
				case FallDamageMode.Off:
					__instance.takingFallDamage = false;
					break;
				case FallDamageMode.VanillaHeights:
				{
					float num = 1f / Mathf.Sqrt(Gravity.Scale);
					_savedFall = __instance.fallValue;
					_savedUncapped = __instance.fallValueUncapped;
					__instance.fallValue *= num;
					__instance.fallValueUncapped *= num;
					_scaled = true;
					break;
				}
				}
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB), "PlayerHitGroundEffects")]
		[HarmonyPostfix]
		private static void AfterHitGround(PlayerControllerB __instance)
		{
			if (_scaled)
			{
				__instance.fallValue = _savedFall;
				__instance.fallValueUncapped = _savedUncapped;
				_scaled = false;
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB), "DamagePlayer")]
		[HarmonyPrefix]
		private static bool BeforeDamage(PlayerControllerB __instance, CauseOfDeath causeOfDeath, bool fallDamage)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Invalid comparison between Unknown and I4
			if (!Gravity.Active || Plugin.FallDamage.Value != FallDamageMode.Off || !Gravity.IsLocal(__instance))
			{
				return true;
			}
			if (!fallDamage)
			{
				return (int)causeOfDeath != 2;
			}
			return false;
		}
	}
	[HarmonyPatch]
	internal static class WorldPatches
	{
		[HarmonyPatch(typeof(GrabbableObject), "FallWithCurve")]
		[HarmonyPostfix]
		private static void AfterFall(GrabbableObject __instance)
		{
			if (!Gravity.Active || (Object)(object)__instance == (Object)null)
			{
				return;
			}
			float num = Mathf.Clamp(Plugin.ItemFallSpeed.Value, 0.1f, 1f);
			if (!(num >= 0.999f))
			{
				float num2 = __instance.startFallingPosition.y - __instance.targetFloorPosition.y;
				if (!(Mathf.Abs(num2) < 0.001f))
				{
					__instance.fallTime -= Mathf.Abs(Time.deltaTime * 6f / num2) * (1f - num);
				}
			}
		}

		[HarmonyPatch(typeof(VehicleController), "FixedUpdate")]
		[HarmonyPostfix]
		private static void AfterVehicleFixed(VehicleController __instance)
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			if (!Gravity.Active || !Plugin.CruiserNormalGravity.Value)
			{
				return;
			}
			Rigidbody mainRigidbody = __instance.mainRigidbody;
			if (!((Object)(object)mainRigidbody == (Object)null) && !mainRigidbody.isKinematic && mainRigidbody.useGravity)
			{
				float scale = Gravity.Scale;
				if (!(scale >= 0.999f))
				{
					mainRigidbody.AddForce(Physics.gravity * ((1f - scale) / scale), (ForceMode)5);
				}
			}
		}
	}
	internal static class Monsters
	{
		private class State
		{
			public float BaseAnimSpeed = 1f;

			public float LastSetAnim = -1f;

			public Transform Model;

			public Vector3 Offset;

			public Vector3 LastPos;

			public float Speed;

			public float Phase;

			public float BaseAccel = -1f;

			public float LastSetAccel = -1f;

			public float BaseAngular = -1f;

			public float LastSetAngular = -1f;
		}

		private const float GaitSpeed = 0.75f;

		private const float BobHeight = 0.25f;

		private const float BobHz = 1.1f;

		private static readonly Dictionary<EnemyAI, State> States = new Dictionary<EnemyAI, State>();

		private static readonly HashSet<string> NoBob = new HashSet<string>
		{
			"RedLocustBees", "DocileLocustBees", "ButlerBeesEnemyAI", "DoublewingAI", "FlowerSnakeEnemy", "CentipedeAI", "SandWormAI", "DressGirlAI", "RadMechAI", "BlobAI",
			"SandSpiderAI", "LassoManAI"
		};

		internal static int Bobbing
		{
			get
			{
				//IL_001b: 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)
				int num = 0;
				foreach (State value in States.Values)
				{
					if (value.Offset != Vector3.zero)
					{
						num++;
					}
				}
				return num;
			}
		}

		internal static int Tracked => States.Count;

		internal static void Undo()
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//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_0044: 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)
			foreach (KeyValuePair<EnemyAI, State> state in States)
			{
				State value = state.Value;
				if ((Object)(object)value.Model != (Object)null && value.Offset != Vector3.zero)
				{
					Transform model = value.Model;
					model.localPosition -= value.Offset;
				}
				value.Offset = Vector3.zero;
			}
		}

		internal static void Apply()
		{
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0300: Unknown result type (might be due to invalid IL or missing references)
			//IL_0302: Unknown result type (might be due to invalid IL or missing references)
			//IL_030e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0310: Unknown result type (might be due to invalid IL or missing references)
			RoundManager instance = RoundManager.Instance;
			if (!Gravity.Active || (Object)(object)instance == (Object)null || (!Plugin.EnemyFloatyGait.Value && !Plugin.EnemyDrift.Value))
			{
				Clear();
				return;
			}
			bool flag = (Object)(object)NetworkManager.Singleton != (Object)null && NetworkManager.Singleton.IsServer;
			float num = Mathf.Max(Time.deltaTime, 0.0001f);
			foreach (EnemyAI spawnedEnemy in instance.SpawnedEnemies)
			{
				if ((Object)(object)spawnedEnemy == (Object)null || spawnedEnemy.isEnemyDead)
				{
					continue;
				}
				if (!States.TryGetValue(spawnedEnemy, out var value))
				{
					value = new State
					{
						LastPos = ((Component)spawnedEnemy).transform.position,
						Phase = (float)(((NetworkBehaviour)spawnedEnemy).NetworkObjectId % 97) / 97f
					};
					Animator creatureAnimator = spawnedEnemy.creatureAnimator;
					bool flag2 = ((object)spawnedEnemy).GetType().Assembly == typeof(EnemyAI).Assembly;
					if ((Object)(object)creatureAnimator != (Object)null && (Object)(object)((Component)creatureAnimator).transform != (Object)(object)((Component)spawnedEnemy).transform && flag2 && !NoBob.Contains(((object)spawnedEnemy).GetType().Name))
					{
						value.Model = ((Component)creatureAnimator).transform;
					}
					States[spawnedEnemy] = value;
				}
				Vector3 position = ((Component)spawnedEnemy).transform.position;
				Vector3 val = position - value.LastPos;
				val.y = 0f;
				value.LastPos = position;
				value.Speed = Mathf.Lerp(value.Speed, Mathf.Min(((Vector3)(ref val)).magnitude / num, 20f), 1f - Mathf.Exp((0f - num) * 6f));
				if (Plugin.EnemyFloatyGait.Value && (Object)(object)spawnedEnemy.creatureAnimator != (Object)null)
				{
					Animator creatureAnimator2 = spawnedEnemy.creatureAnimator;
					if (value.LastSetAnim < 0f || !Mathf.Approximately(creatureAnimator2.speed, value.LastSetAnim))
					{
						value.BaseAnimSpeed = creatureAnimator2.speed;
					}
					value.LastSetAnim = value.BaseAnimSpeed * 0.75f;
					creatureAnimator2.speed = value.LastSetAnim;
				}
				if (Plugin.EnemyFloatyGait.Value && (Object)(object)value.Model != (Object)null && value.Speed > 0.3f)
				{
					float num2 = 0.25f * Mathf.Clamp01((value.Speed - 0.3f) / 2f);
					float num3 = Mathf.Abs(Mathf.Sin((Time.time * 1.1f + value.Phase) * MathF.PI)) * num2;
					Transform parent = value.Model.parent;
					Vector3 val2 = (((Object)(object)parent != (Object)null) ? parent.InverseTransformVector(Vector3.up * num3) : (Vector3.up * num3));
					Transform model = value.Model;
					model.localPosition += val2;
					value.Offset = val2;
				}
				if (flag && Plugin.EnemyDrift.Value && (Object)(object)spawnedEnemy.agent != (Object)null)
				{
					NavMeshAgent agent = spawnedEnemy.agent;
					if (value.LastSetAccel < 0f || !Mathf.Approximately(agent.acceleration, value.LastSetAccel))
					{
						value.BaseAccel = agent.acceleration;
					}
					if (value.LastSetAngular < 0f || !Mathf.Approximately(agent.angularSpeed, value.LastSetAngular))
					{
						value.BaseAngular = agent.angularSpeed;
					}
					value.LastSetAccel = value.BaseAccel * 0.4f;
					agent.acceleration = value.LastSetAccel;
					value.LastSetAngular = value.BaseAngular * 0.5f;
					agent.angularSpeed = value.LastSetAngular;
				}
			}
		}

		internal static void Clear()
		{
			if (States.Count == 0)
			{
				return;
			}
			Undo();
			foreach (KeyValuePair<EnemyAI, State> state in States)
			{
				EnemyAI key = state.Key;
				State value = state.Value;
				if (!((Object)(object)key == (Object)null))
				{
					if ((Object)(object)key.creatureAnimator != (Object)null && value.LastSetAnim >= 0f && Mathf.Approximately(key.creatureAnimator.speed, value.LastSetAnim))
					{
						key.creatureAnimator.speed = value.BaseAnimSpeed;
					}
					if ((Object)(object)key.agent != (Object)null && value.LastSetAccel >= 0f && Mathf.Approximately(key.agent.acceleration, value.LastSetAccel))
					{
						key.agent.acceleration = value.BaseAccel;
					}
					if ((Object)(object)key.agent != (Object)null && value.LastSetAngular >= 0f && Mathf.Approximately(key.agent.angularSpeed, value.LastSetAngular))
					{
						key.agent.angularSpeed = value.BaseAngular;
					}
				}
			}
			States.Clear();
		}
	}
	public static class PluginInfo
	{
		public const string Guid = "daniel.lethalcompany.lowgravity";

		public const string Name = "Low Gravity";

		public const string Version = "0.1.0";
	}
	[BepInPlugin("daniel.lethalcompany.lowgravity", "Low Gravity", "0.1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Log;

		internal static ConfigEntry<float> GravityScale;

		internal static ConfigEntry<float> JumpForce;

		internal static ConfigEntry<FallDamageMode> FallDamage;

		internal static ConfigEntry<float> ItemFallSpeed;

		internal static ConfigEntry<bool> ItemDrift;

		internal static ConfigEntry<float> ItemDriftInterval;

		internal static ConfigEntry<bool> EnemyFloatyGait;

		internal static ConfigEntry<bool> EnemyDrift;

		internal static ConfigEntry<bool> CruiserNormalGravity;

		internal static ConfigEntry<bool> DustParticles;

		internal static ConfigEntry<bool> FogTint;

		internal static ConfigEntry<bool> LandingTip;

		internal static ConfigEntry<bool> EveryDay;

		private readonly Harmony _harmony = new Harmony("daniel.lethalcompany.lowgravity");

		private void Awake()
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Expected O, but got Unknown
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Expected O, but got Unknown
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Expected O, but got Unknown
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Expected O, but got Unknown
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			GravityScale = ((BaseUnityPlugin)this).Config.Bind<float>("Gravity", "GravityScale", 0.35f, new ConfigDescription("Gravity on Low Gravity days, as a share of normal (players, falling scrap, bodies).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 1f), Array.Empty<object>()));
			JumpForce = ((BaseUnityPlugin)this).Config.Bind<float>("Gravity", "JumpForce", 9f, new ConfigDescription("Jump force on Low Gravity days (vanilla is 5).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 20f), Array.Empty<object>()));
			FallDamage = ((BaseUnityPlugin)this).Config.Bind<FallDamageMode>("Gravity", "FallDamage", FallDamageMode.Natural, "Natural: vanilla rules with low gravity, so only very long drops (about 50 m) hurt. Off: no fall damage on these days. VanillaHeights: the same heights hurt as on a normal day.");
			ItemFallSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Scrap", "ItemFallSpeed", 0.35f, new ConfigDescription("How fast dropped scrap falls, as a share of normal.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 1f), Array.Empty<object>()));
			ItemDrift = ((BaseUnityPlugin)this).Config.Bind<bool>("Scrap", "ItemDrift", true, "Now and then a loose piece of scrap outside lifts and drifts a little (host decides).");
			ItemDriftInterval = ((BaseUnityPlugin)this).Config.Bind<float>("Scrap", "ItemDriftInterval", 20f, new ConfigDescription("Seconds between drifts (host).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(3f, 600f), Array.Empty<object>()));
			EnemyFloatyGait = ((BaseUnityPlugin)this).Config.Bind<bool>("Monsters", "EnemyFloatyGait", true, "Walking monsters animate slower and bob along in floaty hops. Visual only: their real speed is unchanged.");
			EnemyDrift = ((BaseUnityPlugin)this).Config.Bind<bool>("Monsters", "EnemyDrift", false, "Monsters accelerate and turn more slowly, so they overshoot corners (host). Makes them easier.");
			CruiserNormalGravity = ((BaseUnityPlugin)this).Config.Bind<bool>("Gravity", "CruiserNormalGravity", true, "The Company Cruiser keeps normal gravity so it stays drivable.");
			DustParticles = ((BaseUnityPlugin)this).Config.Bind<bool>("Visuals", "DustParticles", true, "Dust drifting slowly upward around you outside.");
			FogTint = ((BaseUnityPlugin)this).Config.Bind<bool>("Visuals", "FogTint", true, "A faint violet tint on the outdoor fog.");
			LandingTip = ((BaseUnityPlugin)this).Config.Bind<bool>("Visuals", "LandingTip", true, "Show a tip when the ship lands on a Low Gravity day.");
			EveryDay = ((BaseUnityPlugin)this).Config.Bind<bool>("Testing", "EveryDay", false, "Playtest switch (host): every moon gets Low Gravity every day, overriding WeatherRegistry's pick. Set back to false for the normal chance (about 1 moon in 10).");
			WeatherHook.Register();
			_harmony.PatchAll(typeof(Plugin).Assembly);
			GameObject val = new GameObject("LowGravity.Runner");
			Object.DontDestroyOnLoad((Object)val);
			((Object)val).hideFlags = (HideFlags)61;
			val.AddComponent<Runner>();
			val.AddComponent<EarlyRunner>();
			Log.LogInfo((object)"Low Gravity 0.1.0 loaded.");
		}
	}
	public enum FallDamageMode
	{
		Natural,
		Off,
		VanillaHeights
	}
	[DefaultExecutionOrder(-10000)]
	internal class EarlyRunner : MonoBehaviour
	{
		private void Update()
		{
			try
			{
				Gravity.Tick();
				Monsters.Undo();
				Drift.EnsureRegistered();
			}
			catch (Exception arg)
			{
				Plugin.Log.LogError((object)$"Low Gravity (early): {arg}");
			}
		}

		private void OnDestroy()
		{
			if (Gravity.Active)
			{
				Gravity.End();
			}
			Monsters.Clear();
			Visuals.Untint();
		}
	}
	[DefaultExecutionOrder(10000)]
	internal class Runner : MonoBehaviour
	{
		private void Update()
		{
			try
			{
				Monsters.Apply();
			}
			catch (Exception arg)
			{
				Plugin.Log.LogError((object)$"Low Gravity (monsters): {arg}");
				Monsters.Clear();
			}
		}

		private void LateUpdate()
		{
			try
			{
				Drift.HostTick();
				Drift.Tick();
				Visuals.Tick();
			}
			catch (Exception arg)
			{
				Plugin.Log.LogError((object)$"Low Gravity (late): {arg}");
			}
		}
	}
	internal static class ShockwaveLink
	{
		private static bool _looked;

		private static FieldInfo _landed;

		private static FieldInfo _openUntil;

		private static FieldInfo _gravity;

		internal static bool InFlight(out float gravity)
		{
			gravity = 1f;
			if (!_looked)
			{
				_looked = true;
				try
				{
					Type type = AccessTools.TypeByName("ShockwaveGrenade.FallGuard");
					if (type != null)
					{
						_landed = AccessTools.Field(type, "_landed");
						_openUntil = AccessTools.Field(type, "_openUntil");
						_gravity = AccessTools.Field(type, "_gravity");
						if (_landed == null || _openUntil == null || _gravity == null)
						{
							_landed = null;
						}
						else
						{
							Plugin.Log.LogInfo((object)"Shockwave Grenade found: launches fly higher on Low Gravity days.");
						}
					}
				}
				catch (Exception ex)
				{
					Plugin.Log.LogWarning((object)("Shockwave link off: " + ex.Message));
					_landed = null;
				}
			}
			if (_landed == null)
			{
				return false;
			}
			if ((bool)_landed.GetValue(null) || Time.time > (float)_openUntil.GetValue(null))
			{
				return false;
			}
			gravity = Mathf.Clamp((float)_gravity.GetValue(null), 0.1f, 1f);
			return true;
		}
	}
	internal static class Visuals
	{
		private static ParticleSystem _dust;

		private static bool _tipShown;

		private static readonly List<(Fog fog, Color albedo, bool overridden)> Tinted = new List<(Fog, Color, bool)>();

		private static readonly Color Violet = new Color(0.72f, 0.55f, 1f, 1f);

		internal static void Tick()
		{
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			StartOfRound instance = StartOfRound.Instance;
			if (!Gravity.Active)
			{
				_tipShown = false;
				if ((Object)(object)_dust != (Object)null && _dust.isPlaying)
				{
					_dust.Stop(true, (ParticleSystemStopBehavior)1);
				}
				if (Tinted.Count > 0)
				{
					Untint();
				}
				return;
			}
			if (Plugin.FogTint.Value && Tinted.Count == 0)
			{
				Tint();
			}
			if (!_tipShown && (Object)(object)instance != (Object)null && instance.shipHasLanded && (Object)(object)HUDManager.Instance != (Object)null)
			{
				_tipShown = true;
				if (Plugin.LandingTip.Value)
				{
					int num = Mathf.RoundToInt((((WeatherHook.Weather != null) ? WeatherHook.Weather.ScrapValueMultiplier : 1.25f) - 1f) * 100f);
					string text = ((num > 0) ? $" Scrap is worth {num}% more today." : "");
					HUDManager.Instance.DisplayTip("LOW GRAVITY", "Jump carefully." + text, false, false, "LC_Tip1");
				}
			}
			PlayerControllerB val = (((Object)(object)GameNetworkManager.Instance != (Object)null) ? GameNetworkManager.Instance.localPlayerController : null);
			Camera val2 = (((Object)(object)instance != (Object)null) ? instance.activeCamera : null);
			bool flag = (Object)(object)val != (Object)null && !val.isPlayerDead && !val.isInsideFactory && !val.isInHangarShipRoom;
			if (!Plugin.DustParticles.Value || (Object)(object)val2 == (Object)null || !flag)
			{
				if ((Object)(object)_dust != (Object)null && _dust.isPlaying)
				{
					_dust.Stop(true, (ParticleSystemStopBehavior)1);
				}
				return;
			}
			if ((Object)(object)_dust == (Object)null)
			{
				_dust = MakeDust();
			}
			if (!((Object)(object)_dust == (Object)null))
			{
				((Component)_dust).transform.position = ((Component)val2).transform.position;
				if (!_dust.isPlaying)
				{
					_dust.Play(true);
				}
			}
		}

		private static ParticleSystem MakeDust()
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			//IL_0051: 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_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: 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_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: 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_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: 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_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: 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_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: 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_0254: 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)
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0279: Expected O, but got Unknown
			//IL_0274: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b4: Expected O, but got Unknown
			//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
			Shader val = Shader.Find("HDRP/Lit");
			if ((Object)(object)val == (Object)null)
			{
				Plugin.Log.LogWarning((object)"Low Gravity: HDRP/Lit not found, no dust.");
				Plugin.DustParticles.Value = false;
				return null;
			}
			GameObject val2 = new GameObject("LowGravity.Dust");
			Object.DontDestroyOnLoad((Object)(object)val2);
			ParticleSystem val3 = val2.AddComponent<ParticleSystem>();
			val3.Stop(true, (ParticleSystemStopBehavior)0);
			MainModule main = val3.main;
			((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
			((MainModule)(ref main)).startLifetime = new MinMaxCurve(6f, 10f);
			((MainModule)(ref main)).startSpeed = MinMaxCurve.op_Implicit(0f);
			((MainModule)(ref main)).startSize = new MinMaxCurve(0.015f, 0.06f);
			((MainModule)(ref main)).startRotation3D = true;
			MinMaxCurve val4 = default(MinMaxCurve);
			((MinMaxCurve)(ref val4))..ctor(0f, 6.28f);
			((MainModule)(ref main)).startRotationZ = val4;
			MinMaxCurve startRotationX = (((MainModule)(ref main)).startRotationY = val4);
			((MainModule)(ref main)).startRotationX = startRotationX;
			((MainModule)(ref main)).startColor = new MinMaxGradient(new Color(0.42f, 0.38f, 0.34f), new Color(0.62f, 0.58f, 0.52f));
			((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(0f);
			((MainModule)(ref main)).maxParticles = 160;
			EmissionModule emission = val3.emission;
			((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(18f);
			ShapeModule shape = val3.shape;
			((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)0;
			((ShapeModule)(ref shape)).radius = 7f;
			VelocityOverLifetimeModule velocityOverLifetime = val3.velocityOverLifetime;
			((VelocityOverLifetimeModule)(ref velocityOverLifetime)).enabled = true;
			((VelocityOverLifetimeModule)(ref velocityOverLifetime)).space = (ParticleSystemSimulationSpace)1;
			((VelocityOverLifetimeModule)(ref velocityOverLifetime)).x = new MinMaxCurve(-0.08f, 0.08f);
			((VelocityOverLifetimeModule)(ref velocityOverLifetime)).y = new MinMaxCurve(0.12f, 0.35f);
			((VelocityOverLifetimeModule)(ref velocityOverLifetime)).z = new MinMaxCurve(-0.08f, 0.08f);
			RotationOverLifetimeModule rotationOverLifetime = val3.rotationOverLifetime;
			((RotationOverLifetimeModule)(ref rotationOverLifetime)).enabled = true;
			((RotationOverLifetimeModule)(ref rotationOverLifetime)).separateAxes = true;
			((MinMaxCurve)(ref val4))..ctor(-0.6f, 0.6f);
			((RotationOverLifetimeModule)(ref rotationOverLifetime)).z = val4;
			startRotationX = (((RotationOverLifetimeModule)(ref rotationOverLifetime)).y = val4);
			((RotationOverLifetimeModule)(ref rotationOverLifetime)).x = startRotationX;
			SizeOverLifetimeModule sizeOverLifetime = val3.sizeOverLifetime;
			((SizeOverLifetimeModule)(ref sizeOverLifetime)).enabled = true;
			((SizeOverLifetimeModule)(ref sizeOverLifetime)).size = new MinMaxCurve(1f, new AnimationCurve((Keyframe[])(object)new Keyframe[4]
			{
				new Keyframe(0f, 0f),
				new Keyframe(0.15f, 1f),
				new Keyframe(0.85f, 1f),
				new Keyframe(1f, 0f)
			}));
			ParticleSystemRenderer component = val2.GetComponent<ParticleSystemRenderer>();
			component.renderMode = (ParticleSystemRenderMode)4;
			GameObject val7 = GameObject.CreatePrimitive((PrimitiveType)3);
			component.mesh = val7.GetComponent<MeshFilter>().sharedMesh;
			Object.Destroy((Object)(object)val7);
			Material val8 = new Material(val);
			val8.SetColor("_BaseColor", Color.white);
			val8.SetFloat("_Smoothness", 0.1f);
			val8.enableInstancing = true;
			((Renderer)component).material = val8;
			((Renderer)component).shadowCastingMode = (ShadowCastingMode)0;
			((Renderer)component).receiveShadows = true;
			return val3;
		}

		private static void Tint()
		{
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			Volume[] array = Object.FindObjectsOfType<Volume>();
			Fog val3 = default(Fog);
			foreach (Volume val in array)
			{
				if ((Object)(object)val == (Object)null || !val.isGlobal)
				{
					continue;
				}
				VolumeProfile val2 = (val.HasInstantiatedProfile() ? val.profile : val.sharedProfile);
				if ((Object)(object)val2 == (Object)null || !val2.TryGet<Fog>(ref val3) || (Object)(object)val3 == (Object)null)
				{
					continue;
				}
				bool flag = false;
				foreach (var item in Tinted)
				{
					if ((Object)(object)item.fog == (Object)(object)val3)
					{
						flag = true;
					}
				}
				if (!flag)
				{
					Tinted.Add((val3, ((VolumeParameter<Color>)(object)val3.albedo).value, ((VolumeParameter)val3.albedo).overrideState));
					((VolumeParameter)val3.albedo).overrideState = true;
					((VolumeParameter<Color>)(object)val3.albedo).value = Color.Lerp(((VolumeParameter<Color>)(object)val3.albedo).value, Violet, 0.35f);
				}
			}
			if (Tinted.Count == 0)
			{
				Tinted.Add((null, Color.clear, false));
			}
		}

		internal static void Untint()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			foreach (var (val, value, overrideState) in Tinted)
			{
				if (!((Object)(object)val == (Object)null))
				{
					((VolumeParameter<Color>)(object)val.albedo).value = value;
					((VolumeParameter)val.albedo).overrideState = overrideState;
				}
			}
			Tinted.Clear();
		}
	}
	internal static class WeatherHook
	{
		internal const string WeatherName = "Low Gravity";

		internal static Weather Weather;

		internal static void Register()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Expected O, but got Unknown
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Expected O, but got Unknown
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Expected O, but got Unknown
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Expected O, but got Unknown
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Expected O, but got Unknown
			//IL_00e4: Expected O, but got Unknown
			//IL_00e9: Expected O, but got Unknown
			ImprovedWeatherEffect val = ScriptableObject.CreateInstance<ImprovedWeatherEffect>();
			((Object)val).name = "Low Gravity";
			val.SunAnimatorBool = "";
			TMP_ColorGradient val2 = ScriptableObject.CreateInstance<TMP_ColorGradient>();
			val2.colorMode = (ColorMode)2;
			val2.topLeft = (val2.topRight = new Color(0.45f, 0.9f, 1f, 1f));
			val2.bottomLeft = (val2.bottomRight = new Color(0.72f, 0.5f, 1f, 1f));
			Weather = new Weather("Low Gravity", val)
			{
				ColorGradient = val2,
				Config = new RegistryWeatherConfig
				{
					DefaultWeight = new IntegerConfigHandler(45, true),
					ScrapValueMultiplier = new FloatConfigHandler(1.25f, true),
					ScrapAmountMultiplier = new FloatConfigHandler(1f, true),
					LevelFilters = new LevelListConfigHandler("Company;", true),
					FilteringOption = new BooleanConfigHandler((FilteringOption)1, true)
				}
			};
			WeatherManager.RegisterWeather(Weather);
		}

		internal static bool TryGetType(out LevelWeatherType t)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected I4, but got Unknown
			t = (LevelWeatherType)(-1);
			if (Weather == null || !WeatherManager.IsSetupFinished)
			{
				return false;
			}
			t = (LevelWeatherType)(int)Weather.VanillaWeatherType;
			return (int)t >= 0;
		}

		internal static bool TodayHere()
		{
			//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_0058: 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)
			StartOfRound instance = StartOfRound.Instance;
			TimeOfDay instance2 = TimeOfDay.Instance;
			if ((Object)(object)instance == (Object)null || (Object)(object)instance2 == (Object)null || instance.inShipPhase || instance.shipIsLeaving || (Object)(object)instance.currentLevel == (Object)null)
			{
				return false;
			}
			if (!TryGetType(out var t))
			{
				return false;
			}
			if (instance2.currentLevelWeather != t)
			{
				return instance.currentLevel.currentWeather == t;
			}
			return true;
		}
	}
}