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.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using DunGen;
using HarmonyLib;
using LobbyCompatibility.Enums;
using LobbyCompatibility.Features;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Rendering;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("RestoreMapper")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Restore the unused mapper item in the shop")]
[assembly: AssemblyFileVersion("1.3.1.0")]
[assembly: AssemblyInformationalVersion("1.3.1+1fd7fba769e5ce299a0d8f1c7c6fca6a7df7465c")]
[assembly: AssemblyProduct("RestoreMapper")]
[assembly: AssemblyTitle("RestoreMapper")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.3.1.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;
}
}
}
namespace RestoreMapper
{
internal static class LobbyCompatibility
{
internal static void Init()
{
PluginHelper.RegisterPlugin("butterystancakes.lethalcompany.restoremapper", Version.Parse("1.3.1"), (CompatibilityLevel)2, (VersionStrictness)0);
}
}
public class MapperScreen : MonoBehaviour
{
public Camera cam;
public Light light;
public Renderer transition;
public Transform target;
public LineRenderer line;
public bool drawPath;
private NavMeshPath path;
private Canvas mapperCanvas;
private float ratio = 1f;
private void Awake()
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Expected O, but got Unknown
if ((Object)(object)cam == (Object)null)
{
cam = ((Component)this).GetComponent<Camera>();
}
path = new NavMeshPath();
SetupCanvas();
SetupLine();
}
private void LateUpdate()
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)target == (Object)null))
{
Vector3 position = target.position;
position.y += 3.636f;
((Component)this).transform.position = position;
}
}
private void OnDisable()
{
target = null;
drawPath = false;
}
private void OnDestroy()
{
if ((Object)(object)mapperCanvas != (Object)null)
{
Object.Destroy((Object)(object)((Component)mapperCanvas).gameObject);
}
}
private void OnEnable()
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_0106: Unknown result type (might be due to invalid IL or missing references)
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: Unknown result type (might be due to invalid IL or missing references)
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)target == (Object)null || target.position.y >= -80f || !Plugin.configShowPath.Value)
{
return;
}
bool flag = RoundManager.Instance.currentDungeonType == 4 && (Object)(object)RoundManager.Instance.currentMineshaftElevator != (Object)null;
if ((!flag || !(Vector3.Distance(target.position, RoundManager.Instance.currentMineshaftElevator.elevatorInsidePoint.position) <= 1f)) && NavMesh.CalculatePath(target.position, (flag && !((Bounds)(ref RestoreMapperPatches.mineStartBounds)).Contains(target.position)) ? RoundManager.Instance.currentMineshaftElevator.elevatorBottomPoint.position : RestoreMapperPatches.mainEntrancePos, -1, path) && path.corners.Length >= 2)
{
Vector3[] array = (Vector3[])(object)new Vector3[path.corners.Length];
for (int i = 0; i < path.corners.Length; i++)
{
array[i] = path.corners[i] + Vector3.up * 1.25f;
}
line.positionCount = Mathf.Min(array.Length, 50);
line.SetPositions(array);
drawPath = true;
}
}
private void SetupCanvas()
{
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Expected O, but got Unknown
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Expected O, but got Unknown
mapperCanvas = Object.Instantiate<GameObject>(((Component)StartOfRound.Instance.radarCanvas).gameObject, ((Component)StartOfRound.Instance.radarCanvas).transform.parent, true).GetComponent<Canvas>();
foreach (Transform item in ((Component)mapperCanvas).transform)
{
Transform val = item;
if (((Object)val).name == "MonitoringPlayerUIContainer")
{
foreach (Transform item2 in val)
{
Transform val2 = item2;
if (((Object)val2).name == "CompassRose")
{
((Component)val2).gameObject.SetActive(true);
}
else
{
Object.Destroy((Object)(object)((Component)val2).gameObject);
}
}
((Component)val).gameObject.SetActive(true);
}
else
{
Object.Destroy((Object)(object)((Component)val).gameObject);
}
}
mapperCanvas.worldCamera = ((Component)this).GetComponent<Camera>();
RenderTexture targetTexture = StartOfRound.Instance.mapScreen.cam.targetTexture;
ratio = ((float)((Texture)cam.targetTexture).width / (float)((Texture)targetTexture).width + (float)((Texture)cam.targetTexture).height / (float)((Texture)targetTexture).height) / 2f;
if (ratio != 1f)
{
Canvas obj = mapperCanvas;
obj.scaleFactor *= ratio;
}
}
private void SetupLine()
{
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
line = Object.Instantiate<GameObject>(((Component)StartOfRound.Instance.mapScreen.lineFromRadarTargetToExit).gameObject, ((Component)StartOfRound.Instance.mapScreen.lineFromRadarTargetToExit).transform.parent, true).GetComponent<LineRenderer>();
((Renderer)line).forceRenderingOff = true;
((Renderer)line).material.SetTextureOffset("_MainTex", Vector2.zero);
((Renderer)line).enabled = true;
}
}
[BepInPlugin("butterystancakes.lethalcompany.restoremapper", "Restore Mapper", "1.3.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
internal const string PLUGIN_GUID = "butterystancakes.lethalcompany.restoremapper";
internal const string PLUGIN_NAME = "Restore Mapper";
internal const string PLUGIN_VERSION = "1.3.1";
internal static ManualLogSource Logger;
internal static ConfigEntry<bool> configLowQuality;
internal static ConfigEntry<bool> configShowPath;
private const string GUID_LOBBY_COMPATIBILITY = "BMX.LobbyCompatibility";
private void Awake()
{
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
Logger = ((BaseUnityPlugin)this).Logger;
if (Chainloader.PluginInfos.ContainsKey("BMX.LobbyCompatibility"))
{
Logger.LogInfo((object)"CROSS-COMPATIBILITY - Lobby Compatibility detected");
LobbyCompatibility.Init();
}
configShowPath = ((BaseUnityPlugin)this).Config.Bind<bool>("Gameplay", "Show Path", false, "Should the mapper draw a line back to main entrance for its user?");
configLowQuality = ((BaseUnityPlugin)this).Config.Bind<bool>("Performance", "Low Quality", false, "Decreases the resolution of the mapper's image, to match the radar camera.\nThis will reduce memory usage and might also reduce lag spikes when activating the device.");
new Harmony("butterystancakes.lethalcompany.restoremapper").PatchAll();
RenderPipelineManager.beginCameraRendering += RenderingOverrides.OnBeginCameraRendering;
RenderPipelineManager.endCameraRendering += RenderingOverrides.OnEndCameraRendering;
Logger.LogInfo((object)"Restore Mapper v1.3.1 loaded");
}
}
[HarmonyPatch]
internal class RestoreMapperPatches
{
[CompilerGenerated]
private sealed class <pingMapSystem>d__8 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public MapDevice mapDevice;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <pingMapSystem>d__8(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
((Component)mapDevice.mapCamera).gameObject.SetActive(true);
mapDevice.mapAnimatorTransition.SetTrigger("Transition");
<>2__current = (object)new WaitForSeconds(0.235f);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
((Component)mapDevice.mapCamera).gameObject.SetActive(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();
}
}
internal static Vector3 mainEntrancePos;
internal static Bounds mineStartBounds;
[HarmonyPatch(typeof(Terminal), "Awake")]
[HarmonyPostfix]
private static void Terminal_Post_Awake(Terminal __instance)
{
TerminalKeyword? obj = ((IEnumerable<TerminalKeyword>)__instance.terminalNodes?.allKeywords).FirstOrDefault((Func<TerminalKeyword, bool>)((TerminalKeyword keyword) => ((Object)keyword).name == "Buy"));
TerminalNode val = ((IEnumerable<CompatibleNoun>)obj?.compatibleNouns).FirstOrDefault((Func<CompatibleNoun, bool>)delegate(CompatibleNoun compatibleNoun)
{
TerminalKeyword noun2 = compatibleNoun.noun;
return ((noun2 != null) ? ((Object)noun2).name : null) == "Mapper";
}).result;
CompatibleNoun val2 = ((IEnumerable<CompatibleNoun>)val?.terminalOptions).FirstOrDefault((Func<CompatibleNoun, bool>)delegate(CompatibleNoun compatibleNoun)
{
TerminalKeyword noun = compatibleNoun.noun;
return ((noun != null) ? ((Object)noun).name : null) == "Confirm";
});
List<Item> list = StartOfRound.Instance?.allItemsList?.itemsList;
Item val3 = list?.FirstOrDefault((Func<Item, bool>)((Item item) => ((Object)item).name == "MapDevice"));
if ((Object)(object)obj == (Object)null || (Object)(object)val == (Object)null || val2 == null || list == null || (Object)(object)val3 == (Object)null)
{
Plugin.Logger.LogError((object)"Encountered an error while caching essential references. Loading will be skipped.");
return;
}
__instance.buyableItemsList = CollectionExtensions.AddItem<Item>((IEnumerable<Item>)__instance.buyableItemsList, val3).ToArray();
val.buyItemIndex = __instance.buyableItemsList.Length - 1;
val2.result.buyItemIndex = val.buyItemIndex;
Plugin.Logger.LogDebug((object)"Assigned IDs");
val3.creditsWorth = 150;
Plugin.Logger.LogDebug((object)"Assigned price");
Item val4 = ((IEnumerable<Item>)list).FirstOrDefault((Func<Item, bool>)((Item item) => ((Object)item).name == "ProFlashlight"));
if ((Object)(object)val4 != (Object)null)
{
val3.grabSFX = val4.grabSFX;
val3.dropSFX = val4.dropSFX;
val3.pocketSFX = val4.pocketSFX;
Plugin.Logger.LogDebug((object)"Assigned SFX");
}
else
{
Plugin.Logger.LogWarning((object)"Couldn't find pro-flashlight item. Sound effects will be missing.");
}
try
{
AssetBundle val5 = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "restoremapper"));
val3.itemIcon = val5.LoadAsset<Sprite>("MapperIcon");
val5.Unload(false);
Plugin.Logger.LogDebug((object)"Assigned special icon");
}
catch
{
Plugin.Logger.LogWarning((object)"Encountered some error loading asset bundle. Inventory icon will be incorrect.");
Item val6 = list?.FirstOrDefault((Func<Item, bool>)delegate(Item item)
{
Sprite itemIcon = item.itemIcon;
return ((itemIcon != null) ? ((Object)itemIcon).name : null) == "caticontest";
});
if ((Object)(object)val6 != (Object)null)
{
val3.itemIcon = val6.itemIcon;
}
}
}
[HarmonyPatch(typeof(MapDevice), "Start")]
[HarmonyPrefix]
private static bool MapDevice_Pre_Start(MapDevice __instance)
{
if ((Object)(object)__instance.mapCamera != (Object)null)
{
Plugin.Logger.LogWarning((object)$"Mapper #{((Object)__instance).GetInstanceID()} tried to call Start() more than once, this is dangerous and would've caused a memory leak");
return false;
}
return true;
}
[HarmonyPatch(typeof(MapDevice), "Start")]
[HarmonyPostfix]
private static void MapDevice_Post_Start(MapDevice __instance)
{
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Expected O, but got Unknown
//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
if (((Component)__instance.mapCamera).CompareTag("MapCamera"))
{
__instance.mapCamera = Object.Instantiate<GameObject>(((Component)__instance.mapCamera).gameObject, ((Component)__instance.mapCamera).transform.parent).GetComponent<Camera>();
((Component)__instance.mapCamera).tag = "Untagged";
RenderTexture targetTexture = __instance.mapCamera.targetTexture;
int num = 655;
int num2 = 455;
if (Plugin.configLowQuality.Value)
{
num = ((Texture)targetTexture).width;
num2 = ((Texture)targetTexture).height;
}
__instance.mapCamera.targetTexture = new RenderTexture(num, num2, targetTexture.depth, targetTexture.format);
Plugin.Logger.LogDebug((object)$"Mapper #{((Object)__instance).GetInstanceID()} camera and texture cloned");
MapperScreen mapperScreen = ((Component)__instance.mapCamera).gameObject.AddComponent<MapperScreen>();
mapperScreen.cam = __instance.mapCamera;
__instance.mapLight = ((Component)__instance.mapCamera).GetComponentInChildren<Light>();
mapperScreen.light = __instance.mapLight;
__instance.mapAnimatorTransition = ((Component)__instance.mapCamera).GetComponentInChildren<Animator>();
mapperScreen.transition = ((Component)__instance.mapAnimatorTransition).GetComponent<Renderer>();
((Component)__instance.mapCamera).gameObject.SetActive(false);
((Behaviour)__instance.mapCamera).enabled = true;
((Behaviour)__instance.mapLight).enabled = false;
mapperScreen.transition.forceRenderingOff = true;
Plugin.Logger.LogDebug((object)$"Mapper #{((Object)__instance).GetInstanceID()} light setup");
MeshRenderer componentInChildren = ((Component)__instance).GetComponentInChildren<MeshRenderer>();
Material[] materials = ((Renderer)componentInChildren).materials;
((IEnumerable<Material>)materials).FirstOrDefault((Func<Material, bool>)((Material mat) => ((Object)mat).name.StartsWith("MapScreen"))).mainTexture = (Texture)(object)__instance.mapCamera.targetTexture;
((Renderer)componentInChildren).materials = materials;
Plugin.Logger.LogDebug((object)$"Mapper #{((Object)__instance).GetInstanceID()} screen retextured");
((Component)__instance.mapAnimatorTransition).transform.localPosition = new Vector3(0f, 0f, -0.95f);
}
}
[HarmonyPatch(typeof(MapDevice), "ItemActivate")]
[HarmonyPrefix]
private static bool MapDevice_Pre_ItemActivate(MapDevice __instance)
{
if ((Object)(object)((GrabbableObject)__instance).playerHeldBy == (Object)null || ((Component)__instance.mapCamera).CompareTag("MapCamera"))
{
return true;
}
if (__instance.pingMapCoroutine != null)
{
((MonoBehaviour)__instance).StopCoroutine(__instance.pingMapCoroutine);
}
MapperScreen mapperScreen = default(MapperScreen);
if (((Component)__instance.mapCamera).TryGetComponent<MapperScreen>(ref mapperScreen))
{
mapperScreen.target = ((Component)((GrabbableObject)__instance).playerHeldBy).transform;
}
((MonoBehaviour)__instance).StartCoroutine(pingMapSystem(__instance));
return false;
}
[HarmonyPatch(typeof(NetworkBehaviour), "OnDestroy")]
[HarmonyPostfix]
private static void NetworkBehaviour_Post_OnDestroy(NetworkBehaviour __instance)
{
MapDevice val = (MapDevice)(object)((__instance is MapDevice) ? __instance : null);
if (val != null && (Object)(object)val.mapCamera != (Object)null && !((Component)val.mapCamera).CompareTag("MapCamera"))
{
if (val.mapCamera.targetTexture.IsCreated())
{
val.mapCamera.targetTexture.Release();
}
Object.Destroy((Object)(object)val.mapCamera.targetTexture);
Object.Destroy((Object)(object)((Component)val.mapCamera).gameObject);
Plugin.Logger.LogDebug((object)$"Mapper #{((Object)__instance).GetInstanceID()} cleaned up");
}
}
[HarmonyPatch(typeof(GrabbableObject), "UseItemBatteries")]
[HarmonyPrefix]
private static bool GrabbableObject_Pre_UseItemBatteries(GrabbableObject __instance)
{
if (__instance is MapDevice)
{
return !StartOfRound.Instance.mapScreen.overrideCameraForOtherUse;
}
return true;
}
[IteratorStateMachine(typeof(<pingMapSystem>d__8))]
private static IEnumerator pingMapSystem(MapDevice mapDevice)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <pingMapSystem>d__8(0)
{
mapDevice = mapDevice
};
}
[HarmonyPatch(typeof(StartOfRound), "SwitchMapMonitorPurpose")]
[HarmonyPostfix]
private static void StartOfRound_Post_SwitchMapMonitorPurpose(bool displayInfo)
{
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
if (!displayInfo)
{
return;
}
RenderTexture active = RenderTexture.active;
MapDevice[] array = Object.FindObjectsByType<MapDevice>((FindObjectsSortMode)0);
foreach (MapDevice val in array)
{
if ((Object)(object)val.mapCamera != (Object)null && !((Component)val.mapCamera).CompareTag("MapCamera"))
{
((Component)val.mapCamera).gameObject.SetActive(false);
RenderTexture.active = val.mapCamera.targetTexture;
GL.Clear(true, true, Color.clear);
}
}
RenderTexture.active = active;
}
[HarmonyPatch(typeof(MapDevice), "EquipItem")]
[HarmonyPostfix]
private static void MapDevice_Post_EquipItem(MapDevice __instance)
{
((GrabbableObject)__instance).playerHeldBy.equippedUsableItemQE = false;
}
[HarmonyPatch(typeof(RoundManager), "FinishGeneratingNewLevelClientRpc")]
[HarmonyPostfix]
private static void RoundManager_Post_FinishGeneratingNewLevelClientRpc(RoundManager __instance)
{
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: 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_0107: Unknown result type (might be due to invalid IL or missing references)
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_013d: Unknown result type (might be due to invalid IL or missing references)
//IL_0142: Unknown result type (might be due to invalid IL or missing references)
//IL_0158: Unknown result type (might be due to invalid IL or missing references)
//IL_015d: Unknown result type (might be due to invalid IL or missing references)
//IL_0173: Unknown result type (might be due to invalid IL or missing references)
//IL_0178: Unknown result type (might be due to invalid IL or missing references)
//IL_018e: Unknown result type (might be due to invalid IL or missing references)
//IL_0193: Unknown result type (might be due to invalid IL or missing references)
//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
//IL_01da: Unknown result type (might be due to invalid IL or missing references)
//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0203: 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_021d: Unknown result type (might be due to invalid IL or missing references)
//IL_0226: Unknown result type (might be due to invalid IL or missing references)
//IL_022d: Unknown result type (might be due to invalid IL or missing references)
//IL_022f: Unknown result type (might be due to invalid IL or missing references)
EntranceTeleport val = ((IEnumerable<EntranceTeleport>)Object.FindObjectsByType<EntranceTeleport>((FindObjectsSortMode)0)).FirstOrDefault((Func<EntranceTeleport, bool>)((EntranceTeleport teleport) => teleport.entranceId == 0 && !teleport.isEntranceToBuilding));
mainEntrancePos = (((Object)(object)val != (Object)null) ? val.entrancePoint.position : Vector3.zero);
if (__instance.currentDungeonType != 4)
{
return;
}
GameObject val2 = __instance.dungeonGenerator?.Root ?? GameObject.Find("/Systems/LevelGeneration/LevelGenerationRoot");
if ((Object)(object)val2 == (Object)null)
{
if (((Object)StartOfRound.Instance.currentLevel).name != "CompanyBuildingLevel")
{
Plugin.Logger.LogWarning((object)"Landed on a moon with no dungeon generated. This shouldn't happen");
}
return;
}
Tile[] componentsInChildren = val2.GetComponentsInChildren<Tile>();
foreach (Tile val3 in componentsInChildren)
{
if (((Object)val3).name.StartsWith("MineshaftStartTile"))
{
Vector3[] array = (Vector3[])(object)new Vector3[8]
{
new Vector3(-16f, 41.37f, -4.3f),
new Vector3(14f, 41.37f, -4.3f),
new Vector3(-16f, 61.37f, -4.3f),
new Vector3(14f, 61.37f, -4.3f),
new Vector3(-16f, 41.37f, 10.7f),
new Vector3(14f, 41.37f, 10.7f),
new Vector3(-16f, 61.37f, 10.7f),
new Vector3(14f, 61.37f, 10.7f)
};
((Component)val3).transform.TransformPoints((Span<Vector3>)array);
Vector3 val4 = array[0];
Vector3 val5 = array[0];
for (int j = 1; j < array.Length; j++)
{
val4 = Vector3.Min(val4, array[j]);
val5 = Vector3.Max(val5, array[j]);
}
Bounds val6 = default(Bounds);
((Bounds)(ref val6)).min = val4;
((Bounds)(ref val6)).max = val5;
mineStartBounds = val6;
Plugin.Logger.LogDebug((object)"Calculated bounds for mineshaft elevator's start room");
}
}
}
}
internal class RenderingOverrides
{
private static MapperScreen currentScreen;
private static bool? lineNotRendering;
public static void OnBeginCameraRendering(ScriptableRenderContext context, Camera camera)
{
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
ResetRendering();
currentScreen = ((Component)camera).GetComponent<MapperScreen>();
if (!((Object)(object)currentScreen != (Object)null))
{
return;
}
((Behaviour)currentScreen.light).enabled = true;
currentScreen.transition.forceRenderingOff = false;
((Renderer)currentScreen.line).forceRenderingOff = !currentScreen.drawPath;
if ((Object)(object)StartOfRound.Instance?.mapScreen != (Object)null)
{
if (StartOfRound.Instance.currentLevelID == 3 || ((Component)camera).transform.position.y < -80f)
{
camera.nearClipPlane = StartOfRound.Instance.mapScreen.cameraNearPlane;
camera.farClipPlane = Mathf.Max(StartOfRound.Instance.mapScreen.cameraFarPlane, 7.52f);
}
else
{
camera.nearClipPlane = -22.47f;
camera.farClipPlane = 27.52f;
}
lineNotRendering = ((Renderer)StartOfRound.Instance.mapScreen.lineFromRadarTargetToExit).forceRenderingOff;
((Renderer)StartOfRound.Instance.mapScreen.lineFromRadarTargetToExit).forceRenderingOff = true;
}
}
public static void OnEndCameraRendering(ScriptableRenderContext context, Camera camera)
{
ResetRendering();
}
private static void ResetRendering()
{
if (lineNotRendering.HasValue)
{
if ((Object)(object)StartOfRound.Instance?.mapScreen?.lineFromRadarTargetToExit != (Object)null)
{
((Renderer)StartOfRound.Instance.mapScreen.lineFromRadarTargetToExit).forceRenderingOff = lineNotRendering.Value;
}
lineNotRendering = null;
}
if ((Object)(object)currentScreen != (Object)null)
{
((Behaviour)currentScreen.light).enabled = false;
currentScreen.transition.forceRenderingOff = true;
((Renderer)currentScreen.line).forceRenderingOff = true;
}
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "RestoreMapper";
public const string PLUGIN_NAME = "RestoreMapper";
public const string PLUGIN_VERSION = "1.3.1";
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}