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.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Obeliskial_Essentials;
using TMPro;
using TownMap;
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 = ".NET Standard 2.1")]
[assembly: AssemblyCompany("com.binbin.TownMap")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0+3ed76f0b7cd7d7c976657cd5fd45ded413374d4d")]
[assembly: AssemblyProduct("TownMap")]
[assembly: AssemblyTitle("com.binbin.TownMap")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.0.0")]
[module: UnverifiableCode]
[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;
}
}
}
public static class EssentialsCompatibility
{
private static bool? _enabled;
public static bool Enabled
{
get
{
bool valueOrDefault = _enabled == true;
if (!_enabled.HasValue)
{
valueOrDefault = Chainloader.PluginInfos.ContainsKey("com.stiffmeds.obeliskialessentials");
_enabled = valueOrDefault;
}
return _enabled.Value;
}
}
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
public static void EssentialsRegister()
{
Essentials.RegisterMod(Plugin.PluginName, "binbin", "Town Map", Plugin.PluginVersion, Plugin.ModDate, "https://github.com/binbinmods/TownMap", (string[])null, "", 100, (string[])null, "", true);
Plugin.LogInfo(Plugin.PluginGUID + " " + Plugin.PluginVersion + " has loaded with Essentials!");
}
}
namespace TownMap
{
[HarmonyPatch]
public class AntiCheat
{
[HarmonyPrefix]
[HarmonyPatch(typeof(SteamManager), "SetObeliskScore")]
public static bool SetObeliskScorePrefix(ref SteamManager __instance, int score, bool singleplayer = true)
{
return false;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(SteamManager), "SetScore")]
public static bool SetScorePrefix(ref SteamManager __instance, int score, bool singleplayer = true)
{
return false;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(SteamManager), "SetSingularityScore")]
public static bool SetSingularityScorePrefix(ref SteamManager __instance, int score, bool singleplayer = true)
{
return false;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(SteamManager), "SetObeliskScoreLeaderboard")]
public static bool SetObeliskScoreLeaderboardPrefix(ref SteamManager __instance, int score, bool singleplayer = true)
{
return false;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(SteamManager), "SetScoreLeaderboard")]
public static bool SetScoreLeaderboardPrefix(ref SteamManager __instance, int score, bool singleplayer = true)
{
return false;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(SteamManager), "SetSingularityScoreLeaderboard")]
public static bool SetSingularityScoreLeaderboardPrefix(ref SteamManager __instance, int score, bool singleplayer = true)
{
return false;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(SteamManager), "SetWeeklyScore")]
public static bool SetWeeklyScorePrefix(ref SteamManager __instance, int score, int week, string nick, string nickgroup, bool singleplayer = true)
{
return false;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(SteamManager), "SetWeeklyScoreLeaderboard")]
public static bool SetWeeklyScoreLeaderboardPrefix(ref SteamManager __instance, int score, int week, string nick, string nickgroup, bool singleplayer = true)
{
return false;
}
}
[BepInPlugin("com.binbin.TownMap", "TownMap", "1.1.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInProcess("AcrossTheObelisk.exe")]
public class Plugin : BaseUnityPlugin
{
public static bool EssentialsInstalled = false;
public static string PluginName;
public static string PluginVersion;
public static string PluginGUID;
internal static int ModDate = int.Parse(DateTime.Today.ToString("yyyyMMdd"));
private readonly Harmony harmony = new Harmony("com.binbin.TownMap");
internal static ManualLogSource Log;
public static string debugBase = "com.binbin.TownMap ";
public static ConfigEntry<bool> EnableMod { get; set; }
public static ConfigEntry<bool> EnableDebugging { get; set; }
public static ConfigEntry<int> IconHorizontalShift { get; set; }
private void Awake()
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Expected O, but got Unknown
//IL_0039: Expected O, but got Unknown
//IL_004b: 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_0066: Expected O, but got Unknown
//IL_0066: Expected O, but got Unknown
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Expected O, but got Unknown
//IL_0093: Expected O, but got Unknown
Log = ((BaseUnityPlugin)this).Logger;
string text = "TownMap";
EnableMod = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition(text, "EnableMod"), true, new ConfigDescription("Enables the mod. If false, the mod will not work then next time you load the game.", (AcceptableValueBase)null, Array.Empty<object>()));
EnableDebugging = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition(text, "EnableDebugging"), false, new ConfigDescription("Enables the debugging", (AcceptableValueBase)null, Array.Empty<object>()));
IconHorizontalShift = ((BaseUnityPlugin)this).Config.Bind<int>(new ConfigDefinition(text, "IconHorizontalShift"), 0, new ConfigDescription("Shifts the Town Map Icons. More positive is more to the right, more negative is more to the left. A value of 100 will shift the UI one \"Icon\" to the right.", (AcceptableValueBase)null, Array.Empty<object>()));
PluginName = "TownMap";
PluginVersion = "1.1.0";
PluginGUID = "com.binbin.TownMap";
if (EnableMod.Value)
{
if (EssentialsCompatibility.Enabled)
{
EssentialsCompatibility.EssentialsRegister();
}
else
{
LogDebug("Essentials is not installed. Mod will load normally, but Essentials features are unavaiable.");
}
harmony.PatchAll();
}
}
internal static void LogDebug(string msg)
{
if (EnableDebugging.Value)
{
Log.LogDebug((object)(debugBase + msg));
}
}
internal static void LogInfo(string msg)
{
Log.LogInfo((object)(debugBase + msg));
}
internal static void LogError(string msg)
{
Log.LogError((object)(debugBase + msg));
}
}
public class TownMapFunctions
{
public static List<string> townNodes = new List<string>();
public static bool IsHost()
{
return GameManager.Instance.IsMultiplayer() && NetworkManager.Instance.IsMaster();
}
public static bool IsMP()
{
return GameManager.Instance.IsMultiplayer();
}
public static Transform CreateIcon(Transform original, string name = "", List<GameObject> buttonList = null)
{
//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)
GameObject val = Object.Instantiate<GameObject>(((Component)original).gameObject, Vector3.zero, Quaternion.identity, (Transform)null);
if ((Object)(object)val == (Object)null)
{
Plugin.LogDebug("Failed to instantiate game object clone");
return null;
}
Transform transform = val.transform;
if ((Object)(object)transform == (Object)null)
{
Plugin.LogDebug("Cloned object has no transform component");
return null;
}
Object.DontDestroyOnLoad((Object)(object)transform);
((Component)transform).gameObject.SetActive(false);
((Object)((Component)transform).gameObject).name = name;
buttonList?.Add(((Component)transform).gameObject);
return transform;
}
public static void SetButtons(List<GameObject> gameObjects, bool active)
{
foreach (GameObject gameObject in gameObjects)
{
gameObject.SetActive(active);
}
}
public static bool IsTownNode()
{
if (townNodes.Contains(AtOManager.Instance.currentMapNode))
{
Plugin.LogDebug("IsTownNode: " + AtOManager.Instance.currentMapNode);
return true;
}
return false;
}
public static void SetTownNodes()
{
townNodes = new List<string>();
Dictionary<string, NodeData> value = Traverse.Create((object)Globals.Instance).Field("_NodeDataSource").GetValue<Dictionary<string, NodeData>>();
foreach (string key in value.Keys)
{
NodeData val = value[key];
if (val != null && val.GoToTown)
{
townNodes.Add(key);
}
}
Plugin.LogDebug("SetTownNodes: " + string.Join(", ", townNodes));
}
public static void HandleSeeMap()
{
Plugin.LogDebug("HandleSeeMap");
SceneStatic.LoadByName("Map");
}
public static void HandleGoToTown()
{
Plugin.LogDebug("HandleGoToTown");
SceneStatic.LoadByName("Town");
}
}
[HarmonyPatch]
public class TownMapPatches
{
public static bool devMode;
public static bool bSelectingPerk;
public static Transform iconTownMap;
public static Transform iconGoToTown;
public static List<GameObject> buttonListInTown;
public static List<GameObject> buttonListGoToTown;
public static bool IsHost()
{
return GameManager.Instance.IsMultiplayer() && NetworkManager.Instance.IsMaster();
}
[HarmonyPostfix]
[HarmonyPatch(typeof(OptionsManager), "Awake")]
public static void AwakePostfix(OptionsManager __instance, List<GameObject> ___buttonOrder)
{
Plugin.LogDebug("AwakePostfix");
buttonListInTown = new List<GameObject>();
buttonListGoToTown = new List<GameObject>();
iconTownMap = TownMapFunctions.CreateIcon(__instance.iconStats, "townmap", buttonListInTown);
iconGoToTown = TownMapFunctions.CreateIcon(__instance.iconRetry, "gototown", buttonListGoToTown);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(OptionsManager), "Show")]
public static void ShowPostfix(OptionsManager __instance, List<GameObject> ___buttonOrder)
{
//IL_0177: Unknown result type (might be due to invalid IL or missing references)
//IL_018e: Unknown result type (might be due to invalid IL or missing references)
//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
//IL_01f5: 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_021a: Unknown result type (might be due to invalid IL or missing references)
//IL_028e: 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_02ba: Unknown result type (might be due to invalid IL or missing references)
//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
//IL_030c: Unknown result type (might be due to invalid IL or missing references)
//IL_0327: Unknown result type (might be due to invalid IL or missing references)
//IL_0331: Unknown result type (might be due to invalid IL or missing references)
TownMapFunctions.SetButtons(buttonListInTown, active: false);
TownMapFunctions.SetButtons(buttonListGoToTown, active: false);
Plugin.LogDebug($"ShowPostfix - InTown {(Object)(object)TownManager.Instance != (Object)null || AtOManager.Instance.CharInTown()}, IsPrimaryCharacter {IsHost() || !TownMapFunctions.IsMP()}, MapManager.Instance{(Object)(object)MapManager.Instance != (Object)null}, IsTownNode {TownMapFunctions.IsTownNode()}, currentMapNode {AtOManager.Instance.currentMapNode}");
if (((Object)(object)TownManager.Instance != (Object)null || AtOManager.Instance.CharInTown()) && (IsHost() || !TownMapFunctions.IsMP()))
{
Plugin.LogDebug("Setting buttonListInTown to true");
TownMapFunctions.SetButtons(buttonListInTown, active: true);
}
else if ((Object)(object)MapManager.Instance != (Object)null && TownMapFunctions.IsTownNode() && (IsHost() || !TownMapFunctions.IsMP()))
{
Plugin.LogDebug("Setting buttonListGoToTown to true");
TownMapFunctions.SetButtons(buttonListGoToTown, active: true);
}
float num = 0.95f;
float num2 = 0.65f;
for (int i = 0; i < buttonListInTown.Count; i++)
{
if (buttonListInTown[i].activeSelf)
{
buttonListInTown[i].transform.position = new Vector3(((Component)__instance.iconTome).transform.position.x - num, ((Component)__instance.iconTome).transform.position.y, ((Component)__instance.iconTome).transform.position.z);
buttonListInTown[i].transform.localPosition = new Vector3(num - num2 * 6.35f + (float)Plugin.IconHorizontalShift.Value * 0.01f, buttonListInTown[i].transform.localPosition.y, buttonListInTown[i].transform.localPosition.z);
num -= num2;
}
}
num = 0.95f;
for (int j = 0; j < buttonListGoToTown.Count; j++)
{
if (buttonListGoToTown[j].activeSelf)
{
buttonListGoToTown[j].transform.position = new Vector3(((Component)__instance.iconTome).transform.position.x - num, ((Component)__instance.iconTome).transform.position.y, ((Component)__instance.iconTome).transform.position.z);
buttonListGoToTown[j].transform.localPosition = new Vector3(num - num2 * 6.35f + (float)Plugin.IconHorizontalShift.Value * 0.01f, buttonListGoToTown[j].transform.localPosition.y, buttonListGoToTown[j].transform.localPosition.z);
num -= num2;
}
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(BotonRollover), "ShowText")]
public static void BotonRolloverShowText(BotonRollover __instance)
{
if (((Object)((Component)__instance).gameObject).name == "townmap")
{
((Component)__instance.rollOverText).GetComponent<TMP_Text>().text = "See Map";
}
if (((Object)((Component)__instance).gameObject).name == "gototown")
{
((Component)__instance.rollOverText).GetComponent<TMP_Text>().text = "Go to Town";
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(BotonRollover), "OnMouseUp")]
public static void BotonRolloverOnMouseUp(BotonRollover __instance)
{
if (!Functions.ClickedThisTransform(((Component)__instance).transform) || AlertManager.Instance.IsActive() || GameManager.Instance.IsTutorialActive() || SettingsManager.Instance.IsActive() || DamageMeterManager.Instance.IsActive() || (Object.op_Implicit((Object)(object)MapManager.Instance) && MapManager.Instance.IsCharacterUnlock()) || (Object.op_Implicit((Object)(object)MatchManager.Instance) && MatchManager.Instance.console.IsActive()))
{
return;
}
string name = ((Object)((Component)__instance).gameObject).name;
CloseWindows(__instance, name);
Plugin.LogDebug("BotonRolloverOnMouseUp " + (name ?? "null object"));
string text = name;
string text2 = text;
if (!(text2 == "townmap"))
{
if (text2 == "gototown")
{
TownMapFunctions.HandleGoToTown();
}
}
else
{
TownMapFunctions.HandleSeeMap();
}
fRollOut(__instance);
}
[HarmonyReversePatch(/*Could not decode attribute arguments.*/)]
[HarmonyPatch(typeof(BotonRollover), "fRollOut")]
public static void fRollOut(BotonRollover __instance)
{
}
[HarmonyReversePatch(/*Could not decode attribute arguments.*/)]
[HarmonyPatch(typeof(BotonRollover), "CloseWindows")]
public static void CloseWindows(BotonRollover __instance, string botName)
{
}
[HarmonyPostfix]
[HarmonyPatch(typeof(MainMenuManager), "Start")]
public static void MMStartPostfix(ref MainMenuManager __instance)
{
Plugin.LogDebug("MMStartPostfix");
TownMapFunctions.SetTownNodes();
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "com.binbin.TownMap";
public const string PLUGIN_NAME = "TownMap";
public const string PLUGIN_VERSION = "1.1.0";
}
}