Decompiled source of Deuce v0.1.0

Deuce.dll

Decompiled 3 weeks ago
using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using Deuce.Cards;
using Microsoft.CodeAnalysis;
using UnboundLib;
using UnboundLib.Cards;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: AssemblyCompany("Deuce")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+3d27d726b8f5eb4253d0a40f7db79a13e54f6be1")]
[assembly: AssemblyProduct("Deuce")]
[assembly: AssemblyTitle("Deuce")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class IsReadOnlyAttribute : Attribute
	{
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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 Deuce
{
	public struct SetupContext
	{
		public CardInfo card;

		public Gun gun;

		public ApplyCardStats cardStats;

		public CharacterStatModifiers statModifiers;
	}
	public readonly struct ApplyContext
	{
		public readonly Player player;

		public readonly Gun gun;

		public readonly GunAmmo gunAmmo;

		public readonly CharacterData data;

		public readonly HealthHandler health;

		public readonly Gravity gravity;

		public readonly Block block;

		public readonly CharacterStatModifiers characterStats;

		public ApplyContext(Player player, Gun gun, GunAmmo gunAmmo, CharacterData data, HealthHandler health, Gravity gravity, Block block, CharacterStatModifiers characterStats)
		{
			this.player = player;
			this.gun = gun;
			this.gunAmmo = gunAmmo;
			this.data = data;
			this.health = health;
			this.gravity = gravity;
			this.block = block;
			this.characterStats = characterStats;
		}
	}
	public abstract class DeuceUpgrade : MonoBehaviour
	{
		public virtual int Count { get; set; }

		public virtual ApplyContext Context { get; set; }
	}
	public abstract class DeuceCard : CustomCard
	{
		protected abstract string Name { get; }

		protected abstract string Description { get; }

		protected abstract Rarity Rarity { get; }

		protected abstract CardThemeColorType Theme { get; }

		protected abstract CardInfoStat[] Stats { get; }

		protected virtual GameObject? CardArt => null;

		protected virtual Type? ComponentType => null;

		protected virtual void Setup(SetupContext ctx)
		{
		}

		protected virtual void Add(ApplyContext ctx)
		{
		}

		protected virtual void Remove(ApplyContext ctx)
		{
		}

		private int GetCount(Player player)
		{
			return player.data.currentCards.Count((CardInfo card) => card.cardName == Name);
		}

		public override void SetupCard(CardInfo cardInfo, Gun gun, ApplyCardStats cardStats, CharacterStatModifiers statModifiers)
		{
			Setup(new SetupContext
			{
				card = cardInfo,
				gun = gun,
				cardStats = cardStats,
				statModifiers = statModifiers
			});
		}

		public override void OnAddCard(Player player, Gun gun, GunAmmo gunAmmo, CharacterData data, HealthHandler health, Gravity gravity, Block block, CharacterStatModifiers characterStats)
		{
			ApplyContext applyContext = new ApplyContext(player, gun, gunAmmo, data, health, gravity, block, characterStats);
			Add(applyContext);
			if (!(ComponentType == null))
			{
				int count = GetCount(player);
				DeuceUpgrade deuceUpgrade;
				if (count == 0)
				{
					deuceUpgrade = (DeuceUpgrade)(object)((Component)player).gameObject.AddComponent(ComponentType);
					deuceUpgrade.Context = applyContext;
				}
				else
				{
					deuceUpgrade = (DeuceUpgrade)(object)((Component)player).GetComponent(ComponentType);
				}
				deuceUpgrade.Count = count + 1;
			}
		}

		public override void OnRemoveCard(Player player, Gun gun, GunAmmo gunAmmo, CharacterData data, HealthHandler health, Gravity gravity, Block block, CharacterStatModifiers characterStats)
		{
			Remove(new ApplyContext(player, gun, gunAmmo, data, health, gravity, block, characterStats));
		}

		protected override GameObject? GetCardArt()
		{
			return CardArt;
		}

		protected override string GetDescription()
		{
			return Description;
		}

		protected override Rarity GetRarity()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			return Rarity;
		}

		protected override CardThemeColorType GetTheme()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			return Theme;
		}

		protected override string GetTitle()
		{
			return Name;
		}

		protected override CardInfoStat[] GetStats()
		{
			return Stats;
		}
	}
	[BepInPlugin("com.kesomannen.deuce", "Deuce", "0.1.0")]
	public class Plugin : BaseUnityPlugin
	{
		public static ManualLogSource Logger;

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
		}

		private void Start()
		{
			Unbound.RegisterCredits("Deuce", new string[1] { "Kesomannen" }, new string[2] { "github", "Support Kesomannen" }, new string[2] { "https://github.com/Kesomannen/Deuce", "https://ko-fi.com/Kesomannen" });
			CustomCard.BuildCard<Accelerator>();
			Logger.LogInfo((object)"Plugin loaded!");
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "Deuce";

		public const string PLUGIN_NAME = "Deuce";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace Deuce.Cards
{
	public class Accelerator : DeuceCard
	{
		private class Component : DeuceUpgrade
		{
			private float _value;

			private float _velocity;

			private void Start()
			{
				CharacterStatModifiers characterStats = Context.characterStats;
				characterStats.DealtDamageAction = (Action<Vector2, bool>)Delegate.Combine(characterStats.DealtDamageAction, new Action<Vector2, bool>(OnDealDamage));
			}

			private void OnDestroy()
			{
				CharacterStatModifiers characterStats = Context.characterStats;
				characterStats.DealtDamageAction = (Action<Vector2, bool>)Delegate.Remove(characterStats.DealtDamageAction, new Action<Vector2, bool>(OnDealDamage));
			}

			private void OnDealDamage(Vector2 amount, bool selfDamage)
			{
				if (!selfDamage)
				{
					_value += Count;
				}
			}

			private void Update()
			{
				_value = Mathf.SmoothDamp(_value, 0f, ref _velocity, 2f);
				float num = Mathf.Sqrt(_value) + 0.5f;
				Gun gun = Context.gun;
				gun.attackSpeedMultiplier *= num;
			}
		}

		protected override string Name => "Accelerator";

		protected override string Description => "Temporarily increases attack speed with each hit.";

		protected override Rarity Rarity => (Rarity)1;

		protected override CardThemeColorType Theme => (CardThemeColorType)1;

		protected override CardInfoStat[] Stats => (CardInfoStat[])(object)new CardInfoStat[1]
		{
			new CardInfoStat
			{
				stat = "Attack speed",
				amount = "-50%",
				positive = false,
				simepleAmount = (SimpleAmount)7
			}
		};

		protected override Type? ComponentType => typeof(Component);

		protected override void Setup(SetupContext ctx)
		{
		}
	}
}