using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using ACTQoL.Extensions;
using ACTQoL.Utils;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.SceneManagement;
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: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("ACTQoL")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("ACTQoL")]
[assembly: AssemblyFileVersion("0.2.0.0")]
[assembly: AssemblyInformationalVersion("0.2.0+dd5d3fbba016089e5c620454bf4aec87b0a17c34")]
[assembly: AssemblyProduct("ACTQoL")]
[assembly: AssemblyTitle("ACTQoL")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.2.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace ACTQoL
{
public static class ModHelper
{
internal static readonly Dictionary<string, Sprite> Sprites = new Dictionary<string, Sprite>();
public static Assembly GetAssembly()
{
return Assembly.GetAssembly(typeof(ModMain));
}
public static Sprite GetSprite(string fileName)
{
//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)
//IL_0044: Expected O, but got Unknown
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
Assembly assembly = GetAssembly();
string[] manifestResourceNames = assembly.GetManifestResourceNames();
if (Sprites.ContainsKey(fileName))
{
return Sprites[fileName];
}
byte[] array = null;
Texture2D val = new Texture2D(2, 2)
{
filterMode = (FilterMode)1
};
string[] array2 = manifestResourceNames;
foreach (string text in array2)
{
string[] array3 = text.Split(new char[1] { '.' });
string text2 = array3[2];
if (text2 == fileName)
{
array = assembly.GetManifestResourceStream(text).GetByteArray();
break;
}
}
if (array != null)
{
ImageConversion.LoadImage(val, array);
Sprite val2 = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 10.8f);
Sprites[fileName] = val2;
return val2;
}
return null;
}
public static void Msg(string msg)
{
ModMain.logSource.LogInfo((object)msg);
}
}
[BepInPlugin("ACTQoL", "ACTQoL", "0.2.0")]
[BepInProcess("AnotherCrabsTreasure.exe")]
public class ModMain : BaseUnityPlugin
{
public static bool fromPretitle = true;
public static bool DEBUG = true;
public static ManualLogSource logSource;
public static List<Enemy> crystalEnemies;
public static List<Item> items;
public static List<GameObject> mapMarkers = new List<GameObject>();
public static bool RenderWorldMarkers = true;
private void Awake()
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Expected O, but got Unknown
logSource = ((BaseUnityPlugin)this).Logger;
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin ACTQoL is loaded!");
Harmony val = new Harmony("com.example.patch");
val.PatchAll();
}
public void Update()
{
crystalEnemies = Object.FindObjectsOfType<Enemy>(true).ToList();
items = Object.FindObjectsOfType<Item>(true).ToList();
}
public void OnGUI()
{
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: 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_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: 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_027f: Unknown result type (might be due to invalid IL or missing references)
//IL_0284: Unknown result type (might be due to invalid IL or missing references)
//IL_028b: Unknown result type (might be due to invalid IL or missing references)
//IL_028d: Unknown result type (might be due to invalid IL or missing references)
//IL_0292: Unknown result type (might be due to invalid IL or missing references)
//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
//IL_02be: Unknown result type (might be due to invalid IL or missing references)
//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
if (!RenderWorldMarkers)
{
return;
}
if (crystalEnemies != null)
{
foreach (Enemy crystalEnemy in crystalEnemies)
{
object value = Traverse.Create((object)crystalEnemy).Field("saveState").GetValue();
SaveStateKillableEntity val = (SaveStateKillableEntity)((value is SaveStateKillableEntity) ? value : null);
if (!((Object)(object)val == (Object)null) && !((Object)(object)((Component)crystalEnemy).transform == (Object)null) && !crystalEnemy.isBoss && !val.killedPreviously && crystalEnemy.umamiDrops > 0)
{
Vector3 center = ((Entity)crystalEnemy).GetCenter();
Vector3 val2 = Camera.main.WorldToScreenPoint(center);
Texture2D texture = ModHelper.GetSprite("crystal").texture;
float num = 64f;
if (val2.z > 0f)
{
GUI.DrawTexture(new Rect(new Vector2(val2.x - num / 2f, (float)Screen.height - val2.y - num / 2f), new Vector2(num, num)), (Texture)(object)texture, (ScaleMode)2);
}
}
}
}
if (items == null)
{
return;
}
foreach (Item item in items)
{
string text = item.DisplayName.Replace("Item_", "").Replace("_Name", "").ToLower();
string fileName = (ItemNameToResource.ItemToResource.ContainsKey(text) ? ItemNameToResource.ItemToResource[text] : (text.Contains("stowaway") ? "stowaways" : (text.Contains("claw") ? "junk" : ((!text.Contains("costume")) ? "junk" : "costume"))));
object value2 = Traverse.Create((object)item).Field("save").GetValue();
SaveStateKillableEntity val3 = (SaveStateKillableEntity)((value2 is SaveStateKillableEntity) ? value2 : null);
if (!((Object)(object)val3 == (Object)null) && !((Object)(object)item == (Object)null) && !val3.killedPreviously)
{
Vector3 center2 = ((Entity)item).GetCenter();
Vector3 val4 = Camera.main.WorldToScreenPoint(center2);
Texture2D texture2 = ModHelper.GetSprite(fileName).texture;
float num2 = 64f;
if (val4.z > 0f)
{
GUI.DrawTexture(new Rect(new Vector2(val4.x - num2 / 2f, (float)Screen.height - val4.y - num2 / 2f), new Vector2(num2, num2)), (Texture)(object)texture2, (ScaleMode)2);
}
}
}
}
public static bool EnemiesAggro()
{
bool result = false;
foreach (Enemy crystalEnemy in crystalEnemies)
{
if (crystalEnemy.aggro)
{
result = true;
}
}
return result;
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "ACTQoL";
public const string PLUGIN_NAME = "ACTQoL";
public const string PLUGIN_VERSION = "0.2.0";
}
}
namespace ACTQoL.Utils
{
internal class ItemNameToResource
{
public static Dictionary<string, string> ItemToResource = new Dictionary<string, string>
{
{ "barbedhook", "hook" },
{ "oldworldwhorl", "whorl" },
{ "heartkelpsprout", "heartkelp" },
{ "bloodstarlimb", "bloodstar" },
{ "stainlessrelic", "key" }
};
}
}
namespace ACTQoL.Patches
{
[HarmonyPatch(typeof(MoonSnailShell), "SpawnPlayer")]
internal class ShellHealthRestore
{
[HarmonyPostfix]
public static void Postfix()
{
if (Object.op_Implicit((Object)(object)Player.singlePlayer.equippedShell))
{
float startingHealth = ((Entity)Player.singlePlayer.equippedShell).startingHealth;
((Entity)Player.singlePlayer.equippedShell).SetHealth(startingHealth);
}
if (Object.op_Implicit((Object)(object)Player.singlePlayer.equippedShellHammer))
{
float startingHealth2 = ((Entity)Player.singlePlayer.equippedShellHammer).startingHealth;
((Entity)Player.singlePlayer.equippedShellHammer).SetHealth(startingHealth2);
}
}
}
}
namespace ACTQoL.Patches.MapPatches
{
[HarmonyPatch(typeof(AreaMap), "OnDisable")]
internal class ClearMapMarkers
{
[HarmonyPostfix]
public static void Postfix()
{
foreach (GameObject mapMarker in ModMain.mapMarkers)
{
Object.Destroy((Object)(object)mapMarker);
}
ModMain.mapMarkers.Clear();
ModMain.RenderWorldMarkers = true;
}
}
[HarmonyPatch(typeof(AreaMap), "RefreshMapWithFile")]
internal class CrystalTracker
{
[HarmonyPostfix]
public static void Postfix(AreaMap __instance)
{
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: 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_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_014f: Unknown result type (might be due to invalid IL or missing references)
//IL_0171: Unknown result type (might be due to invalid IL or missing references)
//IL_0176: 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_0181: Unknown result type (might be due to invalid IL or missing references)
//IL_018d: Unknown result type (might be due to invalid IL or missing references)
GameObject gameObject = ((Component)__instance.pagurusIcon).gameObject;
GameObject gameObject2 = ((Component)((Component)__instance.pagurusIcon).transform.parent).gameObject;
List<Enemy> crystalEnemies = ModMain.crystalEnemies;
PlayerLocationData locationData = CrabFile.current.locationData;
LevelData dataFromLevel = WorldData.globalWorldData.GetDataFromLevel(locationData.currentLevel);
Vector2 treasureMapBottomLeft = dataFromLevel.treasureMapBottomLeft;
Vector2 treasureMapTopRight = dataFromLevel.treasureMapTopRight;
int value = Traverse.Create((object)__instance).Field<int>("activeDataSetIndex").Value;
AreaMapDataSet val = __instance.areaMapDataSets[value];
Sprite sprite = ModHelper.GetSprite("crystal");
foreach (Enemy item in crystalEnemies)
{
object value2 = Traverse.Create((object)item).Field("saveState").GetValue();
SaveStateKillableEntity val2 = (SaveStateKillableEntity)((value2 is SaveStateKillableEntity) ? value2 : null);
if (!((Object)(object)val2 == (Object)null) && !((Object)(object)((Component)item).transform == (Object)null) && !item.isBoss && !val2.killedPreviously && item.umamiDrops > 0)
{
GameObject val3 = Object.Instantiate<GameObject>(gameObject, gameObject2.transform);
if ((Object)(object)sprite != (Object)null)
{
val3.GetComponent<Image>().sprite = sprite;
}
val3.transform.localScale = new Vector3(0.25f, 0.25f);
ModMain.mapMarkers.Add(val3);
__instance.Triangulate(val3.GetComponent<RectTransform>(), ((Entity)item).GetCenter(), treasureMapBottomLeft, treasureMapTopRight, val.areaMapBottomLeft.anchoredPosition, val.areaMapTopRight.anchoredPosition);
val3.SetActive(true);
((Behaviour)val3.GetComponent<Image>()).enabled = true;
}
}
}
}
[HarmonyPatch(typeof(Enemy), "Aggro")]
internal class EnemyAggroHide
{
[HarmonyPostfix]
public static void Postfix()
{
ModMain.RenderWorldMarkers = !ModMain.EnemiesAggro();
}
}
[HarmonyPatch(typeof(Enemy), "DropAggro")]
internal class EnemyDropAggroHide
{
[HarmonyPostfix]
public static void Postfix()
{
ModMain.RenderWorldMarkers = !ModMain.EnemiesAggro();
}
}
[HarmonyPatch(typeof(AudioManager), "OnGamePaused")]
internal class HideWorldMarkers
{
[HarmonyPostfix]
public static void Postfix(bool paused)
{
ModMain.RenderWorldMarkers = !paused;
}
}
[HarmonyPatch(typeof(AreaMap), "RefreshMapWithFile")]
internal class ItemTracker
{
[HarmonyPostfix]
public static void Postfix(AreaMap __instance)
{
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: 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_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
//IL_0204: Unknown result type (might be due to invalid IL or missing references)
//IL_0209: Unknown result type (might be due to invalid IL or missing references)
//IL_020b: Unknown result type (might be due to invalid IL or missing references)
//IL_0214: Unknown result type (might be due to invalid IL or missing references)
//IL_0220: Unknown result type (might be due to invalid IL or missing references)
GameObject gameObject = ((Component)__instance.pagurusIcon).gameObject;
GameObject gameObject2 = ((Component)((Component)__instance.pagurusIcon).transform.parent).gameObject;
List<Item> items = ModMain.items;
PlayerLocationData locationData = CrabFile.current.locationData;
LevelData dataFromLevel = WorldData.globalWorldData.GetDataFromLevel(locationData.currentLevel);
Vector2 treasureMapBottomLeft = dataFromLevel.treasureMapBottomLeft;
Vector2 treasureMapTopRight = dataFromLevel.treasureMapTopRight;
int value = Traverse.Create((object)__instance).Field<int>("activeDataSetIndex").Value;
AreaMapDataSet val = __instance.areaMapDataSets[value];
foreach (Item item in items)
{
string text = item.DisplayName.Replace("Item_", "").Replace("_Name", "").ToLower();
string fileName;
if (ItemNameToResource.ItemToResource.ContainsKey(text))
{
fileName = ItemNameToResource.ItemToResource[text];
}
else if (text.Contains("stowaway"))
{
fileName = "stowaways";
}
else if (text.Contains("claw"))
{
fileName = "junk";
}
else if (text.Contains("costume"))
{
fileName = "costume";
}
else
{
fileName = "junk";
ModHelper.Msg(text);
}
Sprite sprite = ModHelper.GetSprite(fileName);
object value2 = Traverse.Create((object)item).Field("save").GetValue();
SaveStateKillableEntity val2 = (SaveStateKillableEntity)((value2 is SaveStateKillableEntity) ? value2 : null);
if (!((Object)(object)val2 == (Object)null) && !((Object)(object)item == (Object)null) && !val2.killedPreviously)
{
GameObject val3 = Object.Instantiate<GameObject>(gameObject, gameObject2.transform);
if ((Object)(object)sprite != (Object)null)
{
val3.GetComponent<Image>().sprite = sprite;
}
val3.transform.localScale = new Vector3(0.25f, 0.25f);
ModMain.mapMarkers.Add(val3);
__instance.Triangulate(val3.GetComponent<RectTransform>(), ((Entity)item).GetCenter(), treasureMapBottomLeft, treasureMapTopRight, val.areaMapBottomLeft.anchoredPosition, val.areaMapTopRight.anchoredPosition);
val3.SetActive(true);
((Behaviour)val3.GetComponent<Image>()).enabled = true;
}
}
}
}
}
namespace ACTQoL.Patches.DebugStuff
{
[HarmonyPatch(typeof(StartScreen), "SetContinueButton")]
internal class AutoContinue
{
[HarmonyPostfix]
public static void Postfix(StartScreen __instance)
{
if (ModMain.fromPretitle)
{
__instance.continueButton.OnClick();
ModMain.fromPretitle = false;
}
}
}
[HarmonyPatch(typeof(UserSettings), "InitSettings")]
internal class PreTitleSkip
{
[HarmonyPostfix]
public static void Postfix()
{
SceneManager.LoadSceneAsync("Title");
}
}
}
namespace ACTQoL.Extensions
{
public static class AreaMapExt
{
public static void Triangulate(this AreaMap areaMap, RectTransform icon, Vector3 worldPosition, Vector2 worldBottomLeft, Vector2 worldTopRight, Vector2 mapBottomLeft, Vector2 mapTopRight, bool isPlayer = false, bool centered = false)
{
//IL_0022: 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_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
MethodInfo method = ((object)areaMap).GetType().GetMethod("Triangulate", BindingFlags.Instance | BindingFlags.NonPublic);
method.Invoke(areaMap, new object[8] { icon, worldPosition, worldBottomLeft, worldTopRight, mapBottomLeft, mapTopRight, isPlayer, centered });
}
}
public static class StreamExt
{
public static byte[] GetByteArray(this Stream stream)
{
if (stream == null)
{
return null;
}
try
{
using (stream)
{
if (stream is MemoryStream memoryStream)
{
return memoryStream.ToArray();
}
MemoryStream memoryStream2;
using (memoryStream2 = new MemoryStream())
{
stream.CopyTo(memoryStream2);
return memoryStream2.ToArray();
}
}
}
catch (Exception)
{
return null;
}
}
}
}