Decompiled source of Cream Me Up Join Warp v1.0.0

JoinWarp.dll

Decompiled a week ago
using System;
using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyVersion("0.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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;
		}
	}
}
[BepInPlugin("dairymods.joinwarp", "Join Warp", "1.0.0")]
public class WarpPlugin : BaseUnityPlugin
{
	private class Handler : MonoBehaviourPunCallbacks
	{
		private WarpPlugin plugin;

		private ConfigEntry<float> delay;

		public void Init(WarpPlugin p, ConfigEntry<float> d)
		{
			plugin = p;
			delay = d;
		}

		public override void OnPlayerEnteredRoom(Player newPlayer)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			if (PhotonNetwork.IsMasterClient)
			{
				Scene activeScene = SceneManager.GetActiveScene();
				if (!(((Scene)(ref activeScene)).name == "Airport"))
				{
					((BaseUnityPlugin)plugin).Logger.LogInfo((object)(newPlayer.NickName + " joined mid-climb, waiting for their character"));
					((MonoBehaviour)this).StartCoroutine(Catchup(newPlayer));
				}
			}
		}

		private IEnumerator Catchup(Player newPlayer)
		{
			float giveUp = Time.time + 60f;
			Character joined;
			while (true)
			{
				Character playerCharacter;
				joined = (playerCharacter = PlayerHandler.GetPlayerCharacter(newPlayer));
				if (Object.op_Implicit((Object)(object)playerCharacter))
				{
					break;
				}
				if (Time.time > giveUp)
				{
					((BaseUnityPlugin)plugin).Logger.LogError((object)("No character for " + newPlayer.NickName + " after 60 s, not warping"));
					yield break;
				}
				yield return null;
			}
			yield return (object)new WaitForSeconds(delay.Value);
			if (!Object.op_Implicit((Object)(object)joined) || !PhotonNetwork.IsMasterClient)
			{
				yield break;
			}
			Character val = null;
			foreach (Character allPlayerCharacter in PlayerHandler.GetAllPlayerCharacters())
			{
				if (Object.op_Implicit((Object)(object)allPlayerCharacter) && (Object)(object)allPlayerCharacter != (Object)(object)joined && !allPlayerCharacter.data.dead && (!Object.op_Implicit((Object)(object)val) || allPlayerCharacter.Center.y < val.Center.y))
				{
					val = allPlayerCharacter;
				}
			}
			if (!Object.op_Implicit((Object)(object)val))
			{
				((BaseUnityPlugin)plugin).Logger.LogError((object)"No living climber to warp to");
				yield break;
			}
			((BaseUnityPlugin)plugin).Logger.LogInfo((object)("Warping " + joined.characterName + " to " + val.characterName));
			((MonoBehaviourPun)joined).photonView.RPC("WarpPlayerRPC", (RpcTarget)0, new object[2]
			{
				val.Head + Vector3.up,
				false
			});
		}
	}

	private void Awake()
	{
		ConfigEntry<float> d = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Delay Seconds", 5f, "Wait this long after the joining player's character appears, so the game's own spawn move happens first.");
		((Component)this).gameObject.AddComponent<Handler>().Init(this, d);
	}
}
internal static class Draw
{
	private static GUIStyle style;

	public static Camera Cam
	{
		get
		{
			MainCamera instance = MainCamera.instance;
			Camera val = (Object.op_Implicit((Object)(object)instance) ? ((Component)instance).GetComponent<Camera>() : null);
			if (!Object.op_Implicit((Object)(object)val))
			{
				return Camera.main;
			}
			return val;
		}
	}

	public static bool ToGui(Camera cam, Vector3 world, out Vector2 gui)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0009: 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_0029: 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_0033: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val = cam.WorldToViewportPoint(world);
		gui = new Vector2(val.x * (float)Screen.width, (1f - val.y) * (float)Screen.height);
		return val.z > 0f;
	}

	public static void Line(Vector2 a, Vector2 b, Color c, float width)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: 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_0036: 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_0060: Unknown result type (might be due to invalid IL or missing references)
		Matrix4x4 matrix = GUI.matrix;
		Vector2 val = b - a;
		GUI.color = c;
		GUIUtility.RotateAroundPivot(Mathf.Atan2(val.y, val.x) * 57.29578f, a);
		GUI.DrawTexture(new Rect(a.x, a.y - width / 2f, ((Vector2)(ref val)).magnitude, width), (Texture)(object)Texture2D.whiteTexture);
		GUI.matrix = matrix;
		GUI.color = Color.white;
	}

	public static void Dot(Vector2 p, Color c, float size)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: 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_0033: Unknown result type (might be due to invalid IL or missing references)
		GUI.color = c;
		GUI.DrawTexture(new Rect(p.x - size / 2f, p.y - size / 2f, size, size), (Texture)(object)Texture2D.whiteTexture);
		GUI.color = Color.white;
	}

	public static void Text(Rect r, string s, Color c, int size = 18, TextAnchor anchor = (TextAnchor)0)
	{
		//IL_0039: 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_0065: 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_00b1: 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_0011: 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)
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Expected O, but got Unknown
		if (style == null)
		{
			style = new GUIStyle(GUI.skin.label)
			{
				fontStyle = (FontStyle)1,
				wordWrap = false
			};
		}
		style.fontSize = size;
		style.alignment = anchor;
		style.normal.textColor = new Color(0f, 0f, 0f, c.a * 0.8f);
		GUI.Label(new Rect(((Rect)(ref r)).x + 2f, ((Rect)(ref r)).y + 2f, ((Rect)(ref r)).width, ((Rect)(ref r)).height), s, style);
		style.normal.textColor = c;
		GUI.Label(r, s, style);
	}
}