Decompiled source of SnapfreezeDefense v1.0.2

SnapfreezeDefense.dll

Decompiled 2 months ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using DefenseMatrixManager;
using R2API;
using R2API.Utils;
using RoR2;
using RoR2.Projectile;
using SnapfreezeDefense.Components;
using UnityEngine;
using UnityEngine.AddressableAssets;
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.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("SnapfreezeDefense")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+528b4dae83499648da463de2f702b91c733a1500")]
[assembly: AssemblyProduct("SnapfreezeDefense")]
[assembly: AssemblyTitle("SnapfreezeDefense")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace SnapfreezeDefense
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.Moffein.SnapfreezeDefense", "SnapfreezeDefense", "1.0.2")]
	[R2APISubmoduleDependency(new string[] { "PrefabAPI", "ContentAddition" })]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	public class SnapfreezeDefense : BaseUnityPlugin
	{
		public static GameObject modifiedIceWallPillarProjectile;

		public static GameObject modifiedIceWallWalkerProjectile;

		public void Awake()
		{
			BuildProjectile();
		}

		private void BuildProjectile()
		{
			//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_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: 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)
			modifiedIceWallPillarProjectile = PrefabAPI.InstantiateClone(Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Mage/MageIcewallPillarProjectile.prefab").WaitForCompletion(), "StandaloneRiskyModIceWallPillarProjectile", true);
			modifiedIceWallPillarProjectile.AddComponent<IceWallDefenseComponent>();
			ContentAddition.AddProjectile(modifiedIceWallPillarProjectile);
			modifiedIceWallWalkerProjectile = PrefabAPI.InstantiateClone(Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Mage/MageIcewallWalkerProjectile.prefab").WaitForCompletion(), "StandaloneRiskyModIceWallWalkerProjectile", true);
			ProjectileMageFirewallWalkerController component = modifiedIceWallWalkerProjectile.GetComponent<ProjectileMageFirewallWalkerController>();
			if (Object.op_Implicit((Object)(object)component))
			{
				component.firePillarPrefab = modifiedIceWallPillarProjectile;
			}
			ContentAddition.AddProjectile(modifiedIceWallWalkerProjectile);
			SetEntityStateField("EntityStates.Mage.Weapon.PrepWall", "projectilePrefab", (Object)(object)modifiedIceWallWalkerProjectile);
			GameObject val = PrefabAPI.InstantiateClone(Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Common/VFX/OmniImpactVFXFrozen.prefab").WaitForCompletion(), "StandaloneRiskyModIceWallDeletionEffect", false);
			EffectComponent component2 = val.GetComponent<EffectComponent>();
			component2.soundName = "Play_captain_drone_zap";
			ContentAddition.AddEffect(val);
			IceWallDefenseComponent.projectileDeletionEffectPrefab = val;
		}

		private bool SetEntityStateField(string entityStateName, string fieldName, Object newObject)
		{
			EntityStateConfiguration val = LegacyResourcesAPI.Load<EntityStateConfiguration>("entitystateconfigurations/" + entityStateName);
			for (int i = 0; i < val.serializedFieldsCollection.serializedFields.Length; i++)
			{
				if (val.serializedFieldsCollection.serializedFields[i].fieldName == fieldName)
				{
					val.serializedFieldsCollection.serializedFields[i].fieldValue.objectValue = newObject;
					return true;
				}
			}
			return false;
		}
	}
}
namespace SnapfreezeDefense.Components
{
	public class IceWallDefenseComponent : MonoBehaviour
	{
		public static GameObject projectileDeletionEffectPrefab;

		private GameObject matrixObject;

		private DefenseMatrixInfo defenseMatrixInfo;

		private BoxCollider collider;

		private TeamFilter tf;

		public void Start()
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Invalid comparison between Unknown and I4
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Expected O, but got Unknown
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: 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_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Expected O, but got Unknown
			if (Object.op_Implicit((Object)(object)matrixObject))
			{
				return;
			}
			tf = ((Component)this).GetComponent<TeamFilter>();
			if (Object.op_Implicit((Object)(object)tf) && (int)tf.teamIndex != -1 && Object.op_Implicit((Object)(object)((Component)this).transform))
			{
				GameObject val = new GameObject
				{
					layer = LayerIndex.world.intVal
				};
				BoxCollider val2 = val.AddComponent<BoxCollider>();
				val2.size = new Vector3(2.5f, 2.5f, 7f);
				((Collider)val2).enabled = false;
				val.transform.localPosition = ((Component)this).transform.localPosition;
				val.transform.localRotation = ((Component)this).transform.localRotation;
				val.transform.localScale = ((Component)this).transform.localScale;
				matrixObject = val;
				collider = matrixObject.GetComponent<BoxCollider>();
				if (Object.op_Implicit((Object)(object)collider))
				{
					defenseMatrixInfo = new DefenseMatrixInfo((Collider[])(object)new Collider[1] { (Collider)collider }, tf.teamIndex);
					DefenseMatrixManager.AddMatrix(defenseMatrixInfo);
				}
			}
		}

		public void FixedUpdate()
		{
			if (NetworkServer.active && Object.op_Implicit((Object)(object)tf) && Object.op_Implicit((Object)(object)collider))
			{
				DeleteProjectile();
			}
		}

		public void DeleteProjectile()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			List<ProjectileController> list = new List<ProjectileController>();
			Vector3 size = collider.size;
			Collider[] array = Physics.OverlapBox(((Component)collider).transform.position, size, ((Component)collider).transform.rotation, LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.projectile)).mask));
			Collider[] array2 = array;
			foreach (Collider val in array2)
			{
				ProjectileController componentInParent = ((Component)val).GetComponentInParent<ProjectileController>();
				if (Object.op_Implicit((Object)(object)componentInParent) && !componentInParent.cannotBeDeleted && (!Object.op_Implicit((Object)(object)componentInParent.teamFilter) || componentInParent.teamFilter.teamIndex != tf.teamIndex))
				{
					bool flag = false;
					ProjectileSimple component = ((Component)componentInParent).gameObject.GetComponent<ProjectileSimple>();
					ProjectileCharacterController component2 = ((Component)componentInParent).gameObject.GetComponent<ProjectileCharacterController>();
					if ((!Object.op_Implicit((Object)(object)component) || (Object.op_Implicit((Object)(object)component) && component.desiredForwardSpeed == 0f)) && !Object.op_Implicit((Object)(object)component2))
					{
						flag = true;
					}
					if (!flag)
					{
						list.Add(componentInParent);
					}
				}
			}
			int count = list.Count;
			for (int j = 0; j < count; j++)
			{
				GameObject gameObject = ((Component)list[j]).gameObject;
				if (Object.op_Implicit((Object)(object)gameObject))
				{
					if (Object.op_Implicit((Object)(object)gameObject.transform) && Object.op_Implicit((Object)(object)projectileDeletionEffectPrefab))
					{
						EffectManager.SimpleEffect(projectileDeletionEffectPrefab, gameObject.transform.position, default(Quaternion), true);
					}
					Object.Destroy((Object)(object)gameObject);
				}
			}
		}

		public void OnDestroy()
		{
			if (defenseMatrixInfo != null)
			{
				DefenseMatrixManager.RemoveMatrix(defenseMatrixInfo);
			}
			if (Object.op_Implicit((Object)(object)matrixObject))
			{
				Object.Destroy((Object)(object)matrixObject);
			}
		}
	}
}