Decompiled source of PeeP Test Base v1.1.1

BepInEx/plugins/SCPCBDunGen/SCPCBDunGen.dll

Decompiled 2 years ago
using System;
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 HarmonyLib;
using LethalLib.Extras;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;

[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("SCPCBDunGen")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("A template for Lethal Company")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+9853fbb2cf891836416f22f91261757146b9267b")]
[assembly: AssemblyProduct("SCPCBDunGen")]
[assembly: AssemblyTitle("SCPCBDunGen")]
[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 SCPDoorMover : NetworkBehaviour
{
	public AnimatedObjectTrigger animObjectTrigger;

	public NavMeshObstacle navObstacle;

	private float fEnemyDoorMeter;

	private void ToggleDoor(PlayerControllerB player)
	{
		animObjectTrigger.TriggerAnimation(player);
		((Behaviour)navObstacle).enabled = !animObjectTrigger.boolValue;
	}

	private void OnTriggerStay(Collider other)
	{
		if ((Object)(object)animObjectTrigger == (Object)null || (Object)(object)NetworkManager.Singleton == (Object)null || !((NetworkBehaviour)this).IsServer || animObjectTrigger.boolValue || !((Component)other).CompareTag("Enemy"))
		{
			return;
		}
		EnemyAICollisionDetect component = ((Component)other).GetComponent<EnemyAICollisionDetect>();
		if ((Object)(object)component != (Object)null)
		{
			fEnemyDoorMeter += Time.deltaTime * component.mainScript.openDoorSpeedMultiplier;
			if (fEnemyDoorMeter > 1f)
			{
				fEnemyDoorMeter = 0f;
				animObjectTrigger.TriggerAnimationNonPlayer(component.mainScript.useSecondaryAudiosOnAnimatedObjects, true, false);
				((Behaviour)navObstacle).enabled = !animObjectTrigger.boolValue;
			}
		}
	}
}
namespace SCPCBDunGen
{
	[BepInPlugin("SCPCBDunGen", "SCPCBDunGen", "1.2.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class SCPCBDunGen : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(RoundManager))]
		internal class RoundManagerPatch
		{
			[HarmonyPatch("GenerateNewFloor")]
			[HarmonyPostfix]
			private static void FixTeleportDoors()
			{
				Instance.mls.LogInfo((object)"Attempting to fix entrance teleporters.");
				SpawnSyncedObject[] array = Object.FindObjectsOfType<SpawnSyncedObject>();
				NetworkManager val = Object.FindObjectOfType<NetworkManager>();
				bool flag = false;
				bool flag2 = false;
				int num = 0;
				SpawnSyncedObject[] array2 = array;
				foreach (SpawnSyncedObject val2 in array2)
				{
					if (((Object)val2.spawnPrefab).name == "EntranceTeleportA_EMPTY")
					{
						NetworkPrefab val3 = val.NetworkConfig.Prefabs.m_Prefabs.First((NetworkPrefab x) => ((Object)x.Prefab).name == "EntranceTeleportA");
						if (val3 == null)
						{
							Instance.mls.LogError((object)"Failed to find EntranceTeleportA prefab.");
							return;
						}
						Instance.mls.LogInfo((object)"Found and replaced EntranceTeleportA prefab.");
						flag = true;
						val2.spawnPrefab = val3.Prefab;
					}
					else if (((Object)val2.spawnPrefab).name == "EntranceTeleportB_EMPTY")
					{
						NetworkPrefab val4 = val.NetworkConfig.Prefabs.m_Prefabs.First((NetworkPrefab x) => ((Object)x.Prefab).name == "EntranceTeleportB");
						if (val4 == null)
						{
							Instance.mls.LogError((object)"Failed to find EntranceTeleportB prefab.");
							return;
						}
						Instance.mls.LogInfo((object)"Found and replaced EntranceTeleportB prefab.");
						flag2 = true;
						val2.spawnPrefab = val4.Prefab;
					}
					else if (((Object)val2.spawnPrefab).name == "VentDummy")
					{
						NetworkPrefab val5 = val.NetworkConfig.Prefabs.m_Prefabs.First((NetworkPrefab x) => ((Object)x.Prefab).name == "VentEntrance");
						if (val5 == null)
						{
							Instance.mls.LogError((object)"Failed to find VentEntrance prefab.");
							return;
						}
						Instance.mls.LogInfo((object)"Found and replaced VentEntrance prefab.");
						num++;
						val2.spawnPrefab = val5.Prefab;
					}
				}
				if (!flag && !flag2)
				{
					Instance.mls.LogError((object)"Failed to find entrance teleporters to replace.");
				}
				else if (num == 0)
				{
					Instance.mls.LogError((object)"No vents found to replace.");
				}
				else
				{
					Instance.mls.LogInfo((object)$"{num} vents found and replaced with network prefab.");
				}
			}
		}

		private const string modGUID = "SCPCBDunGen";

		private const string modName = "SCPCBDunGen";

		private const string modVersion = "1.2.0";

		private readonly Harmony harmony = new Harmony("SCPCBDunGen");

		private static SCPCBDunGen Instance;

		internal ManualLogSource mls;

		public static AssetBundle SCPCBAssets;

		private ConfigEntry<int> configSCPRarity;

		private ConfigEntry<string> configMoons;

		private ConfigEntry<bool> configGuaranteedSCP;

		private string[] MoonConfigs = new string[3] { "all", "paid", "titan" };

		private void Awake()
		{
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Expected O, but got Unknown
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Expected O, but got Unknown
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Expected O, but got Unknown
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Invalid comparison between Unknown and I4
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("SCPCBDunGen");
			SCPCBAssets = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "scpcb_dungeon"));
			if ((Object)(object)SCPCBAssets == (Object)null)
			{
				mls.LogError((object)"Failed to load SCPCB Dungeon assets.");
				return;
			}
			GameObject val = SCPCBAssets.LoadAsset<GameObject>("assets/Mods/SCP/prefabs/SCPDoorBtn.prefab");
			if ((Object)(object)val == (Object)null)
			{
				mls.LogError((object)"Failed to load SCP Door.");
				return;
			}
			NetworkPrefabs.RegisterNetworkPrefab(val);
			harmony.PatchAll(typeof(SCPCBDunGen));
			harmony.PatchAll(typeof(RoundManagerPatch));
			configSCPRarity = ((BaseUnityPlugin)this).Config.Bind<int>("General", "FoundationRarity", 100, new ConfigDescription("How rare it is for the foundation to be chosen. Higher values increases the chance of spawning the foundation.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 300), Array.Empty<object>()));
			configMoons = ((BaseUnityPlugin)this).Config.Bind<string>("General", "FoundationMoons", "titan", new ConfigDescription("The moon(s) that the foundation can spawn on, from the given presets.", (AcceptableValueBase)(object)new AcceptableValueList<string>(MoonConfigs), Array.Empty<object>()));
			configGuaranteedSCP = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "FoundationGuaranteed", false, new ConfigDescription("If enabled, the foundation will be effectively guaranteed to spawn. Only recommended for debugging/sightseeing purposes.", (AcceptableValueBase)null, Array.Empty<object>()));
			DungeonFlow val2 = SCPCBAssets.LoadAsset<DungeonFlow>("assets/Mods/SCP/data/SCPFlow.asset");
			if ((Object)(object)val2 == (Object)null)
			{
				mls.LogError((object)"Failed to load SCP:CB Dungeon Flow.");
				return;
			}
			LevelTypes levelTypeFromMoonConfig = GetLevelTypeFromMoonConfig(configMoons.Value.ToLower());
			if ((int)levelTypeFromMoonConfig == 1)
			{
				mls.LogError((object)"Config file invalid, moon config does not match one of the preset values.");
				return;
			}
			DungeonDef obj = ScriptableObject.CreateInstance<DungeonDef>();
			obj.dungeonFlow = val2;
			obj.rarity = (configGuaranteedSCP.Value ? 99999 : configSCPRarity.Value);
			obj.firstTimeDungeonAudio = SCPCBAssets.LoadAsset<AudioClip>("assets/Mods/SCP/snd/Horror8.ogg");
			Dungeon.AddDungeon(obj, levelTypeFromMoonConfig);
			mls.LogInfo((object)"SCP:SB DunGen for Lethal Company [Version 1.2.0] successfully loaded.");
		}

		private LevelTypes GetLevelTypeFromMoonConfig(string sConfigName)
		{
			return (LevelTypes)(sConfigName switch
			{
				"all" => 478, 
				"paid" => 448, 
				"titan" => 256, 
				_ => 1, 
			});
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "SCPCBDunGen";

		public const string PLUGIN_NAME = "SCPCBDunGen";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}