Decompiled source of DSPHideEverything v0.1.2

DSPHideEverything.dll

Decompiled a year ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;
using UnityEngine.Events;
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: AssemblyTitle("DspFontPatcher")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("DspFontPatcher")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("81DF3045-8007-4F6A-AAF6-903139D85B6C")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("0.1.0.0")]
namespace DSPHideEverything;

internal class Event
{
	public static void OnDroneButtonClick()
	{
		Main.disableLogisticDrones.Value = !Main.disableLogisticDrones.Value;
		GameMain.mainPlayer.factoryModel.disableLogisticDrones = Main.disableLogisticDrones.Value;
		UI.DroneButton.GetComponent<UIButton>().highlighted = !Main.disableLogisticDrones.Value;
	}

	public static void OnVesselButtonClick()
	{
		Main.disableShips.Value = !Main.disableShips.Value;
		UI.VesselButton.GetComponent<UIButton>().highlighted = !Main.disableShips.Value;
	}

	public static void OnSphereButtonClick()
	{
		Main.disableDysonSphere.Value = !Main.disableDysonSphere.Value;
		UI.SphereButton.GetComponent<UIButton>().highlighted = !Main.disableDysonSphere.Value;
	}

	public static void OnPrebuildButtonClick()
	{
		Main.disablePreBuild.Value = !Main.disablePreBuild.Value;
		GameMain.gpuiManager.renderPrebuild = !Main.disablePreBuild.Value;
		UI.PrebuildButton.GetComponent<UIButton>().highlighted = !Main.disablePreBuild.Value;
	}

	public static void OnVegetableButtonClick()
	{
		Main.disableVegetable.Value = !Main.disableVegetable.Value;
		UI.VegetableButton.GetComponent<UIButton>().highlighted = !Main.disableVegetable.Value;
	}

	public static void OnBuildingButtonClick()
	{
		Main.disableBuilding.Value = !Main.disableBuilding.Value;
		GameMain.mainPlayer.factoryModel.disableTraffics = Main.disableBuilding.Value;
		GameMain.gpuiManager.renderEntity = !Main.disableBuilding.Value;
		UI.BuildingButton.GetComponent<UIButton>().highlighted = !Main.disableBuilding.Value;
	}

	public static void OnMiniMapClick()
	{
		Main.disableMiniMap.Value = !Main.disableMiniMap.Value;
		UI.MiniMapButton.GetComponent<UIButton>().highlighted = !Main.disableMiniMap.Value;
	}

	public static void OnCargoButtonClick()
	{
		Main.disableCargoes.Value = !Main.disableCargoes.Value;
		GameMain.mainPlayer.factoryModel.disableCargos = Main.disableCargoes.Value;
		UI.CargoButton.GetComponent<UIButton>().highlighted = !Main.disableCargoes.Value;
	}
}
public class LogManager
{
	public static ManualLogSource Logger;
}
[BepInPlugin("Appun.DSP.plugin.HideEverything", "DSPHideEverything", "0.1.3")]
[BepInProcess("DSPGAME.exe")]
public class Main : BaseUnityPlugin
{
	public static ConfigEntry<bool> disableLogisticDrones;

	public static ConfigEntry<bool> disableShips;

	public static ConfigEntry<bool> disableDysonSphere;

	public static ConfigEntry<bool> disablePreBuild;

	public static ConfigEntry<bool> disableVegetable;

	public static ConfigEntry<bool> disableBuilding;

	public static ConfigEntry<bool> disableMiniMap;

	public static ConfigEntry<bool> disableCargoes;

	public static ConfigEntry<bool> disableLogisticsBot;

