using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
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.catchup", "Catch Up", "1.0.0")]
public class CatchUpPlugin : BaseUnityPlugin
{
private ConfigEntry<Key> key;
private ConfigEntry<float> minGap;
private ConfigEntry<float> cooldown;
private float readyAt;
private float messageUntil;
private string message;
private void Awake()
{
key = ((BaseUnityPlugin)this).Config.Bind<Key>("General", "Catch Up Key", (Key)25, "Press to warp to the lowest other living climber.");
minGap = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Minimum Gap", 30f, "You must be at least this many metres below that climber. Keeps it a catch-up, not a shortcut.");
cooldown = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Cooldown Seconds", 60f, "");
}
private void Say(string text)
{
message = text;
messageUntil = Time.time + 4f;
((BaseUnityPlugin)this).Logger.LogInfo((object)text);
}
private void Update()
{
//IL_0006: 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_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_012a: 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_017d: Unknown result type (might be due to invalid IL or missing references)
//IL_0182: Unknown result type (might be due to invalid IL or missing references)
//IL_0187: Unknown result type (might be due to invalid IL or missing references)
//IL_018c: 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_00ed: 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_01f8: Unknown result type (might be due to invalid IL or missing references)
if ((int)key.Value == 0 || Keyboard.current == null || !((ButtonControl)Keyboard.current[key.Value]).wasPressedThisFrame)
{
return;
}
Character localCharacter = Character.localCharacter;
if (!Object.op_Implicit((Object)(object)localCharacter) || localCharacter.data.dead || localCharacter.warping)
{
return;
}
Scene activeScene = SceneManager.GetActiveScene();
if (((Scene)(ref activeScene)).name == "Airport")
{
return;
}
if (Time.time < readyAt)
{
Say($"Catch Up ready in {readyAt - Time.time:0} s");
return;
}
Character val = null;
foreach (Character allPlayerCharacter in PlayerHandler.GetAllPlayerCharacters())
{
if (Object.op_Implicit((Object)(object)allPlayerCharacter) && (Object)(object)allPlayerCharacter != (Object)(object)localCharacter && !allPlayerCharacter.data.dead && (!Object.op_Implicit((Object)(object)val) || allPlayerCharacter.Center.y < val.Center.y))
{
val = allPlayerCharacter;
}
}
if (!Object.op_Implicit((Object)(object)val))
{
Say("Catch Up: nobody to warp to");
return;
}
float num = val.Center.y - localCharacter.Center.y;
if (num < minGap.Value)
{
Say($"Catch Up: {val.characterName} is only {num:0} m above you (needs {minGap.Value:0})");
return;
}
Vector3 val2 = val.Head + Vector3.up;
if (PhotonNetwork.IsMasterClient)
{
((MonoBehaviourPun)localCharacter).photonView.RPC("WarpPlayerRPC", (RpcTarget)0, new object[2] { val2, true });
}
else
{
MethodInfo methodInfo = AccessTools.Method(typeof(Character), "WarpPlayer", (Type[])null, (Type[])null);
if (methodInfo == null)
{
Say("Catch Up: game update removed Character.WarpPlayer");
return;
}
methodInfo.Invoke(localCharacter, new object[2] { val2, true });
}
readyAt = Time.time + cooldown.Value;
Say("Catch Up: warped to " + val.characterName);
}
private void OnGUI()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Invalid comparison between Unknown and I4
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
if ((int)Event.current.type == 7 && !(Time.time >= messageUntil))
{
Draw.Text(new Rect(0f, (float)Screen.height * 0.2f, (float)Screen.width, 32f), message, new Color(1f, 1f, 1f, Mathf.Clamp01(messageUntil - Time.time)), 20, (TextAnchor)1);
}
}
}
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);
}
}