Decompiled source of Root Maps v0.3.3

Root_Maps.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Jotunn.Utils;
using Photon.Pun;
using Sonigon;
using SoundImplementation;
using UnboundLib;
using UnboundLib.Utils;
using UnityEngine;
using UnityEngine.Audio;

[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("Root_Maps")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Root_Maps")]
[assembly: AssemblyTitle("Root_Maps")]
[assembly: AssemblyVersion("1.0.0.0")]
public class EventAudioMixerFix : MonoBehaviour
{
	public enum AudioType
	{
		SFX,
		MASTER,
		MUSIC
	}

	public AudioType type;

	private Dictionary<AudioType, string> groupNames = new Dictionary<AudioType, string>
	{
		{
			AudioType.MASTER,
			"MasterPrivate"
		},
		{
			AudioType.MUSIC,
			"MUS"
		},
		{
			AudioType.SFX,
			"SFX"
		}
	};

	private AudioMixerGroup audioGroup;

	private void Awake()
	{
		audioGroup = SoundVolumeManager.Instance.audioMixer.FindMatchingGroups(groupNames[type])[0];
		SoundUnityEventPlayer component = ((Component)this).GetComponent<SoundUnityEventPlayer>();
		SetAudioMixerGroup(component.soundStart);
		SetAudioMixerGroup(component.soundStartLoop);
		SetAudioMixerGroup(component.soundEnd);
	}

	private void OnDestroy()
	{
		SoundUnityEventPlayer component = ((Component)this).GetComponent<SoundUnityEventPlayer>();
		SoundManager.Instance.StopAtPosition(component.soundStartLoop, ((Component)this).transform, true);
	}

	private void SetAudioMixerGroup(SoundEvent soundEvent)
	{
		if (!((Object)(object)soundEvent == (Object)null))
		{
			soundEvent.variables.audioMixerGroup = audioGroup;
		}
	}
}
public class one_onesprites : MonoBehaviour
{
	private void Start()
	{
		Debug.Log((object)"MapStart!");
		ExtensionMethods.ExecuteAfterFrames((MonoBehaviour)(object)this, 20, (Action)delegate
		{
			((Component)this).GetComponentsInChildren<SpriteRenderer>().ToList().ForEach(delegate(SpriteRenderer sr)
			{
				//IL_0015: Unknown result type (might be due to invalid IL or missing references)
				sr.color = new Color(0.6f, 0.6f, 0.6f, 1f);
			});
			((Component)this).GetComponentsInChildren<SpriteMask>().ToList().ForEach((Action<SpriteMask>)Object.Destroy);
			PlayerManager.instance.players.ForEach(delegate(Player player)
			{
				PlayerJump component = ((Component)player).GetComponent<PlayerJump>();
				component.upForce *= 2f;
			});
		});
	}

	private void OnDestroy()
	{
		Debug.Log((object)"MapEnd!");
		PlayerManager.instance.players.ForEach(delegate(Player player)
		{
			PlayerJump component = ((Component)player).GetComponent<PlayerJump>();
			component.upForce /= 2f;
		});
	}
}
public class RopeAudioMixerFix : MonoBehaviour
{
	public enum AudioType
	{
		SFX,
		MASTER,
		MUSIC
	}

	public AudioType type;

	private Dictionary<AudioType, string> groupNames = new Dictionary<AudioType, string>
	{
		{
			AudioType.MASTER,
			"MasterPrivate"
		},
		{
			AudioType.MUSIC,
			"MUS"
		},
		{
			AudioType.SFX,
			"SFX"
		}
	};

	private AudioMixerGroup audioGroup;

	private void Awake()
	{
		audioGroup = SoundVolumeManager.Instance.audioMixer.FindMatchingGroups(groupNames[type])[0];
		MapObjet_Rope component = ((Component)this).GetComponent<MapObjet_Rope>();
		SetAudioMixerGroup(component.soundRopeLoop);
	}

	private void SetAudioMixerGroup(SoundEvent soundEvent)
	{
		if (!((Object)(object)soundEvent == (Object)null))
		{
			soundEvent.variables.audioMixerGroup = audioGroup;
		}
	}
}
namespace Root_Maps
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("root.custom.maps", "Root_Maps", "0.3.3")]
	[BepInProcess("Rounds.exe")]
	public class Main : BaseUnityPlugin
	{
		private const string ModId = "root.custom.maps";

		private const string ModName = "Root_Maps";

		public const string Version = "0.3.3";

		private void Awake()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			Harmony val = new Harmony("root.custom.maps");
			val.PatchAll();
		}

		private void Start()
		{
			LevelManager.RegisterMaps(AssetUtils.LoadAssetBundleFromResources("root_maps", typeof(Main).Assembly), "<b><#54018f>Root Maps");
		}
	}
}
namespace Root_Maps.Scripts
{
	public class Kill_On : MonoBehaviour
	{
		public BoxCollider2D box;

