Decompiled source of RadarEdits v1.0.4

BepInEx/plugins/RadarEdit.dll

Decompiled 20 hours ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
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<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");
		cameraNearPlane = cfg.Bind<float>("all", "cameraNearPlane", -2.47f, "cameraNearPlane");
		cameraFarPlane = cfg.Bind<float>("all", "cameraFarPlane", 60f, "cameraFarPlane");
	}
}
[BepInPlugin("hlb.RadarEdit", "RadarEdit", "1.0.0")]
public class huluoboRadarEdits : BaseUnityPlugin
{
	internal class RadarEdits
	{
		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)__instance.cam == (Object)null)
			{
				return;
			}
			int mask = LayerMask.GetMask(new string[4] { "Default", "Room", "Foliage", "MapRadar" });
			__instance.cam.cullingMask = mask;
			__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>();
			component.weight = 0.7f;
			Volume lensDistortionVolume = __instance.lensDistortionVolume;
			if (lensDistortionVolume != null)
			{
				((Component)lensDistortionVolume).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), "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()
		{
			int num = LayerMask.NameToLayer("MapRadar");
			SpriteRenderer[] array = Object.FindObjectsOfType<SpriteRenderer>();
			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);
			}
		}
	}

	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 Config RadarEditsConfig { get; internal set; }

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