Decompiled source of TeleporterBeam v1.0.1

TeleporterBeam.dll

Decompiled 2 months ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using On.RoR2;
using R2API;
using RoR2;
using UnityEngine;
using UnityEngine.AddressableAssets;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("TeleporterBeam")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("TeleporterBeam")]
[assembly: AssemblyTitle("TeleporterBeam")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace TeleporterBeam;

[BepInPlugin("com.rob.TeleporterBeam", "TeleporterBeam", "1.0.1")]
public class Plugin : BaseUnityPlugin
{
	public const string MODUID = "com.rob.TeleporterBeam";

	public static GameObject beamPrefab;

	private void Awake()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0095: Expected O, but got Unknown
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a7: Expected O, but got Unknown
		beamPrefab = PrefabAPI.InstantiateClone(((Component)Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/arena/ArenaMissionController.prefab").WaitForCompletion().transform.Find("NullSafeZone (1)/BuiltInEffects/WardOn")).gameObject, "RobTeleporterBeam");
		Material val = Object.Instantiate<Material>(Addressables.LoadAssetAsync<Material>((object)"RoR2/Base/Common/VFX/matGlowPaintSmall.mat").WaitForCompletion());
		val.SetColor("_TintColor", Color.green);
		((Renderer)((Component)beamPrefab.transform.Find("Beam")).gameObject.GetComponent<ParticleSystemRenderer>()).material = val;
		TeleporterInteraction.Awake += new hook_Awake(TeleporterInteraction_Awake);
		TeleporterInteraction.OnInteractionBegin += new hook_OnInteractionBegin(TeleporterInteraction_OnInteractionBegin);
	}

	private void TeleporterInteraction_OnInteractionBegin(orig_OnInteractionBegin orig, TeleporterInteraction self, Interactor activator)
	{
		orig.Invoke(self, activator);
		if (!((Object)(object)self != (Object)null))
		{
			return;
		}
		ModelLocator component = ((Component)self).GetComponent<ModelLocator>();
		if (!Object.op_Implicit((Object)(object)component))
		{
			return;
		}
		Transform modelTransform = component.modelTransform;
		if (Object.op_Implicit((Object)(object)modelTransform))
		{
			Transform val = modelTransform.Find("TeleporterBeam");
			if (Object.op_Implicit((Object)(object)val))
			{
				((Component)val).gameObject.SetActive(false);
			}
		}
	}

	private void TeleporterInteraction_Awake(orig_Awake orig, TeleporterInteraction self)
	{
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		if (Object.op_Implicit((Object)(object)self))
		{
			ModelLocator component = ((Component)self).GetComponent<ModelLocator>();
			if (Object.op_Implicit((Object)(object)component))
			{
				Transform modelTransform = component.modelTransform;
				if (Object.op_Implicit((Object)(object)modelTransform))
				{
					GameObject val = Object.Instantiate<GameObject>(beamPrefab);
					val.SetActive(true);
					((Object)val).name = "TeleporterBeam";
					val.transform.parent = modelTransform;
					val.transform.localPosition = new Vector3(0f, 0f, 0f);
					val.transform.localRotation = Quaternion.Euler(new Vector3(90f, 0f, 0f));
				}
			}
		}
		orig.Invoke(self);
	}
}