Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of CraftFromContainers v1.3.2
CraftFromContainers.dll
Decompiled 2 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Jotunn.Utils; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("CraftFromContainers")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("CraftFromContainers")] [assembly: AssemblyTitle("CraftFromContainers")] [assembly: AssemblyVersion("1.0.0.0")] [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 CraftFromContainers { internal static class Containers { private sealed class Entry { public Container C; public ZNetView NView; public Piece Piece; public string Prefab; public bool Vehicle; public bool Excluded; } internal const string RpcRequestOwn = "CFC_RequestOwn"; private static readonly FieldRef<Container, ZNetView> NViewRef = AccessTools.FieldRefAccess<Container, ZNetView>("m_nview"); private static readonly FieldRef<Container, Piece> PieceRef = AccessTools.FieldRefAccess<Container, Piece>("m_piece"); private static readonly FieldRef<InventoryGui, Container> OpenContainerRef = AccessTools.FieldRefAccess<InventoryGui, Container>("m_currentContainer"); private static readonly List<Entry> Registry = new List<Entry>(); private static readonly Dictionary<Container, Entry> ByContainer = new Dictionary<Container, Entry>(); private static readonly Dictionary<Container, float> LastUsed = new Dictionary<Container, float>(); private static int _frame = -1; private static readonly Dictionary<string, int> OwnedStock = new Dictionary<string, int>(); private static readonly List<Entry> Owned = new List<Entry>(); private static readonly List<Entry> NotOwned = new List<Entry>(); private static readonly List<ItemData> Scratch = new List<ItemData>(); private static Vector3 _center; private static readonly List<Container> NotOwnedView = new List<Container>(); private static readonly MethodInfo InventoryChanged = AccessTools.Method(typeof(Inventory), "Changed", (Type[])null, (Type[])null); internal static List<Container> NotOwnedContainers { get { Refresh(); NotOwnedView.Clear(); foreach (Entry item in NotOwned) { NotOwnedView.Add(item.C); } return NotOwnedView; } } internal static void OnAwake(Container c) { ZNetView val = NViewRef.Invoke(c); if (!((Object)(object)val == (Object)null) && val.GetZDO() != null) { val.Register<long>("CFC_RequestOwn", (Action<long, long>)delegate(long sender, long playerID) { OnRequestOwn(c, sender, playerID); }); if ((!((Object)(object)ZNet.instance != (Object)null) || !ZNet.instance.IsDedicated()) && !ByContainer.ContainsKey(c)) { Piece piece = PieceRef.Invoke(c) ?? ((Component)c).GetComponentInParent<Piece>(); Entry entry = new Entry { C = c, NView = val, Piece = piece, Prefab = Utils.GetPrefabName(((Component)c).gameObject), Vehicle = ((Object)(object)c.m_wagon != (Object)null || (Object)(object)((Component)c).GetComponentInParent<Ship>() != (Object)null), Excluded = (c.m_autoDestroyEmpty || (Object)(object)((Component)c).GetComponent<TombStone>() != (Object)null || (Object)(object)((Component)c).GetComponentInParent<Player>() != (Object)null) }; Registry.Add(entry); ByContainer[c] = entry; } } } internal static void Invalidate() { _frame = -1; } internal static void Refresh() { //IL_004b: 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) if (_frame == Time.frameCount) { return; } _frame = Time.frameCount; OwnedStock.Clear(); Owned.Clear(); NotOwned.Clear(); Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return; } _center = ((Component)localPlayer).transform.position; float value = Plugin.Range.Value; float range = value * value; long playerID = localPlayer.GetPlayerID(); for (int num = Registry.Count - 1; num >= 0; num--) { Entry entry = Registry[num]; if ((Object)(object)entry.C == (Object)null || (Object)(object)entry.NView == (Object)null || !entry.NView.IsValid()) { ByContainer.Remove(entry.C); Registry[num] = Registry[Registry.Count - 1]; Registry.RemoveAt(Registry.Count - 1); } else if (Eligible(entry, range, playerID)) { if (!entry.NView.IsOwner()) { NotOwned.Add(entry); } else { Owned.Add(entry); Inventory inventory = entry.C.GetInventory(); if (inventory != null) { foreach (ItemData allItem in inventory.GetAllItems()) { if (Usable(allItem)) { OwnedStock.TryGetValue(allItem.m_shared.m_name, out var value2); OwnedStock[allItem.m_shared.m_name] = value2 + allItem.m_stack; } } } } } } Owned.Sort(delegate(Entry a, Entry b) { //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_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_003a: 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) Vector3 val = ((Component)a.C).transform.position - _center; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; val = ((Component)b.C).transform.position - _center; return sqrMagnitude.CompareTo(((Vector3)(ref val)).sqrMagnitude); }); } internal static int OwnedCount(string name) { Refresh(); if (!OwnedStock.TryGetValue(name, out var value)) { return 0; } return value; } private static bool Eligible(Entry e, float range2, long playerID) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //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_0026: 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) if (e.Excluded) { return false; } Container c = e.C; Vector3 val = ((Component)c).transform.position - _center; if (((Vector3)(ref val)).sqrMagnitude > range2) { return false; } if (e.Vehicle && !Plugin.IncludeVehicles.Value) { return false; } if (!e.Vehicle && Plugin.PlayerBuiltOnly.Value && ((Object)(object)e.Piece == (Object)null || e.Piece.GetCreator() == 0L)) { return false; } if (Plugin.Excluded.Count > 0 && Plugin.Excluded.Contains(e.Prefab)) { return false; } if (!HasAccess(c, e.Piece, playerID)) { return false; } if (!PrivateArea.CheckAccess(((Component)c).transform.position, 0f, false, false)) { return false; } if (InUseByOther(e)) { return false; } return true; } private static bool HasAccess(Container c, Piece piece, long playerID) { //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_0007: 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 PrivacySetting privacy = c.m_privacy; if ((int)privacy != 0) { if ((int)privacy == 2) { return true; } return false; } if ((Object)(object)piece != (Object)null) { return piece.GetCreator() == playerID; } return false; } private static bool IsOpenByMe(Container c) { InventoryGui instance = InventoryGui.instance; if ((Object)(object)instance != (Object)null && InventoryGui.IsVisible()) { return (Object)(object)OpenContainerRef.Invoke(instance) == (Object)(object)c; } return false; } private static bool InUseByOther(Entry e) { if (IsOpenByMe(e.C)) { return false; } if ((Object)(object)e.C.m_wagon != (Object)null && e.C.m_wagon.InUse()) { return true; } if (e.NView.IsOwner()) { return e.C.IsInUse(); } return e.NView.GetZDO().GetInt(ZDOVars.s_inUse, 0) == 1; } internal static bool Usable(ItemData it) { if (it == null || it.m_stack <= 0) { return false; } if (it.m_shared.m_maxQuality > 1) { return false; } if (it.m_worldLevel < Game.m_worldLevel) { return false; } if (it.m_equipped) { return false; } if (Plugin.SkipCustomDataItems.Value && it.m_customData != null && it.m_customData.Count > 0) { return false; } return true; } private static void CollectMatching(Inventory inv, string name) { Scratch.Clear(); foreach (ItemData allItem in inv.GetAllItems()) { if (allItem.m_shared.m_name == name && Usable(allItem)) { Scratch.Add(allItem); } } } internal static int StageInto(Inventory target, string name, int amount) { Refresh(); int num = 0; foreach (Entry item in Owned) { if (num >= amount) { break; } if (!item.NView.IsValid() || !item.NView.IsOwner()) { continue; } Inventory inventory = item.C.GetInventory(); if (inventory == null) { continue; } CollectMatching(inventory, name); foreach (ItemData item2 in Scratch) { int num2 = item2.m_stack; int num3 = Mathf.Max(1, item2.m_shared.m_maxStackSize); while (num < amount && num2 > 0) { int num4 = Mathf.Min(new int[3] { amount - num, num2, num3 }); if (!target.CanAddItem(item2, num4)) { Invalidate(); return num; } ItemData val = item2.Clone(); val.m_stack = num4; val.m_equipped = false; if (!inventory.RemoveItem(item2, num4)) { break; } num2 -= num4; if (!target.AddItem(val)) { inventory.AddItem(val); Plugin.Log.LogWarning((object)("Nie udalo sie dodac " + num4 + "x " + name + " do ekwipunku; zwrocono do skrzyni.")); Invalidate(); return num; } num += num4; LastUsed[item.C] = Time.time; } if (num >= amount) { break; } } } Invalidate(); return num; } internal static int RemoveDirect(string name, int amount) { Refresh(); int num = 0; foreach (Entry item in Owned) { if (num >= amount) { break; } if (!item.NView.IsValid() || !item.NView.IsOwner()) { continue; } Inventory inventory = item.C.GetInventory(); if (inventory == null) { continue; } CollectMatching(inventory, name); foreach (ItemData item2 in Scratch) { int num2 = Mathf.Min(amount - num, item2.m_stack); if (num2 <= 0) { break; } if (inventory.RemoveItem(item2, num2)) { num += num2; LastUsed[item.C] = Time.time; } if (num >= amount) { break; } } } Invalidate(); return num; } internal static void CollectOwnedItems(List<ItemData> into, HashSet<Container> touched) { Refresh(); foreach (Entry item in Owned) { Inventory inventory = item.C.GetInventory(); if (inventory == null) { continue; } bool flag = false; foreach (ItemData allItem in inventory.GetAllItems()) { if (allItem != null && allItem.m_stack > 0 && !allItem.m_equipped) { into.Add(allItem); flag = true; } } if (flag) { touched.Add(item.C); } } } internal static int RemoveExact(ItemData item, int amount) { if (item == null || amount <= 0) { return 0; } Refresh(); foreach (Entry item2 in Owned) { if (!item2.NView.IsValid() || !item2.NView.IsOwner()) { continue; } Inventory inventory = item2.C.GetInventory(); if (inventory != null && inventory.ContainsItem(item)) { int stack = item.m_stack; int num = Mathf.Min(amount, stack); if (!inventory.RemoveItem(item, num)) { return 0; } LastUsed[item2.C] = Time.time; Invalidate(); return num; } } return 0; } internal static void MarkChanged(Container c) { ZNetView val = (((Object)(object)c == (Object)null) ? null : NViewRef.Invoke(c)); if (!((Object)(object)val == (Object)null) && val.IsValid() && val.IsOwner()) { Inventory inventory = c.GetInventory(); if (inventory != null && !(InventoryChanged == null)) { InventoryChanged.Invoke(inventory, new object[2] { false, false }); } } } private static void OnRequestOwn(Container c, long sender, long playerID) { //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: 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_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)c == (Object)null) { return; } ZNetView val = NViewRef.Invoke(c); if ((Object)(object)val == (Object)null || !val.IsValid() || !val.IsOwner() || sender == ZDOMan.GetSessionID()) { return; } if (c.IsInUse() || ((Object)(object)c.m_wagon != (Object)null && c.m_wagon.InUse())) { Plugin.Debug("Odmowa (skrzynia otwarta): " + ((Object)c).name); } else { if (LastUsed.TryGetValue(c, out var value) && Time.time - value < 3f) { return; } if (OwnershipRequester.LocallyBusy && (Object)(object)Player.m_localPlayer != (Object)null) { Vector3 val2 = ((Component)c).transform.position - ((Component)Player.m_localPlayer).transform.position; if (((Vector3)(ref val2)).sqrMagnitude <= Plugin.Range.Value * Plugin.Range.Value) { return; } } Piece piece = PieceRef.Invoke(c) ?? ((Component)c).GetComponentInParent<Piece>(); if (HasAccess(c, piece, playerID)) { ZDOMan.instance.ForceSendZDO(sender, val.GetZDO().m_uid); val.GetZDO().SetOwner(sender); Invalidate(); Plugin.Debug("Przekazano wlasnosc " + ((Object)c).name + " -> " + sender); } } } internal static void RequestOwnership(Container c, long playerID) { ZNetView val = NViewRef.Invoke(c); if (!((Object)(object)val == (Object)null) && val.IsValid() && !val.IsOwner()) { if (!val.GetZDO().HasOwner()) { val.ClaimOwnership(); Invalidate(); } else { val.InvokeRPC("CFC_RequestOwn", new object[1] { playerID }); } } } internal static void PruneLastUsed() { if (LastUsed.Count == 0) { return; } List<Container> list = new List<Container>(); float time = Time.time; foreach (KeyValuePair<Container, float> item in LastUsed) { if ((Object)(object)item.Key == (Object)null || time - item.Value > 10f) { list.Add(item.Key); } } foreach (Container item2 in list) { LastUsed.Remove(item2); } } } internal static class EpicLootBridge { internal const string EpicLootGuid = "randyknapp.mods.epicloot"; private static readonly List<ItemData> Items = new List<ItemData>(); private static int _itemsFrame = -1; private static readonly HashSet<Container> Touched = new HashSet<Container>(); private static float _nextSave; private static bool _wasOpen; private static Func<bool> _enchantingVisible; private static bool _tried; internal static bool EnchantingOpen { get { try { return _enchantingVisible != null && _enchantingVisible(); } catch { return false; } } } internal static void TryRegister() { if (_tried) { return; } _tried = true; if (!Chainloader.PluginInfos.TryGetValue("randyknapp.mods.epicloot", out var value) || (Object)(object)value.Instance == (Object)null) { return; } try { MethodInfo methodInfo = ((object)value.Instance).GetType().Assembly.GetType("EpicLoot.API")?.GetMethod("RegisterInventoryProvider", BindingFlags.Static | BindingFlags.Public); if (methodInfo == null) { Plugin.Log.LogWarning((object)"EpicLoot bez API.RegisterInventoryProvider - stol zaklinania nie bedzie bral ze skrzyn."); return; } Func<List<ItemData>> func = GetItems; Func<string, int> func2 = (string name) => Usable() ? Containers.OwnedCount(name) : 0; Func<string, int, int> func3 = (string name, int amount) => Usable() ? Containers.RemoveDirect(name, amount) : 0; Func<ItemData, int, int> func4 = (ItemData item, int amount) => (Usable() && Plugin.EnchantFromChests.Value) ? Containers.RemoveExact(item, amount) : 0; bool flag = (bool)methodInfo.Invoke(null, new object[5] { "local.craftfromcontainers", func, func2, func3, func4 }); Plugin.Log.LogInfo((object)(flag ? "Stol zaklinania EpicLoot pobiera materialy ze skrzyn." : "EpicLoot odrzucil rejestracje dostawcy.")); Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); for (int num = 0; num < assemblies.Length; num++) { Type type = assemblies[num].GetType("EpicLoot_UnityLib.EnchantingTableUI", throwOnError: false); if (!(type == null)) { MethodInfo method = type.GetMethod("IsVisible", BindingFlags.Static | BindingFlags.Public, null, Type.EmptyTypes, null); if (method != null) { _enchantingVisible = (Func<bool>)Delegate.CreateDelegate(typeof(Func<bool>), method); } break; } } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Integracja z EpicLoot nie wstala: " + ex.Message)); } } private static bool Usable() { if (Plugin.Active) { return Plugin.CraftEnabled.Value; } return false; } private static List<ItemData> GetItems() { if (_itemsFrame == Time.frameCount) { return Items; } _itemsFrame = Time.frameCount; Items.Clear(); if (Usable() && Plugin.EnchantFromChests.Value) { Containers.CollectOwnedItems(Items, Touched); } return Items; } internal static void Tick() { bool enchantingOpen = EnchantingOpen; if (Touched.Count == 0) { _wasOpen = enchantingOpen; return; } bool flag = _wasOpen && !enchantingOpen; _wasOpen = enchantingOpen; if (!flag && (!enchantingOpen || Time.time < _nextSave)) { return; } _nextSave = Time.time + 1f; foreach (Container item in Touched) { Containers.MarkChanged(item); } if (flag) { Touched.Clear(); } } } internal static class MultiCraft { [HarmonyPatch(typeof(InventoryGui), "UpdateRecipe")] private static class InventoryGui_UpdateRecipe { private static void Prefix(InventoryGui __instance) { Apply(__instance); } private static void Postfix(InventoryGui __instance) { if (!Enabled) { if ((Object)(object)_root != (Object)null) { _root.SetActive(false); } return; } EnsureUi(__instance); if (!((Object)(object)_root == (Object)null)) { bool flag = Applies(__instance) && CraftTimer.Invoke(__instance) < 0f && ((Component)__instance.m_craftButton).gameObject.activeInHierarchy; if (flag) { Reposition(); } if (_root.activeSelf != flag) { _root.SetActive(flag); } } } } [HarmonyPatch(typeof(InventoryGui), "OnCraftPressed")] private static class InventoryGui_OnCraftPressed { private static void Prefix(InventoryGui __instance) { Apply(__instance); } } [CompilerGenerated] private static class <>O { public static UnityAction <0>__SetMin; public static UnityAction <1>__SetMax; } [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static UnityAction <>9__26_0; public static UnityAction <>9__26_1; internal void <EnsureUi>b__26_0() { Change(-1); } internal void <EnsureUi>b__26_1() { Change(1); } } private static readonly FieldRef<InventoryGui, bool> TouchMulti = AccessTools.FieldRefAccess<InventoryGui, bool>("m_touchMultiCrafting"); private static readonly FieldRef<InventoryGui, float> CraftTimer = AccessTools.FieldRefAccess<InventoryGui, float>("m_craftTimer"); private static readonly FieldInfo SelectedField = AccessTools.Field(typeof(InventoryGui), "m_selectedRecipe"); private static PropertyInfo _recipeProp; private static PropertyInfo _itemProp; private static int _amount = 1; private static bool _touchSetByUs; private static int _vanillaAmount = -1; private static GameObject _root; private static InventoryGui _owner; private static RectTransform _craftRect; private static readonly Vector3[] Corners = (Vector3[])(object)new Vector3[4]; private static RectTransform _panelRect; private static bool Enabled => Plugin.MultiCraftEnabled.Value; private static int Max => Mathf.Max(2, Plugin.MultiCraftMax.Value); private static Recipe Selected(InventoryGui gui, out ItemData upgradeItem) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Expected O, but got Unknown object value = SelectedField.GetValue(gui); if (_recipeProp == null) { _recipeProp = AccessTools.Property(value.GetType(), "Recipe"); _itemProp = AccessTools.Property(value.GetType(), "ItemData"); } upgradeItem = (ItemData)_itemProp.GetValue(value); return (Recipe)_recipeProp.GetValue(value); } private static bool Applies(InventoryGui gui) { if (!Enabled) { return false; } if ((Object)(object)Selected(gui, out var upgradeItem) != (Object)null) { return upgradeItem == null; } return false; } private static void Apply(InventoryGui gui) { if (_vanillaAmount < 0) { _vanillaAmount = gui.m_multiCraftAmount; } if (Applies(gui) && _amount > 1) { gui.m_multiCraftAmount = _amount; TouchMulti.Invoke(gui) = true; _touchSetByUs = true; return; } gui.m_multiCraftAmount = _vanillaAmount; if (_touchSetByUs) { TouchMulti.Invoke(gui) = false; } _touchSetByUs = false; } private static void Change(int delta) { if (ZInput.GetKey((KeyCode)306, true) || ZInput.GetKey((KeyCode)305, true)) { delta *= 10; } _amount = Mathf.Clamp(_amount + delta, 1, Max); } private static void SetMax() { InventoryGui instance = InventoryGui.instance; Player localPlayer = Player.m_localPlayer; if ((Object)(object)instance == (Object)null || (Object)(object)localPlayer == (Object)null || !Applies(instance)) { return; } ItemData upgradeItem; Recipe val = Selected(instance, out upgradeItem); Inventory inventory = ((Humanoid)localPlayer).GetInventory(); int amount = 1; for (int num = Max; num >= 1; num--) { if (localPlayer.HaveRequirements(val, false, 1, num) && inventory.CanAddItem(((Component)val.m_item).gameObject, val.m_amount * num)) { amount = num; break; } } _amount = amount; } private static void SetMin() { _amount = 1; } private static void Reposition() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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_009b: 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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_root == (Object)null) && !((Object)(object)_craftRect == (Object)null)) { RectTransform val = (RectTransform)_root.transform.parent; _craftRect.GetWorldCorners(Corners); Vector3 val2 = ((Transform)val).InverseTransformPoint(Corners[0]); float num = val2.y; if ((Object)(object)_panelRect != (Object)null) { _panelRect.GetWorldCorners(Corners); num = Mathf.Min(num, ((Transform)val).InverseTransformPoint(Corners[0]).y); } _root.transform.localPosition = new Vector3(val2.x, num - 6f, 0f); } } private static void EnsureUi(InventoryGui gui) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: 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_00c1: Expected O, but got Unknown //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Expected O, but got Unknown //IL_00f0: 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_010a: 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_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Expected O, but got Unknown //IL_019c: 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_01a7: Expected O, but got Unknown //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Expected O, but got Unknown //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Expected O, but got Unknown if ((Object)(object)_root != (Object)null && (Object)(object)_owner == (Object)(object)gui) { return; } _owner = gui; RectTransform component = ((Component)gui.m_craftButton).GetComponent<RectTransform>(); Transform parent = ((Transform)component).parent; RectTransform val = (RectTransform)(object)((parent is RectTransform) ? parent : null); if ((Object)(object)component == (Object)null || (Object)(object)val == (Object)null) { return; } float num = 4f; Rect rect = component.rect; float width = ((Rect)(ref rect)).width; float num2 = (width - num) / 2f; rect = component.rect; float num3 = Mathf.Clamp(((Rect)(ref rect)).height * 0.6f, 26f, 40f); float num4 = 2f * num3 + num; _root = new GameObject("CFC_MultiCraft", new Type[1] { typeof(RectTransform) }); RectTransform val2 = (RectTransform)_root.transform; ((Transform)val2).SetParent((Transform)(object)val, false); Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor(0.5f, 0.5f); val2.anchorMax = val3; val2.anchorMin = val3; val2.pivot = new Vector2(0f, 1f); val2.sizeDelta = new Vector2(width, num4); _craftRect = component; _panelRect = gui.m_crafting; Reposition(); object obj = <>c.<>9__26_0; if (obj == null) { UnityAction val4 = delegate { Change(-1); }; <>c.<>9__26_0 = val4; obj = (object)val4; } MakeButton(gui, val2, "-", 0f, 0f, num2, num3, (UnityAction)obj); float x = num2 + num; object obj2 = <>c.<>9__26_1; if (obj2 == null) { UnityAction val5 = delegate { Change(1); }; <>c.<>9__26_1 = val5; obj2 = (object)val5; } MakeButton(gui, val2, "+", x, 0f, num2, num3, (UnityAction)obj2); float y = 0f - (num3 + num); object obj3 = <>O.<0>__SetMin; if (obj3 == null) { UnityAction val6 = SetMin; <>O.<0>__SetMin = val6; obj3 = (object)val6; } MakeButton(gui, val2, "Min", 0f, y, num2, num3, (UnityAction)obj3); float x2 = num2 + num; float y2 = 0f - (num3 + num); object obj4 = <>O.<1>__SetMax; if (obj4 == null) { UnityAction val7 = SetMax; <>O.<1>__SetMax = val7; obj4 = (object)val7; } MakeButton(gui, val2, "Max", x2, y2, num2, num3, (UnityAction)obj4); _root.SetActive(false); } private static void MakeButton(InventoryGui gui, RectTransform parent, string label, float x, float y, float w, float h, UnityAction onClick) { //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: 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_00c8: 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_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: 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_0118: Expected O, but got Unknown GameObject val = Object.Instantiate<GameObject>(((Component)gui.m_craftButton).gameObject, (Transform)(object)parent, false); ((Object)val).name = "CFC_MultiCraft_" + label; UIGamePad[] componentsInChildren = val.GetComponentsInChildren<UIGamePad>(true); for (int i = 0; i < componentsInChildren.Length; i++) { Object.Destroy((Object)(object)componentsInChildren[i]); } EventTrigger[] componentsInChildren2 = val.GetComponentsInChildren<EventTrigger>(true); for (int i = 0; i < componentsInChildren2.Length; i++) { Object.Destroy((Object)(object)componentsInChildren2[i]); } MonoBehaviour[] componentsInChildren3 = val.GetComponentsInChildren<MonoBehaviour>(true); foreach (MonoBehaviour val2 in componentsInChildren3) { if ((Object)(object)val2 != (Object)null && ((object)val2).GetType().Name == "UITooltip") { Object.Destroy((Object)(object)val2); } } RectTransform val3 = (RectTransform)val.transform; Vector2 val4 = default(Vector2); ((Vector2)(ref val4))..ctor(0f, 1f); val3.anchorMax = val4; val3.anchorMin = val4; val3.pivot = new Vector2(0f, 1f); val3.sizeDelta = new Vector2(w, h); val3.anchoredPosition = new Vector2(x, y); Button component = val.GetComponent<Button>(); component.onClick = new ButtonClickedEvent(); ((UnityEvent)component.onClick).AddListener(onClick); ((Selectable)component).interactable = true; TMP_Text componentInChildren = val.GetComponentInChildren<TMP_Text>(true); if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.text = label; componentInChildren.enableAutoSizing = true; componentInChildren.fontSizeMin = 8f; } } } internal class OwnershipRequester : MonoBehaviour { internal static bool LocallyBusy; private const float Interval = 0.5f; private const int BudgetPerTick = 6; private const float Cooldown = 5f; private readonly Dictionary<Container, float> _asked = new Dictionary<Container, float>(); private float _next; private float _nextPrune; private void Update() { EpicLootBridge.Tick(); Player localPlayer = Player.m_localPlayer; LocallyBusy = (Object)(object)localPlayer != (Object)null && Plugin.Active && IsCraftingOrBuilding(localPlayer); if (!LocallyBusy || Time.time < _next) { return; } _next = Time.time + 0.5f; long playerID = localPlayer.GetPlayerID(); int num = 6; foreach (Container notOwnedContainer in Containers.NotOwnedContainers) { if (num == 0) { break; } if (!_asked.TryGetValue(notOwnedContainer, out var value) || !(Time.time - value < 5f)) { Inventory inventory = notOwnedContainer.GetInventory(); if (inventory != null && inventory.NrOfItems() != 0) { _asked[notOwnedContainer] = Time.time; num--; Containers.RequestOwnership(notOwnedContainer, playerID); Plugin.Debug("Prosba o wlasnosc: " + ((Object)notOwnedContainer).name); } } } if (!(Time.time >= _nextPrune)) { return; } _nextPrune = Time.time + 30f; List<Container> list = new List<Container>(); foreach (KeyValuePair<Container, float> item in _asked) { if ((Object)(object)item.Key == (Object)null || Time.time - item.Value > 5f) { list.Add(item.Key); } } foreach (Container item2 in list) { _asked.Remove(item2); } Containers.PruneLastUsed(); } private static bool IsCraftingOrBuilding(Player player) { if (Plugin.CraftEnabled.Value && InventoryGui.IsVisible() && (Object)(object)InventoryGui.instance != (Object)null && InventoryGui.instance.InCraftTab()) { return true; } if (Plugin.CraftEnabled.Value && EpicLootBridge.EnchantingOpen) { return true; } if (Plugin.BuildEnabled.Value) { return ((Character)player).InPlaceMode(); } return false; } } [HarmonyPatch(typeof(Container), "Awake")] internal static class Container_Awake { [HarmonyPriority(0)] private static void Postfix(Container __instance) { Containers.OnAwake(__instance); } } [HarmonyPatch(typeof(Player), "HaveRequirementItems")] internal static class Player_HaveRequirementItems { [HarmonyPriority(800)] private static void Postfix(Player __instance, ref bool __result, Recipe piece, bool discover, int qualityLevel, int amount) { if (__result || discover || (Object)(object)__instance != (Object)(object)Player.m_localPlayer || !Plugin.CraftEnabled.Value || !Plugin.Active || (Object)(object)piece == (Object)null || piece.m_resources == null || piece.m_requireOnlyOneIngredient) { return; } CraftingStation currentCraftingStation = __instance.GetCurrentCraftingStation(); Inventory inventory = ((Humanoid)__instance).GetInventory(); Requirement[] resources = piece.m_resources; foreach (Requirement val in resources) { if ((!((Object)(object)currentCraftingStation != (Object)null) || currentCraftingStation.m_upgrader == val.m_upgraderResource) && (!((Object)(object)currentCraftingStation == (Object)null) || !val.m_upgraderResource) && Object.op_Implicit((Object)(object)val.m_resItem)) { int num = val.GetAmount(qualityLevel) * amount; SharedData shared = val.m_resItem.m_itemData.m_shared; int num2 = 0; for (int j = 1; j <= shared.m_maxQuality; j++) { num2 = Mathf.Max(num2, inventory.CountItems(shared.m_name, j, true)); } if (shared.m_maxQuality <= 1) { num2 += Containers.OwnedCount(shared.m_name); } if (num2 < num) { return; } } } __result = true; } } [HarmonyPatch(typeof(Player), "HaveRequirements", new Type[] { typeof(Piece), typeof(RequirementMode) })] internal static class Player_HaveRequirements_Piece { private static readonly FieldRef<Player, Dictionary<string, int>> KnownStations = AccessTools.FieldRefAccess<Player, Dictionary<string, int>>("m_knownStations"); [HarmonyPriority(800)] private static void Postfix(Player __instance, ref bool __result, Piece piece, RequirementMode mode) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Invalid comparison between Unknown and I4 //IL_0074: 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_0113: Invalid comparison between Unknown and I4 if (__result || (int)mode == 1 || (Object)(object)piece == (Object)null || (Object)(object)__instance != (Object)(object)Player.m_localPlayer || !Plugin.BuildEnabled.Value || !Plugin.Active) { return; } if (Object.op_Implicit((Object)(object)piece.m_craftingStation)) { if ((int)mode == 2) { if (!KnownStations.Invoke(__instance).ContainsKey(piece.m_craftingStation.m_name)) { return; } } else if (!Object.op_Implicit((Object)(object)CraftingStation.HaveBuildStationInRange(piece.m_craftingStation.m_name, ((Component)__instance).transform.position)) && !ZoneSystem.instance.GetGlobalKey((GlobalKeys)27)) { return; } } if (piece.m_dlc.Length > 0 && !DLCMan.instance.IsDLCInstalled(piece.m_dlc)) { return; } Inventory inventory = ((Humanoid)__instance).GetInventory(); Requirement[] resources = piece.m_resources; foreach (Requirement val in resources) { if (!Object.op_Implicit((Object)(object)val.m_resItem) || val.m_amount <= 0) { continue; } SharedData shared = val.m_resItem.m_itemData.m_shared; int num = ((shared.m_maxQuality <= 1) ? Containers.OwnedCount(shared.m_name) : 0); if ((int)mode == 2) { if (!inventory.HaveItem(shared.m_name, true) && num <= 0) { return; } } else if (inventory.CountItems(shared.m_name, -1, true) + num < val.m_amount) { return; } } __result = true; } } [HarmonyPatch(typeof(Player), "ConsumeResources")] internal static class Player_ConsumeResources { [HarmonyPriority(800)] private static void Prefix(Player __instance, Requirement[] requirements, int qualityLevel, int itemQuality, int multiplier) { if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer || requirements == null || !Plugin.Active || (InventoryGui.IsVisible() ? (!Plugin.CraftEnabled.Value) : (!Plugin.BuildEnabled.Value)) || itemQuality > 1) { return; } CraftingStation currentCraftingStation = __instance.GetCurrentCraftingStation(); Inventory inventory = ((Humanoid)__instance).GetInventory(); foreach (Requirement val in requirements) { if (!Object.op_Implicit((Object)(object)val.m_resItem) || (((Object)(object)currentCraftingStation != (Object)null) ? (currentCraftingStation.m_upgrader != val.m_upgraderResource) : val.m_upgraderResource)) { continue; } SharedData shared = val.m_resItem.m_itemData.m_shared; if (shared.m_maxQuality > 1) { continue; } int num = val.GetAmount(qualityLevel) * multiplier; if (num <= 0) { continue; } int num2 = num - inventory.CountItems(shared.m_name, itemQuality, true); if (num2 > 0) { int num3 = Containers.StageInto(inventory, shared.m_name, num2); int num4 = num2 - num3; int num5 = ((num4 > 0) ? Containers.RemoveDirect(shared.m_name, num4) : 0); num4 -= num5; Plugin.Debug($"{shared.m_name}: brakowalo {num2}, przeniesiono {num3}, zdjeto wprost {num5}"); if (num4 > 0) { Plugin.Log.LogWarning((object)$"Nie znaleziono w skrzyniach {num4}x {shared.m_name} (brakowalo {num2})."); } } } } } [HarmonyPatch(typeof(InventoryGui), "SetupRequirement")] internal static class InventoryGui_SetupRequirement { private static void Postfix(bool __result, Transform elementRoot, Requirement req, Player player, bool craft, int quality, int craftMultiplier) { //IL_00cd: Unknown result type (might be due to invalid IL or missing references) if (!__result || req == null || (Object)(object)req.m_resItem == (Object)null || (Object)(object)player == (Object)null || (Object)(object)player != (Object)(object)Player.m_localPlayer || !Plugin.Active || (craft ? (!Plugin.CraftEnabled.Value) : (!Plugin.BuildEnabled.Value))) { return; } SharedData shared = req.m_resItem.m_itemData.m_shared; if (shared.m_maxQuality > 1) { return; } int num = Containers.OwnedCount(shared.m_name); if (num <= 0) { return; } int num2 = req.GetAmount(quality) * craftMultiplier; if (num2 <= 0) { return; } Transform obj = elementRoot.Find("res_amount"); TMP_Text val = ((obj != null) ? ((Component)obj).GetComponent<TMP_Text>() : null); if (!((Object)(object)val == (Object)null)) { if (((Humanoid)player).GetInventory().CountItems(shared.m_name, -1, true) + num >= num2) { ((Graphic)val).color = Color.white; } if (Plugin.ShowCounts.Value) { val.text = num2 + " <size=70%><color=#9ae59a>+" + num + "</color></size>"; } } } } [BepInPlugin("local.craftfromcontainers", "Craft From Containers", "1.3.2")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] [SynchronizationMode(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string GUID = "local.craftfromcontainers"; public const string NAME = "Craft From Containers"; public const string VERSION = "1.3.2"; internal const string DvergerGuid = "MidngightsFX.DvergerAutomation"; private static readonly string[] ConflictingGuids = new string[2] { "aedenthorn.CraftFromContainers", "buldosik.EpicLootCraftFromContainers" }; internal static ManualLogSource Log; internal static ConfigEntry<bool> Enabled; internal static ConfigEntry<float> Range; internal static ConfigEntry<bool> CraftEnabled; internal static ConfigEntry<bool> BuildEnabled; internal static ConfigEntry<bool> PlayerBuiltOnly; internal static ConfigEntry<bool> IncludeVehicles; internal static ConfigEntry<bool> SkipCustomDataItems; internal static ConfigEntry<string> ExcludedContainers; internal static ConfigEntry<bool> EnchantFromChests; internal static ConfigEntry<bool> StarLootEnabled; internal static ConfigEntry<float> StarLootPerStar; internal static ConfigEntry<bool> MultiCraftEnabled; internal static ConfigEntry<int> MultiCraftMax; internal static ConfigEntry<bool> ShowCounts; internal static ConfigEntry<bool> DebugLog; internal static readonly HashSet<string> Excluded = new HashSet<string>(StringComparer.OrdinalIgnoreCase); private static ConfigEntryBase _dvergerCraft; private static bool _dvergerResolved; private static bool _dvergerLoaded; private static string _conflict; private static bool _conflictWarned; internal static bool Active { get { if (!Enabled.Value) { return false; } string text = FindConflict(); if (text == null) { return true; } if (!_conflictWarned) { _conflictWarned = true; Log.LogWarning((object)("Craft From Containers wstrzymany: " + text + " tez pobiera skladniki ze skrzyn, wiec schodzilyby podwojnie. Odinstaluj go (Dverger: wystarczy wylaczyc 'Craft From Storage').")); } return false; } } private void Awake() { //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_0018: Expected O, but got Unknown //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Expected O, but got Unknown //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Expected O, but got Unknown //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Expected O, but got Unknown //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Expected O, but got Unknown //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Expected O, but got Unknown //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Expected O, but got Unknown //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Expected O, but got Unknown //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Expected O, but got Unknown //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Expected O, but got Unknown //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Expected O, but got Unknown //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Expected O, but got Unknown //IL_0319: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; ConfigurationManagerAttributes val = new ConfigurationManagerAttributes { IsAdminOnly = true }; Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Serwer", "Wlaczony", true, new ConfigDescription("Glowny wlacznik. Ustawiany przez serwer.", (AcceptableValueBase)null, new object[1] { val })); Range = ((BaseUnityPlugin)this).Config.Bind<float>("Serwer", "Zasieg", 20f, new ConfigDescription("Promien (m) wokol gracza, z ktorego brane sa skrzynie.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 50f), new object[1] { val })); CraftEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Serwer", "Crafting ze skrzyn", true, new ConfigDescription("Czy stacje rzemieslnicze moga brac skladniki ze skrzyn.", (AcceptableValueBase)null, new object[1] { val })); BuildEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Serwer", "Budowanie ze skrzyn", true, new ConfigDescription("Czy mlotek moze brac materialy ze skrzyn.", (AcceptableValueBase)null, new object[1] { val })); PlayerBuiltOnly = ((BaseUnityPlugin)this).Config.Bind<bool>("Serwer", "Tylko skrzynie graczy", true, new ConfigDescription("Tylko skrzynie postawione przez gracza. Wylacza skrzynie w lochach, wraki i inne pojemniki swiata.", (AcceptableValueBase)null, new object[1] { val })); IncludeVehicles = ((BaseUnityPlugin)this).Config.Bind<bool>("Serwer", "Wozki i lodzie", false, new ConfigDescription("Czy liczyc ladownie wozkow i lodzi. Domyslnie wylaczone: przejmowanie wlasnosci lodzi przenosi tez jej fizyke.", (AcceptableValueBase)null, new object[1] { val })); SkipCustomDataItems = ((BaseUnityPlugin)this).Config.Bind<bool>("Serwer", "Pomijaj przedmioty magiczne", true, new ConfigDescription("Nie zuzywa przedmiotow z dodatkowymi danymi (np. zaklete z EpicLoot, z gniazdami).", (AcceptableValueBase)null, new object[1] { val })); EnchantFromChests = ((BaseUnityPlugin)this).Config.Bind<bool>("Serwer", "Stol zaklinania: przedmioty ze skrzyn", true, new ConfigDescription("Stol zaklinania EpicLoot widzi przedmioty ze skrzyn w poblizu - mozna je zaklinac, poswiecac i odczarowywac bez przenoszenia do ekwipunku. Wylacz, jesli boisz sie pomylki przy poswiecaniu.", (AcceptableValueBase)null, new object[1] { val })); ExcludedContainers = ((BaseUnityPlugin)this).Config.Bind<string>("Serwer", "Wykluczone pojemniki", "", new ConfigDescription("Nazwy prefabow pojemnikow do pominiecia, oddzielone przecinkami.", (AcceptableValueBase)null, new object[1] { val })); StarLootEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Loot za gwiazdki", "Wlaczony", true, new ConfigDescription("Kazda gwiazdka StarLevelSystem dodaje czesc bazowego dropu zamiast mnozyc go x2, x3. Dotyczy dropow, ktore w vanilli rosna z poziomem (mieso, skory...). Trofea bez zmian.", (AcceptableValueBase)null, new object[1] { val })); StarLootPerStar = ((BaseUnityPlugin)this).Config.Bind<float>("Loot za gwiazdki", "Premia za gwiazdke", 0.3333f, new ConfigDescription("Ulamek bazowej ilosci dodawany za kazda gwiazdke. 0.3333 = 3 mieso -> 4 -> 5 -> 6.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 2f), new object[1] { val })); MultiCraftEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Klient", "Multi-crafting", true, "Przyciski -/+/Min/Max pod przyciskiem Craft do craftowania wielu sztuk naraz (Ctrl + klik = o 10)."); MultiCraftMax = ((BaseUnityPlugin)this).Config.Bind<int>("Klient", "Multi-crafting maks", 100, new ConfigDescription("Najwieksza ilosc do wyboru przyciskami.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(2, 999), Array.Empty<object>())); ShowCounts = ((BaseUnityPlugin)this).Config.Bind<bool>("Klient", "Pokazuj ilosci ze skrzyn", true, "Dopisuje przy skladniku ile sztuk jest w skrzyniach (+N)."); DebugLog = ((BaseUnityPlugin)this).Config.Bind<bool>("Klient", "Log diagnostyczny", false, "Loguje kazde pobranie ze skrzyni i kazda prosbe o wlasnosc."); RebuildExcluded(); ExcludedContainers.SettingChanged += delegate { RebuildExcluded(); }; new Harmony("local.craftfromcontainers").PatchAll(typeof(Plugin).Assembly); ((Component)this).gameObject.AddComponent<OwnershipRequester>(); Log.LogInfo((object)"Craft From Containers 1.3.2 zaladowany."); } private static void RebuildExcluded() { Excluded.Clear(); string[] array = ExcludedContainers.Value.Split(','); for (int i = 0; i < array.Length; i++) { string text = array[i].Trim(); if (text.Length > 0) { Excluded.Add(text); } } } private void Start() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown EpicLootBridge.TryRegister(); StarLoot.Patch(new Harmony("local.craftfromcontainers.starloot")); } private static string FindConflict() { if (!_dvergerResolved) { _dvergerResolved = true; string[] conflictingGuids = ConflictingGuids; foreach (string text in conflictingGuids) { if (Chainloader.PluginInfos.ContainsKey(text)) { _conflict = text; break; } } if (Chainloader.PluginInfos.TryGetValue("MidngightsFX.DvergerAutomation", out var value) && (Object)(object)value.Instance != (Object)null) { _dvergerLoaded = true; foreach (KeyValuePair<ConfigDefinition, ConfigEntryBase> item in value.Instance.Config) { if (item.Key.Section == "Client config" && item.Key.Key == "Craft From Storage") { _dvergerCraft = item.Value; break; } } } } if (_conflict != null) { return _conflict; } if (!_dvergerLoaded) { return null; } if (_dvergerCraft != null) { object boxedValue = _dvergerCraft.BoxedValue; bool flag = default(bool); int num; if (boxedValue is bool) { flag = (bool)boxedValue; num = 1; } else { num = 0; } if (((uint)num & (flag ? 1u : 0u)) == 0) { return null; } } return "MidngightsFX.DvergerAutomation"; } internal static void Debug(string msg) { if (DebugLog.Value) { Log.LogInfo((object)msg); } } } internal static class StarLoot { internal const string SlsGuid = "MidnightsFX.StarLevelSystem"; private static int _level; private static bool Active => Plugin.StarLootEnabled.Value; internal static void Patch(Harmony harmony) { //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Expected O, but got Unknown //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Expected O, but got Unknown //IL_00fb: Expected O, but got Unknown if (!Chainloader.PluginInfos.TryGetValue("MidnightsFX.StarLevelSystem", out var value) || (Object)(object)value.Instance == (Object)null) { Plugin.Log.LogInfo((object)"StarLevelSystem nie jest zaladowany - loot za gwiazdki wylaczony."); return; } Type type = ((object)value.Instance).GetType().Assembly.GetType("StarLevelSystem.modules.Loot.LootPatches+CalculateLootPerLevelStyle"); MethodInfo methodInfo = ((type == null) ? null : AccessTools.Method(type, "DetermineLootScale", (Type[])null, (Type[])null)); if (methodInfo == null) { Plugin.Log.LogWarning((object)"Nie znaleziono StarLevelSystem DetermineLootScale (inna wersja SLS?) - loot za gwiazdki wylaczony."); return; } harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(StarLoot), "DetermineLootScalePrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)AccessTools.Method(typeof(CharacterDrop), "GenerateDropList", (Type[])null, (Type[])null), new HarmonyMethod(typeof(StarLoot), "GenerateDropListPrefix", (Type[])null) { priority = 800 }, new HarmonyMethod(typeof(StarLoot), "GenerateDropListPostfix", (Type[])null) { priority = 0 }, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private static void GenerateDropListPrefix() { _level = 0; } private static bool DetermineLootScalePrefix(Character character, ref int __result) { if (!Active || (Object)(object)character == (Object)null) { return true; } _level = character.GetLevel(); __result = 1; return false; } private static void GenerateDropListPostfix(CharacterDrop __instance, List<KeyValuePair<GameObject, int>> __result) { int level = _level; _level = 0; if (level <= 1 || __result == null || __result.Count == 0) { return; } float num = 1f + Plugin.StarLootPerStar.Value * (float)(level - 1); for (int i = 0; i < __result.Count; i++) { KeyValuePair<GameObject, int> keyValuePair = __result[i]; if (ScalesWithLevel(__instance, keyValuePair.Key)) { int value = Mathf.Max(keyValuePair.Value, (int)Math.Round((float)keyValuePair.Value * num, MidpointRounding.AwayFromZero)); __result[i] = new KeyValuePair<GameObject, int>(keyValuePair.Key, value); } } } private static bool ScalesWithLevel(CharacterDrop cdrop, GameObject prefab) { foreach (Drop drop in cdrop.m_drops) { if ((Object)(object)drop.m_prefab == (Object)(object)prefab) { return drop.m_levelMultiplier && !drop.m_onePerPlayer; } } return false; } } }