Decompiled source of TheWastes v1.0.6

Mods/TheWastes.dll

Decompiled a day ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using CustomMapLib;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppRUMBLE.MoveSystem;
using MelonLoader;
using Microsoft.CodeAnalysis;
using TheWastes;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(WastesMap), "The Wastes", "1.0.6", "SisterPankake", null)]
[assembly: MelonGame(null, null)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("TheWastes")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+e45ecad39fe16e634e6bab439099e3fbfb1c8687")]
[assembly: AssemblyProduct("TheWastes")]
[assembly: AssemblyTitle("TheWastes")]
[assembly: AssemblyVersion("1.0.0.0")]
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;
		}
	}
}
namespace TheWastes
{
	public static class BuildInfo
	{
		public const string Name = "The Wastes";

		public const string Description = "A huge desolate Island";

		public const string Author = "SisterPankake";

		public const string Company = null;

		public const string Version = "1.0.6";

		public const string DownloadLink = null;
	}
	public class WastesMap : Map
	{
		private GameObject arena = new GameObject();

		private GameObject spawn = new GameObject();

		private GameObject islands = new GameObject();

		private GameObject sun = new GameObject();

		private Material skybox = null;

		private bool wasLightmapChanged = false;

		private Texture2D lightmap = null;

		private Il2CppAssetBundle assetBundle = null;

		private GameObject CombatFloorHolder = null;

		public override void OnLateInitializeMelon()
		{
			((Map)this).Initialize("The Wastes", "1.0.6", "SisterPankake");
		}

		public override void OnMapCreation()
		{
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: 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)
			assetBundle = LoadBundle("TheWastes.Resources.wastes");
			arena = Object.Instantiate<GameObject>(assetBundle.LoadAsset<GameObject>("TheWastes"));
			spawn = ((Component)arena.transform.GetChild(0)).gameObject;
			islands = ((Component)arena.transform.GetChild(1)).gameObject;
			sun = ((Component)arena.transform.GetChild(2)).gameObject;
			CombatFloorHolder = ((Component)arena.transform.Find("Colliders/CombatFloor")).gameObject;
			if ((Object)(object)CombatFloorHolder == (Object)null)
			{
				MelonLogger.Error("Failed to find Combat Floor");
			}
			arena.transform.SetParent(base.mapParent.transform);
			skybox = assetBundle.LoadAsset<Material>("Desert_Sky");
			base.HostPedestal.SetFirstSequence(spawn.transform.GetChild(0).position);
			base.HostPedestal.SetSecondSequence(spawn.transform.GetChild(1).position);
			base.ClientPedestal.SetFirstSequence(spawn.transform.GetChild(2).position);
			base.ClientPedestal.SetSecondSequence(spawn.transform.GetChild(3).position);
			SetupLayers(CombatFloorHolder, (ObjectType)9);
		}

		public override void OnMapMatchLoad(bool amHost)
		{
			//IL_0035: 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)
			RenderSettings.skybox = skybox;
			GameObject val = GameObject.Find("Directional Light");
			if ((Object)(object)val != (Object)null)
			{
				val.transform.position = sun.transform.position;
				val.transform.rotation = sun.transform.rotation;
			}
			else
			{
				MelonLogger.Error("Failed to find Directional Light in scene");
			}
			DynamicGI.UpdateEnvironment();
		}

		public Il2CppAssetBundle LoadBundle(string path)
		{
			using Stream stream = ((MelonBase)this).MelonAssembly.Assembly.GetManifestResourceStream(path);
			if (stream == null)
			{
				MelonLogger.Error("Failed to find resource stream!");
				return null;
			}
			byte[] array = new byte[stream.Length];
			stream.Read(array, 0, array.Length);
			return Il2CppAssetBundleManager.LoadFromMemory(Il2CppStructArray<byte>.op_Implicit(array));
		}

		private void SetupLayers(GameObject parent, ObjectType type)
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Invalid comparison between Unknown and I4
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Invalid comparison between Unknown and I4
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Invalid comparison between Unknown and I4
			if ((Object)(object)parent == (Object)null)
			{
				MelonLogger.Error("Passed a null parent: " + ((Object)parent).name);
			}
			else
			{
				if (parent.transform.childCount <= 0)
				{
					return;
				}
				for (int i = 0; i <= parent.transform.childCount - 1; i++)
				{
					if ((int)type != 1)
					{
						if ((int)type != 9)
						{
							if ((int)type == 11)
							{
								((Component)parent.transform.GetChild(i)).gameObject.layer = 11;
							}
						}
						else
						{
							((Component)parent.transform.GetChild(i)).gameObject.layer = 9;
							GroundCollider val = ((Component)parent.transform.GetChild(i)).gameObject.AddComponent<GroundCollider>();
							val.collider = (Collider)(object)((Component)parent.transform.GetChild(i)).GetComponent<MeshCollider>();
						}
					}
					else
					{
						((Component)parent.transform.GetChild(i)).gameObject.layer = 1;
					}
				}
			}
		}
	}
}