Decompiled source of Cyphers Teleporter Turrets v1.0.1

TeleporterTurrets.dll

Decompiled a week 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.Configuration;
using KinematicCharacterController;
using Microsoft.CodeAnalysis;
using On.RoR2;
using RoR2;
using UnityEngine;
using UnityEngine.Networking;

[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 = ".NET Standard 2.1")]
[assembly: AssemblyCompany("TeleporterTurrets")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("TeleporterTurrets")]
[assembly: AssemblyTitle("TeleporterTurrets")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace RuneFoxMods
{
	[BepInPlugin("Cyphers.TeleporterTurrets", "Teleporter Turrets", "1.0.0")]
	public class TeleporterTurrets : BaseUnityPlugin
	{
		public static ConfigEntry<float> TurretRadius;

		public void Awake()
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			TurretRadius = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "Turret Radius", 8f, "How far away from the teleporter center the turrets should spawn.");
			TeleporterInteraction.OnInteractionBegin += new hook_OnInteractionBegin(TeleporterInteraction_OnInteractionBegin);
		}

		private void TeleporterInteraction_OnInteractionBegin(orig_OnInteractionBegin orig, TeleporterInteraction self, Interactor activator)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Invalid comparison between Unknown and I4
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self, activator);
			if (!NetworkServer.active)
			{
				return;
			}
			List<CharacterBody> list = new List<CharacterBody>();
			BodyIndex val = BodyCatalog.FindBodyIndex("Turret1Body");
			foreach (CharacterBody readOnlyInstances in CharacterBody.readOnlyInstancesList)
			{
				if (Object.op_Implicit((Object)(object)readOnlyInstances) && readOnlyInstances.bodyIndex == val && (int)readOnlyInstances.teamComponent.teamIndex == 1)
				{
					list.Add(readOnlyInstances);
				}
			}
			int count = list.Count;
			if (count == 0)
			{
				return;
			}
			float value = TurretRadius.Value;
			float num = MathF.PI * 2f / (float)count;
			for (int i = 0; i < count; i++)
			{
				try
				{
					float num2 = (float)i * num;
					Vector3 val2 = new Vector3(Mathf.Cos(num2), 0f, Mathf.Sin(num2)) * value;
					Vector3 val3 = ((Component)self).transform.position + val2 + Vector3.up * 1.5f;
					CharacterBody val4 = list[i];
					if (Object.op_Implicit((Object)(object)val4.characterMotor))
					{
						((BaseCharacterController)val4.characterMotor).Motor.SetPosition(val3, true);
						val4.characterMotor.velocity = Vector3.zero;
					}
					else if (Object.op_Implicit((Object)(object)val4.rigidbody))
					{
						val4.rigidbody.MovePosition(val3);
					}
					else
					{
						((Component)val4).transform.position = val3;
					}
					Util.PlaySound("Play_huntress_shift_mini_blink_end", ((Component)val4).gameObject);
				}
				catch (Exception ex)
				{
					((BaseUnityPlugin)this).Logger.LogError((object)$"Failed to move turret {i}: {ex.Message}");
				}
			}
		}
	}
}