	public void Start()
	{
		LogManager.Logger = ((BaseUnityPlugin)this).Logger;
		Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
		disableLogisticDrones = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "disableLogisticDrones", false, "hide Logistic Drones");
		disableShips = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "disableShips", false, "hide Logistic Vessels");
		disableDysonSphere = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "disableDysonSphere", false, "hide Dyson Sphere");
		disablePreBuild = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "disablePreBuild", false, "hide Pre Build View");
		disableVegetable = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "disableTreeAndRock", false, "hide Tree & Rock");
		disableBuilding = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "disableBuilding", false, "hide Buildings & Conveyor Belts");
		disableCargoes = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "disableCargo", false, "hide Cargoes");
		disableLogisticsBot = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "disableLogisticsBot", true, "hide Logistics Bot ");
		UI.LoadIcon();
		UI.Create();
		PowerSystemRenderer.forceArcsOff = !PowerSystemRenderer.powerGraphOn;
	}
}
[HarmonyPatch]
internal class HarmonyPatches
{
	[HarmonyPrefix]
	[HarmonyPatch(typeof(LogisticCourierRenderer), "Draw")]
	[HarmonyPatch(typeof(LogisticCourierRenderer), "SetCapacity")]
	[HarmonyPatch(typeof(LogisticCourierRenderer), "Update")]
	public static bool LogisticCourierRenderer_Update_PrePatch(LogisticCourierRenderer __instance)
	{
		if (GameMain.isRunning && Main.disableLogisticsBot.Value && !((ManualBehaviour)UIRoot.instance.uiGame.dysonEditor).active)
		{
			return false;
		}
		return true;
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(MeshDataRenderer), "Update")]
	public static bool MeshDataRenderer_Update_PrePatch(MeshDataRenderer __instance)
	{
		if (GameMain.isRunning && Main.disablePreBuild.Value && !((ManualBehaviour)UIRoot.instance.uiGame.dysonEditor).active)
		{
			__instance.castShadows = false;
			__instance.receiveShadows = false;
			return false;
		}
		return true;
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(ConnGizmoRenderer), "Draw")]
	[HarmonyPatch(typeof(ConnGizmoRenderer), "Update")]
	public static bool ConnGizmoRenderer_Render_PrePatch()
	{
		if (GameMain.isRunning && Main.disablePreBuild.Value && !((ManualBehaviour)UIRoot.instance.uiGame.dysonEditor).active)
		{
			return false;
		}
		return true;
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(VegeRenderer), "Render")]
	[HarmonyPatch(typeof(VegeRenderer), "SetInstCapacity")]
	[HarmonyPatch(typeof(VegeRenderer), "SyncInstBuffer")]
	public static bool VegeRenderer_PrePatch()
	{
		if (GameMain.isRunning && Main.disableVegetable.Value)
		{
			return false;
		}
		return true;
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(DysonSphere), "DrawModel")]
	[HarmonyPatch(typeof(DysonSphere), "DrawPost")]
	[HarmonyPatch(typeof(DysonSphere), "UpdateProgress", new Type[] { typeof(DysonNode) })]
	[HarmonyPatch(typeof(DysonSphere), "UpdateProgress", new Type[] { typeof(DysonFrame) })]
	[HarmonyPatch(typeof(DysonSphere), "UpdateStates", new Type[]
	{
		typeof(DysonNode),
		typeof(uint),
		typeof(bool),
		typeof(bool)
	})]
	[HarmonyPatch(typeof(DysonSphere), "UpdateStates", new Type[]
	{
		typeof(DysonFrame),
		typeof(uint),
		typeof(bool),
		typeof(bool)
	})]
	[HarmonyPatch(typeof(DysonSphere), "UpdateStates", new Type[]
	{
		typeof(DysonShell),
		typeof(uint),
		typeof(bool),
		typeof(bool)
	})]
	public static bool DysonSphere_PrePatch()
	{
		if (GameMain.isRunning && Main.disableDysonSphere.Value && !((ManualBehaviour)UIRoot.instance.uiGame.dysonEditor).active)
		{
			return false;
		}
		return true;
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(DysonSwarm), "DrawModel")]
	[HarmonyPatch(typeof(DysonSwarm), "GameTick")]
	public static bool DysonSwarm_PrePatch()
	{
		if (GameMain.isRunning && Main.disableDysonSphere.Value && !((ManualBehaviour)UIRoot.instance.uiGame.dysonEditor).active)
		{
			return false;
		}
		return true;
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(DysonSphereSegmentRenderer), "DrawFrameMesh")]
	[HarmonyPatch(typeof(DysonSphereSegmentRenderer), "DrawModels")]
	[HarmonyPatch(typeof(DysonSphereSegmentRenderer), "DrawNodeMesh")]
	[HarmonyPatch(typeof(DysonSphereSegmentRenderer), "RebuildModels")]
	[HarmonyPatch(typeof(DysonSphereSegmentRenderer), "LoadStatic")]
	[HarmonyPatch(typeof(DysonSphereSegmentRenderer), "RebuildModels")]
	public static bool DysonSphereSegmentRenderer_PrePatch()
	{
		if (GameMain.isRunning && Main.disableDysonSphere.Value && !((ManualBehaviour)UIRoot.instance.uiGame.dysonEditor).active)
		{
			return false;
		}
		return true;
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(DysonRocketRenderer), "Draw")]
	[HarmonyPatch(typeof(DysonRocketRenderer), "SetCapacity")]
	[HarmonyPatch(typeof(DysonRocketRenderer), "Update")]
	public static bool DysonRocketRenderer_PrePatch()
	{
		if (GameMain.isRunning && Main.disableDysonSphere.Value && !((ManualBehaviour)UIRoot.instance.uiGame.dysonEditor).active)
		{
			return false;
		}
		return true;
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(LogisticDroneRenderer), "Draw")]
	[HarmonyPatch(typeof(LogisticDroneRenderer), "SetCapacity")]
	[HarmonyPatch(typeof(LogisticDroneRenderer), "Update")]
	public static bool LogisticDroneRenderer_Draw_PrePatch()
	{
		if (GameMain.isRunning && Main.disableLogisticDrones.Value)
		{
			return false;
		}
		return true;
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(LogisticShipRenderer), "Draw")]
	[HarmonyPatch(typeof(LogisticShipRenderer), "SetCapacity")]
	[HarmonyPatch(typeof(LogisticShipRenderer), "Update")]
	[HarmonyPatch(typeof(LogisticShipUIRenderer), "Draw")]
	[HarmonyPatch(typeof(LogisticShipUIRenderer), "SetCapacity")]
	[HarmonyPatch(typeof(LogisticShipUIRenderer), "Update")]
	public static bool LogisticShipRenderer_Draw_PrePatch()
	{
		if (GameMain.isRunning && Main.disableShips.Value)
		{
			return false;
		}
		return true;
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(UISpaceGuide), "CheckVisible")]
	[HarmonyPatch(typeof(UISpaceGuide), "SetEntry")]
	[HarmonyPatch(typeof(UISpaceGuide), "_OnLateUpdate")]
	public static bool UISpaceGuider_OnLateUpdate_PrePatch()
	{
		if (GameMain.isRunning && Main.disableShips.Value)
		{
			return false;
		}
		return true;
	}
}
internal class UI : MonoBehaviour
{
	public static GameObject DroneButton;

