Decompiled source of LethalApertureDunGen v1.1.2

PortalDunGen.dll

Decompiled 4 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using DunGen.Graph;
using GameNetcodeStuff;
using LethalLevelLoader;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Playables;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("PortalDunGen")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Adds Portal DunGen to Lethal Company")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+75abbe3fcb5bd5ea0cc062092254e8b3aa415ff0")]
[assembly: AssemblyProduct("PortalDunGen")]
[assembly: AssemblyTitle("PortalDunGen")]
[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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
public class EXT_ChallengeModeTurret : MonoBehaviour
{
	public PlayableDirector pd;

	public GameObject spawnOn;

	public IEnumerator SpawnCoroutine(GameObject turretPrefab)
	{
		pd.Play();
		yield return (object)new WaitForSeconds(1.5f);
		Transform t = spawnOn.transform;
		GameObject gameObject = Object.Instantiate<GameObject>(turretPrefab, t.position, t.rotation);
		gameObject.GetComponent<NetworkObject>().Spawn(true);
	}
}
[RequireComponent(typeof(AudioSource))]
public class EXT_PlayRandomSound : MonoBehaviour
{
	public List<AudioClip> Sounds;

	public void PlayRandomSound()
	{
		int index = Random.Range(0, Sounds.Count);
		AudioSource component = ((Component)this).GetComponent<AudioSource>();
		component.clip = Sounds[index];
		component.Play();
	}
}
public class EXT_ChallengeModeIntro : NetworkBehaviour
{
	public void DoChallengeModeIntro()
	{
		Debug.Log((object)"[EXT_ChallengeModeIntro] Firing...");
		NetworkManager component = ((Component)GameNetworkManager.Instance).GetComponent<NetworkManager>();
		GameObject val = null;
		foreach (NetworkPrefab prefab in component.NetworkConfig.Prefabs.Prefabs)
		{
			if (((Object)prefab.Prefab).name == "TurretContainer")
			{
				val = prefab.Prefab;
				break;
			}
		}
		if ((Object)(object)val == (Object)null)
		{
			Debug.LogError((object)"[EXT_ChallengeModeIntro] Failed to find TurretContainer");
			return;
		}
		EXT_ChallengeModeTurret[] array = Object.FindObjectsByType<EXT_ChallengeModeTurret>((FindObjectsSortMode)0);
		Debug.Log((object)$"[EXT_ChallengeModeIntro] Found {array.Length} turrets to spawn");
		EXT_ChallengeModeTurret[] array2 = array;
		foreach (EXT_ChallengeModeTurret eXT_ChallengeModeTurret in array2)
		{
			((MonoBehaviour)this).StartCoroutine(eXT_ChallengeModeTurret.SpawnCoroutine(val));
		}
	}
}
public class EXT_TimelineTrampoline : MonoBehaviour
{
	public InteractEvent OnSignal;

	public void DoSignalTrampoline()
	{
		((UnityEvent<PlayerControllerB>)(object)OnSignal).Invoke(GameNetworkManager.Instance.localPlayerController);
	}
}
public class EXT_RandomFanSpeed : MonoBehaviour
{
	private void Awake()
	{
		Animator component = ((Component)this).GetComponent<Animator>();
		component.speed = Random.Range(0.2f, 0.9f);
	}
}
[Serializable]
public class BoolEvent : UnityEvent<bool>
{
}
public class EXT_FloorButtonTrigger : NetworkBehaviour
{
	public bool Persistent = false;

	public List<GrabbableObject> contained = new List<GrabbableObject>();

	private bool IsPressed = false;

	public InteractEvent OnDepressed;

	public InteractEvent OnReleased;

	public bool GetNewIsPressed()
	{
		return contained.Count > 0;
	}

	private void UpdateIsPressed()
	{
		if (Persistent && IsPressed)
		{
			return;
		}
		bool newIsPressed = GetNewIsPressed();
		if (newIsPressed != IsPressed)
		{
			IsPressed = newIsPressed;
			if (IsPressed)
			{
				((UnityEvent<PlayerControllerB>)(object)OnDepressed).Invoke(GameNetworkManager.Instance.localPlayerController);
			}
			else
			{
				((UnityEvent<PlayerControllerB>)(object)OnReleased).Invoke(GameNetworkManager.Instance.localPlayerController);
			}
		}
	}

	private void OnTriggerEnter(Collider other)
	{
		if (((NetworkBehaviour)this).NetworkManager.IsServer)
		{
			GrabbableObject component = ((Component)other).GetComponent<GrabbableObject>();
			if (!((Object)(object)component == (Object)null) && !contained.Contains(component))
			{
				Debug.Log((object)("Portal DunGen New thing entered input trigger: " + ((Object)((Component)other).gameObject).name + "."));
				contained.Add(component);
				UpdateIsPressed();
			}
		}
	}

	private void OnTriggerStay(Collider other)
	{
		if (((NetworkBehaviour)this).NetworkManager.IsServer)
		{
			GrabbableObject component = ((Component)other).GetComponent<GrabbableObject>();
			if (!((Object)(object)component == (Object)null) && !contained.Contains(component))
			{
				Debug.Log((object)("Portal DunGen New thing entered input trigger: " + ((Object)((Component)other).gameObject).name + "."));
				contained.Add(component);
				UpdateIsPressed();
			}
		}
	}

	private void FixedUpdate()
	{
		//IL_0042: 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_004c: Unknown result type (might be due to invalid IL or missing references)
		Collider component = ((Component)this).GetComponent<Collider>();
		List<GrabbableObject> list = contained.ToList();
		foreach (GrabbableObject item in list)
		{
			Collider component2 = ((Component)item).GetComponent<Collider>();
			if (!((Object)(object)component2 == (Object)null))
			{
				Bounds bounds = component2.bounds;
				if (!((Bounds)(ref bounds)).Intersects(component.bounds))
				{
					Debug.Log((object)("Portal DunGen Thing has left input trigger in FixedUpdate: " + ((Object)((Component)item).gameObject).name + "."));
					contained.Remove(item);
				}
			}
		}
		UpdateIsPressed();
	}

	private void OnTriggerExit(Collider other)
	{
		if (((NetworkBehaviour)this).NetworkManager.IsServer)
		{
			GrabbableObject component = ((Component)other).GetComponent<GrabbableObject>();
			if (!((Object)(object)component == (Object)null))
			{
				Debug.Log((object)("Portal DunGen Thing has left input trigger: " + ((Object)((Component)other).gameObject).name + "."));
				contained.Remove(component);
				UpdateIsPressed();
			}
		}
	}
}
public class EXT_CarryCubeItem : GrabbableObject
{
}
namespace PortalDunGen
{
	[BepInPlugin("PortalDunGen", "PortalDunGen", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class PortalDunGenPlugin : BaseUnityPlugin
	{
		public ManualLogSource mls;

		public static AssetBundle assets;

		private ConfigEntry<bool> configHideAperatureLogos;

		private ConfigEntry<string> configLevelMatchingProperties;

		private ConfigEntry<int> configLengthOverride;

		private void Awake()
		{
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Expected O, but got Unknown
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Expected O, but got Unknown
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_029a: 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)
			//IL_031a: Expected O, but got Unknown
			//IL_0332: Unknown result type (might be due to invalid IL or missing references)
			//IL_033c: Expected O, but got Unknown
			//IL_0407: Unknown result type (might be due to invalid IL or missing references)
			//IL_0411: Expected O, but got Unknown
			//IL_0394: Unknown result type (might be due to invalid IL or missing references)
			//IL_039e: Expected O, but got Unknown
			//IL_03b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c0: Expected O, but got Unknown
			mls = Logger.CreateLogSource("PortalDunGen");
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			assets = AssetBundle.LoadFromFile(Path.Combine(directoryName, "portaldungen.compressed"));
			if ((Object)(object)assets == (Object)null)
			{
				mls.LogError((object)"Failed to load Portal DunGen assets.");
				return;
			}
			DungeonFlow val = assets.LoadAsset<DungeonFlow>("assets/portaldungenflow.asset");
			if ((Object)(object)val == (Object)null)
			{
				mls.LogError((object)"Failed to load Portal DunGen Dungeon Flow.");
				return;
			}
			AudioClip val2 = assets.LoadAsset<AudioClip>("assets/misc/sp_a1_intro1_b2b.ogg");
			if ((Object)(object)val2 == (Object)null)
			{
				mls.LogWarning((object)"Failed to load Portal DunGen Audio... weird");
			}
			configLevelMatchingProperties = ((BaseUnityPlugin)this).Config.Bind<string>("General", "LevelMatchingProperties", "portal:99999,all:25,titan:100", new ConfigDescription("Controls how the DunGen will spawn. A list of the form `[name]:[rarity],[name]:[rarity],...`. Defaults to `portal:99999` so it always spawns on moons related to portal. Rarity is an integer. Name can be one of:\n* portal - Spawns only on portal-related maps using ContentTags\n* all - Spawns on everything\n* [name] - Name of a specific moon.\n\nIf no rarity is specified, the rarity for that item defaults to 0 and it wont spawn.", (AcceptableValueBase)null, Array.Empty<object>()));
			configLengthOverride = ((BaseUnityPlugin)this).Config.Bind<int>("General", "PortalDunGenLengthOverride", -1, new ConfigDescription(string.Format("If not -1, overrides the foundation length to whatever you'd like. Adjusts how long/large the dungeon generates.\nSetting it too high has the potential to generate too much and crash the game. Untested over 50.\nFor reference, the default value for the current version [{0}] is {1}.", "1.0.0", val.Length.Min), (AcceptableValueBase)null, Array.Empty<object>()));
			configHideAperatureLogos = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "PortalDunGenHideAperatureLogos", false, "Hides Aperature logos inside");
			if (configLengthOverride.Value != -1)
			{
				mls.LogInfo((object)$"Portal DunGen length override has been set to {configLengthOverride.Value}");
				val.Length.Min = configLengthOverride.Value;
				val.Length.Max = configLengthOverride.Value;
			}
			if (configHideAperatureLogos.Value)
			{
				mls.LogInfo((object)"Portal DunGen Aperature logos will be hidden");
				GlobalPropSettings val3 = val.GlobalProps.Find((GlobalPropSettings t) => t.ID == 101010);
				val3.Count.Min = 0;
				val3.Count.Max = 0;
			}
			mls.LogInfo((object)"Portal DunGen registering...");
			ExtendedDungeonFlow val4 = ScriptableObject.CreateInstance<ExtendedDungeonFlow>();
			val4.DungeonFlow = val;
			val4.DungeonName = "Portal DunGen";
			val4.FirstTimeDungeonAudio = val2;
			val4.DynamicDungeonSizeMinMax = new Vector2(1f, 3f);
			val4.DynamicDungeonSizeLerpRate = 0f;
			val4.LevelMatchingProperties = ScriptableObject.CreateInstance<LevelMatchingProperties>();
			List<StringWithRarity> list = ConfigHelper.ConvertToStringWithRarityList(configLevelMatchingProperties.Value, Vector2.zero);
			foreach (StringWithRarity item in list)
			{
				if (item.Name == "portal")
				{
					mls.LogInfo((object)$"Portal DunGen registering with 'portal' ContentTag at rarity {item.Rarity}");
					val4.LevelMatchingProperties.levelTags.Add(new StringWithRarity("portal", item.Rarity));
					val4.LevelMatchingProperties.planetNames.Add(new StringWithRarity("Portal Moon", item.Rarity));
				}
				else if (item.Name == "all")
				{
					mls.LogInfo((object)$"Portal DunGen registering against all moons ('custom' and 'vanilla' ContentTags) at rarity {item.Rarity}");
					val4.LevelMatchingProperties.levelTags.Add(new StringWithRarity("custom", item.Rarity));
					val4.LevelMatchingProperties.levelTags.Add(new StringWithRarity("vanilla", item.Rarity));
				}
				else
				{
					mls.LogInfo((object)$"Portal DunGen registering against moon name {item.Name} at rarity {item.Rarity}");
					val4.LevelMatchingProperties.planetNames.Add(new StringWithRarity(item.Name, item.Rarity));
				}
			}
			PatchedContent.RegisterExtendedDungeonFlow(val4);
			mls.LogInfo((object)"Portal DunGen for Lethal Company [Version 1.0.0] successfully loaded.");
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "PortalDunGen";

		public const string PLUGIN_NAME = "PortalDunGen";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}