using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Microsoft.CodeAnalysis;
using UI;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using Wildskies.UI.Hud;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("Joew_LostSkies_Markers")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("My first plugin")]
[assembly: AssemblyTitle("Joew_LostSkies_Markers")]
[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 Joew_LostSkies_Markers
{
public class CustomMarkers : MonoBehaviour
{
public static bool showGui = false;
private static string inputName = "";
private static string inputCoords = "";
private const float REF_WIDTH = 1920f;
private const float REF_HEIGHT = 1080f;
private static Rect windowRect = setWindowRect();
public static readonly Dictionary<Vector3, GameObject> markerObjects = new Dictionary<Vector3, GameObject>();
public static Dictionary<string, Vector3> markersList = new Dictionary<string, Vector3>();
public static Dictionary<string, bool> markersSelected = new Dictionary<string, bool>();
public static CompassHud CompassHudInstance;
private Vector3 lastCoords;
private static readonly string iniPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Joew_LostSkies_Tweaks_Markers.ini");
private Vector2 scrollPosition = Vector2.zero;
private GUIStyle styleToggleLarge;
private Texture2D texToggleOff;
private Texture2D texToggleOn;
private static float scaleFactor => Mathf.Min((float)Screen.width / 1920f, (float)Screen.height / 1080f);
private static Rect setWindowRect()
{
//IL_012d: Unknown result type (might be due to invalid IL or missing references)
//IL_0132: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_0138: Unknown result type (might be due to invalid IL or missing references)
//IL_013d: Unknown result type (might be due to invalid IL or missing references)
//IL_0140: Unknown result type (might be due to invalid IL or missing references)
if (Screen.width <= 2560)
{
windowRect = new Rect(((float)Screen.width - 768f * Mathf.Clamp(scaleFactor, 0.5f, 1.5f)) / 2f, ((float)Screen.height - 648f * Mathf.Clamp(scaleFactor, 0.5f, 1.5f)) / 2f, 768f * Mathf.Clamp(scaleFactor, 0.5f, 1.5f), 648f * Mathf.Clamp(scaleFactor, 0.5f, 1.5f));
}
else
{
windowRect = new Rect(((float)Screen.width - 960f * Mathf.Clamp(scaleFactor, 0.5f, 1.5f)) / 2f, ((float)Screen.height - 756f * Mathf.Clamp(scaleFactor, 0.5f, 1.5f)) / 2f, 960f * Mathf.Clamp(scaleFactor, 0.5f, 1.5f), 756f * Mathf.Clamp(scaleFactor, 0.5f, 1.5f));
}
return windowRect;
}
private float CalculateFontSize()
{
float num = 14f;
float num2 = 24f;
float num3 = Mathf.Clamp((float)Screen.width / 1920f, 1f, 2f);
return Mathf.Lerp(num, num2, (num3 - 1f) / 1f);
}
private void CreateToggleTexturesAndStyle()
{
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Expected O, but got Unknown
//IL_005b: 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)
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: Expected O, but got Unknown
//IL_013a: Unknown result type (might be due to invalid IL or missing references)
//IL_0144: Expected O, but got Unknown
//IL_020c: Unknown result type (might be due to invalid IL or missing references)
//IL_0222: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
int num = Mathf.Clamp(Mathf.RoundToInt(24f * scaleFactor), 18, 36);
int num2 = Mathf.Clamp(Mathf.RoundToInt(2f * scaleFactor), 1, 4);
texToggleOff = new Texture2D(num, num);
Color val = default(Color);
((Color)(ref val))..ctor(0f, 0f, 0f, 0f);
Color white = Color.white;
for (int i = 0; i < num; i++)
{
for (int j = 0; j < num; j++)
{
bool flag = j < num2 || j >= num - num2 || i < num2 || i >= num - num2;
texToggleOff.SetPixel(j, i, flag ? white : val);
}
}
texToggleOff.Apply();
texToggleOn = new Texture2D(num, num);
for (int k = 0; k < num; k++)
{
for (int l = 0; l < num; l++)
{
texToggleOn.SetPixel(l, k, white);
}
}
texToggleOn.Apply();
styleToggleLarge = new GUIStyle(GUI.skin.toggle);
styleToggleLarge.normal.background = texToggleOff;
styleToggleLarge.onNormal.background = texToggleOn;
styleToggleLarge.hover.background = texToggleOff;
styleToggleLarge.onHover.background = texToggleOn;
styleToggleLarge.active.background = texToggleOff;
styleToggleLarge.onActive.background = texToggleOn;
styleToggleLarge.fixedWidth = num;
styleToggleLarge.fixedHeight = num;
styleToggleLarge.fontSize = Mathf.RoundToInt(CalculateFontSize());
styleToggleLarge.normal.textColor = Color.white;
styleToggleLarge.onNormal.textColor = Color.white;
}
private void OnGUI()
{
//IL_0a98: Unknown result type (might be due to invalid IL or missing references)
//IL_0a9f: Expected O, but got Unknown
//IL_0233: Unknown result type (might be due to invalid IL or missing references)
//IL_0239: Expected O, but got Unknown
//IL_024c: Unknown result type (might be due to invalid IL or missing references)
//IL_0261: Unknown result type (might be due to invalid IL or missing references)
//IL_0267: Expected O, but got Unknown
//IL_027a: Unknown result type (might be due to invalid IL or missing references)
//IL_028f: Unknown result type (might be due to invalid IL or missing references)
//IL_0296: Expected O, but got Unknown
//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
//IL_02c7: Expected O, but got Unknown
//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
//IL_0300: Unknown result type (might be due to invalid IL or missing references)
//IL_0307: Expected O, but got Unknown
//IL_031c: Unknown result type (might be due to invalid IL or missing references)
//IL_0330: Unknown result type (might be due to invalid IL or missing references)
//IL_020b: Unknown result type (might be due to invalid IL or missing references)
//IL_0210: Unknown result type (might be due to invalid IL or missing references)
//IL_0627: Unknown result type (might be due to invalid IL or missing references)
//IL_062c: Unknown result type (might be due to invalid IL or missing references)
//IL_064b: Unknown result type (might be due to invalid IL or missing references)
//IL_0650: Unknown result type (might be due to invalid IL or missing references)
//IL_0652: Unknown result type (might be due to invalid IL or missing references)
//IL_06ba: Unknown result type (might be due to invalid IL or missing references)
//IL_05c2: Unknown result type (might be due to invalid IL or missing references)
//IL_05f1: Unknown result type (might be due to invalid IL or missing references)
//IL_05f6: Unknown result type (might be due to invalid IL or missing references)
//IL_0728: Unknown result type (might be due to invalid IL or missing references)
//IL_0839: Unknown result type (might be due to invalid IL or missing references)
//IL_0453: Unknown result type (might be due to invalid IL or missing references)
//IL_097e: Unknown result type (might be due to invalid IL or missing references)
//IL_0889: Unknown result type (might be due to invalid IL or missing references)
//IL_09cd: Unknown result type (might be due to invalid IL or missing references)
//IL_09dd: Unknown result type (might be due to invalid IL or missing references)
//IL_09e2: Unknown result type (might be due to invalid IL or missing references)
//IL_0a2b: Unknown result type (might be due to invalid IL or missing references)
//IL_09b4: Unknown result type (might be due to invalid IL or missing references)
//IL_07b3: Unknown result type (might be due to invalid IL or missing references)
if (!showGui)
{
return;
}
Cursor.lockState = (CursorLockMode)0;
Cursor.visible = true;
if (styleToggleLarge == null)
{
CreateToggleTexturesAndStyle();
}
if (string.IsNullOrEmpty(inputCoords) || $"{Plugin.coords.x.ToString("0.00", CultureInfo.InvariantCulture)} {Plugin.coords.y.ToString("0.00", CultureInfo.InvariantCulture)} {Plugin.coords.z.ToString("0.00", CultureInfo.InvariantCulture)}" != $"{lastCoords.x.ToString("0.00", CultureInfo.InvariantCulture)} {lastCoords.y.ToString("0.00", CultureInfo.InvariantCulture)} {lastCoords.z.ToString("0.00", CultureInfo.InvariantCulture)}")
{
inputCoords = $"{Plugin.coords.x.ToString("0.00", CultureInfo.InvariantCulture)} {Plugin.coords.y.ToString("0.00", CultureInfo.InvariantCulture)} {Plugin.coords.z.ToString("0.00", CultureInfo.InvariantCulture)}";
lastCoords = Plugin.coords;
}
float num = CalculateFontSize();
float fixedHeight = styleToggleLarge.fixedHeight;
GUIStyle val = new GUIStyle(GUI.skin.label);
val.fontSize = Mathf.RoundToInt(num);
val.normal.textColor = Color.white;
GUIStyle val2 = new GUIStyle(GUI.skin.textField);
val2.fontSize = Mathf.RoundToInt(num);
val2.normal.textColor = Color.white;
GUIStyle val3 = new GUIStyle(GUI.skin.button);
val3.fontSize = Mathf.RoundToInt(num);
val3.normal.textColor = Color.white;
GUIStyle val4 = new GUIStyle(GUI.skin.label);
val4.fontSize = Mathf.RoundToInt(num * 1.5f);
val4.normal.textColor = Color.white;
val4.alignment = (TextAnchor)4;
GUIStyle val5 = new GUIStyle(GUI.skin.label);
val5.fontSize = Mathf.RoundToInt(num);
val5.normal.textColor = Color.white;
val5.alignment = (TextAnchor)4;
GUILayout.BeginArea(windowRect);
GUILayout.Box("Add Custom Marker", val4, (Il2CppReferenceArray<GUILayoutOption>)null);
GUILayout.Label("Name:", val, (Il2CppReferenceArray<GUILayoutOption>)null);
inputName = GUILayout.TextField(inputName, 100, val2, (GUILayoutOption[])(object)new GUILayoutOption[2]
{
GUILayout.Width(((Rect)(ref windowRect)).width * 0.9f),
GUILayout.Height(fixedHeight)
});
GUILayout.Label("Coords (x y z):", val, (Il2CppReferenceArray<GUILayoutOption>)null);
inputCoords = GUILayout.TextField(inputCoords, 100, val2, (GUILayoutOption[])(object)new GUILayoutOption[2]
{
GUILayout.Width(((Rect)(ref windowRect)).width * 0.9f),
GUILayout.Height(fixedHeight)
});
inputCoords = inputCoords.Replace(',', '.');
GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
if (GUILayout.Button("Add Marker", val3, (GUILayoutOption[])(object)new GUILayoutOption[2]
{
GUILayout.Width(((Rect)(ref windowRect)).width * 0.45f),
GUILayout.Height(fixedHeight)
}))
{
if (TryParseCoords(inputCoords, out var coords) && !string.IsNullOrEmpty(inputName))
{
AddMarker(inputName, coords);
SaveMarkersToIni();
}
else
{
Plugin.Log.LogWarning((object)"Invalid input. Please enter a name and valid coordinates.");
}
}
if (GUILayout.Button("Cancel", val3, (GUILayoutOption[])(object)new GUILayoutOption[2]
{
GUILayout.Width(((Rect)(ref windowRect)).width * 0.45f),
GUILayout.Height(fixedHeight)
}))
{
showGui = false;
}
GUILayout.EndHorizontal();
GUILayout.Space(10.8f * scaleFactor);
GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
GUILayout.Space(9.599999f * scaleFactor);
GUILayout.Label($"Markers ({markersList.Count}):", val4, (Il2CppReferenceArray<GUILayoutOption>)null);
GUILayout.Space(9.599999f * scaleFactor);
GUILayout.EndHorizontal();
GUILayout.Space(5.4f * scaleFactor);
float num2 = fixedHeight + 21.6f * scaleFactor;
float num3 = ((Rect)(ref windowRect)).height - 270f * scaleFactor - num2;
float num4 = fixedHeight * 1.1f;
GUILayout.BeginVertical(GUI.skin.box, (GUILayoutOption[])(object)new GUILayoutOption[2]
{
GUILayout.Width(((Rect)(ref windowRect)).width * 0.95f),
GUILayout.Height(num3)
});
scrollPosition = GUILayout.BeginScrollView(scrollPosition, false, true, (GUILayoutOption[])(object)new GUILayoutOption[2]
{
GUILayout.Width(((Rect)(ref windowRect)).width * 0.95f),
GUILayout.Height(num3)
});
List<string> list = new List<string>(markersList.Keys);
bool flag3 = default(bool);
for (int i = 0; i < list.Count; GUI.EndGroup(), i++)
{
string text = list[i];
Vector3 val6 = markersList[text];
Rect rect = GUILayoutUtility.GetRect(0f, 99999f, num4, num4, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
GUI.BeginGroup(rect);
float num5 = 0f;
float num6 = 0f;
float num7 = ((Rect)(ref windowRect)).width * 0.95f;
float num8 = num7 * 0.09f;
float num9 = num7 * 0.33f;
float num10 = num7 * 0.33f;
float num11 = num7 * 0.15f;
float num12 = num7 * 0.1f;
GUI.Label(new Rect(num5, num6, num8 * 0.5f, num4), $"{i + 1}-", val);
bool flag = markersSelected.ContainsKey(text) && markersSelected[text];
bool flag2 = GUI.Toggle(new Rect(num5 + num8 * 0.5f, num6 + (num4 - fixedHeight) / 2f, fixedHeight, fixedHeight), flag, "", styleToggleLarge);
if (flag2 != flag)
{
if (flag2)
{
foreach (string key in markersSelected.Keys)
{
markersSelected[key] = false;
}
markersSelected[text] = true;
OnMarkerSelected(text, val6);
SaveLastActiveMarker();
}
else
{
markersSelected[text] = false;
if (!markersSelected.Values.Any((bool sel) => sel))
{
WaypointComponent.ResetWaypoint();
SaveLastActiveMarker();
}
}
}
num5 += num8;
string text2 = GUI.TextField(new Rect(num5, num6 + 2f, num9, num4 - 4f), text, val2);
if (text2 != text && !string.IsNullOrEmpty(text2) && !markersList.ContainsKey(text2))
{
markersList.Remove(text);
markersList[text2] = val6;
bool value = markersSelected.ContainsKey(text) && markersSelected[text];
markersSelected.Remove(text);
markersSelected[text2] = value;
list[i] = text2;
text = text2;
}
num5 += num9;
string text3 = $"{val6.x.ToString("0.00", CultureInfo.InvariantCulture)} {val6.y.ToString("0.00", CultureInfo.InvariantCulture)} {val6.z.ToString("0.00", CultureInfo.InvariantCulture)}";
string text4 = GUI.TextField(new Rect(num5, num6 + 2f, num10, num4 - 4f), text3, val2);
if (text4 != text3 && TryParseCoords(text4, out var coords2))
{
markersList[text] = coords2;
}
num5 += num10;
GUI.Label(new Rect(num5, num6, num11, num4), $"{Vector3.Distance(Plugin.coords, val6):0.0}m", val5);
num5 += num11;
if (!GUI.Button(new Rect(num5, num6 + 2f, num12, num4 - 4f), "X", val3))
{
continue;
}
try
{
markersList.Remove(text);
markersSelected.Remove(text);
if (WaypointComponent.targetName == text)
{
WaypointComponent.ResetWaypoint();
}
SaveMarkersToIni();
SaveLastActiveMarker();
}
catch (Exception ex)
{
ManualLogSource log = Plugin.Log;
BepInExErrorLogInterpolatedStringHandler val7 = new BepInExErrorLogInterpolatedStringHandler(25, 1, ref flag3);
if (flag3)
{
((BepInExLogInterpolatedStringHandler)val7).AppendLiteral("Failed to remove Marker: ");
((BepInExLogInterpolatedStringHandler)val7).AppendFormatted<Exception>(ex);
}
log.LogError(val7);
continue;
}
break;
}
GUILayout.EndScrollView();
GUILayout.EndVertical();
GUILayout.Space(10.8f * scaleFactor);
if (GUILayout.Button("Save", val3, (GUILayoutOption[])(object)new GUILayoutOption[2]
{
GUILayout.Width(((Rect)(ref windowRect)).width * 0.95f),
GUILayout.Height(fixedHeight)
}))
{
SaveMarkersToIni();
SaveLastActiveMarker();
}
GUILayout.Space(10.8f * scaleFactor);
if (GUILayout.Button(Plugin.pluginName + " - " + Plugin.pluginUrl, val3, (GUILayoutOption[])(object)new GUILayoutOption[2]
{
GUILayout.Width(((Rect)(ref windowRect)).width * 0.95f),
GUILayout.Height(fixedHeight)
}))
{
Application.OpenURL(Plugin.pluginUrl ?? "");
}
GUILayout.EndArea();
}
private void OnMarkerSelected(string key, Vector3 position)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Expected O, but got Unknown
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
WaypointComponent.targetName = key;
WaypointComponent.targetPosition = position;
WaypointComponent.hideArrow = false;
ManualLogSource log = Plugin.Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(21, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Marker selected: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(key);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" at ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Vector3>(position);
}
log.LogInfo(val);
}
private static bool TryParseCoords(string coordsString, out Vector3 coords)
{
//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_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
coords = Vector3.zero;
string[] array = coordsString.Split(new string[2] { " ", "," }, StringSplitOptions.RemoveEmptyEntries);
if (array.Length != 3)
{
return false;
}
float result;
bool flag = float.TryParse(array[0], NumberStyles.Float, CultureInfo.InvariantCulture, out result);
float result2;
bool flag2 = float.TryParse(array[1], NumberStyles.Float, CultureInfo.InvariantCulture, out result2);
float result3;
bool flag3 = float.TryParse(array[2], NumberStyles.Float, CultureInfo.InvariantCulture, out result3);
if (flag && flag2 && flag3)
{
coords = new Vector3(result, result2, result3);
return true;
}
return false;
}
public static void ToggleAddMarkersGUI()
{
showGui = !showGui;
if (showGui)
{
inputName = "";
inputCoords = "";
}
}
public static void AddMarker(string name, Vector3 position)
{
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Expected O, but got Unknown
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)CompassHudInstance == (Object)null)
{
Plugin.Log.LogWarning((object)"CustomMarkers: CompassHud not found.");
}
if (markersList.ContainsKey(name))
{
Plugin.Log.LogWarning((object)"CustomMarkers: Marker already exists at this position.");
return;
}
markersList[name] = position;
ManualLogSource log = Plugin.Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(34, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("CustomMarkers: Added marker '");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(name);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' at ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Vector3>(position);
}
log.LogInfo(val);
}
private static void SaveMarkersToIniVEIO()
{
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_011c: Expected O, but got Unknown
try
{
int num = 1;
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.AppendLine("[Markers]");
foreach (KeyValuePair<string, Vector3> markers in markersList)
{
Vector3 value = markers.Value;
string key = markers.Key;
StringBuilder stringBuilder2 = stringBuilder;
StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(5, 4, stringBuilder2);
handler.AppendFormatted(key);
handler.AppendLiteral(" = ");
handler.AppendFormatted(value.x.ToString(CultureInfo.InvariantCulture));
handler.AppendLiteral(" ");
handler.AppendFormatted(value.y.ToString(CultureInfo.InvariantCulture));
handler.AppendLiteral(" ");
handler.AppendFormatted(value.z.ToString(CultureInfo.InvariantCulture));
stringBuilder2.AppendLine(ref handler);
num++;
}
File.WriteAllText(iniPath, stringBuilder.ToString());
ManualLogSource log = Plugin.Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(38, 3, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("CustomMarkers: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" Markers saved to INI: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(Environment.NewLine);
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(iniPath);
}
log.LogInfo(val);
}
catch (Exception ex)
{
Plugin.Log.LogError((object)("CustomMarkers: Failed to save INI: " + Environment.NewLine + iniPath + ex));
}
}
private static void SaveMarkersToIni()
{
//IL_002f: 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_0131: Unknown result type (might be due to invalid IL or missing references)
//IL_0136: Unknown result type (might be due to invalid IL or missing references)
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.AppendLine("[Markers]");
foreach (KeyValuePair<string, Vector3> markers in markersList)
{
Vector3 value = markers.Value;
StringBuilder stringBuilder2 = stringBuilder;
StringBuilder stringBuilder3 = stringBuilder2;
StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(5, 4, stringBuilder2);
handler.AppendFormatted(markers.Key);
handler.AppendLiteral(" = ");
handler.AppendFormatted(value.x.ToString(CultureInfo.InvariantCulture));
handler.AppendLiteral(" ");
handler.AppendFormatted(value.y.ToString(CultureInfo.InvariantCulture));
handler.AppendLiteral(" ");
handler.AppendFormatted(value.z.ToString(CultureInfo.InvariantCulture));
stringBuilder3.AppendLine(ref handler);
}
stringBuilder.AppendLine();
stringBuilder.AppendLine("[SavedMarker]");
if (!string.IsNullOrEmpty(WaypointComponent.targetName) && markersList.ContainsKey(WaypointComponent.targetName))
{
Vector3 val = markersList[WaypointComponent.targetName];
StringBuilder stringBuilder2 = stringBuilder;
StringBuilder stringBuilder4 = stringBuilder2;
StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(9, 1, stringBuilder2);
handler.AppendLiteral("Active = ");
handler.AppendFormatted(WaypointComponent.targetName);
stringBuilder4.AppendLine(ref handler);
stringBuilder2 = stringBuilder;
StringBuilder stringBuilder5 = stringBuilder2;
handler = new StringBuilder.AppendInterpolatedStringHandler(11, 3, stringBuilder2);
handler.AppendLiteral("Coords = ");
handler.AppendFormatted(val.x.ToString(CultureInfo.InvariantCulture));
handler.AppendLiteral(" ");
handler.AppendFormatted(val.y.ToString(CultureInfo.InvariantCulture));
handler.AppendLiteral(" ");
handler.AppendFormatted(val.z.ToString(CultureInfo.InvariantCulture));
stringBuilder5.AppendLine(ref handler);
}
else
{
stringBuilder.AppendLine("Active = None");
}
File.WriteAllText(iniPath, stringBuilder.ToString());
}
public static void LoadMarkersFromIni()
{
//IL_0037: 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_01c3: 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_012f: Unknown result type (might be due to invalid IL or missing references)
if (!File.Exists(iniPath))
{
return;
}
string[] array = File.ReadAllLines(iniPath);
string text = "";
markersList.Clear();
string text2 = null;
Vector3 coords = Vector3.zero;
string[] array2 = array;
foreach (string text3 in array2)
{
string text4 = text3.Trim();
if (string.IsNullOrEmpty(text4) || text4.StartsWith(";") || text4.StartsWith("#"))
{
continue;
}
if (text4.StartsWith("[") && text4.EndsWith("]"))
{
text = text4.Substring(1, text4.Length - 2);
continue;
}
string[] array3 = text4.Split(new char[1] { '=' }, 2);
if (array3.Length != 2)
{
continue;
}
string text5 = array3[0].Trim();
string text6 = array3[1].Trim();
if (text == "Markers")
{
if (TryParseCoords(text6, out var coords2))
{
markersList[text5] = coords2;
}
}
else if (text == "SavedMarker")
{
if (text5 == "Active")
{
text2 = text6;
}
else if (text5 == "Coords")
{
TryParseCoords(text6, out coords);
}
}
}
if (!string.IsNullOrEmpty(text2) && text2 != "none" && markersList.ContainsKey(text2))
{
WaypointComponent.targetName = text2;
WaypointComponent.targetPosition = coords;
markersSelected[text2] = true;
}
else
{
WaypointComponent.ResetWaypoint();
}
}
public static void LoadLastActiveMarker()
{
//IL_0031: 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_0194: Unknown result type (might be due to invalid IL or missing references)
//IL_0196: Unknown result type (might be due to invalid IL or missing references)
if (!File.Exists(iniPath))
{
return;
}
try
{
string[] array = File.ReadAllLines(iniPath, Encoding.UTF8);
string text = "";
string text2 = null;
Vector3 coords = Vector3.zero;
string[] array2 = array;
foreach (string text3 in array2)
{
string text4 = text3.Trim();
if (string.IsNullOrEmpty(text4) || text4.StartsWith(";") || text4.StartsWith("#"))
{
continue;
}
if (text4.StartsWith("[") && text4.EndsWith("]"))
{
text = text4.Substring(1, text4.Length - 2);
continue;
}
string[] array3 = text4.Split(new char[1] { '=' }, 2);
if (array3.Length != 2)
{
continue;
}
string text5 = array3[0].Trim();
string text6 = array3[1].Trim();
if (text == "SavedMarker")
{
if (text5.Equals("Active", StringComparison.OrdinalIgnoreCase))
{
text2 = text6;
}
else if (text5.Equals("Coords", StringComparison.OrdinalIgnoreCase))
{
TryParseCoords(text6, out coords);
}
}
}
markersSelected.Clear();
if (!string.IsNullOrEmpty(text2) && !text2.Equals("none", StringComparison.OrdinalIgnoreCase) && markersList.ContainsKey(text2))
{
WaypointComponent.targetName = text2;
WaypointComponent.targetPosition = coords;
markersSelected[text2] = true;
WaypointComponent.hideArrow = false;
}
else
{
WaypointComponent.ResetWaypoint();
}
}
catch (Exception ex)
{
Plugin.Log.LogError((object)("Failed to load last active marker: " + ex));
}
}
private static void SaveLastActiveMarker()
{
//IL_0031: 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_0104: Unknown result type (might be due to invalid IL or missing references)
//IL_0109: Unknown result type (might be due to invalid IL or missing references)
//IL_015b: Unknown result type (might be due to invalid IL or missing references)
//IL_0160: Unknown result type (might be due to invalid IL or missing references)
try
{
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.AppendLine("[Markers]");
foreach (KeyValuePair<string, Vector3> markers in markersList)
{
Vector3 value = markers.Value;
StringBuilder stringBuilder2 = stringBuilder;
StringBuilder stringBuilder3 = stringBuilder2;
StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(5, 4, stringBuilder2);
handler.AppendFormatted(markers.Key);
handler.AppendLiteral(" = ");
handler.AppendFormatted(value.x.ToString(CultureInfo.InvariantCulture));
handler.AppendLiteral(" ");
handler.AppendFormatted(value.y.ToString(CultureInfo.InvariantCulture));
handler.AppendLiteral(" ");
handler.AppendFormatted(value.z.ToString(CultureInfo.InvariantCulture));
stringBuilder3.AppendLine(ref handler);
}
stringBuilder.AppendLine();
stringBuilder.AppendLine("[SavedMarker]");
string value2 = null;
Vector3 val = Vector3.zero;
foreach (KeyValuePair<string, bool> item in markersSelected)
{
if (item.Value && markersList.ContainsKey(item.Key))
{
value2 = item.Key;
val = markersList[item.Key];
break;
}
}
if (!string.IsNullOrEmpty(value2))
{
StringBuilder stringBuilder2 = stringBuilder;
StringBuilder stringBuilder4 = stringBuilder2;
StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(9, 1, stringBuilder2);
handler.AppendLiteral("Active = ");
handler.AppendFormatted(value2);
stringBuilder4.AppendLine(ref handler);
stringBuilder2 = stringBuilder;
StringBuilder stringBuilder5 = stringBuilder2;
handler = new StringBuilder.AppendInterpolatedStringHandler(11, 3, stringBuilder2);
handler.AppendLiteral("Coords = ");
handler.AppendFormatted(val.x.ToString(CultureInfo.InvariantCulture));
handler.AppendLiteral(" ");
handler.AppendFormatted(val.y.ToString(CultureInfo.InvariantCulture));
handler.AppendLiteral(" ");
handler.AppendFormatted(val.z.ToString(CultureInfo.InvariantCulture));
stringBuilder5.AppendLine(ref handler);
}
else
{
stringBuilder.AppendLine("Active = None");
}
File.WriteAllText(iniPath, stringBuilder.ToString());
}
catch (Exception ex)
{
Plugin.Log.LogError((object)("Failed to save last active marker: " + ex));
}
}
public static void ShowAndUnlockCursor()
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Invalid comparison between Unknown and I4
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: 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)
if (!Cursor.visible || (int)Cursor.lockState > 0)
{
Cursor.visible = true;
Cursor.lockState = (CursorLockMode)0;
Texture2D val = CreateWhiteTriangleCursor();
Vector2 zero = Vector2.zero;
Cursor.SetCursor(val, zero, (CursorMode)0);
}
}
public static void HideAndLockCursor()
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Invalid comparison between Unknown and I4
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
if (Cursor.visible || (int)Cursor.lockState != 1)
{
Cursor.visible = false;
Cursor.lockState = (CursorLockMode)1;
Cursor.SetCursor((Texture2D)null, Vector2.zero, (CursorMode)0);
}
}
public static Texture2D CreateWhiteTriangleCursor()
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Expected O, but got Unknown
//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_003e: 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)
int num = 32;
Texture2D val = new Texture2D(num, num, (TextureFormat)5, false);
Color val2 = default(Color);
((Color)(ref val2))..ctor(0f, 0f, 0f, 0f);
Color white = Color.white;
for (int i = 0; i < num; i++)
{
for (int j = 0; j < num; j++)
{
val.SetPixel(j, i, val2);
}
}
for (int k = 0; k < num; k++)
{
for (int l = 0; l <= k; l++)
{
val.SetPixel(l, num - 1 - k, white);
}
}
val.Apply();
((Texture)val).filterMode = (FilterMode)0;
return val;
}
}
[HarmonyPatch(typeof(CompassHud))]
public class CompassHudPatches
{
[HarmonyPatch(typeof(PlayerHUD), "SetGrappleState")]
public static class PlayerHUDPatches
{
[HarmonyPrefix]
public static void PlayerHUD_SetGrappleState(ref bool canGrapple)
{
if (CustomMarkers.showGui)
{
canGrapple = false;
}
}
}
[HarmonyPostfix]
[HarmonyPatch("Start")]
public static void CacheCompassHud(CompassHud __instance)
{
CustomMarkers.CompassHudInstance = __instance;
CustomMarkers.LoadMarkersFromIni();
CustomMarkers.LoadLastActiveMarker();
}
[HarmonyPrefix]
[HarmonyPatch("OnDestroy")]
public static void ClearCompassHud(CompassHud __instance)
{
if ((Object)(object)CustomMarkers.CompassHudInstance == (Object)(object)__instance)
{
CustomMarkers.CompassHudInstance = null;
}
}
[HarmonyPostfix]
[HarmonyPatch("Update")]
public static void UpdateMarkers(CompassHud __instance)
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: 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_006a: 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_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: 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_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
if (CustomMarkers.markerObjects.Count == 0)
{
return;
}
Vector3 coords = Plugin.coords;
Transform val = null;
foreach (KeyValuePair<Vector3, GameObject> markerObject in CustomMarkers.markerObjects)
{
GameObject value = markerObject.Value;
if (!((Object)(object)value == (Object)null))
{
Vector3 val2 = markerObject.Key - coords;
Vector3 forward = Vector3.forward;
if ((Object)(object)val != (Object)null)
{
forward = val.forward;
}
float num = Vector3.SignedAngle(forward, val2, Vector3.up);
float num2 = 400f;
float x = Mathf.Clamp(num / 90f, -1f, 1f) * (num2 / 2f);
Vector3 localPosition = value.transform.localPosition;
localPosition.x = x;
value.transform.localPosition = localPosition;
bool active = Mathf.Abs(num) <= 90f;
value.SetActive(active);
}
}
}
}
public class DisplayCoords : MonoBehaviour
{
public static PlayerNetwork LocalPlayerNetwork;
[HarmonyPatch(typeof(PlayerNetwork), "Update")]
[HarmonyPrefix]
private static void Update(PlayerNetwork __instance)
{
//IL_0020: 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)
if (!__instance.NetworkInstantiated)
{
Plugin.name = __instance.CharacterName;
Plugin.coords = __instance.PlayerSync.PlayerWorldPosition;
LocalPlayerNetwork = __instance;
}
}
}
public class Hotkey
{
public List<Key> keys;
public Action action;
public bool pressed;
public Hotkey(List<Key> keys, Action action)
{
this.keys = keys ?? throw new ArgumentNullException("keys");
this.action = action ?? throw new ArgumentNullException("action");
pressed = false;
}
}
public static class HotkeyParser
{
public static List<Key> ParseHotkeyString(string hotkeyString, List<Key> defaultCombination)
{
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Expected O, but got Unknown
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
if (string.IsNullOrWhiteSpace(hotkeyString))
{
return defaultCombination;
}
List<Key> list = new List<Key>();
string[] array = hotkeyString.Split(new char[1] { '+' }, StringSplitOptions.RemoveEmptyEntries);
string[] array2 = array;
bool flag = default(bool);
foreach (string text in array2)
{
string text2 = text.Trim();
if (Enum.TryParse<Key>(text2, ignoreCase: true, out Key result))
{
list.Add(result);
continue;
}
ManualLogSource log = Plugin.Log;
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(57, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("HotkeyParser: Invalid key '");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text2);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' in string '");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(hotkeyString);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'. Using default.");
}
log.LogWarning(val);
return defaultCombination;
}
return (list.Count > 0) ? list : defaultCombination;
}
}
public class HotkeysManager : MonoBehaviour
{
private List<Hotkey> hotkeys = new List<Hotkey>();
private void Start()
{
string value = Plugin.addCustomMarkerHotkey.Value;
List<Key> addCustomMarkerDefault = Plugin.addCustomMarkerDefault;
List<Key> keys = HotkeyParser.ParseHotkeyString(value, addCustomMarkerDefault);
hotkeys.Add(new Hotkey(keys, delegate
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Expected O, but got Unknown
CustomMarkers.ToggleAddMarkersGUI();
ManualLogSource log = Plugin.Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(43, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Hotkey pressed! Add Custom marker (Frame: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(Time.frameCount);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")");
}
log.LogInfo(val);
}));
hotkeys.Add(new Hotkey(new List<Key> { (Key)60 }, delegate
{
CustomMarkers.showGui = false;
}));
}
private void Update()
{
foreach (Hotkey hotkey in hotkeys)
{
if (IsHotkeyPressed(hotkey))
{
if (!hotkey.pressed && Time.time - Plugin.lastActionTime >= 0.5f)
{
Plugin.lastActionTime = Time.time;
hotkey.action();
hotkey.pressed = true;
}
}
else if (hotkey.pressed)
{
hotkey.pressed = false;
Plugin.Log.LogInfo((object)"Hotkey cleared!");
}
}
}
private bool IsHotkeyPressed(Hotkey hotkey)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
foreach (Key key in hotkey.keys)
{
if (!((ButtonControl)Keyboard.current[key]).isPressed)
{
return false;
}
}
Key val = hotkey.keys[hotkey.keys.Count - 1];
return ((ButtonControl)Keyboard.current[val]).wasPressedThisFrame;
}
}
[BepInPlugin("Joew_LostSkies_Markers", "My first plugin", "1.0.0")]
public class Plugin : BasePlugin
{
public static readonly string pluginName = "Joew's Lost Skies Tweaks v1.0 - by JoewAlabel";
public static readonly string pluginUrl = "https://thunderstore.io/c/lost-skies/p/JoewAlabel";
internal static ManualLogSource Log;
internal static string name;
internal static Vector3 coords;
internal static ConfigEntry<string> addCustomMarkerHotkey;
internal static List<Key> addCustomMarkerDefault = new List<Key> { (Key)67 };
internal static float lastActionTime;
internal const float actionCooldown = 0.5f;
internal static ConfigFile configFile;
private Harmony harmony;
public override void Load()
{
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Expected O, but got Unknown
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Expected O, but got Unknown
//IL_0116: Unknown result type (might be due to invalid IL or missing references)
//IL_011d: Expected O, but got Unknown
//IL_0188: Unknown result type (might be due to invalid IL or missing references)
//IL_018e: Expected O, but got Unknown
//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
//IL_01a7: Expected O, but got Unknown
//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
//IL_01c0: Expected O, but got Unknown
//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
//IL_01da: Expected O, but got Unknown
//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
//IL_01fd: Expected O, but got Unknown
//IL_024e: Unknown result type (might be due to invalid IL or missing references)
//IL_0255: Expected O, but got Unknown
Log = ((BasePlugin)this).Log;
configFile = ((BasePlugin)this).Config;
addCustomMarkerHotkey = ((BasePlugin)this).Config.Bind<string>("Hotkeys", "addCustomMarker", "PageUp", "Use Unity InputSystem Key names (https://docs.unity3d.com/ScriptReference/KeyCode.html), separated by '+'). Examples: RightControl + LeftShift + Insert");
IL2CPPChainloader.AddUnityComponent<HotkeysManager>();
IL2CPPChainloader.AddUnityComponent<DisplayCoords>();
IL2CPPChainloader.AddUnityComponent<CustomMarkers>();
IL2CPPChainloader.AddUnityComponent<WaypointComponent>();
harmony = new Harmony("Joew_LostSkies_Markers");
harmony.PatchAll();
harmony.PatchAll(typeof(DisplayCoords));
harmony.PatchAll(typeof(CustomMarkers));
List<MethodBase> list = harmony.GetPatchedMethods().ToList();
ManualLogSource log = Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(42, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Harmony patches applied: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(list.Count);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" methods patched.");
}
log.LogInfo(val);
foreach (MethodBase item in list)
{
ManualLogSource log2 = Log;
val = new BepInExInfoLogInterpolatedStringHandler(17, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Patched method: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(item.DeclaringType.FullName);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(".");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(item.Name);
}
log2.LogInfo(val);
}
GameObject val2 = new GameObject("HotkeysManager");
val2.AddComponent<HotkeysManager>();
Object.DontDestroyOnLoad((Object)(object)val2);
GameObject val3 = new GameObject("DisplayCoords");
val3.AddComponent<DisplayCoords>();
Object.DontDestroyOnLoad((Object)(object)val3);
GameObject val4 = new GameObject("CustomMarkers");
val4.AddComponent<CustomMarkers>();
Object.DontDestroyOnLoad((Object)(object)val4);
GameObject val5 = new GameObject("WaypointComponent");
val5.AddComponent<WaypointComponent>();
Object.DontDestroyOnLoad((Object)(object)val5);
ManualLogSource log3 = Log;
val = new BepInExInfoLogInterpolatedStringHandler(18, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("Joew_LostSkies_Markers");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!");
}
log3.LogInfo(val);
Log.LogInfo((object)"HotkeysManager initialized successfully.");
ManualLogSource log4 = Log;
val = new BepInExInfoLogInterpolatedStringHandler(18, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("Joew_LostSkies_Markers");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!");
}
log4.LogInfo(val);
}
}
public class WaypointComponent : MonoBehaviour
{
public static Vector3 targetPosition = new Vector3(100f, 0f, 100f);
public static string targetName = "Target";
private Camera mainCamera;
private GUIStyle distanceTextStyle;
private GUIStyle nameTextStyle;
private static bool stylesInitialized = false;
private static Texture2D arrowTexture;
private static bool hasLoggedMissingCoords = false;
public static bool hideArrow = true;
public static int scrrenWidth = Screen.width;
private int fontSizeDistance = ((scrrenWidth <= 2560) ? 14 : 20);
private int fontSizeName = ((scrrenWidth <= 2560) ? 16 : 24);
private float arrowTextWidth = ((scrrenWidth <= 2560) ? 400 : 600);
private float arrowTextHeight = ((scrrenWidth <= 2560) ? 20f : 35f);
private float arrowSpacing = ((scrrenWidth <= 2560) ? 5f : 8f);
public static void ResetWaypoint()
{
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
stylesInitialized = false;
hasLoggedMissingCoords = false;
if ((Object)(object)arrowTexture != (Object)null)
{
Object.Destroy((Object)(object)arrowTexture);
arrowTexture = null;
}
targetName = "";
targetPosition = Vector3.zero;
hideArrow = true;
}
private void CreateArrowTexture()
{
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Expected O, but got Unknown
//IL_0067: 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_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)arrowTexture != (Object)null)
{
return;
}
int num;
int num2;
if (scrrenWidth <= 2560)
{
num = 16;
num2 = 32;
}
else
{
num = 32;
num2 = 64;
}
arrowTexture = new Texture2D(num, num2, (TextureFormat)5, false);
Color val = default(Color);
((Color)(ref val))..ctor(0f, 0f, 0f, 0f);
Color red = Color.red;
for (int i = 0; i < num2; i++)
{
for (int j = 0; j < num; j++)
{
arrowTexture.SetPixel(j, i, val);
}
}
for (int k = 0; k < num2; k++)
{
float num3 = (float)num / 2f * (1f - (float)k / (float)num2);
int num4 = Mathf.RoundToInt((float)num / 2f - num3);
int num5 = Mathf.RoundToInt((float)num / 2f + num3);
for (int l = num4; l <= num5; l++)
{
if (l >= 0 && l < num)
{
arrowTexture.SetPixel(l, k, red);
}
}
}
arrowTexture.Apply();
}
protected void OnGUI()
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Invalid comparison between Unknown and I4
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_0137: Unknown result type (might be due to invalid IL or missing references)
//IL_013c: Unknown result type (might be due to invalid IL or missing references)
//IL_0144: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
//IL_0157: Unknown result type (might be due to invalid IL or missing references)
//IL_0167: Expected O, but got Unknown
//IL_0172: Unknown result type (might be due to invalid IL or missing references)
//IL_0177: Unknown result type (might be due to invalid IL or missing references)
//IL_017f: 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_0194: Unknown result type (might be due to invalid IL or missing references)
//IL_019a: Unknown result type (might be due to invalid IL or missing references)
//IL_01aa: Expected O, but got Unknown
//IL_024d: Unknown result type (might be due to invalid IL or missing references)
//IL_0252: Unknown result type (might be due to invalid IL or missing references)
//IL_0253: Unknown result type (might be due to invalid IL or missing references)
//IL_0258: Unknown result type (might be due to invalid IL or missing references)
//IL_0259: Unknown result type (might be due to invalid IL or missing references)
//IL_025e: 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_0290: 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_0298: Unknown result type (might be due to invalid IL or missing references)
//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
//IL_02d1: 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_02d8: Unknown result type (might be due to invalid IL or missing references)
//IL_02dc: 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_02ea: Unknown result type (might be due to invalid IL or missing references)
//IL_0306: Unknown result type (might be due to invalid IL or missing references)
//IL_0316: Unknown result type (might be due to invalid IL or missing references)
//IL_0338: Unknown result type (might be due to invalid IL or missing references)
//IL_0359: Unknown result type (might be due to invalid IL or missing references)
//IL_0375: Unknown result type (might be due to invalid IL or missing references)
//IL_037c: Unknown result type (might be due to invalid IL or missing references)
//IL_03b0: Unknown result type (might be due to invalid IL or missing references)
//IL_03b7: Unknown result type (might be due to invalid IL or missing references)
//IL_03c2: Unknown result type (might be due to invalid IL or missing references)
//IL_03e1: Unknown result type (might be due to invalid IL or missing references)
//IL_03e6: Unknown result type (might be due to invalid IL or missing references)
//IL_03fd: Unknown result type (might be due to invalid IL or missing references)
//IL_03fe: Unknown result type (might be due to invalid IL or missing references)
//IL_040a: 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)
//IL_041c: Unknown result type (might be due to invalid IL or missing references)
//IL_0453: Unknown result type (might be due to invalid IL or missing references)
if (hideArrow || (int)Event.current.type != 7)
{
return;
}
if ((Object)(object)DisplayCoords.LocalPlayerNetwork == (Object)null)
{
Plugin.Log.LogWarning((object)"PLayer not instancioed to display the arrow");
ResetWaypoint();
return;
}
if ((Object)(object)mainCamera == (Object)null)
{
mainCamera = Camera.main;
if ((Object)(object)mainCamera == (Object)null)
{
if (!hasLoggedMissingCoords)
{
Plugin.Log.LogInfo((object)"mainCamera ainda é null no OnGUI, pulando frame.");
hasLoggedMissingCoords = true;
}
return;
}
}
if (Plugin.coords == Vector3.zero)
{
if (!hasLoggedMissingCoords)
{
Plugin.Log.LogInfo((object)"Plugin.coords não está definido ainda, aguardando carregamento do jogo.");
hasLoggedMissingCoords = true;
}
return;
}
if (hasLoggedMissingCoords)
{
Plugin.Log.LogInfo((object)"Plugin.coords detectado, iniciando desenho da seta.");
hasLoggedMissingCoords = false;
}
if (!stylesInitialized)
{
GUIStyle val = new GUIStyle(GUI.skin.label)
{
alignment = (TextAnchor)1,
fontSize = fontSizeDistance
};
val.normal.textColor = Color.white;
distanceTextStyle = val;
GUIStyle val2 = new GUIStyle(GUI.skin.label)
{
alignment = (TextAnchor)1,
fontSize = fontSizeName,
fontStyle = (FontStyle)1
};
val2.normal.textColor = Color.yellow;
nameTextStyle = val2;
CreateArrowTexture();
stylesInitialized = true;
Plugin.Log.LogInfo((object)"Estilos GUI e textura da seta inicializados.");
}
if ((Object)(object)arrowTexture == (Object)null)
{
Plugin.Log.LogWarning((object)"arrowTexture foi destruída, recriando.");
CreateArrowTexture();
if ((Object)(object)arrowTexture == (Object)null)
{
Plugin.Log.LogError((object)"Falha ao recriar arrowTexture no OnGUI, abortando desenho.");
return;
}
}
Vector2 val3 = default(Vector2);
((Vector2)(ref val3))..ctor((float)(Screen.width - ((Texture)arrowTexture).width) / 2f, (float)((scrrenWidth <= 2560) ? 100 : 200));
Vector3 coords = Plugin.coords;
Vector3 val4 = targetPosition - coords;
val4.y = 0f;
Vector3 forward = ((Component)mainCamera).transform.forward;
forward.y = 0f;
((Vector3)(ref forward)).Normalize();
float num = Vector3.SignedAngle(forward, ((Vector3)(ref val4)).normalized, Vector3.up);
Vector2 val5 = val3 + new Vector2((float)((Texture)arrowTexture).width / 2f, (float)((Texture)arrowTexture).height / 2f);
Matrix4x4 matrix = GUI.matrix;
GUIUtility.RotateAroundPivot(num, val5);
GUI.DrawTexture(new Rect(val3.x, val3.y, (float)((Texture)arrowTexture).width, (float)((Texture)arrowTexture).height), (Texture)(object)arrowTexture);
GUI.matrix = matrix;
float num2 = arrowTextWidth;
float num3 = arrowTextHeight;
float num4 = arrowSpacing;
Vector2 val6 = default(Vector2);
((Vector2)(ref val6))..ctor(val3.x + (float)((Texture)arrowTexture).width / 2f - num2 / 2f, val3.y + (float)((Texture)arrowTexture).height + num4);
Vector2 val7 = default(Vector2);
((Vector2)(ref val7))..ctor(val6.x, val6.y + num3 + 2f);
if (nameTextStyle != null && !string.IsNullOrEmpty(targetName))
{
GUI.Label(new Rect(val6.x, val6.y, num2, num3), targetName, nameTextStyle);
}
if (distanceTextStyle != null && targetPosition != Vector3.zero)
{
float value = Vector3.Distance(coords, targetPosition);
GUI.Label(new Rect(val7.x, val7.y, num2, num3), $"{value:F1} m | z: {targetPosition.z - coords.z:0.00}m", distanceTextStyle);
}
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "Joew_LostSkies_Markers";
public const string PLUGIN_NAME = "My first plugin";
public const string PLUGIN_VERSION = "1.0.0";
}
}