	public static GameObject VesselButton;

	public static GameObject SphereButton;

	public static GameObject PrebuildButton;

	public static GameObject VegetableButton;

	public static GameObject BuildingButton;

	public static GameObject MiniMapButton;

	public static GameObject CargoButton;

	public static Sprite DroneIcon;

	public static Sprite VesselIcon;

	public static Sprite SphereIcon;

	public static Sprite PrebuildIcon;

	public static Sprite VegetableIcon;

	public static Sprite BuildingIcon;

	public static Sprite CargoIcon;

	public static Sprite MiniMapIcon;

	public static void LoadIcon()
	{
		try
		{
			AssetBundle val = AssetBundle.LoadFromStream(Assembly.GetExecutingAssembly().GetManifestResourceStream("DSPHideEverything.hideeverythingicon"));
			if ((Object)(object)val == (Object)null)
			{
				LogManager.Logger.LogInfo((object)"Icon loaded.");
				return;
			}
			DroneIcon = val.LoadAsset<Sprite>("drone");
			VesselIcon = val.LoadAsset<Sprite>("vessel");
			PrebuildIcon = val.LoadAsset<Sprite>("BuildPreview");
			SphereIcon = val.LoadAsset<Sprite>("dysonsphere");
			VegetableIcon = val.LoadAsset<Sprite>("Vegitable");
			BuildingIcon = val.LoadAsset<Sprite>("Building");
			CargoIcon = val.LoadAsset<Sprite>("cargo 1");
			MiniMapIcon = val.LoadAsset<Sprite>("Belt");
			val.Unload(false);
		}
		catch (Exception ex)
		{
			LogManager.Logger.LogInfo((object)("e.Message " + ex.Message));
			LogManager.Logger.LogInfo((object)("e.StackTrace " + ex.StackTrace));
		}
	}

