Decompiled source of Absolute Tempest v1.0.0

com.Omniscye.Magic.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Mirror;
using UnityEngine;
using YAPYAP;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("com.Omniscye.Magic")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+174558dd641ee37bf40ded0d24866ac172d24388")]
[assembly: AssemblyProduct("com.Omniscye.Magic")]
[assembly: AssemblyTitle("EmpressMagic")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
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;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace EmpressMagic
{
	[BepInPlugin("com.omniscye.empressmagic", "Empress Magic", "2.3.0")]
	public class EmpressMagicMod : BaseUnityPlugin
	{
		public static EmpressMagicMod Instance;

		public static Harmony HarmonyInstance;

		private void Awake()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Expected O, but got Unknown
			Instance = this;
			HarmonyInstance = new Harmony("com.omniscye.empressmagic");
			HarmonyInstance.PatchAll(typeof(EmpressMagicPatches));
		}
	}
	public static class ChaosManager
	{
		private static StatusLibrarySO _library;

		private static Dictionary<uint, float> _pawnStatusCooldowns = new Dictionary<uint, float>();

		public static StatusLibrarySO GetLibrary()
		{
			if ((Object)(object)_library == (Object)null)
			{
				PawnStatus val = null;
				if ((Object)(object)Pawn.LocalInstance != (Object)null && (Object)(object)Pawn.LocalInstance.PawnStatus != (Object)null)
				{
					val = Pawn.LocalInstance.PawnStatus;
				}
				else
				{
					Pawn val2 = Object.FindFirstObjectByType<Pawn>();
					if ((Object)(object)val2 != (Object)null)
					{
						val = val2.PawnStatus;
					}
				}
				if ((Object)(object)val != (Object)null)
				{
					FieldInfo fieldInfo = AccessTools.Field(typeof(PawnStatus), "_statusLibrary");
					if (fieldInfo != null)
					{
						object? value = fieldInfo.GetValue(val);
						_library = (StatusLibrarySO)((value is StatusLibrarySO) ? value : null);
					}
				}
			}
			return _library;
		}

		public static void ApplyRandomChaos(Pawn pawn)
		{
			if ((Object)(object)pawn == (Object)null || !NetworkServer.active)
			{
				return;
			}
			uint netId = ((NetworkBehaviour)pawn).netId;
			if (!_pawnStatusCooldowns.TryGetValue(netId, out var value) || !(Time.time < value + 0.5f))
			{
				_pawnStatusCooldowns[netId] = Time.time;
				StatusLibrarySO library = GetLibrary();
				if ((Object)(object)library != (Object)null && library.statusSoById.Length != 0)
				{
					StatusSO val = library.statusSoById[Random.Range(0, library.statusSoById.Length)];
					float num = ((Random.value > 0.5f) ? 20f : 10f);
					pawn.PawnStatus.AddStatus(val, num, 0f);
				}
			}
		}
	}
	public static class EmpressMagicPatches
	{
		private static void SetField<T>(object instance, string fieldName, T value)
		{
			FieldInfo fieldInfo = AccessTools.Field(instance.GetType(), fieldName);
			if (fieldInfo != null)
			{
				fieldInfo.SetValue(instance, value);
			}
		}

		private static T GetField<T>(object instance, string fieldName)
		{
			FieldInfo fieldInfo = AccessTools.Field(instance.GetType(), fieldName);
			if (fieldInfo != null)
			{
				return (T)fieldInfo.GetValue(instance);
			}
			return default(T);
		}

		[HarmonyPatch(typeof(YapNetworkManager), "OnStartServer")]
		[HarmonyPostfix]
		public static void BuffPrefabs()
		{
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			if (NetworkManager.singleton?.spawnPrefabs == null)
			{
				return;
			}
			GameObject val = ((IEnumerable<GameObject>)NetworkManager.singleton.spawnPrefabs).FirstOrDefault((Func<GameObject, bool>)((GameObject p) => Object.op_Implicit((Object)(object)p.GetComponent<ProjectileTornado>())));
			if ((Object)(object)val != (Object)null)
			{
				val.transform.localScale = new Vector3(3f, 6f, 3f);
				ProjectileTornado component = val.GetComponent<ProjectileTornado>();
				SetField(component, "ttl", 30f);
				float field = GetField<float>(component, "dragForce");
				SetField(component, "dragForce", field * 4f);
				ParticleSystem[] componentsInChildren = val.GetComponentsInChildren<ParticleSystem>(true);
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					MainModule main = componentsInChildren[i].main;
					((MainModule)(ref main)).startColor = new MinMaxGradient(Color.magenta, new Color(0.5f, 0f, 1f));
					MinMaxCurve startSize = ((MainModule)(ref main)).startSize;
					if ((int)((MinMaxCurve)(ref startSize)).mode == 0)
					{
						((MainModule)(ref main)).startSize = MinMaxCurve.op_Implicit(((MinMaxCurve)(ref startSize)).constant * 1.5f);
					}
				}
				TrailRenderer componentInChildren = val.GetComponentInChildren<TrailRenderer>();
				if ((Object)(object)componentInChildren != (Object)null)
				{
					componentInChildren.startColor = Color.magenta;
					componentInChildren.endColor = new Color(0.5f, 0f, 0.5f, 0f);
				}
			}
			GameObject val2 = ((IEnumerable<GameObject>)NetworkManager.singleton.spawnPrefabs).FirstOrDefault((Func<GameObject, bool>)((GameObject p) => Object.op_Implicit((Object)(object)p.GetComponent<ProjectilePush>())));
			if ((Object)(object)val2 != (Object)null)
			{
				ProjectilePush component2 = val2.GetComponent<ProjectilePush>();
				SetField(component2, "pushForce", GetField<float>(component2, "pushForce") * 5f);
				SetField(component2, "propPushUpwardsForce", GetField<float>(component2, "propPushUpwardsForce") * 5f);
				SetField(component2, "playerPushForceMultiplier", GetField<float>(component2, "playerPushForceMultiplier") * 3f);
			}
		}

		[HarmonyPatch(typeof(ProjectileTornado), "ApplyTornadoForces")]
		[HarmonyPrefix]
		public static bool VortexPhysics(ProjectileTornado __instance, Rigidbody targetRigidbody, object objectData)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: 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_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: 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_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: 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_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: 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_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: 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_00fb: 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_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: 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)
			if ((Object)(object)targetRigidbody == (Object)null)
			{
				return false;
			}
			Vector3 position = ((Component)__instance).transform.position;
			Vector3 position2 = targetRigidbody.position;
			Vector3 val = position - position2;
			val.y = 0f;
			float magnitude = ((Vector3)(ref val)).magnitude;
			Vector3 normalized = ((Vector3)(ref val)).normalized;
			Vector3 val2 = Vector3.Cross(normalized, Vector3.up);
			float num = 80f;
			float num2 = 100f;
			float num3 = 40f;
			float num4 = 6f;
			if (magnitude > 8f)
			{
				num *= 3f;
			}
			else if (magnitude < 2f)
			{
				num *= 0.5f;
			}
			float num5 = position.y + num4 - position2.y;
			Vector3 val3 = Vector3.up * Mathf.Clamp(num5 * 8f, -10f, 10f);
			Vector3 val4 = Random.insideUnitSphere * 20f;
			Vector3 val5 = normalized * num + val2 * num2 + val3 * num3 + val4;
			targetRigidbody.AddForce(val5, (ForceMode)5);
			targetRigidbody.AddTorque(Random.insideUnitSphere * 25f, (ForceMode)1);
			Pawn component = ((Component)targetRigidbody).GetComponent<Pawn>();
			if ((Object)(object)component != (Object)null && NetworkServer.active)
			{
				if (magnitude < 5f)
				{
					if (!component.Blackboard.IsRagdollMode)
					{
						component.SvSetRagdoll(val5 * 0.1f);
					}
					if (Random.value < 0.1f)
					{
						component.SvDropAllProps();
					}
				}
				if (Random.value < 0.05f)
				{
					ChaosManager.ApplyRandomChaos(component);
				}
			}
			return false;
		}

		[HarmonyPatch(typeof(ProjectilePush), "OnTargetHit")]
		[HarmonyPostfix]
		public static void PushChaos(ProjectilePush __instance, Collider target, Rigidbody targetRigidbody)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			if (NetworkServer.active && !((Object)(object)targetRigidbody == (Object)null))
			{
				Pawn component = ((Component)targetRigidbody).GetComponent<Pawn>();
				if ((Object)(object)component != (Object)null)
				{
					ChaosManager.ApplyRandomChaos(component);
					ChaosManager.ApplyRandomChaos(component);
					component.SvSetRagdoll(targetRigidbody.linearVelocity);
				}
			}
		}
	}
}
namespace System.Diagnostics.CodeAnalysis
{
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class ConstantExpectedAttribute : Attribute
	{
		public object? Min { get; set; }

		public object? Max { get; set; }
	}
	[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class ExperimentalAttribute : Attribute
	{
		public string DiagnosticId { get; }

		public string? UrlFormat { get; set; }

		public ExperimentalAttribute(string diagnosticId)
		{
			DiagnosticId = diagnosticId;
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
	[ExcludeFromCodeCoverage]
	internal sealed class MemberNotNullAttribute : Attribute
	{
		public string[] Members { get; }

		public MemberNotNullAttribute(string member)
		{
			Members = new string[1] { member };
		}

		public MemberNotNullAttribute(params string[] members)
		{
			Members = members;
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
	[ExcludeFromCodeCoverage]
	internal sealed class MemberNotNullWhenAttribute : Attribute
	{
		public bool ReturnValue { get; }

		public string[] Members { get; }

		public MemberNotNullWhenAttribute(bool returnValue, string member)
		{
			ReturnValue = returnValue;
			Members = new string[1] { member };
		}

		public MemberNotNullWhenAttribute(bool returnValue, params string[] members)
		{
			ReturnValue = returnValue;
			Members = members;
		}
	}
	[AttributeUsage(AttributeTargets.Constructor, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class SetsRequiredMembersAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class StringSyntaxAttribute : Attribute
	{
		public const string CompositeFormat = "CompositeFormat";

		public const string DateOnlyFormat = "DateOnlyFormat";

		public const string DateTimeFormat = "DateTimeFormat";

		public const string EnumFormat = "EnumFormat";

		public const string GuidFormat = "GuidFormat";

		public const string Json = "Json";

		public const string NumericFormat = "NumericFormat";

		public const string Regex = "Regex";

		public const string TimeOnlyFormat = "TimeOnlyFormat";

		public const string TimeSpanFormat = "TimeSpanFormat";

		public const string Uri = "Uri";

		public const string Xml = "Xml";

		public string Syntax { get; }

		public object?[] Arguments { get; }

		public StringSyntaxAttribute(string syntax)
		{
			Syntax = syntax;
			Arguments = new object[0];
		}

		public StringSyntaxAttribute(string syntax, params object?[] arguments)
		{
			Syntax = syntax;
			Arguments = arguments;
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class UnscopedRefAttribute : Attribute
	{
	}
}
namespace System.Runtime.Versioning
{
	[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class RequiresPreviewFeaturesAttribute : Attribute
	{
		public string? Message { get; }

		public string? Url { get; set; }

		public RequiresPreviewFeaturesAttribute()
		{
		}

		public RequiresPreviewFeaturesAttribute(string? message)
		{
			Message = message;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
	[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class CallerArgumentExpressionAttribute : Attribute
	{
		public string ParameterName { get; }

		public CallerArgumentExpressionAttribute(string parameterName)
		{
			ParameterName = parameterName;
		}
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class CollectionBuilderAttribute : Attribute
	{
		public Type BuilderType { get; }

		public string MethodName { get; }

		public CollectionBuilderAttribute(Type builderType, string methodName)
		{
			BuilderType = builderType;
			MethodName = methodName;
		}
	}
	[AttributeUsage(AttributeTargets.All, AllowMultiple = true, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class CompilerFeatureRequiredAttribute : Attribute
	{
		public const string RefStructs = "RefStructs";

		public const string RequiredMembers = "RequiredMembers";

		public string FeatureName { get; }

		public bool IsOptional { get; set; }

		public CompilerFeatureRequiredAttribute(string featureName)
		{
			FeatureName = featureName;
		}
	}
	[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class InterpolatedStringHandlerArgumentAttribute : Attribute
	{
		public string[] Arguments { get; }

		public InterpolatedStringHandlerArgumentAttribute(string argument)
		{
			Arguments = new string[1] { argument };
		}

		public InterpolatedStringHandlerArgumentAttribute(params string[] arguments)
		{
			Arguments = arguments;
		}
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class InterpolatedStringHandlerAttribute : Attribute
	{
	}
	[EditorBrowsable(EditorBrowsableState.Never)]
	[ExcludeFromCodeCoverage]
	internal static class IsExternalInit
	{
	}
	[AttributeUsage(AttributeTargets.Method, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class ModuleInitializerAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class OverloadResolutionPriorityAttribute : Attribute
	{
		public int Priority { get; }

		public OverloadResolutionPriorityAttribute(int priority)
		{
			Priority = priority;
		}
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = true, AllowMultiple = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class ParamCollectionAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class RequiredMemberAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	[EditorBrowsable(EditorBrowsableState.Never)]
	[ExcludeFromCodeCoverage]
	internal sealed class RequiresLocationAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Event | AttributeTargets.Interface, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class SkipLocalsInitAttribute : Attribute
	{
	}
}