Decompiled source of CharmCoffeeCup v1.0.0

CharmCoffeeCup.dll

Decompiled 7 hours ago
using System;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using CharmCoffeeCup.Domain;
using CharmCore.Api;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("Osmar Briones")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+37fba8dd146354b6a68ea72943749c201f82aedd")]
[assembly: AssemblyProduct("CharmCoffeeCup")]
[assembly: AssemblyTitle("CharmCoffeeCup")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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]
	[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]
	[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 CharmCoffeeCup
{
	[BepInPlugin("com.osmar.CharmCoffeeCup", "CharmCoffeeCup", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class CharmCoffeeCupPlugin : BaseUnityPlugin
	{
		public const string PluginGuid = "com.osmar.CharmCoffeeCup";

		public const string PluginName = "CharmCoffeeCup";

		public const string PluginVersion = "1.0.0";

		internal static ManualLogSource Logger { get; private set; }

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			((Component)this).gameObject.transform.parent = null;
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			CoffeeCupCharm coffeeCupCharm = new CoffeeCupCharm();
			CharmsApi.Register((Charm)(object)coffeeCupCharm, ((BaseUnityPlugin)this).Config);
			((Component)this).gameObject.AddComponent<SecondWind>().Charm = coffeeCupCharm;
			Logger.LogInfo((object)"CharmCoffeeCup 1.0.0 loaded!");
		}
	}
	internal sealed class CoffeeCupCharm : Charm
	{
		internal const string PrefabName = "Valuable Arctic Coffee Cup";

		public override string? Description => SecondWindText.Describe(RestorePercent.Value);

		internal CharmSetting RestorePercent { get; }

		internal CoffeeCupCharm()
			: base("CoffeeCup", "Coffee Cup - Second Wind", 20f, (float?)3f, new string[1] { "Valuable Arctic Coffee Cup" })
		{
			RestorePercent = ((Charm)this).AddSetting("RestorePercent", 30f, 1f, 100f, "Share of your maximum energy that comes back when it runs out, in percent.");
		}
	}
	internal sealed class SecondWind : MonoBehaviour
	{
		internal CoffeeCupCharm Charm { get; set; }

		private void Update()
		{
			if (Charm == null || !((Charm)Charm).IsActive)
			{
				return;
			}
			PlayerController instance = PlayerController.instance;
			if (!((Object)(object)instance == (Object)null) && !(instance.EnergyCurrent > 0f) && ((Charm)Charm).TryUse())
			{
				instance.EnergyCurrent = instance.EnergyStart * (Charm.RestorePercent.Value / 100f);
				if (((Charm)Charm).DebugMode)
				{
					((Charm)Charm).LogDebug($"Second Wind: energy restored to {instance.EnergyCurrent:0} of {instance.EnergyStart:0}");
				}
			}
		}
	}
}
namespace CharmCoffeeCup.Domain
{
	internal static class SecondWindText
	{
		internal static string Describe(float restorePercent)
		{
			return "When your energy runs out, " + Number(restorePercent) + "% of it comes back.";
		}

		private static string Number(float value)
		{
			return value.ToString("0.##", CultureInfo.InvariantCulture);
		}
	}
}