	public static void Create()
	{
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_0113: Unknown result type (might be due to invalid IL or missing references)
		//IL_011d: Expected O, but got Unknown
		//IL_016a: Unknown result type (might be due to invalid IL or missing references)
		//IL_020c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0216: Expected O, but got Unknown
		//IL_0263: Unknown result type (might be due to invalid IL or missing references)
		//IL_0305: Unknown result type (might be due to invalid IL or missing references)
		//IL_030f: Expected O, but got Unknown
		//IL_035c: Unknown result type (might be due to invalid IL or missing references)
		//IL_03fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0408: Expected O, but got Unknown
		//IL_0455: Unknown result type (might be due to invalid IL or missing references)
		//IL_04f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0501: Expected O, but got Unknown
		//IL_054e: Unknown result type (might be due to invalid IL or missing references)
		//IL_05f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_05fa: Expected O, but got Unknown
		//IL_0647: Unknown result type (might be due to invalid IL or missing references)
		//IL_06e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_06f3: Expected O, but got Unknown
		GameObject.Find("UI Root/Overlay Canvas/In Game/Game Menu/detail-func-group").GetComponent<RectTransform>().sizeDelta = new Vector2(350f, 248f);
		DroneButton = Object.Instantiate<GameObject>(GameObject.Find("UI Root/Overlay Canvas/In Game/Game Menu/detail-func-group/dfunc-1"), GameObject.Find("UI Root/Overlay Canvas/In Game/Game Menu/detail-func-group").transform);
		((Object)DroneButton).name = "DroneButton";
		DroneButton.transform.localPosition = new Vector3(-275f, 163f, 0f);
		DroneButton.GetComponent<UIButton>().tips.tipTitle = Localization.Translate("Logistic Drones");
		DroneButton.GetComponent<UIButton>().tips.tipText = Localization.Translate("Click to turn ON / OFF drawing of Logistic Drones");
		((Component)DroneButton.transform.Find("icon")).GetComponent<Image>().sprite = DroneIcon;
		DroneButton.GetComponent<UIButton>().highlighted = !Main.disableLogisticDrones.Value;
		((UnityEvent)DroneButton.GetComponent<UIButton>().button.onClick).AddListener(new UnityAction(Event.OnDroneButtonClick));
		VesselButton = Object.Instantiate<GameObject>(DroneButton.gameObject, DroneButton.transform.parent);
		((Object)VesselButton).name = "VesselButton";
		VesselButton.transform.localPosition = new Vector3(-235f, 163f, 0f);
		VesselButton.GetComponent<UIButton>().tips.tipTitle = Localization.Translate("Logistic Vessels");
		VesselButton.GetComponent<UIButton>().tips.tipText = Localization.Translate("Click to turn ON / OFF drawing of Logistic Vessels");
		((Component)VesselButton.transform.Find("icon")).GetComponent<Image>().sprite = VesselIcon;
		VesselButton.GetComponent<UIButton>().highlighted = !Main.disableShips.Value;
		((UnityEvent)VesselButton.GetComponent<UIButton>().button.onClick).AddListener(new UnityAction(Event.OnVesselButtonClick));
		PrebuildButton = Object.Instantiate<GameObject>(DroneButton.gameObject, DroneButton.transform.parent);
		((Object)PrebuildButton).name = "PrebuildButton";
		PrebuildButton.transform.localPosition = new Vector3(-235f, 123f, 0f);
		PrebuildButton.GetComponent<UIButton>().tips.tipTitle = Localization.Translate("PreBuildView");
		PrebuildButton.GetComponent<UIButton>().tips.tipText = Localization.Translate("Click to turn ON / OFF drawing of PreBuildView");
		((Component)PrebuildButton.transform.Find("icon")).GetComponent<Image>().sprite = PrebuildIcon;
		PrebuildButton.GetComponent<UIButton>().highlighted = !Main.disablePreBuild.Value;
		((UnityEvent)PrebuildButton.GetComponent<UIButton>().button.onClick).AddListener(new UnityAction(Event.OnPrebuildButtonClick));
		SphereButton = Object.Instantiate<GameObject>(DroneButton.gameObject, DroneButton.transform.parent);
		((Object)SphereButton).name = "SphereButton";
		SphereButton.transform.localPosition = new Vector3(-195f, 163f, 0f);
		SphereButton.GetComponent<UIButton>().tips.tipTitle = Localization.Translate("Dyson Sphere");
		SphereButton.GetComponent<UIButton>().tips.tipText = Localization.Translate("Click to turn ON / OFF drawing of Dyson Sphere");
		((Component)SphereButton.transform.Find("icon")).GetComponent<Image>().sprite = SphereIcon;
		SphereButton.GetComponent<UIButton>().highlighted = !Main.disableDysonSphere.Value;
		((UnityEvent)SphereButton.GetComponent<UIButton>().button.onClick).AddListener(new UnityAction(Event.OnSphereButtonClick));
		VegetableButton = Object.Instantiate<GameObject>(DroneButton.gameObject, DroneButton.transform.parent);
		((Object)VegetableButton).name = "VegetableButton";
		VegetableButton.transform.localPosition = new Vector3(-155f, 163f, 0f);
		VegetableButton.GetComponent<UIButton>().tips.tipTitle = Localization.Translate("Trees & Rocks");
		VegetableButton.GetComponent<UIButton>().tips.tipText = Localization.Translate("Click to turn ON / OFF drawing of Trees & Rocks");
		((Component)VegetableButton.transform.Find("icon")).GetComponent<Image>().sprite = VegetableIcon;
		VegetableButton.GetComponent<UIButton>().highlighted = !Main.disableVegetable.Value;
		((UnityEvent)VegetableButton.GetComponent<UIButton>().button.onClick).AddListener(new UnityAction(Event.OnVegetableButtonClick));
		BuildingButton = Object.Instantiate<GameObject>(DroneButton.gameObject, DroneButton.transform.parent);
		((Object)BuildingButton).name = "BuildingButton";
		BuildingButton.transform.localPosition = new Vector3(-275f, 123f, 0f);
		BuildingButton.GetComponent<UIButton>().tips.tipTitle = Localization.Translate("Buildings & Conveyor Belts");
		BuildingButton.GetComponent<UIButton>().tips.tipText = Localization.Translate("Click to turn ON / OFF drawing of Buildings & Conveyor Belts");
		((Component)BuildingButton.transform.Find("icon")).GetComponent<Image>().sprite = BuildingIcon;
		BuildingButton.GetComponent<UIButton>().highlighted = !Main.disableBuilding.Value;
		((UnityEvent)BuildingButton.GetComponent<UIButton>().button.onClick).AddListener(new UnityAction(Event.OnBuildingButtonClick));
		CargoButton = Object.Instantiate<GameObject>(DroneButton.gameObject, DroneButton.transform.parent);
		((Object)CargoButton).name = "CargoButton";
		CargoButton.transform.localPosition = new Vector3(-155f, 123f, 0f);
		CargoButton.GetComponent<UIButton>().tips.tipTitle = Localization.Translate("Cargoes");
		CargoButton.GetComponent<UIButton>().tips.tipText = Localization.Translate("Click to turn ON / OFF drawing of Cargoes");
		((Component)CargoButton.transform.Find("icon")).GetComponent<Image>().sprite = CargoIcon;
		CargoButton.GetComponent<UIButton>().highlighted = !Main.disableCargoes.Value;
		((UnityEvent)CargoButton.GetComponent<UIButton>().button.onClick).AddListener(new UnityAction(Event.OnCargoButtonClick));
	}
}