		private void Start()
		{
		}

		private void Update()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: 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)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < PlayerManager.instance.players.Count; i++)
			{
				if (((Collider2D)box).OverlapPoint(Vector2.op_Implicit(((Component)PlayerManager.instance.players[i]).transform.position)) && PlayerManager.instance.players[i].data.view.IsMine)
				{
					float num = PlayerManager.instance.players[i].data.health + 5f;
					((Damagable)PlayerManager.instance.players[i].data.healthHandler).TakeDamage(Vector2.up * num, Vector2.op_Implicit(((Component)this).transform.position), (GameObject)null, (Player)null, true, false);
				}
			}
		}
	}
	public class Moving_Object_2 : MonoBehaviour
	{
		private int targetID;

		public Vector2[] positions;

		public float drag = 1f;

		public float spring = 1f;

		public float cap = 1f;

		public float vCap = 1f;

		public float threshold = 1f;

		public float timeAtPos;

		private float counter;

		private Vector2 startPos;

		private Vector2 velocity;

		private bool Started = false;

		private Rigidbody2D rig;

		private Map map;

		private string myKey;

		public bool teleport = false;

		private void Start()
		{
			((Component)this).gameObject.layer = 17;
			rig = ((Component)this).GetComponent<Rigidbody2D>();
			map = ((Component)this).GetComponentInParent<Map>();
			int num = (int)ExtensionMethods.GetFieldValue((object)map, "levelID");
			myKey = "MapObect " + num + " " + ((Component)this).transform.GetSiblingIndex() + ((Object)((Component)this).transform.parent).name;
			((Component)MapManager.instance).GetComponent<ChildRPC>().childRPCsInt.Add(myKey, RPCA_SetTargetID);
		}

		private void OnDestroy()
		{
			if (Object.op_Implicit((Object)(object)MapManager.instance))
			{
				((Component)MapManager.instance).GetComponent<ChildRPC>().childRPCsInt.Remove(myKey);
			}
		}

		private void Update()
		{
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: 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_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: 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_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: Unknown result type (might be due to invalid IL or missing references)
			//IL_027b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0285: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0295: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02df: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0301: Unknown result type (might be due to invalid IL or missing references)
			if (MapTransition.isTransitioning || !map.hasEntered)
			{
				return;
			}
			if (!Started)
			{
				startPos = Vector2.op_Implicit(((Component)this).transform.localPosition);
				Started = true;
				vCap /= ((Component)map).transform.localScale.x;
				cap /= ((Component)map).transform.localScale.x;
				return;
			}
			Vector2 val = positions[targetID] + startPos;
			if (teleport && targetID == 0)
			{
				((Component)this).transform.localPosition = Vector2.op_Implicit(positions[targetID]);
				PlayerManager.instance.players.ForEach(delegate(Player player)
				{
					//IL_0013: Unknown result type (might be due to invalid IL or missing references)
					//IL_0023: Expected O, but got Unknown
					PlayerFollowGround component = ((Component)player).GetComponent<PlayerFollowGround>();
					if ((Object)(Rigidbody2D)ExtensionMethods.GetFieldValue((object)component, "lastRig") == (Object)(object)rig)
					{
						ExtensionMethods.SetFieldValue((object)component, "lastRig", (object)null);
					}
				});
				if (!PhotonNetwork.IsMasterClient)
				{
					return;
				}
				counter += TimeHandler.deltaTime;
				if (counter > timeAtPos)
				{
					targetID++;
					if (targetID >= positions.Length)
					{
						targetID = 0;
					}
					((Component)MapManager.instance).GetComponent<ChildRPC>().CallFunction(myKey, targetID);
					counter = 0f;
				}
				return;
			}
			Vector2 val2 = val - Vector2.op_Implicit(((Component)this).transform.localPosition);
			((Vector2)(ref val2)).Normalize();
			Vector2 val3 = val - Vector2.op_Implicit(((Component)this).transform.localPosition);
			val3 = Vector2.op_Implicit(Vector3.ClampMagnitude(Vector2.op_Implicit(val3), cap));
			velocity += val3 * spring * CappedDeltaTime.time;
			velocity -= velocity * drag * CappedDeltaTime.time;
			velocity = Vector2.op_Implicit(Vector3.ClampMagnitude(Vector2.op_Implicit(velocity), vCap));
			Transform transform = ((Component)this).transform;
			transform.localPosition += Vector2.op_Implicit(velocity) * TimeHandler.deltaTime;
			Vector2 val4 = val - Vector2.op_Implicit(((Component)this).transform.localPosition);
			((Vector2)(ref val4)).Normalize();
			if (val4 - val2 != Vector2.zero)
			{
				((Component)this).transform.localPosition = Vector2.op_Implicit(val);
				velocity = Vector2.zero;
			}
			if (!PhotonNetwork.IsMasterClient || !(Vector2.Distance(Vector2.op_Implicit(((Component)this).transform.localPosition), val) < threshold))
			{
				return;
			}
			counter += TimeHandler.deltaTime;
			if (counter > timeAtPos)
			{
				targetID++;
				if (targetID >= positions.Length)
				{
					targetID = 0;
				}
				((Component)MapManager.instance).GetComponent<ChildRPC>().CallFunction(myKey, targetID);
				counter = 0f;
			}
		}

		private void RPCA_SetTargetID(int setValue)
		{
			targetID = setValue;
		}
	}
	internal class Portal : MonoBehaviour
	{
		[CompilerGenerated]
		private sealed class <PortalFoce>d__5 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public PlayerVelocity playerVelocity;

			public Vector2 force;

			public Portal <>4__this;

			private float <c>5__1;

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

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

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

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

			private bool MoveNext()
			{
				//IL_005f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0069: Unknown result type (might be due to invalid IL or missing references)
				//IL_0073: Unknown result type (might be due to invalid IL or missing references)
				//IL_0088: Unknown result type (might be due to invalid IL or missing references)
				//IL_008d: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = null;
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<c>5__1 = 0f;
					break;
				case 2:
					<>1__state = -1;
					break;
				}
				if (<c>5__1 < 0.3f)
				{
					ExtensionMethods.SetFieldValue((object)playerVelocity, "velocity", (object)(force * TimeHandler.deltaTime * 10f + (Vector2)ExtensionMethods.GetFieldValue((object)playerVelocity, "velocity")));
					<c>5__1 += TimeHandler.deltaTime;
					<>2__current = null;
					<>1__state = 2;
					return true;
				}
				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 bool Exit = false;

		public int PortalID = 0;

		public static Dictionary<int, Portal> Exits = new Dictionary<int, Portal>();

		public void Awake()
		{
			if (Exit)
			{
				Exits[PortalID] = this;
			}
		}

		public void Update()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: 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_009d: 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_00c7: 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_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			if (Exit)
			{
				return;
			}
			Collider2D[] array = Physics2D.OverlapCircleAll(Vector2.op_Implicit(((Component)this).transform.position), ((Component)this).transform.localScale.x * 3f);
			for (int i = 0; i < array.Length; i++)
			{
				NetworkPhysicsObject component = ((Component)array[i]).GetComponent<NetworkPhysicsObject>();
				if (component != null && component.photonView.IsMine)
				{
					((Component)component).GetComponent<Rigidbody2D>().velocity = Vector2.op_Implicit(GetRotation() * Vector2.op_Implicit(((Component)component).GetComponent<Rigidbody2D>().velocity));
					Transform transform = ((Component)component).transform;
					Quaternion rotation = GetRotation();
					transform.Rotate(((Quaternion)(ref rotation)).eulerAngles);
					((Component)component).transform.position = ((Component)Exits[PortalID]).transform.position;
					break;
				}
				PlayerVelocity component2 = ((Component)array[i]).GetComponent<PlayerVelocity>();
				if (component2 != null)
				{
					((Component)component2).transform.position = ((Component)Exits[PortalID]).transform.position;
					ExtensionMethods.SetFieldValue((object)component2, "velocity", (object)Vector2.op_Implicit(GetRotation() * Vector2.op_Implicit((Vector2)ExtensionMethods.GetFieldValue((object)component2, "velocity"))));
					((MonoBehaviour)this).StartCoroutine(PortalFoce(component2, (Vector2)ExtensionMethods.GetFieldValue((object)component2, "velocity")));
					((Component)component2).GetComponentInParent<PlayerCollision>().IgnoreWallForFrames(2);
					((Component)component2).GetComponent<CharacterData>().sinceGrounded = 0.025f;
					break;
				}
				MoveTransform componentInParent = ((Component)array[i]).GetComponentInParent<MoveTransform>();
				if (componentInParent != null)
				{
					RayCastTrail componentInParent2 = ((Component)array[i]).GetComponentInParent<RayCastTrail>();
					if (componentInParent2 != null)
					{
						componentInParent.velocity = GetRotation() * componentInParent.velocity;
						((Component)componentInParent).transform.position = ((Component)Exits[PortalID]).transform.position;
						ExtensionMethods.SetFieldValue((object)componentInParent2, "lastPos", (object)((Component)Exits[PortalID]).transform.position);
					}
				}
			}
		}

		[IteratorStateMachine(typeof(<PortalFoce>d__5))]
		private IEnumerator PortalFoce(PlayerVelocity playerVelocity, Vector2 force)
		{
			//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 <PortalFoce>d__5(0)
			{
				<>4__this = this,
				playerVelocity = playerVelocity,
				force = force
			};
		}

		public Quaternion GetRotation()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: 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_0043: Unknown result type (might be due to invalid IL or missing references)
			return Quaternion.Euler(0f, 0f, ((Component)Exits[PortalID]).transform.eulerAngles.z - ((Component)this).transform.eulerAngles.z);
		}
	}
}