Decompiled source of BlacksmithsToolboxRU v2.6.5

BlacksmithsToolbox.dll

Decompiled 5 hours ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using SideLoader;
using SideLoader.Model;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ArmourToolbox")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ArmourToolbox")]
[assembly: AssemblyCopyright("Copyright ©  2019")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("7756f730-2cc1-4e21-bf46-d833536f6bcd")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace BlacksmithsToolbox;

[BepInPlugin("com.sinai.blacksmithstoolbox", "Blacksmith's Toolbox", "2.6.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class BlacksmithsToolbox : BaseUnityPlugin
{
	private const string GUID = "com.sinai.blacksmithstoolbox";

	private const string NAME = "Blacksmith's Toolbox";

	private const string VERSION = "2.6.0";

	public static ConfigEntry<int> ToolboxSilverCostFromStore;

	public static ConfigEntry<int> ToolboxScrapCostPerUse;

	public static ConfigEntry<float> ToolboxDurabilityCostPerUse;

	public const int TOOLBOX_ID = 5850750;

	public Item ToolboxPrefab;

	public static readonly string DROPTABLE_UID = "com.sinai.blacksmithstoolbox_droptable";

	internal void Awake()
	{
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0092: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a7: Expected O, but got Unknown
		//IL_00ae: Expected O, but got Unknown
		//IL_00b5: 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_00f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_010d: Expected O, but got Unknown
		ToolboxSilverCostFromStore = ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "Silver cost from stores", 300, "The cost of the Toolbox from Blacksmith stores. (Requires restart to take effect)");
		ToolboxScrapCostPerUse = ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "Scrap cost per use", 5, "How many iron scrap are consumed per use of the toolbox.");
		ToolboxDurabilityCostPerUse = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "Durability cost per use", 5f, "Durability of the toolbox consumed per use.");
		SL.OnPacksLoaded += OnPacksLoadedSetup;
		SL_DropTable val = new SL_DropTable
		{
			UID = DROPTABLE_UID,
			GuaranteedDrops = new List<SL_ItemDrop>
			{
				new SL_ItemDrop
				{
					DroppedItemID = 5850750
				}
			}
		};
		((ContentTemplate)val).ApplyTemplate();
		SL_DropTableAddition val2 = new SL_DropTableAddition
		{
			SelectorTargets = new List<string> { "3Rx_R0XDLUmYaNWm66SVCQ", "Zdg-qTDRa0-qOzzNSbtvzg", "EYhBqM653UGhDd5kcdMFXg", "QyJwLKySB0epxpEG3EBICQ_3-Finished" },
			DropTableUIDsToAdd = new List<string> { DROPTABLE_UID }
		};
		((ContentTemplate)val2).ApplyTemplate();
	}

	private void OnPacksLoadedSetup()
	{
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: Expected O, but got Unknown
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: Expected O, but got Unknown
		Item itemPrefab = ResourcesPrefabManager.Instance.GetItemPrefab(5850750);
		string description = itemPrefab.Description;
		description = description.Replace("%COST%", ToolboxScrapCostPerUse.Value.ToString());
		CustomItems.SetDescription(itemPrefab, description);
		SL_ItemStats val = new SL_ItemStats
		{
			BaseValue = ToolboxSilverCostFromStore.Value,
			MaxDurability = 100,
			RawWeight = 5f
		};
		val.ApplyToItem(((Component)itemPrefab).GetComponent<ItemStats>());
		GameObject val2 = new GameObject("Effects");
		val2.transform.parent = ((Component)itemPrefab).transform;
		val2.AddComponent<ToolboxEffect>();
	}
}
public class ToolboxEffect : Effect
{
	private void SendUIMessage(Character c, string s)
	{
		c.CharacterUI.ShowInfoNotification(s);
	}

	public override void ActivateLocally(Character _affectedCharacter, object[] _infos)
	{
		if (!_affectedCharacter.IsLocalPlayer)
		{
			return;
		}
		if (BlacksmithsToolbox.ToolboxScrapCostPerUse.Value > 0 && !_affectedCharacter.Inventory.OwnsItem(6400140, BlacksmithsToolbox.ToolboxScrapCostPerUse.Value))
		{
			SendUIMessage(_affectedCharacter, $"You need {BlacksmithsToolbox.ToolboxScrapCostPerUse.Value} Iron Scrap to do that!");
			return;
		}
		bool flag = true;
		Item val = null;
		float num = float.MaxValue;
		foreach (Item ownedItem in _affectedCharacter.Inventory.GetOwnedItems(5850750))
		{
			if (ownedItem.CurrentDurability > 0f && ownedItem.CurrentDurability < num)
			{
				flag = false;
				val = ownedItem;
				num = ownedItem.CurrentDurability;
			}
		}
		if (flag)
		{
			SendUIMessage(_affectedCharacter, $"Your Toolbox is broken!");
			return;
		}
		_affectedCharacter.Inventory.RemoveItem(6400140, BlacksmithsToolbox.ToolboxScrapCostPerUse.Value);
		_affectedCharacter.Inventory.RepairEverything(false);
		val.m_currentDurability = num - BlacksmithsToolbox.ToolboxDurabilityCostPerUse.Value;
		if (val.CurrentDurability <= 0f)
		{
			ItemManager.Instance.DestroyItem(val.UID);
			SendUIMessage(_affectedCharacter, "All items repaired, but your Toolbox was destroyed!");
		}
		else
		{
			SendUIMessage(_affectedCharacter, "All items repaired!");
		}
	}
}