using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("GlassCannon")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.7.0")]
[assembly: AssemblyInformationalVersion("1.0.7")]
[assembly: AssemblyProduct("GlassCannon")]
[assembly: AssemblyTitle("GlassCannon")]
[assembly: AssemblyVersion("1.0.7.0")]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[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;
}
}
}
namespace GlassCannon
{
[BepInPlugin("soundedsquash.glasscannon", "Glass Cannon", "1.0.7.0")]
public class GlassCannonBase : BaseUnityPlugin
{
private const string PluginGuid = "soundedsquash.glasscannon";
private const string PluginName = "Glass Cannon";
private const string PluginVersion = "1.0.7.0";
private readonly Harmony _harmony = new Harmony("soundedsquash.glasscannon");
private static readonly ManualLogSource ManualLogSource = Logger.CreateLogSource("soundedsquash.glasscannon");
public void Awake()
{
Settings.Initialize(((BaseUnityPlugin)this).Config, ManualLogSource);
if (!(Settings.DollarMultiplier.Value > 0f))
{
ManualLogSource.LogError((object)$"Invalid Dollar Multiplier value {Settings.DollarMultiplier.Value}. Resetting to {Settings.DollarMultiplierDefault}");
Settings.DollarMultiplier.Value = Settings.DollarMultiplierDefault;
}
if (Settings.ItemImpactBehavior.Value < 0 || Settings.ItemImpactBehavior.Value > 2)
{
ManualLogSource.LogError((object)$"Invalid Item Impact Behavior value: {Settings.ItemImpactBehavior.Value}. Resetting to {Settings.ItemImpactBehaviorDefault}");
Settings.ItemImpactBehavior.Value = Settings.ItemImpactBehaviorDefault;
}
_harmony.PatchAll();
ManualLogSource.LogInfo((object)"Glass Cannon loaded");
}
}
public static class Settings
{
public static float DollarMultiplierDefault = 2f;
public static int ItemImpactBehaviorDefault = 1;
public static ConfigEntry<float> DollarMultiplier { get; private set; }
public static ConfigEntry<int> ItemImpactBehavior { get; private set; }
public static ManualLogSource Logger { get; private set; }
internal static void Initialize(ConfigFile config, ManualLogSource logger)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Expected O, but got Unknown
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Expected O, but got Unknown
Logger = logger;
DollarMultiplier = config.Bind<float>("General", "DollarMultiplier", 2f, new ConfigDescription("The multiplier that is applied to item value. 2 doubles the value. 1 is the same. Any number between 0 and 1 will lose value.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 10f), Array.Empty<object>()));
ItemImpactBehavior = config.Bind<int>("General", "ItemImpactBehavior", 1, new ConfigDescription("0 - Default impacts. 1 - Break on impact. 2 - No impact damage.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 2), Array.Empty<object>()));
}
}
}
namespace GlassCannon.Patches
{
[HarmonyPatch(typeof(PhysGrabObjectImpactDetector))]
public static class PhysGrabObjectImpactDetectorPatches
{
[HarmonyPatch("Break")]
[HarmonyPrefix]
private static void BreakPrefix(ref float valueLost, Vector3 _contactPoint, int breakLevel, ValuableObject? ___valuableObject)
{
if (!((Object)(object)___valuableObject == (Object)null))
{
valueLost = Settings.ItemImpactBehavior.Value switch
{
1 => ___valuableObject.dollarValueCurrent,
2 => 0f,
_ => valueLost,
};
Settings.Logger.LogDebug((object)$"Break detected. {((Object)___valuableObject).name} lost {valueLost} value. [{Settings.ItemImpactBehavior.Value}]");
}
}
}
[HarmonyPatch(typeof(RoundDirector))]
public static class RoundDirectorPatches
{
private static bool _valueSet;
private static Level? _currentLevel = RunManager.instance?.levelMainMenu;
[HarmonyPatch("StartRoundLogic")]
[HarmonyPrefix]
public static void StartRoundLogicPrefix(RoundDirector __instance, ref int value)
{
if (GameManager.instance.gameMode == 0 || PhotonNetwork.IsMasterClient)
{
_ = PhotonNetwork.LocalPlayer;
if ((Object)(object)_currentLevel != (Object)(object)RunManager.instance.levelCurrent)
{
_valueSet = false;
}
if (!_valueSet)
{
Settings.Logger.LogDebug((object)$"StartRoundLogicPostfix({value}) In");
value = (int)Math.Floor((float)value / Settings.DollarMultiplier.Value);
_valueSet = true;
_currentLevel = RunManager.instance.levelCurrent;
Settings.Logger.LogDebug((object)$"StartRoundLogicPostfix({value}) Out");
}
}
}
}
[HarmonyPatch(typeof(ValuableObject))]
public static class ValuableObjectPatches
{
[HarmonyPatch("DollarValueSetLogic")]
[HarmonyPostfix]
private static void DollarValueSetLogicPostfix(ValuableObject __instance)
{
if (!((Object)(object)((Component)__instance).GetComponentInParent<SurplusValuable>() != (Object)null))
{
Settings.Logger.LogDebug((object)$"DollarValueSetLogicPostfix called. They want their {__instance.dollarValueOriginal} valuable back.");
__instance.dollarValueOriginal *= Settings.DollarMultiplier.Value;
__instance.dollarValueCurrent = __instance.dollarValueOriginal;
}
}
}
}