using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using LC_API.BundleAPI;
using Microsoft.CodeAnalysis;
using TMPro;
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 = "")]
[assembly: AssemblyCompany("LineCompassPlugin")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Line compass plugin")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+70505fc8d9b01a126772d9034154c67e4837d218")]
[assembly: AssemblyProduct("LineCompassPlugin")]
[assembly: AssemblyTitle("LineCompassPlugin")]
[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 Compass
{
public class NewBehaviourScript : MonoBehaviour
{
public LinkedList<RectTransform> points;
private float furthest_extent_left;
private float furthest_extent_right;
private float gap;
private const float north = 359f;
private bool initial_setup = false;
private float previous_r = float.NaN;
public void Load(LinkedList<RectTransform> points)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
this.points = points;
furthest_extent_left = points.First().anchoredPosition.x;
furthest_extent_right = points.Last().anchoredPosition.x;
gap = points.First.Next.Value.anchoredPosition.x - points.First().anchoredPosition.x;
}
private void Update()
{
//IL_0090: 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)
if (!initial_setup)
{
try
{
float num = 359f - GameNetworkManager.Instance.localPlayerController.cameraContainerTransform.eulerAngles.y;
float amount = Math.Abs(num / 90f) * gap;
if (num < 0f)
{
RotateLeft(amount);
}
else
{
RotateRight(amount);
}
}
catch (Exception)
{
return;
}
initial_setup = true;
}
float y = ((Component)GameNetworkManager.Instance.localPlayerController).transform.eulerAngles.y;
if (float.IsNaN(previous_r))
{
previous_r = y;
return;
}
float num2 = previous_r - y;
float amount2 = Math.Abs(num2 / 90f) * gap;
if (num2 < 0f)
{
RotateLeft(amount2);
}
else
{
RotateRight(amount2);
}
previous_r = y;
}
private void RotateLeft(float amount)
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: 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_00ac: 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_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
if (amount == 0f)
{
return;
}
foreach (RectTransform point in points)
{
point.anchoredPosition += Vector2.left * amount;
}
bool flag = false;
do
{
flag = false;
RectTransform val = points.First();
if (val.anchoredPosition.x <= furthest_extent_left - gap)
{
flag = true;
Vector2 anchoredPosition = points.Last().anchoredPosition;
val.anchoredPosition = new Vector2(anchoredPosition.x + gap, anchoredPosition.y);
points.RemoveFirst();
points.AddLast(val);
flag = true;
}
}
while (flag);
}
private void RotateRight(float amount)
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: 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_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
if (amount == 0f)
{
return;
}
foreach (RectTransform point in points)
{
point.anchoredPosition += Vector2.right * amount;
}
bool flag = false;
do
{
flag = false;
RectTransform val = points.Last();
if (val.anchoredPosition.x >= furthest_extent_right + gap)
{
Vector2 anchoredPosition = points.First().anchoredPosition;
val.anchoredPosition = new Vector2(anchoredPosition.x - gap, anchoredPosition.y);
points.RemoveLast();
points.AddFirst(val);
flag = true;
}
}
while (flag);
}
}
[BepInPlugin("LineCompassPlugin", "LineCompassPlugin", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
private class Patch
{
public static void Start()
{
Render();
}
public static void End()
{
if ((Object)(object)instance != (Object)null)
{
Object.Destroy((Object)(object)instance);
}
}
public static void Toggle(bool hide)
{
if (hide)
{
End();
}
else
{
Start();
}
}
}
private static GameObject compass;
private static GameObject instance;
private void Awake()
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Expected O, but got Unknown
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Expected O, but got Unknown
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Expected O, but got Unknown
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Expected O, but got Unknown
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: Expected O, but got Unknown
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Expected O, but got Unknown
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin LineCompassPlugin is loaded!");
Harmony val = new Harmony("LineCompassPlugin");
val.Patch((MethodBase)typeof(HUDManager).GetMethod("OnEnable", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic), (HarmonyMethod)null, new HarmonyMethod(typeof(Patch).GetMethod("Start")), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
val.Patch((MethodBase)typeof(HUDManager).GetMethod("OnDisable", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic), (HarmonyMethod)null, new HarmonyMethod(typeof(Patch).GetMethod("End")), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
val.Patch((MethodBase)typeof(HUDManager).GetMethod("HideHUD", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic), (HarmonyMethod)null, new HarmonyMethod(typeof(Patch).GetMethod("Toggle")), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
BundleLoader.OnLoadedAssets = (OnLoadedAssetsDelegate)Delegate.Combine((Delegate?)(object)BundleLoader.OnLoadedAssets, (Delegate?)(OnLoadedAssetsDelegate)delegate
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin LineCompassPlugin->OnLoadedAssets is called!");
compass = BundleLoader.GetLoadedAsset<GameObject>("assets/LineCompassPlugin/Compass.prefab");
});
}
private static void Render()
{
GameObject val = Object.Instantiate<GameObject>(compass);
val.layer = LayerMask.NameToLayer("UI");
GameObject gameObject = ((Component)val.transform.Find("Image").GetChild(0)).gameObject;
List<RectTransform> list = new List<RectTransform>();
for (int i = 0; i < gameObject.transform.childCount; i++)
{
GameObject gameObject2 = ((Component)gameObject.transform.GetChild(i)).gameObject;
TextMeshProUGUI component = gameObject2.GetComponent<TextMeshProUGUI>();
((TMP_Text)component).text = ((Object)gameObject2).name;
list.Add(gameObject2.GetComponent<RectTransform>());
}
NewBehaviourScript newBehaviourScript = val.AddComponent<NewBehaviourScript>();
newBehaviourScript.Load(new LinkedList<RectTransform>(list));
instance = val;
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "LineCompassPlugin";
public const string PLUGIN_NAME = "LineCompassPlugin";
public const string PLUGIN_VERSION = "1.0.0";
}
}