Decompiled source of Joltium Pack v0.0.2

JoltiumPack.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using JoltiumPack.Items;
using Microsoft.CodeAnalysis;
using R2API;
using RoR2;
using UnityEngine;
using UnityEngine.AddressableAssets;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("JoltiumPack")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("JoltiumPack")]
[assembly: AssemblyTitle("JoltiumPack")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.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 JoltiumPack
{
	public static class Assets
	{
		public static AssetBundle mainBundle;

		public const string bundleName = "joltiumpack_assetbundle";

		public static string AssetBundlePath => Path.Combine(Path.GetDirectoryName(JoltiumPack.PInfo.Location), "joltiumpack_assetbundle");

		public static void Init()
		{
			mainBundle = AssetBundle.LoadFromFile(AssetBundlePath);
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("Joltium.JoltiumPack", "JoltiumPack", "0.0.1")]
	public class JoltiumPack : BaseUnityPlugin
	{
		public const string PluginGUID = "Joltium.JoltiumPack";

		public const string PluginAuthor = "Joltium";

		public const string PluginName = "JoltiumPack";

		public const string PluginVersion = "0.0.1";

		private List<JoltiumPack_Item> ItemCollection;

		public static PluginInfo PInfo { get; private set; }

		public void Awake()
		{
			Log.Init(((BaseUnityPlugin)this).Logger);
			PInfo = ((BaseUnityPlugin)this).Info;
			Log.Info("JoltiumPack Plugin is Awake");
			Log.Info("PInfo: " + ((object)PInfo).ToString());
			ItemCollection = new List<JoltiumPack_Item>();
			ItemCollection.Add(new Multi_Pliers());
			foreach (JoltiumPack_Item item in ItemCollection)
			{
				item.Awake();
			}
		}

		private void Update()
		{
			foreach (JoltiumPack_Item item in ItemCollection)
			{
				item.Update();
			}
		}
	}
	internal static class Log
	{
		private static ManualLogSource _logSource;

		internal static void Init(ManualLogSource logSource)
		{
			_logSource = logSource;
		}

		internal static void Debug(object data)
		{
			_logSource.LogDebug(data);
		}

		internal static void Error(object data)
		{
			_logSource.LogError(data);
		}

		internal static void Fatal(object data)
		{
			_logSource.LogFatal(data);
		}

		internal static void Info(object data)
		{
			_logSource.LogInfo(data);
		}

		internal static void Message(object data)
		{
			_logSource.LogMessage(data);
		}

		internal static void Warning(object data)
		{
			_logSource.LogWarning(data);
		}
	}
}
namespace JoltiumPack.Items
{
	internal class Multi_Pliers : JoltiumPack_Item
	{
		private static Sprite icon;

		private static GameObject prefab;

		public Multi_Pliers()
			: base("BASIC_MULTIPLIER_ITEM_NAME", "BASIC_MULTIPLIER_ITEM_PICKUP", "BASIC_MULTIPLIER_ITEM_DESC", "BASIC_MULTIPLIER_ITEM_LORE", 2, "Assets/Import/Joltium/Items/Multi-Pliers/pliers_icon.png", "Assets/Import/Joltium/Items/Multi-Pliers/pliers.prefab")
		{
			Log.Info("Constructing Multi-Pliers");
		}

		public override void Awake()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			base.Awake();
			RecalculateStatsAPI.GetStatCoefficients += new StatHookEventHandler(RecalculateStatsAPI_GetStatCoefficients);
		}

		private void RecalculateStatsAPI_GetStatCoefficients(CharacterBody sender, StatHookEventArgs args)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			Log.Info("Multi-Pliers RecalculateStats started.");
			if (Object.op_Implicit((Object)(object)sender.inventory))
			{
				int itemCount = sender.inventory.GetItemCount(thisItemDef.itemIndex);
				if (itemCount > 0)
				{
					args.damageMultAdd += 1f * (float)itemCount;
				}
			}
		}

		public override void Update()
		{
			//IL_0031: 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)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: 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_0067: Unknown result type (might be due to invalid IL or missing references)
			if (Input.GetKeyDown((KeyCode)283))
			{
				Transform transform = PlayerCharacterMasterController.instances[0].master.GetBodyObject().transform;
				Log.Info($"Player pressed F2. Spawning our custom item at coordinates {transform.position}");
				PickupDropletController.CreatePickupDroplet(PickupCatalog.FindPickupIndex(thisItemDef.itemIndex), transform.position, transform.forward * 20f);
			}
		}
	}
	internal class JoltiumPack_Item : MonoBehaviour
	{
		private static string name;

		private static string description;

		private static string pickup;

		private static string lore;

		private static int tier;

		private static string iconPath;

		private static string prefabPath;

		public ItemDef thisItemDef;

		private static Sprite icon;

		private static GameObject prefab;

		public JoltiumPack_Item(string itemName, string itemDescription, string itemPickupDesc, string itemLore, int itemTier, string itemIconPath, string itemPrefabPath)
		{
			name = itemName;
			description = itemDescription;
			pickup = itemPickupDesc;
			lore = itemLore;
			tier = itemTier;
			iconPath = itemIconPath;
			prefabPath = itemPrefabPath;
		}

		public virtual void Awake()
		{
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Expected O, but got Unknown
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Expected O, but got Unknown
			thisItemDef = ScriptableObject.CreateInstance<ItemDef>();
			((Object)thisItemDef).name = name;
			thisItemDef.nameToken = name;
			thisItemDef.pickupToken = pickup;
			thisItemDef.descriptionToken = description;
			thisItemDef.loreToken = lore;
			thisItemDef._itemTierDef = Addressables.LoadAssetAsync<ItemTierDef>((object)"RoR2/Base/Common/Tier1Def.asset").WaitForCompletion();
			Log.Info("Attempting to load Assets for JoltiumPack Item \"" + name + "\"...");
			Assets.Init();
			icon = Assets.mainBundle.LoadAsset<Sprite>(iconPath);
			prefab = Assets.mainBundle.LoadAsset<GameObject>(prefabPath);
			thisItemDef.pickupIconSprite = icon;
			thisItemDef.pickupModelPrefab = prefab;
			Log.Info("Assets for JoltiumPack Item \"" + name + "\" loaded.");
			thisItemDef.canRemove = true;
			thisItemDef.hidden = false;
			ItemDisplayRuleDict val = new ItemDisplayRuleDict((ItemDisplayRule[])null);
			ItemAPI.Add(new CustomItem(thisItemDef, val));
		}

		public virtual void Update()
		{
		}
	}
}