using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
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.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using Fishing;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Microsoft.CodeAnalysis;
using Riverboat.Players;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("SwampMap")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Um mapa detalhado para Voodoo Fishin'")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SwampMap")]
[assembly: AssemblyTitle("SwampMap")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.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;
}
}
}
namespace SwampMap
{
[BepInPlugin("com.swamp.map", "Swamp Map", "1.0.0")]
public class Plugin : BasePlugin
{
public const string PluginGuid = "com.swamp.map";
public const string PluginName = "Swamp Map";
public const string PluginVersion = "1.0.0";
internal static ManualLogSource ModLogger;
public override void Load()
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
ModLogger = ((BasePlugin)this).Log;
ManualLogSource log = ((BasePlugin)this).Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(41, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Mod] O mod '");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("Swamp Map");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' foi carregado com sucesso!");
}
log.LogInfo(val);
new Harmony("com.swamp.map").PatchAll();
((BasePlugin)this).Log.LogInfo((object)"[Mod] Patches de Mapa aplicados!");
}
}
[HarmonyPatch(typeof(LocalPlayerInput))]
public static class MapFeaturePatch
{
private static GameObject mapCanvas;
private static bool isMapOpen = false;
private static bool isMapDetached = false;
private static RectTransform mapRect;
private static Transform mapImageTransform;
private static Texture2D arrowTexture;
private static Dictionary<PlayerRelay, RectTransform> playerIcons = new Dictionary<PlayerRelay, RectTransform>();
private static float lastPlayerCheckTime = 0f;
private static GameObject habitatPanel;
private static Text habitatText;
private static object habitatPluginInstance;
private static MethodInfo loadTagsMethod;
private static bool habitatPluginChecked = false;
private static float mapZoom = 1f;
private static Vector2 mapPan = Vector2.zero;
[HarmonyPatch("Awake")]
[HarmonyPostfix]
public static void AwakePostfix(LocalPlayerInput __instance)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Expected O, but got Unknown
//IL_0070: 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)
//IL_0084: 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_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: 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_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_012c: 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_0147: 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_0119: Expected O, but got Unknown
//IL_015e: Unknown result type (might be due to invalid IL or missing references)
//IL_0178: Unknown result type (might be due to invalid IL or missing references)
//IL_0191: Unknown result type (might be due to invalid IL or missing references)
//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
//IL_022c: Unknown result type (might be due to invalid IL or missing references)
//IL_0233: Expected O, but got Unknown
//IL_026c: Unknown result type (might be due to invalid IL or missing references)
//IL_0288: Unknown result type (might be due to invalid IL or missing references)
//IL_029c: Unknown result type (might be due to invalid IL or missing references)
//IL_02ab: 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_02c3: Unknown result type (might be due to invalid IL or missing references)
//IL_0307: Unknown result type (might be due to invalid IL or missing references)
//IL_0322: Unknown result type (might be due to invalid IL or missing references)
//IL_032d: Unknown result type (might be due to invalid IL or missing references)
//IL_0337: 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_0207: Expected O, but got Unknown
Plugin.ModLogger.LogInfo((object)"[MapFeature] Inicializando sistema de mapa estático (Release)...");
if ((Object)(object)mapCanvas == (Object)null)
{
mapCanvas = new GameObject("MapCanvas");
Object.DontDestroyOnLoad((Object)(object)mapCanvas);
Canvas obj = mapCanvas.AddComponent<Canvas>();
obj.renderMode = (RenderMode)0;
obj.sortingOrder = 1000;
CanvasScaler obj2 = mapCanvas.AddComponent<CanvasScaler>();
obj2.uiScaleMode = (ScaleMode)1;
obj2.referenceResolution = new Vector2((float)Screen.width, (float)Screen.height);
GameObject val = new GameObject("MapBackground");
val.transform.SetParent(mapCanvas.transform, false);
((Graphic)val.AddComponent<RawImage>()).color = new Color(0f, 0f, 0f, 1f);
RectTransform component = val.GetComponent<RectTransform>();
component.anchorMin = Vector2.zero;
component.anchorMax = Vector2.one;
component.sizeDelta = Vector2.zero;
Texture2D val2 = null;
string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string path = Path.Combine(directoryName, "mapa.png");
if (File.Exists(path))
{
byte[] array = File.ReadAllBytes(path);
val2 = new Texture2D(2, 2);
ImageConversion.LoadImage(val2, Il2CppStructArray<byte>.op_Implicit(array));
}
GameObject val3 = new GameObject("MapImage");
val3.transform.SetParent(mapCanvas.transform, false);
RawImage val4 = val3.AddComponent<RawImage>();
if ((Object)(object)val2 != (Object)null)
{
val4.texture = (Texture)(object)val2;
}
mapRect = val3.GetComponent<RectTransform>();
mapRect.anchorMin = new Vector2(0.5f, 0.5f);
mapRect.anchorMax = new Vector2(0.5f, 0.5f);
if ((Object)(object)val2 != (Object)null)
{
mapRect.sizeDelta = new Vector2((float)((Texture)val2).width, (float)((Texture)val2).height);
}
else
{
mapRect.sizeDelta = new Vector2(1000f, 1000f);
}
Texture2D val5 = null;
string path2 = Path.Combine(directoryName, "arrow.png");
if (File.Exists(path2))
{
byte[] array2 = File.ReadAllBytes(path2);
val5 = new Texture2D(2, 2);
ImageConversion.LoadImage(val5, Il2CppStructArray<byte>.op_Implicit(array2));
}
arrowTexture = val5;
mapImageTransform = val3.transform;
GameObject val6 = new GameObject("HabitatPanel");
val6.transform.SetParent(mapCanvas.transform, false);
habitatPanel = val6;
((Graphic)val6.AddComponent<Image>()).color = new Color(0.1f, 0.1f, 0.1f, 0.9f);
RectTransform component2 = val6.GetComponent<RectTransform>();
component2.sizeDelta = new Vector2(400f, 45f);
component2.pivot = new Vector2(0.5f, 0f);
GameObject val7 = new GameObject("HabitatText");
val7.transform.SetParent(val6.transform, false);
habitatText = val7.AddComponent<Text>();
habitatText.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
habitatText.fontSize = 18;
((Graphic)habitatText).color = new Color(0.9f, 0.9f, 0.9f, 1f);
habitatText.alignment = (TextAnchor)4;
RectTransform component3 = val7.GetComponent<RectTransform>();
component3.anchorMin = Vector2.zero;
component3.anchorMax = Vector2.one;
component3.sizeDelta = Vector2.zero;
habitatPanel.SetActive(false);
mapCanvas.SetActive(false);
}
}
private static float MapWorldToScreenX(float worldX)
{
float num = -89.42f;
float num2 = 0.3062f;
float num3 = 98.83f;
float num4 = 0.7435f;
return num2 + (worldX - num) * (num4 - num2) / (num3 - num);
}
private static float MapWorldToScreenZ(float worldZ)
{
float num = -98.09f;
float num2 = 0.2592f;
float num3 = 101.55f;
float num4 = 0.7229f;
return num2 + (worldZ - num) * (num4 - num2) / (num3 - num);
}
[HarmonyPatch("LateUpdate")]
[HarmonyPostfix]
public static void LateUpdatePostfix(LocalPlayerInput __instance)
{
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_034f: Unknown result type (might be due to invalid IL or missing references)
//IL_0354: Unknown result type (might be due to invalid IL or missing references)
//IL_011e: Unknown result type (might be due to invalid IL or missing references)
//IL_03a2: Unknown result type (might be due to invalid IL or missing references)
//IL_03a7: Unknown result type (might be due to invalid IL or missing references)
//IL_03cf: Unknown result type (might be due to invalid IL or missing references)
//IL_03d4: Unknown result type (might be due to invalid IL or missing references)
//IL_03eb: Unknown result type (might be due to invalid IL or missing references)
//IL_03f0: Unknown result type (might be due to invalid IL or missing references)
//IL_03fa: Unknown result type (might be due to invalid IL or missing references)
//IL_03ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0400: Unknown result type (might be due to invalid IL or missing references)
//IL_0407: Unknown result type (might be due to invalid IL or missing references)
//IL_0409: Unknown result type (might be due to invalid IL or missing references)
//IL_0423: Unknown result type (might be due to invalid IL or missing references)
//IL_042e: Unknown result type (might be due to invalid IL or missing references)
//IL_0481: Unknown result type (might be due to invalid IL or missing references)
//IL_0486: Unknown result type (might be due to invalid IL or missing references)
//IL_0488: Unknown result type (might be due to invalid IL or missing references)
//IL_048d: Unknown result type (might be due to invalid IL or missing references)
//IL_0494: Unknown result type (might be due to invalid IL or missing references)
//IL_0499: Unknown result type (might be due to invalid IL or missing references)
//IL_049e: Unknown result type (might be due to invalid IL or missing references)
//IL_0441: Unknown result type (might be due to invalid IL or missing references)
//IL_0443: Unknown result type (might be due to invalid IL or missing references)
//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
//IL_04dd: Unknown result type (might be due to invalid IL or missing references)
//IL_04c3: Unknown result type (might be due to invalid IL or missing references)
//IL_04c4: Unknown result type (might be due to invalid IL or missing references)
//IL_04ce: Unknown result type (might be due to invalid IL or missing references)
//IL_04d3: 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_01f6: Unknown result type (might be due to invalid IL or missing references)
//IL_0233: Unknown result type (might be due to invalid IL or missing references)
//IL_0249: Unknown result type (might be due to invalid IL or missing references)
//IL_025f: Unknown result type (might be due to invalid IL or missing references)
//IL_0562: Unknown result type (might be due to invalid IL or missing references)
//IL_0567: Unknown result type (might be due to invalid IL or missing references)
//IL_056d: Unknown result type (might be due to invalid IL or missing references)
//IL_057b: Unknown result type (might be due to invalid IL or missing references)
//IL_0586: Unknown result type (might be due to invalid IL or missing references)
//IL_058b: Unknown result type (might be due to invalid IL or missing references)
//IL_059d: Unknown result type (might be due to invalid IL or missing references)
//IL_05a8: Unknown result type (might be due to invalid IL or missing references)
//IL_05ad: Unknown result type (might be due to invalid IL or missing references)
//IL_062d: Unknown result type (might be due to invalid IL or missing references)
//IL_0651: Unknown result type (might be due to invalid IL or missing references)
//IL_06b2: Unknown result type (might be due to invalid IL or missing references)
//IL_06c6: Unknown result type (might be due to invalid IL or missing references)
//IL_06d2: Unknown result type (might be due to invalid IL or missing references)
//IL_06d7: Unknown result type (might be due to invalid IL or missing references)
if (Keyboard.current != null)
{
bool wasPressedThisFrame = ((ButtonControl)Keyboard.current.mKey).wasPressedThisFrame;
bool flag = isMapOpen && ((ButtonControl)Keyboard.current.escapeKey).wasPressedThisFrame;
if (wasPressedThisFrame || flag)
{
if (flag)
{
isMapOpen = false;
}
else
{
isMapOpen = !isMapOpen;
}
if ((Object)(object)mapCanvas != (Object)null)
{
mapCanvas.SetActive(isMapOpen);
if (isMapOpen)
{
Cursor.visible = true;
Cursor.lockState = (CursorLockMode)0;
isMapDetached = false;
}
else
{
Cursor.visible = false;
Cursor.lockState = (CursorLockMode)1;
habitatPanel.SetActive(false);
}
}
}
}
if (!isMapOpen || Mouse.current == null || !((Object)(object)mapRect != (Object)null))
{
return;
}
float y = ((InputControl<Vector2>)(object)Mouse.current.scroll).ReadValue().y;
if (Mathf.Abs(y) > 0.1f)
{
float num = y * 0.001f;
mapZoom += num;
if (mapZoom < 0.1f)
{
mapZoom = 0.1f;
}
((Transform)mapRect).localScale = new Vector3(mapZoom, mapZoom, 1f);
}
if (Time.time - lastPlayerCheckTime > 1f)
{
lastPlayerCheckTime = Time.time;
Il2CppArrayBase<PlayerRelay> obj = Object.FindObjectsOfType<PlayerRelay>();
HashSet<PlayerRelay> hashSet = new HashSet<PlayerRelay>();
foreach (PlayerRelay item in obj)
{
if ((Object)(object)item == (Object)null || (Object)(object)((Component)item).gameObject == (Object)null)
{
continue;
}
hashSet.Add(item);
if (!playerIcons.ContainsKey(item))
{
GameObject val = new GameObject($"PlayerIcon_{((Object)item).GetInstanceID()}");
val.transform.SetParent(mapImageTransform, false);
RawImage val2 = val.AddComponent<RawImage>();
((Graphic)val2).color = (item.IsLocalPlayer ? Color.red : Color.yellow);
if ((Object)(object)arrowTexture != (Object)null)
{
val2.texture = (Texture)(object)arrowTexture;
}
RectTransform component = val.GetComponent<RectTransform>();
component.anchorMin = new Vector2(0.5f, 0.5f);
component.anchorMax = new Vector2(0.5f, 0.5f);
component.sizeDelta = new Vector2(18f, 18f);
playerIcons[item] = component;
}
}
List<PlayerRelay> list = new List<PlayerRelay>();
foreach (KeyValuePair<PlayerRelay, RectTransform> playerIcon in playerIcons)
{
if ((Object)(object)playerIcon.Key == (Object)null || !hashSet.Contains(playerIcon.Key))
{
if ((Object)(object)playerIcon.Value != (Object)null)
{
Object.Destroy((Object)(object)((Component)playerIcon.Value).gameObject);
}
list.Add(playerIcon.Key);
}
}
foreach (PlayerRelay item2 in list)
{
playerIcons.Remove(item2);
}
}
Vector2 val3 = Vector2.zero;
Rect rect;
foreach (KeyValuePair<PlayerRelay, RectTransform> playerIcon2 in playerIcons)
{
PlayerRelay key = playerIcon2.Key;
RectTransform value = playerIcon2.Value;
if ((Object)(object)key != (Object)null && (Object)(object)value != (Object)null)
{
Vector3 position = ((Component)key).transform.position;
float num2 = MapWorldToScreenX(position.x);
float num3 = MapWorldToScreenZ(position.z);
float num4 = num2 - 0.5f;
rect = mapRect.rect;
float num5 = num4 * ((Rect)(ref rect)).width;
float num6 = num3 - 0.5f;
rect = mapRect.rect;
Vector2 val4 = (value.anchoredPosition = new Vector2(num5, num6 * ((Rect)(ref rect)).height));
Vector2 val6 = val4;
((Transform)value).localEulerAngles = new Vector3(0f, 0f, 0f - ((Component)key).transform.eulerAngles.y);
if (key.IsLocalPlayer)
{
val3 = val6;
}
}
}
if (Mouse.current.leftButton.isPressed)
{
isMapDetached = true;
Vector2 val7 = ((InputControl<Vector2>)(object)((Pointer)Mouse.current).delta).ReadValue();
mapPan += val7 / mapZoom;
}
else if (((ButtonControl)Keyboard.current.spaceKey).wasPressedThisFrame)
{
isMapDetached = false;
}
if (!isMapDetached)
{
mapPan = -val3 * mapZoom;
}
mapRect.anchoredPosition = mapPan;
if (!habitatPluginChecked)
{
habitatPluginChecked = true;
PluginInfo value2 = null;
if (((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.TryGetValue("com.habitat.info", out value2))
{
habitatPluginInstance = value2.Instance;
loadTagsMethod = habitatPluginInstance.GetType().GetMethod("LoadTagsFromArea", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
}
}
if (habitatPluginInstance == null || loadTagsMethod == null || (Object)(object)habitatPanel == (Object)null)
{
return;
}
Vector2 val8 = ((InputControl<Vector2>)(object)((Pointer)Mouse.current).position).ReadValue();
Vector2 val9 = default(Vector2);
if (RectTransformUtility.ScreenPointToLocalPointInRectangle(mapRect, val8, (Camera)null, ref val9))
{
float x = val9.x;
rect = mapRect.rect;
float num7 = x / ((Rect)(ref rect)).width + 0.5f;
float y2 = val9.y;
rect = mapRect.rect;
float num8 = y2 / ((Rect)(ref rect)).height + 0.5f;
float num9 = -89.42f;
float num10 = 0.3062f;
float num11 = 98.83f;
float num12 = (0.7435f - num10) / (num11 - num9);
float num13 = num9 + (num7 - num10) / num12;
float num14 = -98.09f;
float num15 = 0.2592f;
float num16 = 101.55f;
float num17 = (0.7229f - num15) / (num16 - num14);
float num18 = num14 + (num8 - num15) / num17;
Vector3 val10 = default(Vector3);
((Vector3)(ref val10))..ctor(num13, ((Component)__instance).transform.position.y, num18);
if ((Object)(object)FishingManager.Instance == (Object)null)
{
return;
}
FishingArea val11 = FishingManager.Instance.FindFishingArea(val10);
if ((Object)(object)val11 != (Object)null)
{
string text = (string)loadTagsMethod.Invoke(habitatPluginInstance, new object[1] { val11 });
if (!string.IsNullOrEmpty(text))
{
habitatPanel.SetActive(true);
habitatText.text = text;
Vector2 val12 = default(Vector2);
RectTransformUtility.ScreenPointToLocalPointInRectangle(mapCanvas.GetComponent<RectTransform>(), val8, (Camera)null, ref val12);
habitatPanel.GetComponent<RectTransform>().anchoredPosition = val12 + new Vector2(0f, 20f);
}
else
{
habitatPanel.SetActive(false);
}
}
else
{
habitatPanel.SetActive(false);
}
}
else
{
habitatPanel.SetActive(false);
}
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "SwampMap";
public const string PLUGIN_NAME = "SwampMap";
public const string PLUGIN_VERSION = "1.0.0";
}
}