using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using CompassWaypointsOnScreen;
using MelonLoader;
using Microsoft.CodeAnalysis;
using MonoMod.RuntimeDetour;
using ScheduleOne.DevUtilities;
using ScheduleOne.PlayerScripts;
using ScheduleOne.UI.Compass;
using UnityEngine;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: ComVisible(false)]
[assembly: MelonInfo(typeof(Plugin), "CompassWaypointsOnScreen", "9.28.2996", "Coolpaca", null)]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: Guid("f85e11ed-2a8b-4b8c-8a14-84a017c570c1")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("CompassWaypointsOnScreen")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+d640d1fdc68f24db07178ec35278fcd37d6cf709")]
[assembly: AssemblyProduct("CompassWaypointsOnScreen")]
[assembly: AssemblyTitle("CompassWaypointsOnScreen")]
[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 CompassWaypointsOnScreen
{
public class Plugin : MelonMod
{
public static CompassManager manager;
public static PlayerCamera cam;
public static Sprite texture;
public static GameObject prefab;
public static Dictionary<Element, GameObject> dict = new Dictionary<Element, GameObject>();
public static AssetBundle elementBundle;
private static Canvas _overlayCanvas;
public static Canvas GetOrCreateCanvas()
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Expected O, but got Unknown
if ((Object)(object)_overlayCanvas != (Object)null)
{
return _overlayCanvas;
}
GameObject val = new GameObject("OnScreenMarkers");
Canvas val2 = val.AddComponent<Canvas>();
val2.renderMode = (RenderMode)0;
val2.sortingOrder = 100;
val.AddComponent<CanvasScaler>();
Object.DontDestroyOnLoad((Object)(object)val);
_overlayCanvas = val2;
return val2;
}
public override void OnSceneWasInitialized(int buildIndex, string sceneName)
{
((MelonMod)this).OnSceneWasLoaded(buildIndex, sceneName);
_overlayCanvas = GetOrCreateCanvas();
}
public override void OnInitializeMelon()
{
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
((MelonBase)this).OnInitializeMelon();
MelonLogger.Msg("Loaded!");
string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
elementBundle = AssetBundle.LoadFromFile(Path.Combine(directoryName, "onscreenelementprefab"));
texture = LoadImage("DEAL.png");
prefab = elementBundle.LoadAsset<GameObject>("Assets/OnScreenElementPrefab.prefab");
new Hook((MethodBase)typeof(CompassManager).GetMethod("UpdateElement", (BindingFlags)(-1)), (Delegate)new Action<Action<CompassManager, Element>, CompassManager, Element>(UpdateElementHook));
}
public static void UpdateElementHook(Action<CompassManager, Element> orig, CompassManager self, Element element)
{
//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: 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_0105: 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_012b: Unknown result type (might be due to invalid IL or missing references)
orig(self, element);
if (!((Object)(object)cam?.Camera == (Object)null) && !((Object)(object)element.Transform == (Object)null))
{
if (!dict.ContainsKey(element))
{
dict.Add(element, Object.Instantiate<GameObject>(prefab, ((Component)_overlayCanvas).transform));
Random random = new Random(((Object)dict[element]).GetInstanceID());
((Graphic)dict[element].GetComponent<Image>()).color = new Color((float)random.NextDouble(), (float)random.NextDouble(), (float)random.NextDouble());
dict[element].GetComponent<Image>().sprite = texture;
}
dict[element].SetActive(element.Visible);
Vector3 val = cam.Camera.WorldToScreenPoint(element.Transform.position);
if (val.z >= 0f)
{
dict[element].transform.position = val;
}
else
{
dict[element].SetActive(false);
}
}
}
public override void OnUpdate()
{
((MelonBase)this).OnUpdate();
if ((Object)(object)cam == (Object)null)
{
cam = PlayerSingleton<PlayerCamera>.Instance;
}
}
public static Sprite LoadImage(string Name)
{
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Expected O, but got Unknown
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\" + Name;
byte[] array = File.ReadAllBytes(path);
Texture2D val = new Texture2D(2, 2);
if (!ImageConversion.LoadImage(val, array))
{
MelonLogger.Error("Failed to load image. Make sure its named \"" + Name + "\" exactly.");
return null;
}
return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), Vector2.one / 2f);
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}