Decompiled source of Wesleys Levels v1.0.6

WesleysLevels.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using REPOLib.Modules;
using UnityEngine;

[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("Magic_Wesley")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyCopyright("Copyright © 2025 Magic_Wesley")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("WesleysLevels")]
[assembly: AssemblyTitle("WesleysLevels")]
[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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace WesleysLevels
{
	[BepInPlugin("WesleysLevels", "WesleysLevels", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class WesleysLevels : BaseUnityPlugin
	{
		private void Awake()
		{
			string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
			string text = Path.Combine(directoryName, "wesleyslevels_levels");
			AssetBundle val = AssetBundle.LoadFromFile(text);
			Level val2 = val.LoadAsset<Level>("Level - Bunker");
			Levels.RegisterLevel(val2);
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "WesleysLevels";

		public const string PLUGIN_NAME = "WesleysLevels";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace WesleysLevels.LevelFeatures
{
	internal class AntiGravCrystal : MonoBehaviour
	{
		[CompilerGenerated]
		private sealed class <delayCoroutine>d__35 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public float time;

			public AntiGravCrystal <>4__this;

			private float <t>5__1;

			private AntiGravCrystal[] <>s__2;

			private int <>s__3;

			private AntiGravCrystal <antiGravCrystal>5__4;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <delayCoroutine>d__35(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>s__2 = null;
				<antiGravCrystal>5__4 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<t>5__1 = 0f;
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				if (<t>5__1 < time)
				{
					<t>5__1 += Time.deltaTime;
					<>2__current = 0;
					<>1__state = 1;
					return true;
				}
				<>s__2 = <>4__this.connectedAntiGravCrystals;
				for (<>s__3 = 0; <>s__3 < <>s__2.Length; <>s__3++)
				{
					<antiGravCrystal>5__4 = <>s__2[<>s__3];
					<antiGravCrystal>5__4.previousCrystal = <>4__this;
					if ((Object)(object)<antiGravCrystal>5__4 != (Object)(object)<>4__this.previousCrystal)
					{
						<antiGravCrystal>5__4.ActivateCrystal();
					}
					<antiGravCrystal>5__4 = null;
				}
				<>s__2 = null;
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <lerpCoroutine>d__34 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public Color startColor;

			public Color endColor;

			public float duration;

			public float startIntensity;

			public float endIntensity;

			public bool interact;

			public AntiGravCrystal <>4__this;

			private float <t>5__1;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <lerpCoroutine>d__34(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_004d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0053: Unknown result type (might be due to invalid IL or missing references)
				//IL_0065: Unknown result type (might be due to invalid IL or missing references)
				//IL_006a: Unknown result type (might be due to invalid IL or missing references)
				//IL_026e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0273: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
				//IL_020c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0217: Unknown result type (might be due to invalid IL or missing references)
				//IL_0229: Unknown result type (might be due to invalid IL or missing references)
				//IL_022e: 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_00ff: Unknown result type (might be due to invalid IL or missing references)
				//IL_0111: Unknown result type (might be due to invalid IL or missing references)
				//IL_015b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0166: Unknown result type (might be due to invalid IL or missing references)
				//IL_0178: Unknown result type (might be due to invalid IL or missing references)
				//IL_017d: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<t>5__1 = 0f;
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				if (<t>5__1 < duration)
				{
					<t>5__1 += Time.deltaTime;
					<>4__this.crystalEmissionColor = Color.Lerp(startColor, endColor, <t>5__1 / duration);
					<>4__this._lightIntensity = Mathf.Lerp(startIntensity, endIntensity, <t>5__1 / duration);
					if ((Object)(object)<>4__this.previousCrystal != (Object)null && (Object)(object)<>4__this.previousLineTransform != (Object)null)
					{
						if (!interact)
						{
							<>4__this.lineRenderer.SetPosition(1, Vector3.Lerp(<>4__this.previousLineTransform.position, <>4__this.lineTransform.position, <t>5__1 / duration));
							<>4__this._affectRadius = Mathf.Lerp(0f, <>4__this.affectRadiusMax * 0.65f, <t>5__1 / duration);
							<>4__this._sphereScale = Vector3.Lerp(<>4__this._startScale, <>4__this._endScale, <t>5__1 / duration);
						}
						else
						{
							<>4__this.lineRenderer.SetPosition(1, Vector3.Lerp(<>4__this.lineTransform.position, <>4__this.previousLineTransform.position, <t>5__1 / duration));
							<>4__this._affectRadius = Mathf.Lerp(<>4__this.affectRadiusMax * 0.65f, 0f, <t>5__1 / duration);
							<>4__this._sphereScale = Vector3.Lerp(<>4__this._endScale, <>4__this._startScale, <t>5__1 / duration);
						}
					}
					<>2__current = 0;
					<>1__state = 1;
					return true;
				}
				<>4__this.crystalEmissionColor = endColor;
				<>4__this._lightIntensity = endIntensity;
				<>4__this._canInteract = interact;
				if (<>4__this._canInteract)
				{
					((Renderer)<>4__this.lineRenderer).enabled = false;
					<>4__this.previousCrystal = <>4__this;
					<>4__this._crystalLevel = 0;
					<>4__this.spherePart.Stop();
					<>4__this._linesSet = false;
				}
				else
				{
					<>4__this.activateEffect.Play();
				}
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		public Light light;

		public Sound triggerSound;

		public MeshRenderer renderer;

		public LineRenderer lineRenderer;

		public Transform lineTransform;

		public Transform antiGravAreaTransform;

		public int crystalType;

		public float affectRadiusMax;

		public AntiGravCrystal[] connectedAntiGravCrystals;

		public ParticleSystem activateEffect;

		public ParticleSystem spherePart;

		internal List<PhysGrabObject> objectAffected = new List<PhysGrabObject>();

		private PhotonView _photonView;

		private AntiGravCrystal previousCrystal;

		private Transform previousLineTransform;

		private Vector3 _sphereScale;

		private Vector3 _startScale;

		private Vector3 _endScale;

		private ITargetingCondition customTargetingCondition;

		private Color enabledColor = new Color(0.495283f, 1f, 0.9737809f);

		private Color disabledColor = new Color(0f, 0f, 0f);

		private Color crystalEmissionColor;

		internal bool localPlayerAffected;

		private float _crystalTimer;

		private float _lightIntensity;

		private float _affectRadius;

		private bool _canInteract;

		private bool _linesSet;

		private int _crystalLevel;

		private float randomTriggerDelay;

		private float _triggerCooldown;

		private void Awake()
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: 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_0059: Unknown result type (might be due to invalid IL or missing references)
			crystalEmissionColor = disabledColor;
			_canInteract = true;
			previousCrystal = this;
			customTargetingCondition = ((Component)this).GetComponent<ITargetingCondition>();
			_startScale = new Vector3(0f, 0f, 0f);
			_endScale = new Vector3(affectRadiusMax, affectRadiusMax, affectRadiusMax);
			_photonView = ((Component)this).GetComponent<PhotonView>();
		}

		private void Start()
		{
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				float num = Random.Range(0.2f, 0.5f);
				if (GameManager.Multiplayer())
				{
					_photonView.RPC("InitCrystalRPC", (RpcTarget)0, new object[1] { num });
				}
				else
				{
					InitCrystalRPC(num);
				}
			}
		}

		private void Update()
		{
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			if (_triggerCooldown > 0f)
			{
				_triggerCooldown -= Time.deltaTime;
			}
			if (_crystalTimer > 0f)
			{
				_crystalTimer -= Time.deltaTime;
				if (_crystalTimer <= 0f)
				{
					DeactivateCrystal();
				}
			}
			if (_crystalLevel == 0)
			{
				return;
			}
			light.intensity = _lightIntensity;
			((Renderer)renderer).material.SetColor("_EmissionColor", crystalEmissionColor);
			antiGravAreaTransform.localScale = _sphereScale;
			if (_crystalLevel != 2)
			{
				return;
			}
			gravityConstantLogicCheck();
			foreach (PhysGrabObject item in objectAffected)
			{
				if (Object.op_Implicit((Object)(object)item))
				{
					item.OverrideDrag(0.1f, 0.1f);
					item.OverrideAngularDrag(0.2f, 0.1f);
					item.OverrideZeroGravity(0.1f);
				}
			}
			if (localPlayerAffected)
			{
				PlayerController.instance.AntiGravity(0.1f);
			}
		}

		[IteratorStateMachine(typeof(<lerpCoroutine>d__34))]
		private IEnumerator lerpCoroutine(Color startColor, Color endColor, float duration, float startIntensity, float endIntensity, bool interact)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <lerpCoroutine>d__34(0)
			{
				<>4__this = this,
				startColor = startColor,
				endColor = endColor,
				duration = duration,
				startIntensity = startIntensity,
				endIntensity = endIntensity,
				interact = interact
			};
		}

		[IteratorStateMachine(typeof(<delayCoroutine>d__35))]
		private IEnumerator delayCoroutine(float time)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <delayCoroutine>d__35(0)
			{
				<>4__this = this,
				time = time
			};
		}

		public void ActivateCrystal()
		{
			if (_triggerCooldown <= 0f)
			{
				if (GameManager.Multiplayer())
				{
					_photonView.RPC("ActivateCrystalRPC", (RpcTarget)0, new object[1] { randomTriggerDelay });
				}
				else
				{
					ActivateCrystalRPC(randomTriggerDelay);
				}
			}
		}

		[PunRPC]
		private void InitCrystalRPC(float rand)
		{
			randomTriggerDelay = rand;
		}

		[PunRPC]
		private void ActivateCrystalRPC(float delay)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			_triggerCooldown = 5.5f;
			if (_canInteract)
			{
				_crystalLevel = crystalType;
				_crystalTimer = 15f;
				_canInteract = false;
				triggerSound.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
				spherePart.Play();
				((MonoBehaviour)this).StartCoroutine(lerpCoroutine(disabledColor, enabledColor, 0.25f, 0f, 3f, interact: false));
			}
			((MonoBehaviour)this).StartCoroutine(delayCoroutine(delay));
			if ((Object)(object)previousCrystal != (Object)null && !_linesSet)
			{
				_linesSet = true;
				((Renderer)lineRenderer).enabled = true;
				previousLineTransform = previousCrystal.lineTransform;
				lineRenderer.SetPosition(0, previousLineTransform.position);
				lineRenderer.SetPosition(1, previousLineTransform.position);
			}
		}

		private void DeactivateCrystal()
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			((MonoBehaviour)this).StartCoroutine(lerpCoroutine(enabledColor, disabledColor, 3f, 3f, 0f, interact: true));
		}

		private void gravityConstantLogicCheck()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			objectAffected.Clear();
			objectAffected = SemiFunc.PhysGrabObjectGetAllWithinRange(_affectRadius - 1.2f, antiGravAreaTransform.position, false, default(LayerMask), (PhysGrabObject)null);
			List<PhysGrabObject> list = new List<PhysGrabObject>();
			foreach (PhysGrabObject item in objectAffected)
			{
				if (item.isEnemy)
				{
					list.Add(item);
				}
				if (item.isNonValuable)
				{
					list.Add(item);
				}
				if (item.isValuable)
				{
					list.Add(item);
				}
			}
			objectAffected.Clear();
			objectAffected = list;
			localPlayerAffected = SemiFunc.LocalPlayerOverlapCheck(_affectRadius - 1.2f, antiGravAreaTransform.position, false);
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}