using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")]
[assembly: AssemblyCompany("RomansAdditions")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1+64bb55e1e97f502701c01f0aa68d23a41b6dbb85")]
[assembly: AssemblyProduct("Romans Additions")]
[assembly: AssemblyTitle("RomansAdditions")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.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 RomansAdditions
{
[BepInPlugin("RomansAdditions", "Romans Additions", "1.0.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
[HarmonyPatch(typeof(ZNetScene), "Awake")]
public static class TraderAddToSellItems
{
public static void Postfix(ZNetScene __instance)
{
GameObject prefab = __instance.GetPrefab("IronBountyToken");
ItemDrop component = prefab.GetComponent<ItemDrop>();
component.m_itemData.m_shared.m_value = 20;
prefab = __instance.GetPrefab("GoldBountyToken");
component = prefab.GetComponent<ItemDrop>();
component.m_itemData.m_shared.m_value = 100;
prefab = __instance.GetPrefab("ForestToken");
component = prefab.GetComponent<ItemDrop>();
component.m_itemData.m_shared.m_value = 15;
prefab = __instance.GetPrefab("TrophyEikthyr");
component = prefab.GetComponent<ItemDrop>();
component.m_itemData.m_shared.m_value = 25;
prefab = __instance.GetPrefab("TrophyTheElder");
component = prefab.GetComponent<ItemDrop>();
component.m_itemData.m_shared.m_value = 50;
prefab = __instance.GetPrefab("TrophyBonemass");
component = prefab.GetComponent<ItemDrop>();
component.m_itemData.m_shared.m_value = 100;
prefab = __instance.GetPrefab("TrophyDragonQueen");
component = prefab.GetComponent<ItemDrop>();
component.m_itemData.m_shared.m_value = 200;
prefab = __instance.GetPrefab("TrophyGoblinKing");
component = prefab.GetComponent<ItemDrop>();
component.m_itemData.m_shared.m_value = 400;
prefab = __instance.GetPrefab("TrophySeekerQueen");
component = prefab.GetComponent<ItemDrop>();
component.m_itemData.m_shared.m_value = 800;
prefab = __instance.GetPrefab("TrophyFader");
component = prefab.GetComponent<ItemDrop>();
component.m_itemData.m_shared.m_value = 1600;
prefab = __instance.GetPrefab("ShardMagic");
component = prefab.GetComponent<ItemDrop>();
component.m_itemData.m_shared.m_value = 5;
prefab = __instance.GetPrefab("DustMagic");
component = prefab.GetComponent<ItemDrop>();
component.m_itemData.m_shared.m_value = 5;
prefab = __instance.GetPrefab("ReagentMagic");
component = prefab.GetComponent<ItemDrop>();
component.m_itemData.m_shared.m_value = 5;
prefab = __instance.GetPrefab("EssenceMagic");
component = prefab.GetComponent<ItemDrop>();
component.m_itemData.m_shared.m_value = 5;
prefab = __instance.GetPrefab("ShardRare");
component = prefab.GetComponent<ItemDrop>();
component.m_itemData.m_shared.m_value = 10;
prefab = __instance.GetPrefab("DustRare");
component = prefab.GetComponent<ItemDrop>();
component.m_itemData.m_shared.m_value = 10;
prefab = __instance.GetPrefab("ReagentRare");
component = prefab.GetComponent<ItemDrop>();
component.m_itemData.m_shared.m_value = 10;
prefab = __instance.GetPrefab("EssenceRare");
component = prefab.GetComponent<ItemDrop>();
component.m_itemData.m_shared.m_value = 10;
prefab = __instance.GetPrefab("ShardEpic");
component = prefab.GetComponent<ItemDrop>();
component.m_itemData.m_shared.m_value = 15;
prefab = __instance.GetPrefab("DustEpic");
component = prefab.GetComponent<ItemDrop>();
component.m_itemData.m_shared.m_value = 15;
prefab = __instance.GetPrefab("ReagentEpic");
component = prefab.GetComponent<ItemDrop>();
component.m_itemData.m_shared.m_value = 15;
prefab = __instance.GetPrefab("EssenceEpic");
component = prefab.GetComponent<ItemDrop>();
component.m_itemData.m_shared.m_value = 15;
prefab = __instance.GetPrefab("ShardLegendary");
component = prefab.GetComponent<ItemDrop>();
component.m_itemData.m_shared.m_value = 20;
prefab = __instance.GetPrefab("DustLegendary");
component = prefab.GetComponent<ItemDrop>();
component.m_itemData.m_shared.m_value = 20;
prefab = __instance.GetPrefab("ReagentLegendary");
component = prefab.GetComponent<ItemDrop>();
component.m_itemData.m_shared.m_value = 20;
prefab = __instance.GetPrefab("EssenceLegendary");
component = prefab.GetComponent<ItemDrop>();
component.m_itemData.m_shared.m_value = 20;
prefab = __instance.GetPrefab("ShardMythic");
component = prefab.GetComponent<ItemDrop>();
component.m_itemData.m_shared.m_value = 25;
prefab = __instance.GetPrefab("DustMythic");
component = prefab.GetComponent<ItemDrop>();
component.m_itemData.m_shared.m_value = 25;
prefab = __instance.GetPrefab("ReagentMythic");
component = prefab.GetComponent<ItemDrop>();
component.m_itemData.m_shared.m_value = 25;
prefab = __instance.GetPrefab("EssenceMythic");
component = prefab.GetComponent<ItemDrop>();
component.m_itemData.m_shared.m_value = 25;
}
}
[HarmonyPatch(typeof(Inventory), "StackAll")]
internal static class ContainerStackAll
{
private static void Postfix(Inventory __instance, Inventory fromInventory, bool message)
{
//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
List<ItemData> list = new List<ItemData>();
foreach (ItemData allItem in fromInventory.GetAllItems())
{
if (allItem.m_gridPos.y != 0 && allItem.m_shared.m_maxStackSize > 1)
{
list.Add(allItem);
_instance.Logger.LogInfo((object)allItem.m_gridPos.y);
}
}
foreach (ItemData item in list)
{
_instance.Logger.LogInfo((object)item);
}
if ((Object)(object)Player.m_localPlayer == (Object)null)
{
return;
}
Vector3 position = ((Component)Player.m_localPlayer).transform.position;
List<Container> list2 = FindContainersInRadius(position, 30f);
foreach (Container item2 in list2)
{
if (!item2.IsInUse())
{
DistributeStackableItemsInChests(item2, list, fromInventory);
}
}
}
private static List<Container> FindContainersInRadius(Vector3 searchPos, float radius)
{
//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)
Container[] array = Object.FindObjectsOfType<Container>();
List<Container> list = new List<Container>();
Container[] array2 = array;
foreach (Container val in array2)
{
float num = Vector3.Distance(((Component)val).transform.position, searchPos);
if (num <= radius)
{
list.Add(val);
}
}
return list;
}
private static void DistributeStackableItemsInChests(Container chest, List<ItemData> items, Inventory playerInventory)
{
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
for (int num = items.Count - 1; num >= 0; num--)
{
ItemData val = items[num];
Inventory inventory = chest.GetInventory();
if (inventory.ContainsItemByName(val.m_shared.m_name))
{
if (inventory.CanAddItem(val, -1))
{
inventory.AddItem(val);
playerInventory.RemoveItem(val);
items.RemoveAt(num);
PlayItemsPlacedRemoteEffect(chest);
}
else
{
List<ItemData> allItemsOfType = inventory.GetAllItemsOfType(val.m_shared.m_itemType, false);
foreach (ItemData item in allItemsOfType)
{
if (item.m_stack < val.m_shared.m_maxStackSize)
{
int num2 = val.m_shared.m_maxStackSize - item.m_stack;
val.m_stack -= num2;
item.m_stack += num2;
PlayItemsPlacedRemoteEffect(chest);
}
}
}
}
}
}
private static void PlayItemsPlacedRemoteEffect(Container chest)
{
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: 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_0050: 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_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
GameObject prefab = ZNetScene.instance.GetPrefab("vfx_WishbonePing");
GameObject prefab2 = ZNetScene.instance.GetPrefab("sfx_smelter_add");
if (!((Object)(object)prefab == (Object)null))
{
Vector3 position = ((Component)chest).transform.position;
position.y -= 1f;
GameObject val = Object.Instantiate<GameObject>(prefab, position, Quaternion.identity);
GameObject val2 = Object.Instantiate<GameObject>(prefab2, position, Quaternion.identity);
}
}
}
private ManualLogSource Logger;
private Harmony harmony;
private static Plugin _instance;
public const int HotbarRowPlayerInventory = 0;
public const float ChestSearchRadius = 30f;
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
Logger.LogInfo((object)"Plugin testing");
harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "RomansAdditions");
_instance = this;
}
private void OnDestroy()
{
_instance = null;
Harmony obj = harmony;
if (obj != null)
{
obj.UnpatchSelf();
}
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "RomansAdditions";
public const string PLUGIN_NAME = "Romans Additions";
public const string PLUGIN_VERSION = "1.0.1";
}
}