using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using PurrNet;
using StatusMessage.patches;
using TMPro;
using Teleport.patches;
using UnityEngine;
using UnityEngine.InputSystem;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("officerballs.Teleport")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.1.2.0")]
[assembly: AssemblyInformationalVersion("1.1.2")]
[assembly: AssemblyProduct("officerballs.Teleport")]
[assembly: AssemblyTitle("officerballs.Teleport")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.2.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 Teleport
{
[BepInPlugin("officerballs.Teleport", "Teleport", "1.1.2.0")]
[BepInDependency("officerballs.StatusManager", "1.1.0.0")]
public class Plugin : BaseUnityPlugin
{
public const string modGUID = "officerballs.Teleport";
public const string modName = "Teleport";
public const string modVersion = "1.1.2.0";
private Harmony harmony = new Harmony("officerballs.Teleport");
public ManualLogSource mls = Logger.CreateLogSource("officerballs.Teleport");
private void Awake()
{
harmony.PatchAll(typeof(AddModdedTag));
harmony.PatchAll(typeof(TeleportPatch));
harmony.PatchAll(typeof(PCPatcher));
harmony.PatchAll(typeof(Teleporter));
mls.LogInfo((object)"Teleportation system loaded.");
}
}
}
namespace Teleport.patches
{
[HarmonyPatch(typeof(MultiplayerManager))]
public class AddModdedTag
{
[HarmonyPatch("CreateLobby")]
[HarmonyPrefix]
public static void NameChanger(ref List<bool> ___FilterSocialTags)
{
int filterPlayerValue = MonoSingleton<MultiplayerManager>.I.FilterPlayerValue;
string text = MonoSingleton<MainMenuUIController>.I.CreateSessionNameInputField.text;
___FilterSocialTags[4] = true;
}
}
[HarmonyPatch(typeof(PlayerPanelController))]
public static class TeleportPatch
{
public static string targetingString;
public static string combinedName = "";
public static bool setup = false;
public static int index = 1;
public static float wheelstate = 0f;
public static PlayerController target = null;
[HarmonyPatch("Update")]
[HarmonyPrefix]
public static void TelePatch()
{
//IL_027e: Unknown result type (might be due to invalid IL or missing references)
//IL_0283: Unknown result type (might be due to invalid IL or missing references)
//IL_0291: Unknown result type (might be due to invalid IL or missing references)
//IL_0293: Unknown result type (might be due to invalid IL or missing references)
//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
//IL_03f6: Unknown result type (might be due to invalid IL or missing references)
//IL_03fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0411: Unknown result type (might be due to invalid IL or missing references)
FieldRef<CustomizationUIController, GameObject> val = AccessTools.FieldRefAccess<CustomizationUIController, GameObject>("_customizationPanel");
CustomizationUIController i = MonoSingleton<CustomizationUIController>.I;
if (val.Invoke(i).activeSelf)
{
return;
}
FieldRef<PlayerPanelController, GameObject> val2 = AccessTools.FieldRefAccess<PlayerPanelController, GameObject>("_reportPanel");
PlayerPanelController i2 = NetworkSingleton<PlayerPanelController>.I;
if (val2.Invoke(i2).activeSelf)
{
return;
}
int num = 0;
FieldRef<UIManager, TMP_InputField> val3 = AccessTools.FieldRefAccess<UIManager, TMP_InputField>("_messageInputField");
UIManager i3 = MonoSingleton<UIManager>.I;
if (val3.Invoke(i3).isFocused)
{
return;
}
float y = ((Vector2)((InputControl<Vector2>)(object)Mouse.current.scroll).value).y;
string text = "";
if (y < 0f && wheelstate != y)
{
text = "up";
wheelstate = y;
}
else if (y > 0f && wheelstate != y)
{
text = "down";
wheelstate = y;
}
else if (wheelstate != 0f && y == 0f)
{
wheelstate = 0f;
}
if (text == "up" && Input.GetKey((KeyCode)304))
{
if (NetworkSingleton<PlayerPanelController>.I.PlayerIDs.Count == 1)
{
return;
}
index++;
num = 1;
}
else
{
if (!(text == "down") || !Input.GetKey((KeyCode)304))
{
if (Input.GetKeyDown((KeyCode)101) && Input.GetKey((KeyCode)304) && NetworkSingleton<PlayerPanelController>.I.PlayerIDs.Count != 1 && Object.op_Implicit((Object)(object)target))
{
PlayerMovementController componentInChildren = ((Component)((Component)target).transform).GetComponentInChildren<PlayerMovementController>();
Teleporter.warppos = ((Component)componentInChildren).transform.position;
NetworkSingleton<TextChannelManager>.I.MainPlayer.position = ((Component)componentInChildren).transform.position;
}
return;
}
if (NetworkSingleton<PlayerPanelController>.I.PlayerIDs.Count == 1)
{
return;
}
index--;
num = -1;
}
target = null;
for (int j = 0; j < 2; j++)
{
if (index < 0)
{
index = NetworkSingleton<PlayerPanelController>.I.PlayerIDs.Count - 1;
}
else if (index >= NetworkSingleton<PlayerPanelController>.I.PlayerIDs.Count)
{
index = 0;
}
PlayerID val4 = NetworkSingleton<PlayerPanelController>.I.PlayerIDs[index];
PlayerID? localPlayer = ((NetworkIdentity)NetworkSingleton<TextChannelManager>.I).localPlayer;
PlayerID val5 = val4;
PlayerID? val6 = localPlayer;
if (!val6.HasValue || val5 != val6.GetValueOrDefault())
{
target = ((Component)NetworkSingleton<PlayerPanelController>.I.PlayerTransforms[index]).GetComponent<PlayerController>();
break;
}
switch (num)
{
case 1:
index++;
break;
case -1:
index--;
break;
}
}
FieldRef<UIManager, TextMeshProUGUI> val7 = AccessTools.FieldRefAccess<UIManager, TextMeshProUGUI>("_playerText");
UIManager i4 = MonoSingleton<UIManager>.I;
string name = MonoSingleton<DataManager>.I.PlayerData.Name;
if ((Object)(object)target != (Object)null)
{
string text2 = ((TMP_Text)target.PlayerNameText).text;
targetingString = " - " + text2 + " selected";
}
else
{
targetingString = "";
}
if (Chainloader.PluginInfos.TryGetValue("officerballs.StatusManager", out var _))
{
StatusPatch._ifTeleportString = targetingString;
}
((TMP_Text)val7.Invoke(i4)).text = name + targetingString;
}
[HarmonyPatch("DespawnHandle")]
[HarmonyPostfix]
public static void DespawnHandlePatch(PlayerPanelController __instance)
{
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: 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)
target = null;
if (index >= __instance.PlayerSteamIDs.Count)
{
index = __instance.PlayerSteamIDs.Count - 1;
}
for (int i = 0; i < 2; i++)
{
if (index < 0)
{
index = NetworkSingleton<PlayerPanelController>.I.PlayerIDs.Count - 1;
}
else if (index >= NetworkSingleton<PlayerPanelController>.I.PlayerIDs.Count)
{
index = 0;
}
PlayerID val = NetworkSingleton<PlayerPanelController>.I.PlayerIDs[index];
PlayerID? localPlayer = ((NetworkIdentity)NetworkSingleton<TextChannelManager>.I).localPlayer;
PlayerID val2 = val;
PlayerID? val3 = localPlayer;
if (!val3.HasValue || val2 != val3.GetValueOrDefault())
{
target = ((Component)NetworkSingleton<PlayerPanelController>.I.PlayerTransforms[index]).GetComponent<PlayerController>();
break;
}
index--;
}
FieldRef<UIManager, TextMeshProUGUI> val4 = AccessTools.FieldRefAccess<UIManager, TextMeshProUGUI>("_playerText");
UIManager i2 = MonoSingleton<UIManager>.I;
string name = MonoSingleton<DataManager>.I.PlayerData.Name;
if ((Object)(object)target != (Object)null)
{
string text = ((TMP_Text)target.PlayerNameText).text;
targetingString = " - " + text + " selected";
}
else
{
targetingString = "";
}
if (Chainloader.PluginInfos.TryGetValue("officerballs.StatusManager", out var _))
{
StatusPatch._ifTeleportString = targetingString;
}
((TMP_Text)val4.Invoke(i2)).text = name + targetingString;
}
}
[HarmonyPatch(typeof(PlayerMovementController))]
public static class Teleporter
{
public static Vector3 warppos = Vector3.zero;
[HarmonyPatch("MovePlayer")]
[HarmonyPrefix]
public static bool TeleSkip(ref CharacterController ____characterController, PlayerMovementController __instance)
{
//IL_0001: 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_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
if (warppos != Vector3.zero)
{
if ((Object)(object)__instance != (Object)(object)NetworkSingleton<TextChannelManager>.I.MainMovementController)
{
return true;
}
((Component)____characterController).transform.position = warppos;
warppos = Vector3.zero;
return false;
}
return true;
}
}
[HarmonyPatch(typeof(PlayerController))]
public static class PCPatcher
{
[HarmonyPatch("OnDespawned")]
[HarmonyPrefix]
public static bool OverrideStationaryCheck(PlayerController __instance)
{
if (__instance.IsReturningMenu)
{
TeleportPatch.target = null;
TeleportPatch.targetingString = "";
if (Chainloader.PluginInfos.TryGetValue("officerballs.StatusManager", out var _))
{
StatusPatch._ifTeleportString = TeleportPatch.targetingString;
}
}
return true;
}
}
}