using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppSystem;
using SSSGame;
using SandSailorStudio.Inventory;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.UI;
using io.abukaff.bepinex.core;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("io.abukaff.bepinex.aska.itemduper")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("My first plugin")]
[assembly: AssemblyTitle("io.abukaff.bepinex.aska.itemduper")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace io.abukaff.bepinex.aska.itemduper;
public static class ItemDuperStaticFunctions
{
public static List<CraftBlueprintInfo> Blueprints = new List<CraftBlueprintInfo>();
public static List<EquipmentItemObject> EquipmentItemObjects = new List<EquipmentItemObject>();
public static List<CraftBlueprintInfo> CraftBlueprints = new List<CraftBlueprintInfo>();
public static List<ResourceObject> ResourcesObjects = new List<ResourceObject>();
public static List<GameObject> allGridButtons = new List<GameObject>();
public static List<GameObject> allListButtons = new List<GameObject>();
private static ScrollRect scrollView = null;
public static InputManager inputManager;
public static GameObject UICanvasGO = null;
public static void Init()
{
GenerateCraftingItemsList();
}
public static void UpdateResourceObjects()
{
ResourcesObjects = (from obj in (IEnumerable<Object>)Resources.FindObjectsOfTypeAll(Type.GetType("SSSGame.ResourceObject, Assembly-CSharp"))
select ((Il2CppObjectBase)obj).TryCast<ResourceObject>() into obj
where (Object)(object)obj != (Object)null && ((Object)obj).GetIl2CppType().FullName == "SSSGame.ResourceObject" && !Object.op_Implicit((Object)(object)((Component)obj).gameObject.GetComponent(Type.GetType("SSSGame.BiomeObject"))) && !Object.op_Implicit((Object)(object)((Component)obj).GetComponentInChildren<VegetationItemSpawner>())
group obj by ((Object)((Component)obj).gameObject).name into @group
select @group.First()).ToList().ToList();
}
public static void GetEquipmentItemObjects()
{
EquipmentItemObjects = (from obj in (IEnumerable<Object>)Resources.FindObjectsOfTypeAll(Type.GetType("SSSGame.EquipmentItemObject, Assembly-CSharp"))
select ((Il2CppObjectBase)obj).TryCast<EquipmentItemObject>() into x
group x by (x == null) ? null : ((ItemObject)x).GetName() into @group
select @group.First()).ToList();
EquipmentItemObjects.RemoveAll((EquipmentItemObject item) => CraftBlueprints.Any((CraftBlueprintInfo blueprint) => ((ItemInfo)blueprint).Name == ((ItemObject)item).GetName()));
}
private static void GenerateCraftingItemsList()
{
CraftBlueprints = (from obj in (IEnumerable<Object>)Resources.FindObjectsOfTypeAll(Type.GetType("SSSGame.CraftBlueprintInfo, Assembly-CSharp"))
select ((Il2CppObjectBase)obj).TryCast<CraftBlueprintInfo>() into x
group x by (x == null) ? null : ((ItemInfo)x).Name into @group
select @group.First()).ToList();
}
public static void ShowUI(Transform parent)
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Expected O, but got Unknown
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: Unknown result type (might be due to invalid IL or missing references)
//IL_010f: 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_0119: 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_014c: 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_0156: Unknown result type (might be due to invalid IL or missing references)
//IL_015b: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)UICanvasGO != (Object)null)
{
Object.Destroy((Object)(object)UICanvasGO);
return;
}
UICanvasGO = new GameObject("ItemDuperUI");
UICanvasGO.transform.SetParent(parent, false);
Transform transform = UICanvasGO.transform;
transform.localPosition = new Vector3(600f, 0f, 0f);
allListButtons.Clear();
allGridButtons.Clear();
inputManager = Object.FindObjectOfType<InputManager>(false);
UnityAction<string> val = UnityAction<string>.op_Implicit((Action<string>)delegate(string value)
{
if (!string.IsNullOrEmpty(value))
{
bool flag = false;
if (value.Contains("."))
{
value = value.Replace(".", "");
flag = true;
}
foreach (GameObject allListButton in allListButtons)
{
allListButton.SetActive(((Object)allListButton).name.Contains(value, StringComparison.OrdinalIgnoreCase));
}
if (flag)
{
StaticCoreHelpers.EnableGameInputV2(inputManager, true);
EventSystem.current.SetSelectedGameObject((GameObject)null);
}
return;
}
foreach (GameObject allListButton2 in allListButtons)
{
allListButton2.SetActive(true);
}
});
UnityAction<string> val2 = UnityAction<string>.op_Implicit((Action<string>)delegate
{
StaticCoreHelpers.EnableGameInputV2(inputManager, false);
});
UnityAction<string> val3 = UnityAction<string>.op_Implicit((Action<string>)delegate
{
StaticCoreHelpers.EnableGameInputV2(inputManager, true);
});
UIHelpers.AddInputField(transform, "Search", new Vector2(150f, 40f), new Vector2(0f, 260f), UIHelpers.HalfHalf, UIHelpers.HalfHalf, UIHelpers.HalfHalf, true, val, val2, val3);
UIHelpers.AddTextMeshPro("Press \" .\" to exit text field", 10f, transform, new Vector2(150f, 30f), new Vector2(0f, 300f), UIHelpers.HalfHalf, UIHelpers.HalfHalf, UIHelpers.HalfHalf);
BuildListView(transform);
}
private static void BuildListView(Transform parent)
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//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_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: 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_00c6: 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_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0101: Unknown result type (might be due to invalid IL or missing references)
//IL_0106: Unknown result type (might be due to invalid IL or missing references)
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
//IL_01dd: 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_01e7: Unknown result type (might be due to invalid IL or missing references)
//IL_01ec: 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_021c: Unknown result type (might be due to invalid IL or missing references)
//IL_0221: 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)
//IL_022b: Unknown result type (might be due to invalid IL or missing references)
//IL_0230: Unknown result type (might be due to invalid IL or missing references)
//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0300: Unknown result type (might be due to invalid IL or missing references)
//IL_0305: Unknown result type (might be due to invalid IL or missing references)
//IL_030a: Unknown result type (might be due to invalid IL or missing references)
//IL_030f: Unknown result type (might be due to invalid IL or missing references)
//IL_0314: Unknown result type (might be due to invalid IL or missing references)
//IL_033f: Unknown result type (might be due to invalid IL or missing references)
//IL_0344: Unknown result type (might be due to invalid IL or missing references)
//IL_0349: Unknown result type (might be due to invalid IL or missing references)
//IL_034e: Unknown result type (might be due to invalid IL or missing references)
//IL_0353: Unknown result type (might be due to invalid IL or missing references)
//IL_0358: Unknown result type (might be due to invalid IL or missing references)
scrollView = UIHelpers.AddScrollView(parent, new Vector2(420f, 420f), Vector2.zero, UIHelpers.HalfHalf, UIHelpers.HalfHalf, UIHelpers.HalfHalf, true, 2f);
allListButtons.Clear();
foreach (ResourceObject item in ResourcesObjects)
{
UnityAction val = UnityAction.op_Implicit((Action)delegate
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: 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_004c: Unknown result type (might be due to invalid IL or missing references)
GameObject gameObject2 = ((Component)item).gameObject;
Vector3 position3 = StaticCoreHelpers.PlayerCharacter.transform.position;
_ = StaticCoreHelpers.PlayerCharacter.transform.rotation;
Console.WriteLine("Item spawned " + ((Object)gameObject2).name);
Object.Instantiate<GameObject>(gameObject2).transform.position = position3;
});
try
{
if ((Object)(object)((ItemObject)item).GetIcon() != (Object)null)
{
Button val2 = UIHelpers.AddButton(" " + ((ItemObject)item).GetName(), (Transform)(object)scrollView.content, new Vector2(0f, 50f), Vector2.zero, Vector2.zero, UIHelpers.OneZero, UIHelpers.HalfOne, UIHelpers.backGroundColor, val);
new ModImage(((Component)val2).transform, ((ItemObject)item).GetIcon(), new Vector2(50f, 50f), Vector2.zero, UIHelpers.ZeroHalf, UIHelpers.ZeroHalf, UIHelpers.ZeroHalf);
((Object)((Component)val2).gameObject).name = ((ItemObject)item).GetName();
allListButtons.Add(((Component)val2).gameObject);
}
}
catch (Exception)
{
}
}
foreach (CraftBlueprintInfo item2 in CraftBlueprints)
{
UnityAction val3 = UnityAction.op_Implicit((Action)delegate
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: 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_0051: Unknown result type (might be due to invalid IL or missing references)
ItemInfo result = ((BlueprintInfo)item2).result;
Vector3 position2 = StaticCoreHelpers.PlayerCharacter.transform.position;
_ = StaticCoreHelpers.PlayerCharacter.transform.rotation;
Console.WriteLine("Item spawned " + ((Object)result).name);
Object.Instantiate<GameObject>(result.spawnObject).transform.position = position2;
});
try
{
if ((Object)(object)((ItemInfo)item2).icon != (Object)null)
{
Button val4 = UIHelpers.AddButton(" " + ((ItemInfo)item2).Name, (Transform)(object)scrollView.content, new Vector2(0f, 50f), Vector2.zero, Vector2.zero, UIHelpers.OneZero, UIHelpers.HalfOne, UIHelpers.backGroundColor, val3);
new ModImage(((Component)val4).transform, ((ItemInfo)item2).icon, new Vector2(50f, 50f), Vector2.zero, UIHelpers.ZeroHalf, UIHelpers.ZeroHalf, UIHelpers.ZeroHalf);
((Object)((Component)val4).gameObject).name = ((ItemInfo)item2).Name;
allListButtons.Add(((Component)val4).gameObject);
}
}
catch (Exception)
{
}
}
foreach (EquipmentItemObject item3 in EquipmentItemObjects)
{
UnityAction val5 = UnityAction.op_Implicit((Action)delegate
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: 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_004c: Unknown result type (might be due to invalid IL or missing references)
GameObject gameObject = ((Component)item3).gameObject;
Vector3 position = StaticCoreHelpers.PlayerCharacter.transform.position;
_ = StaticCoreHelpers.PlayerCharacter.transform.rotation;
Console.WriteLine("Item spawned " + ((Object)gameObject).name);
Object.Instantiate<GameObject>(gameObject).transform.position = position;
});
try
{
if ((Object)(object)((ItemObject)item3).GetIcon() != (Object)null)
{
Button val6 = UIHelpers.AddButton(" " + ((ItemObject)item3).GetName(), (Transform)(object)scrollView.content, new Vector2(0f, 50f), Vector2.zero, Vector2.zero, UIHelpers.OneZero, UIHelpers.HalfOne, UIHelpers.backGroundColor, val5);
new ModImage(((Component)val6).transform, ((ItemObject)item3).GetIcon(), new Vector2(50f, 50f), Vector2.zero, UIHelpers.ZeroHalf, UIHelpers.ZeroHalf, UIHelpers.ZeroHalf);
((Object)((Component)val6).gameObject).name = ((ItemObject)item3).GetName();
allListButtons.Add(((Component)val6).gameObject);
}
}
catch (Exception)
{
}
}
}
}
[BepInPlugin("io.abukaff.bepinex.aska.itemduper", "My first plugin", "1.0.0")]
public class Plugin : BasePlugin
{
internal static ManualLogSource Log;
public override void Load()
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
Log = ((BasePlugin)this).Log;
ManualLogSource log = Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(18, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("io.abukaff.bepinex.aska.itemduper");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!");
}
log.LogInfo(val);
ItemDuperStaticFunctions.Init();
StaticCoreHelpers.OnBuildMenu = (Action<Transform>)Delegate.Combine(StaticCoreHelpers.OnBuildMenu, new Action<Transform>(OnBuildMenu));
StaticCoreHelpers.OnMainMenu = (Action)Delegate.Combine(StaticCoreHelpers.OnMainMenu, new Action(OnMainMenu));
StaticCoreHelpers.OnCloseModsUI = (Action)Delegate.Combine(StaticCoreHelpers.OnCloseModsUI, new Action(CloseModUI));
}
private void OnMainMenu()
{
ItemDuperStaticFunctions.UpdateResourceObjects();
ItemDuperStaticFunctions.GetEquipmentItemObjects();
}
private void CloseModUI()
{
if (Object.op_Implicit((Object)(object)ItemDuperStaticFunctions.UICanvasGO))
{
Object.Destroy((Object)(object)ItemDuperStaticFunctions.UICanvasGO);
StaticCoreHelpers.EnableGameInputV2(ItemDuperStaticFunctions.inputManager, true);
EventSystem.current.SetSelectedGameObject((GameObject)null);
}
}
private void OnBuildMenu(Transform parent)
{
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: 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_0043: 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)
UnityAction val = UnityAction.op_Implicit((Action)delegate
{
ItemDuperStaticFunctions.ShowUI(parent.parent.parent);
});
UIHelpers.AddButton("Item Duper", parent, new Vector2(50f, 50f), Vector2.zero, Vector2.zero, Vector2.zeroVector, Vector2.zero, UIHelpers.greenColor, val);
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "io.abukaff.bepinex.aska.itemduper";
public const string PLUGIN_NAME = "My first plugin";
public const string PLUGIN_VERSION = "1.0.0";
}