Decompiled source of Pedguins Maps v1.0.6

Pedguins_Maps.dll

Decompiled a month ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using TerrainCustomiser;
using TerrainCustomiser.Networking;
using TerrainCustomiser.TerrainGeneration;
using UnityEngine;

[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("Pedguins_Maps")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Pedguins_Maps")]
[assembly: AssemblyTitle("Pedguins_Maps")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace PedguinsMaps
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("Pedguins_Maps", "Pedguins_Maps", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public static Plugin? Instance;

		private static readonly string RelMapPath = "..\\..\\" + GetDirName(PluginDir);

		private static readonly string RelMapPath1 = RelMapPath + "\\PedguinHell";

		private static readonly string RelMapPath2 = RelMapPath + "\\Snosz-TerrainCustomiser\\Map Saves\\PedguinHell";

		internal ManualLogSource Logger => ((BaseUnityPlugin)this).Logger;

		internal static string PluginDir => new Uri(Assembly.GetExecutingAssembly().Location).LocalPath;

		private static string GetDirName(string path)
		{
			path = path.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
			int num = path.LastIndexOfAny(new char[2]
			{
				Path.DirectorySeparatorChar,
				Path.AltDirectorySeparatorChar
			});
			path = ((num >= 0) ? path.Substring(0, num) : path);
			num = path.LastIndexOfAny(new char[2]
			{
				Path.DirectorySeparatorChar,
				Path.AltDirectorySeparatorChar
			});
			if (num < 0)
			{
				return path;
			}
			string text = path;
			int num2 = num + 1;
			return text.Substring(num2, text.Length - num2);
		}

		private void Awake()
		{
			Logger.LogInfo((object)"[PedguinsMaps] Loaded Pedguins_Maps v1.0.0");
		}

		private void Update()
		{
			Plugin instance = Plugin.Instance;
			if (Time.timeSinceLevelLoad > 5f && Object.op_Implicit((Object)(object)instance) && instance.canLaunchCustomTerrain)
			{
				if (!instance.patchedTerrainGeneration)
				{
					Harmony harmony = Plugin._harmony;
					harmony.PatchAll(typeof(PropGrouperPatch));
					harmony.PatchAll(typeof(LevelGenStepSpawnPatch));
					harmony.PatchAll(typeof(MapHandlerStartPatch));
					instance.patchedTerrainGeneration = true;
				}
				if (Input.GetKey((KeyCode)290) && PhotonNetwork.IsMasterClient)
				{
					LoadPedguinHell(instance);
				}
			}
		}

		private void LoadPedguinHell(Plugin tc)
		{
			Logger.LogInfo((object)"[PedguinsMaps] Loading Pedguin's Maps into TerrainCustomiser...");
			tc.canLaunchCustomTerrain = false;
			TerrainData val = SaveFileManager.LoadRaw(RelMapPath1);
			if (val == null)
			{
				Logger.LogError((object)("[PedguinsMaps] Failed to load " + RelMapPath1));
				val = SaveFileManager.LoadRaw(RelMapPath2);
				if (val == null)
				{
					Logger.LogError((object)("[PedguinsMaps] Failed to load " + RelMapPath2));
					return;
				}
			}
			val.Settings.seed = Random.Range(1, 10001);
			NetworkUtils.SetTerrainDataRoomProperty(val, tc.manager);
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "Pedguins_Maps";

		public const string PLUGIN_NAME = "Pedguins_Maps";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		internal IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}