Decompiled source of RadarEdits v1.0.5

RadarEdit.dll

Decompiled 6 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("0.0.0.0")]
namespace huluoboRadarEdit;

public class Config
{
	public static ConfigEntry<bool> Facialcamera;

	public static ConfigEntry<bool> CompassRose;

	public static ConfigEntry<bool> Defaultlayers;

	public static ConfigEntry<bool> Foliagelayers;

	public static ConfigEntry<float> cameraNearPlane;

	public static ConfigEntry<float> cameraFarPlane;

	public Config(ConfigFile cfg)
	{
		Facialcamera = cfg.Bind<bool>("all", "Facialcamera", false, "toggel Facial camera");
		CompassRose = cfg.Bind<bool>("all", "CompassRose", false, "toggel CompassRose");
		Defaultlayers = cfg.Bind<bool>("all", "Defaultlayers", false, "show Default layers");
		Foliagelayers = cfg.Bind<bool>("all", "Foliagelayers", false, "show Foliage layers");
		cameraNearPlane = cfg.Bind<float>("all", "cameraNearPlane", -2.47f, "cameraNearPlane");
		cameraFarPlane = cfg.Bind<float>("all", "cameraFarPlane", 60f, "cameraFarPlane");
	}
}
[BepInPlugin("hlb.RadarEdit", "RadarEdit", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class huluoboRadarEdits : BaseUnityPlugin
{
	internal class RadarEdits
	{
		public static int mapMasks;

		public static int omapMasks;

		internal static void SetActiveobjfalse(string OBJ)
		{
			try
			{
				GameObject val = GameObject.Find(OBJ);
				if ((Object)(object)val != (Object)null)
				{
					val.SetActive(false);
				}
				else
				{
					mls.LogError((object)("没有找到:" + OBJ));
				}
			}
			catch (Exception ex)
			{
				mls.LogInfo((object)(OBJ + "\r\n" + ex));
			}
		}

		internal static void SetLP(string OBJ, float x, float y, float z)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				GameObject val = GameObject.Find(OBJ);
				if ((Object)(object)val != (Object)null)
				{
					val.transform.localPosition = new Vector3(x, y, z);
				}
				else
				{
					mls.LogError((object)("没有找到:" + OBJ));
				}
			}
			catch (Exception ex)
			{
				mls.LogInfo((object)(OBJ + "\r\n" + ex));
			}
		}

		internal static void SetLS(string OBJ, float x, float y, float z)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				GameObject val = GameObject.Find(OBJ);
				if ((Object)(object)val != (Object)null)
				{
					val.transform.localScale = new Vector3(x, y, z);
				}
				else
				{
					mls.LogError((object)("没有找到:" + OBJ));
				}
			}
			catch (Exception ex)
			{
				mls.LogInfo((object)(OBJ + "\r\n" + ex));
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(ManualCameraRenderer), "Start")]
		private static void RadarEditfix(ManualCameraRenderer __instance)
		{
			if (!((Object)(object)StartOfRound.Instance.mapScreen == (Object)(object)__instance) && !(((Object)((Component)__instance).gameObject).name == "TerminalScript"))
			{
				return;
			}
			List<string> list = new List<string> { "MapRadar", "Room" };
			if (Config.Defaultlayers.Value)
			{
				list.Add("Default");
			}
			if (Config.Foliagelayers.Value)
			{
				list.Add("Foliage");
			}
			string[] array = list.ToArray();
			int cullingMask = (mapMasks = LayerMask.GetMask(array));
			if (UniversalRadar)
			{
				int mask = LayerMask.GetMask(new string[1] { "MapRadar" });
				omapMasks = mask;
			}
			__instance.cam.cullingMask = cullingMask;
			__instance.cam.orthographicSize = 28.5f;
			__instance.cameraNearPlane = Config.cameraNearPlane.Value;
			__instance.cameraFarPlane = Config.cameraFarPlane.Value;
			Volume component = ((Component)((Component)__instance.cam).transform.Find("VolumeMain (1)")).GetComponent<Volume>();
			if ((Object)(object)component != (Object)null)
			{
				component.weight = 0.7f;
			}
			Transform val = ((Component)__instance.cam).transform.Find("VolumeMain (2)");
			if ((Object)(object)val != (Object)null)
			{
				((Component)val).gameObject.SetActive(false);
			}
			if (!Config.Facialcamera.Value)
			{
				Image localPlayerPlaceholder = __instance.localPlayerPlaceholder;
				if (localPlayerPlaceholder != null)
				{
					((Component)localPlayerPlaceholder).gameObject.SetActive(false);
				}
				RawImage headMountedCamUI = __instance.headMountedCamUI;
				if (headMountedCamUI != null)
				{
					((Component)headMountedCamUI).gameObject.SetActive(false);
				}
				SetLP("Systems/GameSystems/ItemSystems/MapScreenUI/MonitoringPlayerUIContainer/PlayerBeingMonitoredBG", -140f, 95f, 1f);
				SetLP("Systems/GameSystems/ItemSystems/MapScreenUI/MonitoringPlayerUIContainer/PlayerBeingMonitored", -140f, 95f, 0f);
				SetLS("Systems/GameSystems/ItemSystems/MapScreenUI/MonitoringPlayerUIContainer/PlayerBeingMonitoredBG", 1.5f, 1.5f, 1.5f);
				SetLS("Systems/GameSystems/ItemSystems/MapScreenUI/MonitoringPlayerUIContainer/PlayerBeingMonitored", 1.5f, 1.5f, 1.5f);
			}
			if (!Config.CompassRose.Value)
			{
				Image compassRose = __instance.compassRose;
				if (compassRose != null)
				{
					((Component)compassRose).gameObject.SetActive(false);
				}
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(ManualCameraRenderer), "Update")]
		private static void RadarEditfix3(ManualCameraRenderer __instance)
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			if (((Object)(object)StartOfRound.Instance.mapScreen == (Object)(object)__instance || ((Object)((Component)__instance).gameObject).name == "TerminalScript") && UniversalRadar)
			{
				if (((Component)__instance.cam).transform.position.y < -80f)
				{
					__instance.cam.cullingMask = mapMasks;
				}
				else
				{
					__instance.cam.cullingMask = omapMasks;
				}
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(ManualCameraRenderer), "MapCameraFocusOnPosition")]
		private static void RadarEditfix2(ManualCameraRenderer __instance, ref Vector3 pos)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null))
			{
				_ = __instance.radarTargets[__instance.targetTransformIndex].transform.position;
				if ((Object)(object)__instance.targetedPlayer != (Object)null && __instance.targetedPlayer.isInHangarShipRoom)
				{
					__instance.mapCamera.nearClipPlane = -0.96f;
					__instance.mapCamera.farClipPlane = Config.cameraFarPlane.Value;
					StartOfRound.Instance.radarCanvas.planeDistance = -0.93f;
				}
				else
				{
					__instance.mapCamera.nearClipPlane = __instance.cameraNearPlane;
					__instance.mapCamera.farClipPlane = __instance.cameraFarPlane;
					StartOfRound.Instance.radarCanvas.planeDistance = -0.93f;
				}
				((Component)__instance.mapCamera).transform.position = new Vector3(pos.x, pos.y + 3.636f, pos.z);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(RoundManager), "FinishGeneratingLevel")]
		private static void Scenefix()
		{
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			int num = LayerMask.NameToLayer("MapRadar");
			SpriteRenderer[] array = Object.FindObjectsOfType<SpriteRenderer>();
			if (!UniversalRadar)
			{
				SpriteRenderer[] array2 = array;
				foreach (SpriteRenderer val in array2)
				{
					if (((Component)val).gameObject.layer == num)
					{
						((Renderer)val).enabled = false;
					}
				}
				mls.LogInfo((object)"隐藏了所有图层为MapRadar的SpriteRenderer");
				GameObject val2 = GameObject.Find("Systems/Radar");
				if (val2 != null)
				{
					val2.SetActive(false);
				}
				return;
			}
			SpriteRenderer[] array3 = array;
			foreach (SpriteRenderer val3 in array3)
			{
				if (((Component)val3).gameObject.layer == num && ((Component)val3).gameObject.transform.position.y < -80f)
				{
					((Renderer)val3).enabled = false;
				}
			}
			mls.LogInfo((object)"隐藏了所有图层为MapRadar的SpriteRenderer");
		}
	}

	private const string GUID = "hlb.RadarEdit";

	private const string Name = "RadarEdit";

	private const string Version = "1.0.0";

	private Harmony harmony;

	public static ManualLogSource mls;

	public static bool UniversalRadar;

	public static Config RadarEditsConfig { get; internal set; }

	private void Awake()
	{
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Expected O, but got Unknown
		mls = Logger.CreateLogSource("hlb.RadarEdit");
		RadarEditsConfig = new Config(((BaseUnityPlugin)this).Config);
		if (Chainloader.PluginInfos.ContainsKey("ScienceBird.UniversalRadar"))
		{
			UniversalRadar = true;
		}
		harmony = new Harmony("hlb.RadarEdit");
		harmony.PatchAll(typeof(RadarEdits));
	}
}