using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Jotunn.Configs;
using Jotunn.Managers;
using QuickPing.Patches;
using QuickPing.Utilities;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
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: AssemblyTitle("QuickPing")]
[assembly: AssemblyDescription("Ping what you see !")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Atopy")]
[assembly: AssemblyProduct("QuickPing")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("31e0f113-b41a-497c-89f8-8db164e0b3eb")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyFileVersion("1.5.8.0")]
[assembly: AssemblyInformationalVersion("1.5.8-beta.1+Branch.hotfix-patch-0.217.4.Sha.d8b12d347e0901656f82cc5fecf8d6fd3ebabdac")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.5.8.0")]
[CompilerGenerated]
[ExcludeFromCodeCoverage]
internal static class GitVersionInformation
{
public static string Major = "1";
public static string Minor = "5";
public static string Patch = "8";
public static string PreReleaseTag = "beta.1";
public static string PreReleaseTagWithDash = "-beta.1";
public static string PreReleaseLabel = "beta";
public static string PreReleaseLabelWithDash = "-beta";
public static string PreReleaseNumber = "1";
public static string WeightedPreReleaseNumber = "30001";
public static string BuildMetaData = "";
public static string BuildMetaDataPadded = "";
public static string FullBuildMetaData = "Branch.hotfix-patch-0.217.4.Sha.d8b12d347e0901656f82cc5fecf8d6fd3ebabdac";
public static string MajorMinorPatch = "1.5.8";
public static string SemVer = "1.5.8-beta.1";
public static string LegacySemVer = "1.5.8-beta1";
public static string LegacySemVerPadded = "1.5.8-beta0001";
public static string AssemblySemVer = "1.5.8.0";
public static string AssemblySemFileVer = "1.5.8.0";
public static string FullSemVer = "1.5.8-beta.1";
public static string InformationalVersion = "1.5.8-beta.1+Branch.hotfix-patch-0.217.4.Sha.d8b12d347e0901656f82cc5fecf8d6fd3ebabdac";
public static string BranchName = "hotfix/patch-0.217.4";
public static string EscapedBranchName = "hotfix-patch-0-217-4";
public static string Sha = "d8b12d347e0901656f82cc5fecf8d6fd3ebabdac";
public static string ShortSha = "d8b12d3";
public static string NuGetVersionV2 = "1.5.8-beta0001";
public static string NuGetVersion = "1.5.8-beta0001";
public static string NuGetPreReleaseTagV2 = "beta0001";
public static string NuGetPreReleaseTag = "beta0001";
public static string VersionSourceSha = "d8b12d347e0901656f82cc5fecf8d6fd3ebabdac";
public static string CommitsSinceVersionSource = "0";
public static string CommitsSinceVersionSourcePadded = "0000";
public static string UncommittedChanges = "0";
public static string CommitDate = "2023-06-21";
}
namespace QuickPing
{
public enum HoverType
{
GameObject,
Character,
Hoverable,
Piece,
Location
}
public class HoverObject : MonoBehaviour
{
public GameObject Hover;
public IDestructible Destructible;
public Vector3 pos;
public Vector3 center;
public HoverType type;
public bool pinable;
public string Name { get; set; }
}
[BepInPlugin("com.atopy.plugins.quickping", "QuickPing", "1.5.8.0")]
public class QuickPingPlugin : BaseUnityPlugin
{
public static QuickPingPlugin Instance { get; set; }
public static ManualLogSource Log { get; private set; }
private void Awake()
{
Log = ((BaseUnityPlugin)this).Logger;
Instance = this;
Settings.Init();
Harmony.CreateAndPatchAll(typeof(Player_Patch), "com.atopy.plugins.quickping");
Harmony.CreateAndPatchAll(typeof(ChatPing_Patch), "com.atopy.plugins.quickping");
Harmony.CreateAndPatchAll(typeof(Minimap_Patch), "com.atopy.plugins.quickping");
Harmony.CreateAndPatchAll(typeof(Terminal_Patch), "com.atopy.plugins.quickping");
Harmony.CreateAndPatchAll(typeof(MineRock5_Patch), "com.atopy.plugins.quickping");
Harmony.CreateAndPatchAll(typeof(Destructible_Patch), "com.atopy.plugins.quickping");
Harmony.CreateAndPatchAll(typeof(ZNet_Patch), "com.atopy.plugins.quickping");
Harmony.CreateAndPatchAll(typeof(WearNTear_Patch), "com.atopy.plugins.quickping");
Player_Patch.OnPlayerPing.AddListener((UnityAction<HoverObject>)Player_Patch.SendPing);
Player_Patch.OnPlayerPing.AddListener((UnityAction<HoverObject>)Minimap_Patch.AddPin);
Player_Patch.OnPlayerForcePing.AddListener((UnityAction<HoverObject>)Player_Patch.SendPing);
Player_Patch.OnPlayerForcePing.AddListener((UnityAction<HoverObject>)Minimap_Patch.ForceAddPin);
Player_Patch.OnPlayerRename.AddListener((UnityAction<HoverObject>)Player_Patch.SendRename);
Player_Patch.OnPlayerRename.AddListener((UnityAction<HoverObject>)Minimap_Patch.RenamePin);
}
}
internal static class Settings
{
public const string DefaultPingText = "PING !";
public static ConfigEntry<bool> PingWhereLooking { get; private set; }
public static ConfigEntry<bool> AddPin { get; private set; }
public static ConfigEntry<KeyCode> PingKey { get; private set; }
public static ConfigEntry<KeyCode> PinEverythingKey { get; internal set; }
public static ConfigEntry<KeyboardShortcut> RenameKey { get; internal set; }
public static ConfigEntry<PinType> DefaultPinType { get; internal set; }
public static ConfigEntry<Color> PlayerColor { get; private set; }
public static ConfigEntry<Color> ShoutColor { get; private set; }
public static ConfigEntry<Color> WhisperColor { get; private set; }
public static ConfigEntry<Color> PingColor { get; private set; }
public static ConfigEntry<Color> DefaultColor { get; private set; }
public static ConfigEntry<float> ClosestPinRange { get; private set; }
public static ButtonConfig PingBtn { get; private set; }
public static ButtonConfig PingEverythingBtn { get; private set; }
public static ButtonConfig RenameBtn { get; private set; }
public static void Init()
{
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_0114: 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_017a: Unknown result type (might be due to invalid IL or missing references)
//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
//IL_0207: Unknown result type (might be due to invalid IL or missing references)
//IL_0217: Unknown result type (might be due to invalid IL or missing references)
//IL_0221: Expected O, but got Unknown
PingWhereLooking = ((BaseUnityPlugin)QuickPingPlugin.Instance).Config.Bind<bool>("General", "PingWhereLooking", true, "Create a ping where you are looking when you press <PingKey>");
AddPin = ((BaseUnityPlugin)QuickPingPlugin.Instance).Config.Bind<bool>("General", "AddPinOnMap", true, "If true, add a pin when useful resources (copper, berries, campfire, portals etc.) are pinged.");
ClosestPinRange = ((BaseUnityPlugin)QuickPingPlugin.Instance).Config.Bind<float>("General", "ClosestPinRange", 2f, "Minimum distance between objects to pin/replace portal tag");
DefaultPinType = ((BaseUnityPlugin)QuickPingPlugin.Instance).Config.Bind<PinType>("General", "DefaultPinType", (PinType)11, "Default pin when forcing adding a pin on map");
PlayerColor = ((BaseUnityPlugin)QuickPingPlugin.Instance).Config.Bind<Color>("Colors", "PlayerColor", Color.green, "Color for Player name in pings/messages.");
ShoutColor = ((BaseUnityPlugin)QuickPingPlugin.Instance).Config.Bind<Color>("Colors", "ShoutColor", Color.yellow, "Color for Shout ping.");
WhisperColor = ((BaseUnityPlugin)QuickPingPlugin.Instance).Config.Bind<Color>("Colors", "WhisperColor", new Color(1f, 1f, 1f, 0.75f), "Color for Whisper ping.");
PingColor = ((BaseUnityPlugin)QuickPingPlugin.Instance).Config.Bind<Color>("Colors", "PingColor", new Color(0.6f, 0.7f, 1f, 1f), "Color for \"Ping\" ping.");
DefaultColor = ((BaseUnityPlugin)QuickPingPlugin.Instance).Config.Bind<Color>("Colors", "DefaultColor", Color.white, "Default color");
PingKey = ((BaseUnityPlugin)QuickPingPlugin.Instance).Config.Bind<KeyCode>("Bindings", "PingInputKey", (KeyCode)116, "The keybind to trigger a ping where you are looking");
PinEverythingKey = ((BaseUnityPlugin)QuickPingPlugin.Instance).Config.Bind<KeyCode>("Bindings", "PingEverythingInputKey", (KeyCode)103, "Add a pin on minimap to whatever you're looking at.");
RenameKey = ((BaseUnityPlugin)QuickPingPlugin.Instance).Config.Bind<KeyboardShortcut>("Bindings", "RenameInputKey", new KeyboardShortcut(PingKey.Value, (KeyCode[])(object)new KeyCode[1] { (KeyCode)308 }), new ConfigDescription("The keybind to rename a ping", (AcceptableValueBase)null, Array.Empty<object>()));
AddInputs();
}
public static void AddInputs()
{
//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_0012: 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_002f: Expected O, but got Unknown
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Expected O, but got Unknown
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Expected O, but got Unknown
PingBtn = new ButtonConfig
{
Name = "Ping",
Config = PingKey,
Hint = "Ping where you are looking, and pin useful resources"
};
PingEverythingBtn = new ButtonConfig
{
Name = "PinEverything",
Config = PinEverythingKey,
Hint = "Pin on map everything you're looking at"
};
RenameBtn = new ButtonConfig
{
Name = "Rename",
ShortcutConfig = RenameKey
};
InputManager.Instance.AddButton("com.atopy.plugins.quickping", RenameBtn);
InputManager.Instance.AddButton("com.atopy.plugins.quickping", PingBtn);
InputManager.Instance.AddButton("com.atopy.plugins.quickping", PingEverythingBtn);
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "com.atopy.plugins.quickping";
public const string PLUGIN_NAME = "QuickPing";
public const string PLUGIN_VERSION = "1.5.8.0";
}
}
namespace QuickPing.Utilities
{
internal static class DataManager
{
public static Dictionary<ZDOID, PinData> PinnedObjects = new Dictionary<ZDOID, PinData>();
public static Dictionary<string, string> CustomNames = new Dictionary<string, string>();
public static bool Save(World world, PlayerProfile playerProfile)
{
bool flag = SaveCustomNames(world, playerProfile);
bool flag2 = SavePinnedObjects(world, playerProfile);
return flag && flag2;
}
public static void Load(World world, PlayerProfile playerProfile)
{
LoadCustomNames(world, playerProfile);
LoadPinnedObjects(world, playerProfile);
}
private static void LoadPinnedObjects(World world, PlayerProfile playerProfile)
{
//IL_001e: 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)
//IL_002a: Expected O, but got Unknown
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Expected O, but got Unknown
PinnedObjects.Clear();
string path = GetPath(world, playerProfile, "pinned");
FileReader val = null;
try
{
val = new FileReader(path, world.m_fileSource, (FileHelperType)0);
}
catch
{
if (val != null)
{
val.Dispose();
}
QuickPingPlugin.Log.LogWarning((object)("Failed to load pinned objects. World: " + world.m_name + " - Profile: " + playerProfile.m_playerName));
return;
}
BinaryReader binary = val.m_binary;
int count = binary.ReadInt32();
ZPackage zPackage = new ZPackage(binary.ReadBytes(count));
UnpackPinnedObjects(zPackage);
}
private static bool SavePinnedObjects(World world, PlayerProfile playerProfile)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Invalid comparison between Unknown and I4
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Expected O, but got Unknown
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Invalid comparison between Unknown and I4
//IL_001b: 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_00a2: Invalid comparison between Unknown and I4
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
ZPackage val = PackPinnedObjects();
if ((int)world.m_fileSource != 2)
{
Directory.CreateDirectory(World.GetWorldSavePath(world.m_fileSource));
}
string path = GetPath(world, playerProfile, "pinned");
string text = path + ".new";
string text2 = path + ".old";
byte[] array = val.GetArray();
FileWriter val2 = new FileWriter(text, (FileHelperType)0, world.m_fileSource);
val2.m_binary.Write(array.Length);
val2.m_binary.Write(array);
val2.Finish();
bool flag = (int)val2.Status != 2 && (int)world.m_fileSource == 2;
if (!flag)
{
FileHelpers.ReplaceOldFile(path, text, text2, world.m_fileSource);
}
return flag;
}
private static void LoadCustomNames(World world, PlayerProfile playerProfile)
{
//IL_001e: 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)
//IL_002a: Expected O, but got Unknown
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Expected O, but got Unknown
CustomNames.Clear();
string path = GetPath(world, playerProfile, "customNames");
FileReader val = null;
try
{
val = new FileReader(path, world.m_fileSource, (FileHelperType)0);
}
catch
{
if (val != null)
{
val.Dispose();
}
QuickPingPlugin.Log.LogWarning((object)("Failed to load custom names. World: " + world.m_name + " - Profile: " + playerProfile.m_playerName));
return;
}
BinaryReader binary = val.m_binary;
int count = binary.ReadInt32();
ZPackage zPackage = new ZPackage(binary.ReadBytes(count));
UnpackCustomNames(zPackage);
}
private static bool SaveCustomNames(World world, PlayerProfile playerProfile)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Invalid comparison between Unknown and I4
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Expected O, but got Unknown
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Invalid comparison between Unknown and I4
//IL_001b: 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_00a2: Invalid comparison between Unknown and I4
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
ZPackage val = PackCustomNames();
if ((int)world.m_fileSource != 2)
{
Directory.CreateDirectory(World.GetWorldSavePath(world.m_fileSource));
}
string path = GetPath(world, playerProfile, "customNames");
string text = path + ".new";
string text2 = path + ".old";
byte[] array = val.GetArray();
FileWriter val2 = new FileWriter(text, (FileHelperType)0, world.m_fileSource);
val2.m_binary.Write(array.Length);
val2.m_binary.Write(array);
val2.Finish();
bool flag = (int)val2.Status != 2 && (int)world.m_fileSource == 2;
if (!flag)
{
FileHelpers.ReplaceOldFile(path, text, text2, world.m_fileSource);
}
return flag;
}
private static string GetPath(World world, PlayerProfile playerProfile, string extension)
{
string text = default(string);
string text2 = default(string);
string text3 = default(string);
FileHelpers.SplitFilePath(world.GetDBPath(), ref text, ref text2, ref text3);
string text4 = text + text2;
string text5 = "." + playerProfile.m_playerName + ".mod.quickping." + extension;
return text4 + text5;
}
private static ZPackage PackPinnedObjects()
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
ZPackage val = new ZPackage();
foreach (KeyValuePair<ZDOID, PinData> pinnedObject in PinnedObjects)
{
val.Write(pinnedObject.Key);
val.Write(pinnedObject.Value);
}
return val;
}
private static ZPackage PackCustomNames()
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
ZPackage val = new ZPackage();
foreach (KeyValuePair<string, string> customName in CustomNames)
{
string key = customName.Key;
if ((key != null && !(key == "")) || 1 == 0)
{
val.Write(customName.Key);
val.Write(customName.Value);
}
}
return val;
}
private static void UnpackCustomNames(ZPackage zPackage)
{
CustomNames.Clear();
while (zPackage.GetPos() < zPackage.Size())
{
string text = zPackage.ReadString();
string value = zPackage.ReadString();
if (!(text == ""))
{
CustomNames.Add(text, value);
}
}
}
private static void UnpackPinnedObjects(ZPackage zPackage)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: 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)
Dictionary<ZDOID, PinData> dictionary = new Dictionary<ZDOID, PinData>();
if (zPackage == null)
{
return;
}
while (zPackage.GetPos() < zPackage.Size())
{
ZDOID key = zPackage.ReadZDOID();
PinData value = zPackage.ReadPinData();
if (!dictionary.ContainsKey(key))
{
dictionary.Add(key, value);
}
}
PinnedObjects = dictionary;
}
private static void Write(this ZPackage zPackage, PinData pinData)
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
zPackage.Write(pinData.m_name);
zPackage.Write(((object)(PinType)(ref pinData.m_type)).ToString());
zPackage.Write(pinData.m_pos);
}
private static PinData ReadPinData(this ZPackage package)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: 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_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
PinData val = new PinData();
val.m_name = package.ReadString();
val.m_type = (PinType)Enum.Parse(typeof(PinType), package.ReadString());
val.m_pos = package.ReadVector3();
return val;
}
}
internal static class GO_Ext
{
public static IDestructible GetRecursiveComponentInParents<IDestructible>(Transform root)
{
if ((Object)(object)root.parent == (Object)null)
{
return default(IDestructible);
}
IDestructible componentInParent = ((Component)root).GetComponentInParent<IDestructible>();
if (componentInParent != null)
{
return componentInParent;
}
return GetRecursiveComponentInParents<IDestructible>(root.parent);
}
public static GameObject GetRecursiveParentWithComponent<T>(Transform root)
{
if (!Object.op_Implicit((Object)(object)root.parent))
{
return null;
}
T val = default(T);
if (((Component)root.parent).gameObject.TryGetComponent<T>(ref val))
{
return ((Component)root.parent).gameObject;
}
return GetRecursiveParentWithComponent<T>(root.parent);
}
}
internal static class DataUtils
{
public static byte[] ReadAllBytes(this BinaryReader reader)
{
using MemoryStream memoryStream = new MemoryStream();
byte[] array = new byte[4096];
int count;
while ((count = reader.Read(array, 0, array.Length)) != 0)
{
memoryStream.Write(array, 0, count);
}
return memoryStream.ToArray();
}
public static bool Compare(this PinData x, PinData y)
{
//IL_0002: 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)
return x.m_pos == y.m_pos && x.m_name == y.m_name;
}
}
}
namespace QuickPing.Patches
{
public class ChatPing_Patch
{
[HarmonyPatch(typeof(Chat))]
[HarmonyPatch("AddInworldText")]
[HarmonyPrefix]
public static bool AddInworldText(Chat __instance, GameObject go, long senderID, Vector3 position, Type type, UserInfo user, string text)
{
//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_0090: 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)
//IL_0098: 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_009c: 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_00b5: Expected I4, but got Unknown
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Expected O, but got Unknown
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_010e: Unknown result type (might be due to invalid IL or missing references)
//IL_0113: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: 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_00e8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_0129: Unknown result type (might be due to invalid IL or missing references)
WorldTextInstance val = __instance.FindExistingWorldText(senderID);
if (val == null)
{
val = new WorldTextInstance();
val.m_talkerID = senderID;
val.m_gui = Object.Instantiate<GameObject>(__instance.m_worldTextBase, ((Component)__instance).transform);
val.m_gui.gameObject.SetActive(true);
Transform val2 = val.m_gui.transform.Find("Text");
val.m_textMeshField = ((Component)val2).GetComponent<TextMeshProUGUI>();
__instance.m_worldTexts.Add(val);
}
val.m_userInfo = user;
val.m_type = type;
val.m_go = go;
val.m_position = position;
Color value;
switch ((int)type)
{
case 2:
value = Settings.ShoutColor.Value;
text = text.ToUpper();
break;
case 0:
value = Settings.WhisperColor.Value;
text = text.ToLowerInvariant();
break;
case 3:
value = Settings.PingColor.Value;
if (text == string.Empty)
{
text = "PING !";
}
break;
default:
value = Settings.DefaultColor.Value;
break;
}
((TMP_Text)val.m_textMeshField).richText = true;
((Graphic)val.m_textMeshField).color = value;
val.m_timer = 0f;
val.m_text = text;
__instance.UpdateWorldTextField(val);
return false;
}
[HarmonyPatch(typeof(Chat), "UpdateWorldTextField")]
[HarmonyPrefix]
public static bool UpdateWorldTextField(WorldTextInstance wt)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Invalid comparison between Unknown and I4
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Invalid comparison between Unknown and I4
//IL_007b: 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)
string text = "";
if ((int)wt.m_type == 2 || (int)wt.m_type == 3)
{
text = "<color=#" + ColorUtility.ToHtmlStringRGBA(Settings.PlayerColor.Value) + ">" + wt.m_name + "</color>: ";
}
text = text + "<color=#" + ColorUtility.ToHtmlStringRGBA(((Graphic)wt.m_textMeshField).color) + ">" + wt.m_text + "</color>";
((TMP_Text)wt.m_textMeshField).text = text;
return false;
}
}
public static class Localization_Patch
{
public static string Localize(Location location)
{
string result = "";
foreach (Location allLocation in Location.m_allLocations)
{
if (((Object)location).name.Contains(((Object)allLocation).name))
{
string text = ((Object)allLocation).name;
if (((Object)allLocation).name.Contains("(Clone)"))
{
text = ((Object)allLocation).name.Replace("(Clone)", "").Trim();
}
switch (text)
{
case "TrollCave01":
case "TrollCave02":
case "TrollCave03":
case "TrollCave":
result = Localization.instance.Localize("$location_forestcave");
break;
case "Crypt2":
case "Crypt3":
case "Crypt4":
result = Localization.instance.Localize("$location_forestcrypt");
break;
case "GoblinCamp1":
case "GoblinCamp2":
result = Localization.instance.Localize("GoblinCamp");
break;
case "StoneHenge1":
case "StoneHenge2":
case "StoneHenge3":
case "StoneHenge4":
case "StoneHenge5":
case "StoneHenge6":
result = Localization.instance.Localize("Stone Henge");
break;
case "SunkenCrypt1":
case "SunkenCrypt2":
case "SunkenCrypt3":
case "SunkenCrypt4":
case "SunkenCrypt4old":
result = Localization.instance.Localize("$location_sunkencrypt");
break;
case "DrakeNest01":
result = Localization.instance.Localize("$item_dragonegg");
break;
case "MountainCave01":
case "MountainCave02":
result = Localization.instance.Localize("$location_mountaincave");
break;
case "Mistlands_DvergrTownEntrance1":
case "Mistlands_DvergrTownEntrance2":
case "Mistlands_DvergrTownEntrance":
result = Localization.instance.Localize("$location_dvergrtown");
break;
}
}
}
return result;
}
public static string GetBaseTranslation(string str)
{
if (str == "")
{
return "noStr";
}
Dictionary<string, string> translations = Localization.instance.m_translations;
string key = translations.FirstOrDefault((KeyValuePair<string, string> x) => x.Value == str).Key;
return "$" + key;
}
}
[HarmonyPatch(typeof(MineRock5))]
internal static class MineRock5_Patch
{
[HarmonyPatch(typeof(MineRock5), "AllDestroyed")]
[HarmonyPostfix]
public static void AllDestroyed(MineRock5 __instance, bool __result)
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: 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_0046: Unknown result type (might be due to invalid IL or missing references)
if (__result && Object.op_Implicit((Object)(object)__instance.m_nview))
{
ZDOID uid = __instance.m_nview.GetZDO().m_uid;
if (DataManager.PinnedObjects.ContainsKey(uid))
{
Minimap.instance.RemovePin(DataManager.PinnedObjects[uid]);
}
}
}
}
[HarmonyPatch(typeof(WearNTear))]
internal static class WearNTear_Patch
{
[HarmonyPatch(typeof(WearNTear), "Destroy")]
[HarmonyPrefix]
public static void Destroy(WearNTear __instance)
{
//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_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
if (Object.op_Implicit((Object)(object)__instance.m_nview) && __instance.m_nview.GetZDO() != null)
{
ZDOID uid = __instance.m_nview.GetZDO().m_uid;
if (DataManager.PinnedObjects.ContainsKey(uid))
{
Minimap.instance.RemovePin(DataManager.PinnedObjects[uid]);
}
}
}
}
[HarmonyPatch(typeof(Destructible))]
internal static class Destructible_Patch
{
[HarmonyPatch(typeof(Destructible), "Destroy")]
[HarmonyPrefix]
public static bool Destroy(Destructible __instance, Vector3 hitPoint, Vector3 hitDir)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: 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_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0174: 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)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_018a: 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)
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: 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_011a: Unknown result type (might be due to invalid IL or missing references)
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_0126: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_0142: Unknown result type (might be due to invalid IL or missing references)
//IL_0163: Unknown result type (might be due to invalid IL or missing references)
__instance.CreateDestructionEffects(hitPoint, hitDir);
if (__instance.m_destroyNoise > 0f)
{
Player closestPlayer = Player.GetClosestPlayer(((Component)__instance).transform.position, 10f);
if (Object.op_Implicit((Object)(object)closestPlayer))
{
((Character)closestPlayer).AddNoise(__instance.m_destroyNoise);
}
}
ZDOID uid = __instance.m_nview.GetZDO().m_uid;
if (Object.op_Implicit((Object)(object)__instance.m_spawnWhenDestroyed))
{
GameObject val = Object.Instantiate<GameObject>(__instance.m_spawnWhenDestroyed, ((Component)__instance).transform.position, ((Component)__instance).transform.rotation);
ZNetView component = val.GetComponent<ZNetView>();
component.SetLocalScale(((Component)__instance).transform.localScale);
Gibber component2 = val.GetComponent<Gibber>();
if (Object.op_Implicit((Object)(object)component2))
{
component2.Setup(hitPoint, hitDir);
}
MineRock5 val2 = default(MineRock5);
if (val.TryGetComponent<MineRock5>(ref val2))
{
if (!DataManager.PinnedObjects.ContainsKey(component.GetZDO().m_uid) && DataManager.PinnedObjects.ContainsKey(uid))
{
ZDOID uid2 = component.GetZDO().m_uid;
PinData value = DataManager.PinnedObjects[uid];
DataManager.PinnedObjects.Add(uid2, value);
DataManager.PinnedObjects.Remove(uid);
}
else if (DataManager.PinnedObjects.ContainsKey(uid))
{
DataManager.PinnedObjects.Remove(uid);
}
}
}
else if (DataManager.PinnedObjects.ContainsKey(uid))
{
Minimap.instance.RemovePin(DataManager.PinnedObjects[uid]);
}
__instance.m_onDestroyed?.Invoke();
ZNetScene.instance.Destroy(((Component)__instance).gameObject);
__instance.m_destroyed = true;
return false;
}
}
[HarmonyPatch(typeof(Character))]
internal static class Character_Patch
{
[HarmonyPatch(typeof(Character), "OnDeath")]
[HarmonyPrefix]
public static void OnDeath(Character __instance)
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: 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)
if (Object.op_Implicit((Object)(object)__instance.m_nview))
{
ZDOID uid = __instance.m_nview.GetZDO().m_uid;
if (DataManager.PinnedObjects.ContainsKey(uid))
{
Minimap.instance.RemovePin(DataManager.PinnedObjects[uid]);
}
}
}
}
internal static class Minimap_Patch
{
private static GameObject panel;
private static GameObject nameInput;
private static GameObject toggleSaveName;
public static bool IsNaming;
private static string tempOriginalText;
public static PinType IsPinable(string strID)
{
//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0200: Unknown result type (might be due to invalid IL or missing references)
//IL_020f: Unknown result type (might be due to invalid IL or missing references)
//IL_0246: Unknown result type (might be due to invalid IL or missing references)
//IL_024a: Unknown result type (might be due to invalid IL or missing references)
//IL_0225: Unknown result type (might be due to invalid IL or missing references)
//IL_0226: Unknown result type (might be due to invalid IL or missing references)
string baseTranslation = Localization_Patch.GetBaseTranslation(strID);
Dictionary<PinType, List<string>> dictionary = new Dictionary<PinType, List<string>>
{
{
(PinType)0,
new List<string> { "$piece_firepit", "$piece_bonfire", "$piece_fire", "GoblinCamp" }
},
{
(PinType)1,
new List<string>()
},
{
(PinType)2,
new List<string> { "$piece_deposit_copper", "$piece_deposit_silver", "$piece_deposit_silvervein", "$piece_deposit_tin", "$piece_mudpile" }
},
{
(PinType)3,
new List<string>
{
"$item_raspberries", "$item_blueberries", "$item_cloudberries", "$item_dragonegg", "$item_dandelion", "$item_mushroomcommon", "$item_magecap", "$item_mushroomblue", "$item_thistle", "$item_jotunpuffs",
"$peRaspberryBushName", "$peBlueberryBushName", "$peCloudberryBushName", "$pePickableMushroomName", "$pePickableYellowMushroomName", "$pePickableBlueMushroomName", "$pePickableThistleName", "$pePickableDandelionName"
}
},
{
(PinType)6,
new List<string> { "$location_forestcave", "$location_forestcrypt", "Stone Henge", "$location_sunkencrypt", "$location_mountaincave", "$location_dvergrtown", "$piece_portal" }
}
};
foreach (PinType key in dictionary.Keys)
{
if (dictionary[key].Contains(strID) || dictionary[key].Contains(baseTranslation))
{
return key;
}
}
return (PinType)8;
}
internal static void RenamePin(HoverObject obj)
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
AddPin(obj.Hover, obj.Destructible, obj.Name, obj.center, force: false, rename: true);
}
public static void AddPin(HoverObject obj)
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
AddPin(obj.Hover, obj.Destructible, obj.Name, obj.center);
}
public static void ForceAddPin(HoverObject obj)
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
AddPin(obj.Hover, obj.Destructible, obj.Name, obj.center, force: true);
}
public static void AddPin(GameObject hover, IDestructible idestructible, string strID, Vector3 pos, bool force = false, bool rename = false)
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Expected O, but got Unknown
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: 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_00bf: 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)
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_012e: Unknown result type (might be due to invalid IL or missing references)
//IL_03d0: Unknown result type (might be due to invalid IL or missing references)
//IL_03d5: Unknown result type (might be due to invalid IL or missing references)
//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
//IL_01a1: 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_03f7: Unknown result type (might be due to invalid IL or missing references)
//IL_01df: Unknown result type (might be due to invalid IL or missing references)
//IL_01e5: Invalid comparison between Unknown and I4
//IL_028a: Unknown result type (might be due to invalid IL or missing references)
//IL_0290: Invalid comparison between Unknown and I4
//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
//IL_020a: 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_026e: Unknown result type (might be due to invalid IL or missing references)
//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
//IL_0321: 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)
if (!Settings.AddPin.Value && !force)
{
return;
}
bool flag = false;
PinData val = new PinData
{
m_type = IsPinable(strID)
};
if (Object.op_Implicit((Object)(object)hover) && Object.op_Implicit((Object)(object)hover.GetComponent<ItemDrop>()))
{
val.m_type = (PinType)8;
}
PinData closestPin = Minimap.instance.GetClosestPin(pos, Settings.ClosestPinRange.Value);
if (strID == "$piece_portal")
{
Hoverable hoverable = default(Hoverable);
if (hover.TryGetComponent<Hoverable>(ref hoverable))
{
val.m_name = GetPortalTag(hoverable);
if (closestPin != null)
{
Minimap.instance.RemovePin(closestPin);
}
val.m_pos = pos;
val = Minimap.instance.AddPin(val.m_pos, val.m_type, val.m_name, true, false, 0L, "");
flag = true;
QuickPingPlugin.Log.LogInfo((object)$"Add Portal Pin : Name:{val.m_name} x:{val.m_pos.x}, y:{val.m_pos.y}, Type:{val.m_type}");
}
}
else if (closestPin == null || rename)
{
PinData val2 = val;
if (val2.m_name == null)
{
val2.m_name = Localization.instance.Localize(strID);
}
bool flag2 = DataManager.CustomNames.ContainsKey(strID);
if (flag2)
{
val.m_name = DataManager.CustomNames[strID];
}
val.m_pos = pos;
if (val.m_name == null || (val.m_name == "" && !flag2))
{
val.m_name = "PING !";
}
if ((int)val.m_type == 8 && force)
{
val.m_type = Settings.DefaultPinType.Value;
val = Minimap.instance.AddPin(val.m_pos, val.m_type, val.m_name, true, false, 0L, "");
flag = true;
QuickPingPlugin.Log.LogInfo((object)$"Add Pin : Name:{val.m_name} x:{val.m_pos.x}, y:{val.m_pos.y}, Type:{val.m_type}");
}
else if ((int)val.m_type != 8)
{
if (closestPin == null)
{
val = Minimap.instance.AddPin(val.m_pos, val.m_type, val.m_name, true, false, 0L, "");
flag = true;
}
else if (rename)
{
val = closestPin;
}
QuickPingPlugin.Log.LogInfo((object)$"Add Pin : Name:{val.m_name} x:{val.m_pos.x}, y:{val.m_pos.y}, Type:{val.m_type}");
if (rename)
{
GUIManager.BlockInput(true);
InitNameInput();
tempOriginalText = strID;
Minimap.instance.ShowPinNameInput(val.m_pos);
}
}
}
if (!(idestructible != null && flag))
{
return;
}
FieldInfo field = ((object)idestructible).GetType().GetField("m_nview", BindingFlags.Instance | BindingFlags.NonPublic);
if (field == null)
{
QuickPingPlugin.Log.LogWarning((object)$"Unable to link destructible {idestructible} to pin: {val.m_name}. (Is it a god?)");
return;
}
object? value = field.GetValue(idestructible);
ZNetView val3 = (ZNetView)((value is ZNetView) ? value : null);
ZDOID uid = val3.GetZDO().m_uid;
bool flag3 = false;
if (!DataManager.PinnedObjects.ContainsKey(uid))
{
DataManager.PinnedObjects[uid] = val;
}
}
public static void UpdateNameInput()
{
if (Minimap.instance.m_namePin == null)
{
Minimap.instance.m_wasFocused = false;
}
if (Minimap.instance.m_namePin != null)
{
panel.SetActive(true);
nameInput.SetActive(true);
toggleSaveName.SetActive(true);
InputField component = nameInput.GetComponent<InputField>();
Toggle component2 = toggleSaveName.GetComponent<Toggle>();
if (!component.isFocused)
{
EventSystem.current.SetSelectedGameObject(nameInput);
}
if (Input.GetKeyDown((KeyCode)13) || Input.GetKeyDown((KeyCode)271))
{
ValidateNameInput(component, component2.isOn);
}
else if (Input.GetKeyDown((KeyCode)27))
{
CancelNameInput();
}
Minimap.instance.m_wasFocused = true;
}
else
{
panel.gameObject.SetActive(false);
IsNaming = false;
tempOriginalText = null;
GUIManager.BlockInput(false);
DestroyGUI();
}
}
private static void CancelNameInput()
{
Minimap.instance.m_namePin = null;
Minimap.instance.m_wasFocused = false;
panel.gameObject.SetActive(false);
IsNaming = false;
tempOriginalText = null;
GUIManager.BlockInput(false);
DestroyGUI();
}
private static void DestroyGUI()
{
Object.Destroy((Object)(object)nameInput);
Object.Destroy((Object)(object)panel);
Object.Destroy((Object)(object)toggleSaveName);
}
private static void ValidateNameInput(InputField inputField, bool save)
{
string text = inputField.text;
text = text.Replace('$', ' ');
text = text.Replace('<', ' ');
text = text.Replace('>', ' ');
string text2 = tempOriginalText;
Minimap.instance.m_namePin.m_name = text;
if (save)
{
QuickPingPlugin.Log.LogInfo((object)("Save name " + Minimap.instance.m_namePin.m_name + " for " + text2));
SaveName(Minimap.instance.m_namePin.m_name, text2);
}
Minimap.instance.m_namePin = null;
}
private static void SaveName(string m_name, string originalName)
{
if (DataManager.CustomNames.ContainsKey(originalName))
{
DataManager.CustomNames[originalName] = m_name;
}
else
{
DataManager.CustomNames.Add(originalName, m_name);
}
}
private static void InitNameInput()
{
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: 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_00d0: Expected O, but got Unknown
//IL_00fa: 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_0118: Unknown result type (might be due to invalid IL or missing references)
//IL_0187: Unknown result type (might be due to invalid IL or missing references)
//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
//IL_01da: Unknown result type (might be due to invalid IL or missing references)
if (GUIManager.Instance == null)
{
QuickPingPlugin.Log.LogError((object)"GUIManager instance is null");
return;
}
if (!Object.op_Implicit((Object)(object)GUIManager.CustomGUIFront))
{
QuickPingPlugin.Log.LogError((object)"GUIManager CustomGUI is null");
return;
}
IsNaming = true;
panel = GUIManager.Instance.CreateWoodpanel(GUIManager.CustomGUIFront.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, 0f), 200f, 90f, true);
VerticalLayoutGroup val = panel.gameObject.AddComponent<VerticalLayoutGroup>();
((HorizontalOrVerticalLayoutGroup)val).spacing = 10f;
((LayoutGroup)val).padding = new RectOffset(10, 10, 10, 10);
((HorizontalOrVerticalLayoutGroup)val).childControlWidth = true;
((HorizontalOrVerticalLayoutGroup)val).childControlHeight = true;
nameInput = GUIManager.Instance.CreateInputField(panel.transform, new Vector2(0.5f, 0.9f), new Vector2(0.5f, 0.9f), new Vector2(0f, 0f), (ContentType)0, "Pin Name", 16, 90f, 30f);
nameInput.SetActive(IsNaming);
toggleSaveName = GUIManager.Instance.CreateToggle(panel.transform, 20f, 20f);
Text component = ((Component)toggleSaveName.transform.Find("Label")).GetComponent<Text>();
((Graphic)component).color = Color.white;
component.text = "Save";
((Behaviour)component).enabled = true;
toggleSaveName.SetActive(IsNaming);
Transform transform = toggleSaveName.transform;
transform.position += new Vector3(20f, 0f, 0f);
}
private static string GetPortalTag(Hoverable hoverable)
{
string hoverText = hoverable.GetHoverText();
return hoverText.Split(new char[1] { '"' })[1];
}
[HarmonyPatch(typeof(Minimap))]
[HarmonyPatch("RemovePin", new Type[] { typeof(PinData) })]
[HarmonyPrefix]
public static bool RemovePin(Minimap __instance, PinData pin)
{
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
if (pin == null || pin.m_name == null || pin.m_name == "")
{
return true;
}
foreach (KeyValuePair<ZDOID, PinData> p in DataManager.PinnedObjects)
{
if (p.Value.Compare(pin))
{
pin = __instance.GetClosestPin(p.Value.m_pos, Settings.ClosestPinRange.Value);
DataManager.PinnedObjects.Remove(DataManager.PinnedObjects.FirstOrDefault((KeyValuePair<ZDOID, PinData> x) => x.Value.Compare(p.Value)).Key);
break;
}
}
if (Object.op_Implicit((Object)(object)pin.m_uiElement))
{
__instance.DestroyPinMarker(pin);
}
__instance.m_pins.Remove(pin);
return false;
}
}
internal static class Player_Patch
{
public static UnityEvent<HoverObject> OnPlayerPing = new UnityEvent<HoverObject>();
public static UnityEvent<HoverObject> OnPlayerForcePing = new UnityEvent<HoverObject>();
public static UnityEvent<HoverObject> OnPlayerRename = new UnityEvent<HoverObject>();
[HarmonyPatch(typeof(Player), "Update")]
[HarmonyPostfix]
private static void Player_Update(Player __instance)
{
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Invalid comparison between Unknown and I4
if (ZInput.instance == null || !Object.op_Implicit((Object)(object)Player.m_localPlayer) || (Object)(object)Player.m_localPlayer != (Object)(object)__instance || (!Settings.PingWhereLooking.Value && !Settings.AddPin.Value))
{
return;
}
if (Minimap_Patch.IsNaming)
{
Minimap_Patch.UpdateNameInput();
}
if (((Character)Player.m_localPlayer).TakeInput() && (int)Settings.PingKey.Value > 0)
{
if (ZInput.GetButtonDown(Settings.RenameBtn.Name))
{
HoverObject hoverObject = FindHoverObject(500f);
hoverObject.Name = GetHoverName(hoverObject.Name, hoverObject.Hover, hoverObject.type);
OnPlayerRename.Invoke(hoverObject);
}
else if (ZInput.GetButtonDown(Settings.PingBtn.Name))
{
HoverObject hoverObject2 = FindHoverObject(500f);
hoverObject2.Name = GetHoverName(hoverObject2.Name, hoverObject2.Hover, hoverObject2.type);
OnPlayerPing.Invoke(hoverObject2);
}
else if (ZInput.GetButtonDown(Settings.PingEverythingBtn.Name))
{
HoverObject hoverObject3 = FindHoverObject(500f);
hoverObject3.Name = GetHoverName(hoverObject3.Name, hoverObject3.Hover, hoverObject3.type);
OnPlayerForcePing.Invoke(hoverObject3);
}
}
}
private static string GetHoverName(string pingText, GameObject hover, HoverType type)
{
switch (type)
{
case HoverType.Hoverable:
{
Hoverable val = default(Hoverable);
hover.TryGetComponent<Hoverable>(ref val);
pingText = ((!val.GetHoverName().StartsWith("$")) ? Localization_Patch.GetBaseTranslation(val.GetHoverName()) : val.GetHoverName());
if (pingText == "$")
{
pingText = val.GetHoverName();
}
if (pingText == "noStr")
{
pingText = val.GetHoverName();
}
if (((object)val).ToString().Contains("ReadMap") || ((object)val).ToString().Contains("WriteMap") || ((object)val).ToString().Contains("add_ore") || ((object)val).ToString().Contains("add_wood") || (((object)val).ToString().Contains("door") && Object.op_Implicit((Object)(object)hover.transform.parent) && Object.op_Implicit((Object)(object)((Component)hover.transform).GetComponentInParent<Piece>())))
{
pingText = hover.GetComponentInParent<Piece>().m_name;
}
break;
}
case HoverType.Piece:
{
Piece component3 = hover.GetComponent<Piece>();
pingText = component3.m_name;
break;
}
case HoverType.Location:
{
Location component2 = hover.GetComponent<Location>();
pingText = Localization_Patch.Localize(component2);
break;
}
case HoverType.Character:
{
Character component = hover.GetComponent<Character>();
pingText = component.m_name;
break;
}
}
return pingText;
}
public static HoverObject FindHoverObject(float range)
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: 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)
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_0120: 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)
//IL_013d: Unknown result type (might be due to invalid IL or missing references)
//IL_0142: Unknown result type (might be due to invalid IL or missing references)
//IL_0149: Unknown result type (might be due to invalid IL or missing references)
//IL_014e: Unknown result type (might be due to invalid IL or missing references)
//IL_016d: Unknown result type (might be due to invalid IL or missing references)
//IL_0172: Unknown result type (might be due to invalid IL or missing references)
//IL_017a: 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_0199: Unknown result type (might be due to invalid IL or missing references)
//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
//IL_0600: Unknown result type (might be due to invalid IL or missing references)
//IL_0605: Unknown result type (might be due to invalid IL or missing references)
//IL_0470: Unknown result type (might be due to invalid IL or missing references)
//IL_0475: Unknown result type (might be due to invalid IL or missing references)
//IL_05e4: Unknown result type (might be due to invalid IL or missing references)
//IL_023b: Unknown result type (might be due to invalid IL or missing references)
//IL_0240: Unknown result type (might be due to invalid IL or missing references)
//IL_029a: Unknown result type (might be due to invalid IL or missing references)
//IL_029f: Unknown result type (might be due to invalid IL or missing references)
//IL_033b: Unknown result type (might be due to invalid IL or missing references)
//IL_0340: Unknown result type (might be due to invalid IL or missing references)
HoverObject hoverObject = new HoverObject
{
type = HoverType.GameObject,
pos = ((Character)Player.m_localPlayer).GetHeadPoint(),
center = ((Character)Player.m_localPlayer).GetHeadPoint(),
Name = "PING !"
};
LayerMask val = LayerMask.op_Implicit(LayerMask.GetMask(new string[12]
{
"Default", "static_solid", "Default_small", "piece", "piece_nonsolid", "terrain", "character", "character_net", "character_ghost", "character_noenv",
"vehicle", "item"
}));
RaycastHit[] array = Physics.RaycastAll(((Component)GameCamera.instance).transform.position, ((Component)GameCamera.instance).transform.forward, range + 10f, LayerMask.op_Implicit(val));
Array.Sort(array, (RaycastHit x, RaycastHit y) => ((RaycastHit)(ref x)).distance.CompareTo(((RaycastHit)(ref y)).distance));
RaycastHit[] array2 = array;
if (array2.Length == 0)
{
Ray val2 = default(Ray);
((Ray)(ref val2))..ctor(((Component)GameCamera.instance).transform.position, ((Component)GameCamera.instance).transform.forward);
hoverObject.pos = ((Ray)(ref val2)).GetPoint(range);
hoverObject.center = hoverObject.pos;
return hoverObject;
}
for (int i = 0; i < 1; i++)
{
hoverObject.pos = ((RaycastHit)(ref array2[i])).point;
RaycastHit raycastHit = array2[i];
if (OverlappingPlayer(ref raycastHit))
{
continue;
}
if (!(Vector3.Distance(((Character)Player.m_localPlayer).GetEyePoint(), ((RaycastHit)(ref raycastHit)).point) < range))
{
break;
}
Character val3 = (Object.op_Implicit((Object)(object)((RaycastHit)(ref raycastHit)).collider.attachedRigidbody) ? ((Component)((RaycastHit)(ref raycastHit)).collider.attachedRigidbody).GetComponent<Character>() : ((Component)((RaycastHit)(ref raycastHit)).collider).GetComponent<Character>());
if ((Object)(object)val3 != (Object)null && (!Object.op_Implicit((Object)(object)val3.GetBaseAI()) || !val3.GetBaseAI().IsSleeping()))
{
hoverObject.type = HoverType.Character;
hoverObject.Hover = ((Component)val3).gameObject;
hoverObject.center = ((Component)val3).transform.position;
}
else if ((hoverObject.type = CheckType(((Component)((RaycastHit)(ref raycastHit)).collider).transform, out hoverObject.Destructible)) != 0)
{
hoverObject.Hover = ((Component)((Component)((RaycastHit)(ref raycastHit)).collider).transform).gameObject;
hoverObject.center = hoverObject.Hover.transform.position;
QuickPingPlugin.Log.LogWarning((object)"Root");
}
else if ((Object)(object)((Component)((RaycastHit)(ref raycastHit)).collider).GetComponentInChildren<GameObject>() != (Object)null)
{
GameObject[] componentsInChildren = ((Component)((RaycastHit)(ref raycastHit)).collider).GetComponentsInChildren<GameObject>();
GameObject[] array3 = componentsInChildren;
foreach (GameObject val4 in array3)
{
if ((hoverObject.type = CheckType(val4.transform, out hoverObject.Destructible)) != 0)
{
hoverObject.Hover = ((Component)val4.transform).gameObject;
hoverObject.center = hoverObject.Hover.transform.position;
QuickPingPlugin.Log.LogWarning((object)"Child");
}
}
}
else if ((Object)(object)((Component)((RaycastHit)(ref raycastHit)).collider).transform.parent != (Object)null)
{
hoverObject.Destructible = GO_Ext.GetRecursiveComponentInParents<IDestructible>(((Component)((RaycastHit)(ref raycastHit)).collider).transform);
if (Object.op_Implicit((Object)(object)(hoverObject.Hover = GO_Ext.GetRecursiveParentWithComponent<Location>(((Component)((RaycastHit)(ref raycastHit)).collider).transform))))
{
hoverObject.type = HoverType.Location;
}
else if (Object.op_Implicit((Object)(object)(hoverObject.Hover = GO_Ext.GetRecursiveParentWithComponent<Piece>(((Component)((RaycastHit)(ref raycastHit)).collider).transform))))
{
hoverObject.type = HoverType.Piece;
}
else if (Object.op_Implicit((Object)(object)(hoverObject.Hover = GO_Ext.GetRecursiveParentWithComponent<Hoverable>(((Component)((RaycastHit)(ref raycastHit)).collider).transform))))
{
hoverObject.type = HoverType.Hoverable;
}
}
break;
}
if (Object.op_Implicit((Object)(object)hoverObject.Hover))
{
hoverObject.center = hoverObject.Hover.transform.position;
switch (hoverObject.type)
{
case HoverType.GameObject:
QuickPingPlugin.Log.LogWarning((object)$"Ping ! : {hoverObject.Hover} (GameObject)");
break;
case HoverType.Hoverable:
{
Hoverable val7 = default(Hoverable);
if (hoverObject.Hover.TryGetComponent<Hoverable>(ref val7))
{
QuickPingPlugin.Log.LogWarning((object)$"Ping ! : {val7} (Hoverable) -> Name: {val7.GetHoverName()}");
}
break;
}
case HoverType.Piece:
{
Piece val8 = default(Piece);
if (hoverObject.Hover.TryGetComponent<Piece>(ref val8))
{
QuickPingPlugin.Log.LogWarning((object)$"Ping ! : {val8} (Piece) -> Name: {((Object)val8).name} -> Trad: {Localization.instance.Localize(((Object)val8).name)}");
}
break;
}
case HoverType.Location:
{
Location val6 = default(Location);
if (hoverObject.Hover.TryGetComponent<Location>(ref val6))
{
QuickPingPlugin.Log.LogWarning((object)$"Ping ! : {val6} (Location) -> Name: {((Object)val6).name} -> Trad: {Localization.instance.Localize(((Object)val6).name)}");
}
break;
}
case HoverType.Character:
{
Character val5 = default(Character);
if (hoverObject.Hover.TryGetComponent<Character>(ref val5))
{
QuickPingPlugin.Log.LogWarning((object)$"Ping ! : {val5} (Character) -> Name: {val5.m_name} -> Trad: {val5.GetHoverName()}");
}
break;
}
}
if (hoverObject.Destructible != null)
{
QuickPingPlugin.Log.LogWarning((object)$"Ping ! : {hoverObject.Destructible} (Destructible) -> Type: {hoverObject.Destructible.GetDestructibleType()}");
}
}
else
{
hoverObject.center = hoverObject.pos;
}
return hoverObject;
}
private static HoverType CheckType(Transform root, out IDestructible destructible)
{
destructible = ((Component)root).GetComponent<IDestructible>();
if (((Component)root).GetComponent<Hoverable>() != null)
{
return HoverType.Hoverable;
}
if ((Object)(object)((Component)root).GetComponent<Location>() != (Object)null)
{
return HoverType.Location;
}
if (Object.op_Implicit((Object)(object)((Component)root).GetComponent<Piece>()))
{
return HoverType.Piece;
}
return HoverType.GameObject;
}
private static bool OverlappingPlayer(ref RaycastHit raycastHit)
{
return Object.op_Implicit((Object)(object)((RaycastHit)(ref raycastHit)).collider.attachedRigidbody) && (Object)(object)((Component)((RaycastHit)(ref raycastHit)).collider.attachedRigidbody).gameObject == (Object)(object)((Component)Player.m_localPlayer).gameObject;
}
internal static void SendRename(HoverObject ping)
{
SendPing(ping);
}
public static void SendPing(HoverObject ping)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
SendPing(ping.pos, Localization.instance.Localize(ping.Name));
}
internal static void SendPing(Vector3 position, string text, bool local = false)
{
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: 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_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
Player localPlayer = Player.m_localPlayer;
if (Object.op_Implicit((Object)(object)localPlayer) && Settings.PingWhereLooking.Value)
{
QuickPingPlugin.Log.LogInfo((object)("SendPing : " + text));
ZRoutedRpc instance = ZRoutedRpc.instance;
long num;
if (!local)
{
num = ZRoutedRpc.Everybody;
}
else
{
ZDOID zDOID = ((Character)Player.m_localPlayer).GetZDOID();
num = ((ZDOID)(ref zDOID)).UserID;
}
instance.InvokeRoutedRPC(num, "ChatMessage", new object[5]
{
position,
3,
UserInfo.GetLocalUser(),
text,
PrivilegeManager.GetNetworkUserId()
});
if (Player.m_debugMode && (Object)(object)Console.instance != (Object)null && ((Terminal)Console.instance).IsCheatsEnabled() && (Object)(object)Console.instance != (Object)null)
{
((Terminal)Console.instance).AddString($"Pinged at: {position.x}, {position.z}");
}
}
}
}
internal class Terminal_Patch
{
[HarmonyPatch(typeof(Terminal), "AddString", new Type[]
{
typeof(string),
typeof(string),
typeof(Type),
typeof(bool)
})]
[HarmonyPrefix]
public static bool AddString(Terminal __instance, string user, string text, Type type, bool timestamp = false)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: 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_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Invalid comparison between Unknown and I4
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: 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)
Color value;
if ((int)type != 0)
{
if ((int)type == 2)
{
value = Settings.ShoutColor.Value;
text = text.ToUpper();
}
else
{
value = Settings.DefaultColor.Value;
}
}
else
{
value = Settings.WhisperColor.Value;
text = text.ToLowerInvariant();
}
string text2 = (timestamp ? ("[" + DateTime.Now.ToString("MM-dd-yyyy HH:mm:ss") + "] ") : "");
text2 = text2 + "<color=#" + ColorUtility.ToHtmlStringRGBA(Settings.PlayerColor.Value) + ">" + user + "</color>: <color=#" + ColorUtility.ToHtmlStringRGBA(value) + ">" + text + "</color>";
__instance.AddString(text2);
return false;
}
}
public class ZNet_Patch
{
[HarmonyPatch(typeof(ZNet), "LoadWorld")]
[HarmonyPostfix]
private static void LoadWorld(ZNet __instance)
{
DataManager.Load(ZNet.m_world, Game.instance.GetPlayerProfile());
}
[HarmonyPatch(typeof(ZNet), "SaveWorldThread")]
[HarmonyPostfix]
private static void SaveWorldThread()
{
bool flag = DataManager.Save(ZNet.m_world, Game.instance.GetPlayerProfile());
QuickPingPlugin.Log.LogInfo((object)$"cloud save : {!flag}");
}
}
}