Decompiled source of GAP Crafted Loot and Carry v1.0.0

plugins/GapCarryWeight.dll

Decompiled a week ago
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Jotunn.Utils;

[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: CompilationRelaxations(8)]
[assembly: AssemblyVersion("0.0.0.0")]
[BepInPlugin("gap.carryweight", "GAP Carry Weight", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
public class GapCarryWeight : BaseUnityPlugin
{
	private static ConfigEntry<float> BaseCapacity;

	private void Awake()
	{
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Expected O, but got Unknown
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		BaseCapacity = ((BaseUnityPlugin)this).Config.Bind<float>("Carry Weight", "Base capacity", 900f, new ConfigDescription("Base carrying capacity; equipment and status bonuses are still applied normally.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(300f, 30000f), new object[0]));
		new Harmony("gap.carryweight").PatchAll(typeof(GapCarryWeight));
		((BaseUnityPlugin)this).Logger.LogInfo((object)("Base carry capacity: " + BaseCapacity.Value + "; native equipment/status bonuses preserved."));
	}

	[HarmonyPatch(typeof(Player), "GetMaxCarryWeight")]
	[HarmonyPrefix]
	private static void SetBase(Player __instance)
	{
		__instance.m_maxCarryWeight = BaseCapacity.Value;
	}
}

plugins/GapCraftedLoot.dll

Decompiled a week ago
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using EpicLoot;
using EpicLoot.GatedItemType;
using HarmonyLib;
using Jotunn.Utils;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("gap.craftedloot", "GAP Crafted Loot", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class GapCraftedLoot : BaseUnityPlugin
{
	[HarmonyPatch]
	private class CheckGate
	{
		private static MethodBase TargetMethod()
		{
			return AccessTools.Method(typeof(GatedItemTypeHelper), "CheckIfItemNeedsGate", new Type[2]
			{
				typeof(GatedItemTypeMode),
				typeof(string)
			}, (Type[])null);
		}

		private static bool Prefix(GatedItemTypeMode mode, string itemName, ref bool __result)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			if (!Active(mode) || !IsEquipment(itemName))
			{
				return true;
			}
			__result = IsLocked(itemName);
			return false;
		}
	}

	[HarmonyPatch]
	private class CheckDetailedGate
	{
		private static MethodBase TargetMethod()
		{
			return AccessTools.Method(typeof(GatedItemTypeHelper), "CheckIfItemNeedsGate", new Type[3]
			{
				typeof(GatedItemTypeMode),
				typeof(string),
				typeof(GatedItemDetails).MakeByRefType()
			}, (Type[])null);
		}

		private static void Postfix(GatedItemTypeMode mode, string itemName, ref bool __result)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			if (Active(mode) && IsEquipment(itemName))
			{
				__result = IsLocked(itemName);
			}
		}
	}

	[HarmonyPatch]
	private class FinalTypeGuard
	{
		private static IEnumerable<MethodBase> TargetMethods()
		{
			return (from m in typeof(GatedItemTypeHelper).GetMethods(BindingFlags.Static | BindingFlags.Public)
				where m.Name == "GetGatedItemFromType"
				select m).Cast<MethodBase>();
		}

		private static void Postfix(GatedItemTypeMode mode, ref string __result)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			if (Active(mode) && IsLocked(__result))
			{
				__result = null;
			}
		}
	}

	[HarmonyPatch(typeof(GatedItemTypeHelper), "GetGatedItemNameFromItemOrType")]
	private class FinalNameGuard
	{
		private static void Postfix(GatedItemTypeMode gatedMode, ref string __result)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			if (Active(gatedMode) && IsLocked(__result))
			{
				__result = null;
			}
		}
	}

	private const string Prefix = "gapcrafted_v1_";

	private static readonly HashSet<string> EquipmentTypes = new HashSet<string>
	{
		"OneHandedWeapon", "TwoHandedWeapon", "TwoHandedWeaponLeft", "Bow", "Shield", "Helmet", "Chest", "Legs", "Shoulder", "Utility",
		"Trinket", "Tool", "Torch", "Staff"
	};

	private float nextSync;

	private static bool Active(GatedItemTypeMode mode)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0002: Invalid comparison between Unknown and I4
		return (int)mode == 4;
	}

	private static string Key(string prefab)
	{
		return "gapcrafted_v1_" + prefab.ToLowerInvariant();
	}

	private static bool IsEquipment(string name)
	{
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)ObjectDB.instance == (Object)null || string.IsNullOrEmpty(name))
		{
			return false;
		}
		GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(name);
		if ((Object)(object)itemPrefab == (Object)null)
		{
			return false;
		}
		ItemDrop component = itemPrefab.GetComponent<ItemDrop>();
		if ((Object)(object)component != (Object)null)
		{
			return EquipmentTypes.Contains(((object)component.m_itemData.m_shared.m_itemType).ToString());
		}
		return false;
	}

	private static bool IsLocked(string name)
	{
		if (IsEquipment(name))
		{
			if (!((Object)(object)ZoneSystem.instance == (Object)null))
			{
				return !ZoneSystem.instance.GetGlobalKey(Key(name));
			}
			return true;
		}
		return false;
	}

	private void Awake()
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		new Harmony("gap.craftedloot").PatchAll(typeof(GapCraftedLoot).Assembly);
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Craft-stat gate loaded. Requires Item Drop Limits = PlayerMustHaveCraftedItem on the host. All peers must use this helper.");
	}

	private void Update()
	{
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		if (Time.realtimeSinceStartup < nextSync)
		{
			return;
		}
		nextSync = Time.realtimeSinceStartup + 5f;
		if ((Object)(object)Player.m_localPlayer == (Object)null || (Object)(object)Game.instance == (Object)null || (Object)(object)ZoneSystem.instance == (Object)null || (Object)(object)ObjectDB.instance == (Object)null || !Active(EpicLoot.GetGatedItemTypeMode()))
		{
			return;
		}
		PlayerProfile playerProfile = Game.instance.GetPlayerProfile();
		if (playerProfile == null || playerProfile.m_playerStats == null || playerProfile.m_playerStats.Length == 0)
		{
			return;
		}
		Dictionary<string, float> itemCraftStats = playerProfile.m_playerStats[0].m_itemCraftStats;
		if (itemCraftStats == null)
		{
			return;
		}
		int num = 0;
		foreach (GameObject item in ObjectDB.instance.m_items)
		{
			if ((Object)(object)item == (Object)null || !IsEquipment(((Object)item).name))
			{
				continue;
			}
			ItemData itemData = item.GetComponent<ItemDrop>().m_itemData;
			if (itemCraftStats.TryGetValue(itemData.m_shared.m_name, out var value) && value > 0f && !ZoneSystem.instance.GetGlobalKey(Key(((Object)item).name)))
			{
				ZoneSystem.instance.SetGlobalKey(Key(((Object)item).name));
				if (++num >= 12)
				{
					break;
				}
			}
		}
	}
}