Decompiled source of LocateNewt v1.0.1

LocateNewt.dll

Decompiled 7 hours ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using RoR2;
using RoR2.UI;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("LocateNewt")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("LocateNewt")]
[assembly: AssemblyTitle("LocateNewt")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("com.yourname.NewtAltarBeacon", "Newt Altar Beacon", "1.0.1")]
public class NewtAltarBeacon : BaseUnityPlugin
{
	private PositionIndicator altarIndicator;

	private ChargeIndicatorController altarChargeController;

	public void Awake()
	{
		((BaseUnityPlugin)this).Logger.LogInfo((object)"LocateNewt loaded!");
		Stage.onStageStartGlobal += OnStageStart;
	}

	private void OnStageStart(Stage stage)
	{
		SceneDef sceneDef = stage.sceneDef;
		string text = ((sceneDef != null) ? sceneDef.cachedName : null) ?? "Unknown";
		((BaseUnityPlugin)this).Logger.LogInfo((object)("Stage started: " + text));
		if (text.ToLower().Contains("bazaar"))
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Bazaar stage detected, skipping Newt altar indicator.");
			return;
		}
		RoR2Application.onNextUpdate += delegate
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: 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_0076: Unknown result type (might be due to invalid IL or missing references)
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Looking for Newt altars...");
			GameObject[] array = Object.FindObjectsOfType<GameObject>();
			foreach (GameObject val in array)
			{
				if (((Object)val).name.Contains("mdlNewtStatue"))
				{
					((BaseUnityPlugin)this).Logger.LogInfo((object)$"Found Newt altar object: {((Object)val).name} at {val.transform.position}");
					CreateAltarIndicator(val.transform.position + Vector3.up * 2f);
					break;
				}
			}
		};
	}

	private void CreateAltarIndicator(Vector3 position)
	{
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)altarIndicator != (Object)null)
		{
			Object.Destroy((Object)(object)((Component)altarIndicator).gameObject);
			altarIndicator = null;
			altarChargeController = null;
		}
		GameObject val = Resources.Load<GameObject>("Prefabs/PositionIndicators/TeleporterChargingPositionIndicator");
		altarIndicator = Object.Instantiate<GameObject>(val, position, Quaternion.identity).GetComponent<PositionIndicator>();
		altarChargeController = ((Component)altarIndicator).GetComponent<ChargeIndicatorController>();
		if ((Object)(object)altarChargeController.chargingText != (Object)null)
		{
			((Component)altarChargeController.chargingText.transform).gameObject.SetActive(false);
		}
		altarChargeController.spriteBaseColor = Color.cyan;
		altarChargeController.spriteFlashColor = Color.cyan;
		altarChargeController.spriteChargedColor = Color.cyan;
		altarChargeController.spriteChargingColor = Color.cyan;
		Sprite val2 = Resources.Load<Sprite>("Textures/MiscIcons/texShopPortalIcon");
		if ((Object)(object)altarChargeController != (Object)null && (Object)(object)val2 != (Object)null)
		{
			SpriteRenderer[] iconSprites = altarChargeController.iconSprites;
			foreach (SpriteRenderer val3 in iconSprites)
			{
				if ((Object)(object)val3 != (Object)null)
				{
					val3.sprite = val2;
				}
			}
		}
		((Component)altarIndicator).gameObject.SetActive(true);
	}
}