Decompiled source of Company Globes v1.0.4

plugins/GlobeScrap.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using Chameleon;
using Chameleon.Patches;
using Dawn;
using Dawn.Utils;
using Dusk;
using Dusk.Weights;
using GlobeScrap.NetcodePatcher;
using LethalLevelLoader;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: IgnoresAccessChecksTo("CelestialTint")]
[assembly: IgnoresAccessChecksTo("Chameleon")]
[assembly: IgnoresAccessChecksTo("LethalLevelLoader")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("GlobeScrap")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.4.0")]
[assembly: AssemblyInformationalVersion("1.0.4")]
[assembly: AssemblyProduct("GlobeScrap")]
[assembly: AssemblyTitle("GlobeScrap")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.4.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
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 GlobeScrap
{
	public class GlobeBehaviour : GrabbableObject
	{
		[CompilerGenerated]
		private sealed class <SpinGlobe>d__14 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public GlobeBehaviour <>4__this;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <SpinGlobe>d__14(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_003d: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>4__this.isSpinning = true;
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				if (<>4__this.spinTime < 2.5f)
				{
					<>4__this.planetContainer.Rotate(Vector3.up, (0f - <>4__this.spinSpeed) * <>4__this.spinDecceleration.Evaluate(<>4__this.spinTime), (Space)1);
					<>4__this.spinTime += Time.deltaTime;
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				<>4__this.isSpinning = false;
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <WaitForID>d__9 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public GlobeBehaviour <>4__this;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <WaitForID>d__9(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				if (!<>4__this.isSet)
				{
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				<>4__this.InitializeItem(<>4__this.planetID);
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		public Transform planetContainer;

		public float spinSpeed = 8f;

		public AnimationCurve spinDecceleration;

		private bool isSpinning;

		private float spinTime;

		private int planetID;

		private bool isSet = false;

		public override void Start()
		{
			((GrabbableObject)this).Start();
			((MonoBehaviour)this).StartCoroutine(WaitForID());
			if (!isSet && ((NetworkBehaviour)this).IsServer)
			{
				SyncPlanetIDRpc();
			}
		}

		[Rpc(/*Could not decode attribute arguments.*/)]
		private void SyncPlanetIDRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_0043: 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_0051: 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_0064: 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_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1)
				{
					RpcAttributeParams val = default(RpcAttributeParams);
					RpcParams val2 = default(RpcParams);
					FastBufferWriter val3 = ((NetworkBehaviour)this).__beginSendRpc(3514806375u, val2, val, (SendTo)7, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendRpc(ref val3, 3514806375u, val2, val, (SendTo)7, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1)
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					planetID = StartOfRound.Instance.currentLevelID;
					isSet = true;
				}
			}
		}

		[IteratorStateMachine(typeof(<WaitForID>d__9))]
		private IEnumerator WaitForID()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <WaitForID>d__9(0)
			{
				<>4__this = this
			};
		}

		private void InitializeItem(int planetID)
		{
			GameObject val = GlobeBuilder.Build(StartOfRound.Instance.levels[planetID]);
			if ((Object)(object)val != (Object)null)
			{
				HidePlaceholderPlanet();
				SetScanNodeData(StartOfRound.Instance.levels[planetID].PlanetName.TrimStart(' ', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-'));
				Object.Instantiate<GameObject>(val, planetContainer, false);
			}
		}

		public override int GetItemDataToSave()
		{
			((GrabbableObject)this).GetItemDataToSave();
			return planetID;
		}

		public override void LoadItemSaveData(int saveData)
		{
			((GrabbableObject)this).LoadItemSaveData(saveData);
			planetID = saveData;
			int num = StartOfRound.Instance.levels.Length;
			if (planetID > num)
			{
				planetID %= num;
			}
			isSet = true;
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			if (!((Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null))
			{
				spinTime = (float)Random.Range(0, 10) / 10f;
				if (!isSpinning)
				{
					((MonoBehaviour)this).StartCoroutine(SpinGlobe());
				}
			}
		}

		[IteratorStateMachine(typeof(<SpinGlobe>d__14))]
		private IEnumerator SpinGlobe()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <SpinGlobe>d__14(0)
			{
				<>4__this = this
			};
		}

		private void HidePlaceholderPlanet()
		{
			((Component)planetContainer.GetChild(0)).gameObject.SetActive(false);
		}

		private void SetScanNodeData(string planetName)
		{
			Transform val = ((Component)this).transform.Find("ScanNode");
			ScanNodeProperties val2 = default(ScanNodeProperties);
			if (((Component)val).TryGetComponent<ScanNodeProperties>(ref val2))
			{
				val2.headerText = planetName.TrimStart(' ', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-') + " Globe";
			}
		}

		protected override void __initializeVariables()
		{
			((GrabbableObject)this).__initializeVariables();
		}

		protected override void __initializeRpcs()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			((NetworkBehaviour)this).__registerRpc(3514806375u, new RpcReceiveHandler(__rpc_handler_3514806375), "SyncPlanetIDRpc");
			((GrabbableObject)this).__initializeRpcs();
		}

		private static void __rpc_handler_3514806375(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((GlobeBehaviour)(object)target).SyncPlanetIDRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "GlobeBehaviour";
		}
	}
	internal static class GlobeBuilder
	{
		private static string cachedLevelName = string.Empty;

		private static GameObject cachedModel;

		public static List<SpecialCaseMoon> moonSpecialCaseList;

		private static bool CelestialTintEnabled;

		private static bool ChameleonEnabled;

		private static bool LLLEnabled;

		private static GameObject planetMesh;

		private static Material artificeMatReference;

		private static Material embrionMatReference;

		private static Material gordionMatReference;

		private static Material desertMatReference;

		private static Material forestMatReference;

		private static Material snowyMatReference;

		public static void Initialise(AssetBundle bundle, bool ChameleonCompatFlag, bool CelestialTintCompatFlag, bool LethalLevelLoaderCompatFlag)
		{
			if (ChameleonCompatFlag)
			{
				LevelLoaderCompat();
			}
			if (CelestialTintCompatFlag)
			{
				CelestialTintCompat();
			}
			LLLEnabled = LethalLevelLoaderCompatFlag;
			cachedModel = bundle.LoadAsset<GameObject>("Assets/LethalCompany/Mods/Globe/Assets/BuilderObjects/cacheObject.prefab");
			planetMesh = bundle.LoadAsset<GameObject>("Assets/LethalCompany/Mods/Globe/Assets/BuilderObjects/Prefab.prefab");
			desertMatReference = bundle.LoadAsset<Material>("Assets/LethalCompany/Mods/Globe/Assets/BuilderObjects/DesertPlanet.mat");
			forestMatReference = bundle.LoadAsset<Material>("Assets/LethalCompany/Mods/Globe/Assets/BuilderObjects/ForestPlanet.mat");
			snowyMatReference = bundle.LoadAsset<Material>("Assets/LethalCompany/Mods/Globe/Assets/BuilderObjects/SnowPlanet.mat");
			gordionMatReference = bundle.LoadAsset<Material>("Assets/LethalCompany/Mods/Globe/Assets/BuilderObjects/OceanPlanet.mat");
			Populate();
		}

		private static void CelestialTintCompat()
		{
			try
			{
				CelestialTintEnabled = !CelestialTint.ModConfig.VanillaMode.Value;
			}
			catch
			{
			}
		}

		private static void LevelLoaderCompat()
		{
			try
			{
				ChameleonEnabled = Configuration.planetPreview.Value;
			}
			catch
			{
			}
		}

		public static GameObject Build(SelectableLevel level)
		{
			if ((Object)(object)cachedModel != (Object)null && cachedLevelName != level.PlanetName)
			{
				cachedLevelName = level.PlanetName;
				if (BuildPrefabbedPlanets(level))
				{
					return cachedModel;
				}
				if (CelestialTintEnabled || !BuildFromPrefab(level))
				{
					if (LLLEnabled)
					{
						BuildFromLevelTag(level);
					}
					else
					{
						NameFallback(level);
					}
				}
			}
			return cachedModel;
		}

		private static bool BuildPrefabbedPlanets(SelectableLevel level)
		{
			switch (level.PlanetName.TrimStart(' ', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-'))
			{
			case "Artifice":
				if (ChameleonEnabled)
				{
					if (!CheckIfBlizzard())
					{
						if ((Object)(object)artificeMatReference == (Object)null)
						{
							artificeMatReference = GetArtMat();
						}
						PresetMoon(artificeMatReference);
					}
					else
					{
						PresetMoon(snowyMatReference);
					}
				}
				else
				{
					PresetMoon(forestMatReference);
				}
				return true;
			case "Embrion":
				if (ChameleonEnabled)
				{
					if ((Object)(object)embrionMatReference == (Object)null)
					{
						embrionMatReference = GetEmbMat();
					}
					PresetMoon(embrionMatReference);
					return true;
				}
				break;
			case "Gordion":
				PresetMoon(gordionMatReference);
				return true;
			}
			return false;
		}

		private static bool CheckIfBlizzard()
		{
			try
			{
				return Object.op_Implicit((Object)(object)Common.artificeBlizzard);
			}
			catch
			{
				return false;
			}
		}

		private static Material GetArtMat()
		{
			try
			{
				if ((Object)(object)PlanetPreviewPatches.artificeMat != (Object)null)
				{
					return PlanetPreviewPatches.artificeMat;
				}
				return null;
			}
			catch
			{
				return null;
			}
		}

		private static Material GetEmbMat()
		{
			try
			{
				if ((Object)(object)PlanetPreviewPatches.embrionMat != (Object)null)
				{
					return PlanetPreviewPatches.embrionMat;
				}
				return null;
			}
			catch
			{
				return null;
			}
		}

		private static bool BuildFromPrefab(SelectableLevel level)
		{
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: 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_0117: 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_0110: Unknown result type (might be due to invalid IL or missing references)
			string planetName = level.PlanetName.TrimStart(' ', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-');
			SpecialCaseMoon specialCaseMoon = moonSpecialCaseList.Find((SpecialCaseMoon x) => x.PlanetName == planetName);
			if (CopyFromPrefab(level.planetPrefab.transform, (specialCaseMoon == null) ? new List<int>() : specialCaseMoon.PositionInPrefab))
			{
				cachedModel.transform.localPosition = ((specialCaseMoon == null || !specialCaseMoon.PositionOverride.HasValue) ? Vector3.zero : specialCaseMoon.PositionOverride.Value);
				cachedModel.transform.localRotation = ((specialCaseMoon == null || !specialCaseMoon.RotationOverride.HasValue) ? Quaternion.Euler(-90f, 0f, 0f) : specialCaseMoon.RotationOverride.Value);
				cachedModel.transform.localScale = ((specialCaseMoon == null || !specialCaseMoon.ScaleOverride.HasValue) ? (Vector3.one * 10.31595f) : specialCaseMoon.ScaleOverride.Value);
				cachedModel.layer = 6;
				return true;
			}
			return false;
		}

		private static void BuildFromLevelTag(SelectableLevel level)
		{
			foreach (ContentTag contentTag in ((ExtendedContent)LevelManager.GetExtendedLevel(level)).ContentTags)
			{
				switch (contentTag.contentTagName)
				{
				case "Desert":
				case "Canyon":
				case "Wasteland":
				case "Volcanic":
				case "Rocky":
				case "Argon":
					PresetMoon(desertMatReference);
					return;
				case "Forest":
				case "Valley":
				case "Marsh":
					PresetMoon(forestMatReference);
					return;
				case "Tundra":
				case "Snow":
					PresetMoon(snowyMatReference);
					return;
				case "Company":
				case "Ocean":
					PresetMoon(gordionMatReference);
					return;
				}
			}
			PresetMoon(desertMatReference);
		}

		private static void NameFallback(SelectableLevel level)
		{
			switch (level.PlanetName.TrimStart(' ', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-'))
			{
			default:
				PresetMoon(desertMatReference);
				break;
			case "Vow":
			case "March":
			case "Adamance":
			case "Artifice":
				PresetMoon(forestMatReference);
				break;
			case "Dine":
			case "Rend":
			case "Titan":
				PresetMoon(snowyMatReference);
				break;
			case "Liquidation":
			case "Gordion":
				PresetMoon(gordionMatReference);
				break;
			}
		}

		private static void PresetMoon(Material overrideMaterial)
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: 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_0089: Unknown result type (might be due to invalid IL or missing references)
			CopyMeshFilter(planetMesh.GetComponent<MeshFilter>(), cachedModel.gameObject);
			MeshRenderer val = cachedModel.GetComponent<MeshRenderer>() ?? cachedModel.AddComponent<MeshRenderer>();
			((Renderer)val).material = overrideMaterial;
			cachedModel.transform.localPosition = Vector3.zero;
			cachedModel.transform.localRotation = Quaternion.Euler(-90f, 0f, 0f);
			cachedModel.transform.localScale = Vector3.one * 10.31595f;
			cachedModel.layer = 6;
		}

		private static bool CopyFromPrefab(Transform reference, List<int> positionInPrefab)
		{
			Transform val = reference;
			for (int i = 0; i < positionInPrefab.Count; i++)
			{
				val = val.GetChild(positionInPrefab[i]);
			}
			if ((Object)(object)val == (Object)null)
			{
				return false;
			}
			((Object)cachedModel).name = ((Object)val).name;
			if ((Object)(object)((Component)val).GetComponent<MeshFilter>() != (Object)null && (Object)(object)((Component)val).GetComponent<MeshRenderer>() != (Object)null)
			{
				CopyMeshFilter(((Component)val).GetComponent<MeshFilter>(), cachedModel.gameObject);
				CopyMeshRenderer(((Component)val).GetComponent<MeshRenderer>(), cachedModel.gameObject);
				return true;
			}
			return false;
		}

		private static void CopyMeshFilter(MeshFilter original, GameObject destination)
		{
			MeshFilter val = destination.GetComponent<MeshFilter>() ?? destination.AddComponent<MeshFilter>();
			val.mesh = original.sharedMesh;
		}

		private static void CopyMeshRenderer(MeshRenderer original, GameObject destination)
		{
			MeshRenderer val = destination.GetComponent<MeshRenderer>() ?? destination.AddComponent<MeshRenderer>();
			((Renderer)val).materials = ((Renderer)original).sharedMaterials;
		}

		public static void Populate()
		{
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: 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_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f8: 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_055e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0577: Unknown result type (might be due to invalid IL or missing references)
			//IL_0581: Unknown result type (might be due to invalid IL or missing references)
			//IL_058b: Unknown result type (might be due to invalid IL or missing references)
			//IL_05bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d1: Unknown result type (might be due to invalid IL or missing references)
			moonSpecialCaseList = new List<SpecialCaseMoon>(39)
			{
				new SpecialCaseMoon("Acidir", new List<int>(2) { 0, 0 }, null, null, null),
				new SpecialCaseMoon("Alcatras", new List<int>(2) { 0, 1 }, null, null, null),
				new SpecialCaseMoon("Assurance", new List<int>(1) { 0 }, null, null, null),
				new SpecialCaseMoon("Asteroid-13", new List<int>(2) { 0, 44 }, null, Quaternion.Euler(313.7936f, 115.4804f, 236.1909f), Vector3.one * 2.7f),
				new SpecialCaseMoon("Awakening", new List<int>(1) { 2 }, null, null, null),
				new SpecialCaseMoon("Calist", new List<int>(2) { 0, 0 }, null, Quaternion.Euler(0f, 180f, -90f), null),
				new SpecialCaseMoon("Core", new List<int>(1) { 0 }, null, null, null),
				new SpecialCaseMoon("Cubatres", new List<int>(1) { 0 }, null, Quaternion.Euler(329.7869f, 139.6691f, 272.1489f), Vector3.one * 6.7f),
				new SpecialCaseMoon("Demetrica", new List<int>(2) { 0, 0 }, null, null, null),
				new SpecialCaseMoon("Desolation", new List<int>(2) { 0, 1 }, null, null, null),
				new SpecialCaseMoon("Duckstroid-14", new List<int>(1) { 0 }, (Vector3?)new Vector3(0f, -9.749605f, 3.74985f), (Quaternion?)null, (Vector3?)(Vector3.one * 0.7118006f)),
				new SpecialCaseMoon("Empra", new List<int>(2) { 0, 0 }, null, null, null),
				new SpecialCaseMoon("Espira", new List<int>(1) { 0 }, null, null, null),
				new SpecialCaseMoon("Experimentation", new List<int>(1) { 0 }, null, null, null),
				new SpecialCaseMoon("Faith", new List<int>(1) { 0 }, null, null, null),
				new SpecialCaseMoon("Filitrios", new List<int>(2) { 0, 1 }, null, null, null),
				new SpecialCaseMoon("Fission-C", new List<int>(1) { 0 }, null, null, null),
				new SpecialCaseMoon("Galetry", new List<int>(2) { 0, 0 }, null, null, null),
				new SpecialCaseMoon("Gloom", new List<int>(2) { 0, 1 }, null, null, null),
				new SpecialCaseMoon("Hope", new List<int>(1) { 2 }, null, null, null),
				new SpecialCaseMoon("Hyve", new List<int>(2) { 0, 19 }, Vector3.up, Quaternion.Euler(349.7223f, 153.4135f, 236.2058f), Vector3.one * 2.3f),
				new SpecialCaseMoon("Hyx", new List<int>(1) { 1 }, null, Quaternion.identity, Vector3.one * 5f),
				new SpecialCaseMoon("Impact", new List<int>(1) { 2 }, null, null, null),
				new SpecialCaseMoon("Junic", new List<int>(2) { 0, 1 }, null, null, null),
				new SpecialCaseMoon("Lecaro", new List<int>(2) { 0, 1 }, null, null, null),
				new SpecialCaseMoon("Lithium", new List<int>(1) { 0 }, null, null, null),
				new SpecialCaseMoon("Lua", new List<int>(1) { 0 }, null, null, null),
				new SpecialCaseMoon("Motra", new List<int>(2) { 0, 0 }, null, null, null),
				new SpecialCaseMoon("Navel", new List<int>(1) { 2 }, null, null, null),
				new SpecialCaseMoon("Offense", new List<int>(1) { 0 }, null, null, null),
				new SpecialCaseMoon("Oldred", new List<int>(2) { 0, 1 }, null, null, null),
				new SpecialCaseMoon("Oxyde", new List<int>(2) { 0, 0 }, null, null, null),
				new SpecialCaseMoon("Perplexing", new List<int>(1) { 2 }, null, null, null),
				new SpecialCaseMoon("Spring", new List<int>(1) { 2 }, null, null, null),
				new SpecialCaseMoon("Thalasso", new List<int>(2) { 0, 0 }, null, null, null),
				new SpecialCaseMoon("Trial", new List<int>(1) { 2 }, null, null, null),
				new SpecialCaseMoon("Trite", new List<int>(2) { 0, 0 }, null, null, null),
				new SpecialCaseMoon("Utril", new List<int>(2) { 0, 0 }, null, null, null),
				new SpecialCaseMoon("Wistful", new List<int>(1) { 2 }, null, null, null)
			};
		}
	}
	internal class SpecialCaseMoon
	{
		private readonly string planetName;

		private readonly List<int> positionInPrefab;

		private Vector3? positionOverride;

		private Quaternion? rotationOverride;

		private Vector3? scaleOverride;

		public string PlanetName => planetName;

		public List<int> PositionInPrefab => positionInPrefab;

		public Vector3? PositionOverride => positionOverride;

		public Quaternion? RotationOverride => rotationOverride;

		public Vector3? ScaleOverride => scaleOverride;

		public SpecialCaseMoon(string planetName, List<int> positionInPrefab, Vector3? positionOverride, Quaternion? rotationOverride, Vector3? scaleOverride)
		{
			this.planetName = planetName;
			this.positionInPrefab = positionInPrefab;
			this.positionOverride = positionOverride;
			this.rotationOverride = rotationOverride;
			this.scaleOverride = scaleOverride;
			base..ctor();
		}
	}
	[BepInPlugin("CompanyGlobes", "CompanyGlobes", "1.0.4")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public static class ScrapItemKey
		{
			public static NamespacedKey<DawnItemInfo> GlobeItem = NamespacedKey<DawnItemInfo>.From("Company_Globes", "CS_Globe");
		}

		public class ScrapConfig
		{
			public ConfigEntry<string> MoonSpawnWeights;

			public ConfigEntry<string> InteriorSpawnWeights;

			public ConfigEntry<string> WeatherSpawnWeights;

			public ConfigEntry<BoundedRange> Value;
		}

		public const string PLUGIN_GUID = "CompanyGlobes";

		public const string PLUGIN_NAME = "CompanyGlobes";

		public const string PLUGIN_VERSION = "1.0.4";

		public static Plugin instance;

		public ScrapConfig scrapConfig;

		private const string dawnLib_GUID = "com.github.teamxiaolan.dawnlib";

		private const string chameleon_GUID = "butterystancakes.lethalcompany.chameleon";

		private const string celestialTint_GUID = "CelestialTint";

		private const string lethalLevelLoader_GUID = "imabatby.lethallevelloader";

		public static DuskMod Mod { get; private set; }

		public SpawnWeightsPreset SpawnWeights { get; private set; } = new SpawnWeightsPreset();


		private void Awake()
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			instance = this;
			AssetBundle val = AssetBundleUtils.LoadBundle(Assembly.GetExecutingAssembly(), "globescrap");
			DuskItemDefinition val2 = val.LoadAsset<DuskItemDefinition>("Assets/LethalCompany/Mods/Globe/Assets/GlobeDefinition.asset");
			ConfigContext val3 = new ConfigContext(((BaseUnityPlugin)this).Config, val2.Item.itemName + " Options");
			try
			{
				scrapConfig = CreateItemConfig(val3, val2);
				SpawnWeights.SetupSpawnWeightsPreset(ConvertManyFromString(scrapConfig.MoonSpawnWeights.Value), ConvertManyFromString(scrapConfig.InteriorSpawnWeights.Value), ConvertManyFromString(scrapConfig.WeatherSpawnWeights.Value), 0);
				val2.Item.minValue = (int)(scrapConfig.Value.Value.Min * 2.5f);
				val2.Item.maxValue = (int)(scrapConfig.Value.Value.Max * 2.5f);
				DawnLib.RegisterNetworkPrefab(val2.Item.spawnPrefab);
				DawnLib.DefineItem(((DuskContentDefinition<DawnItemInfo>)(object)val2).TypedKey, val2.Item, (Action<ItemInfoBuilder>)delegate(ItemInfoBuilder builder)
				{
					builder.DefineScrap((Action<ScrapBuilder>)delegate(ScrapBuilder scrapBuilder)
					{
						scrapBuilder.SetWeights((Action<WeightTableBuilder<DawnMoonInfo>>)delegate(WeightTableBuilder<DawnMoonInfo> weightBuilder)
						{
							weightBuilder.SetGlobalWeight((IWeighted)(object)SpawnWeights);
						});
					});
				});
				bool chameleonCompatFlag = Chainloader.PluginInfos.ContainsKey("butterystancakes.lethalcompany.chameleon");
				bool celestialTintCompatFlag = Chainloader.PluginInfos.ContainsKey("CelestialTint");
				bool lethalLevelLoaderCompatFlag = Chainloader.PluginInfos.ContainsKey("imabatby.lethallevelloader");
				GlobeBuilder.Initialise(val, chameleonCompatFlag, celestialTintCompatFlag, lethalLevelLoaderCompatFlag);
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin GlobeScrap is loaded!");
			}
			finally
			{
				((IDisposable)val3)?.Dispose();
			}
		}

		public ScrapConfig CreateItemConfig(ConfigContext context, DuskItemDefinition duskItemDefinition)
		{
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Expected O, but got Unknown
			return new ScrapConfig
			{
				MoonSpawnWeights = context.Bind<string>("Preset Moon Weights", "Preset moon weights for " + duskItemDefinition.Item.itemName + ".", ConvertManyToString(duskItemDefinition.MoonSpawnWeightsConfig)),
				InteriorSpawnWeights = context.Bind<string>("Preset Interior Weights", "Preset interior weights for " + duskItemDefinition.Item.itemName + ".", ConvertManyToString(duskItemDefinition.InteriorSpawnWeightsConfig)),
				WeatherSpawnWeights = context.Bind<string>("Preset Weather Weights", "Preset weather weights for " + duskItemDefinition.Item.itemName + ".", ConvertManyToString(duskItemDefinition.WeatherSpawnWeightsConfig)),
				Value = context.Bind<BoundedRange>("Value", "How much " + duskItemDefinition.Item.itemName + " is worth when spawning.", new BoundedRange((float)duskItemDefinition.Item.minValue * 0.4f, (float)duskItemDefinition.Item.maxValue * 0.4f))
			};
		}

		internal static string ConvertManyToString(List<NamespacedConfigWeight> input)
		{
			string text = string.Empty;
			foreach (NamespacedConfigWeight item in input)
			{
				text = text + ConvertToString(item) + ",";
			}
			return StringExtensions.RemoveEnd(text, ",");
		}

		internal static string ConvertToString(NamespacedConfigWeight input)
		{
			//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_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Expected I4, but got Unknown
			if (input == null || input.NamespacedKey == null || string.IsNullOrEmpty(input.NamespacedKey.Namespace) || string.IsNullOrEmpty(input.NamespacedKey.Key))
			{
				return string.Empty;
			}
			MathOperation mathOperation = input.MathOperation;
			if (1 == 0)
			{
			}
			string text = (int)mathOperation switch
			{
				0 => "+", 
				1 => "-", 
				2 => "*", 
				3 => "/", 
				_ => "+", 
			};
			if (1 == 0)
			{
			}
			string arg = text;
			return $"{input.NamespacedKey}={arg}{input.Weight}";
		}

		internal static List<NamespacedConfigWeight> ConvertManyFromString(string input)
		{
			string[] array = input.Split(',');
			List<NamespacedConfigWeight> list = new List<NamespacedConfigWeight>(array.Length);
			string[] array2 = array;
			string[] array3 = array2;
			foreach (string input2 in array3)
			{
				list.Add(ConvertFromString(input2));
			}
			return list;
		}

		internal static NamespacedConfigWeight ConvertFromString(string input)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: 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_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Expected O, but got Unknown
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: 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_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: 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_007e: Unknown result type (might be due to invalid IL or missing references)
			string[] array = input.Split('=');
			NamespacedKey namespacedKey = NamespacedKey.ForceParse(array[0]);
			MathOperation mathOperation = (MathOperation)0;
			float result = 0f;
			if (array.Length > 1)
			{
				char c = array[1][0];
				if (1 == 0)
				{
				}
				MathOperation val = (MathOperation)(c switch
				{
					'+' => 0, 
					'-' => 1, 
					'*' => 2, 
					'/' => 3, 
					_ => 0, 
				});
				if (1 == 0)
				{
				}
				mathOperation = val;
				string text = array[1];
				string text2 = text;
				if (!float.TryParse(text2.Substring(0, text2.Length), NumberStyles.Float, CultureInfo.InvariantCulture, out result))
				{
					text = array[1];
					text2 = text;
					result = float.Parse(text2.Substring(1, text2.Length - 1), NumberStyles.Float, CultureInfo.InvariantCulture);
				}
			}
			return new NamespacedConfigWeight
			{
				NamespacedKey = namespacedKey,
				MathOperation = mathOperation,
				Weight = result
			};
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "GlobeScrap";

		public const string PLUGIN_NAME = "GlobeScrap";

		public const string PLUGIN_VERSION = "1.0.4";
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}
namespace __GEN
{
	internal class NetworkVariableSerializationHelper
	{
		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeSerialization()
		{
		}
	}
}
namespace GlobeScrap.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}