using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using Fusion;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("SpinWheelCustomizer")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.11.0")]
[assembly: AssemblyInformationalVersion("0.1.11+bf57c9dae974d93b8b4f23e937cb81620ff3be86")]
[assembly: AssemblyProduct("SpinWheelCustomizer")]
[assembly: AssemblyTitle("SpinWheelCustomizer")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.11.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[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 SpinWheelCustomizer
{
[BepInPlugin("dev.chaosholz.spinwheelcustomizer", "SpinWheelCustomizer", "0.2.11")]
public class Plugin : BasePlugin
{
private const string modGUID = "dev.chaosholz.spinwheelcustomizer";
private const string modName = "SpinWheelCustomizer";
private const string modVersion = "0.2.11";
private static readonly Harmony _harmony = new Harmony("dev.chaosholz.spinwheelcustomizer");
internal static readonly ManualLogSource logger = Logger.CreateLogSource("SpinWheelCustomizer");
internal static ConfigEntry<bool> autoCoinCollect;
internal static ConfigEntry<float> tokenMultiplier;
internal static ConfigEntry<float> spinDuration;
internal static ConfigEntry<int> spinCost;
internal static float spinDurationValue => Mathf.Max(0.1f, spinDuration?.Value ?? 4f);
internal static int spinCostValue => Mathf.Max(0, spinCost?.Value ?? 5);
public override void Load()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Expected O, but got Unknown
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(11, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("SpinWheelCustomizer");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!");
}
logger.LogInfo(val);
Configs();
_harmony.PatchAll();
}
private void Configs()
{
autoCoinCollect = ((BasePlugin)this).Config.Bind<bool>("SpinWheel", "Auto Coin Collect", true, "Automatically collects token rewards after spinning instead of spawning coins.\n \nWorks only if the host has this enabled.");
tokenMultiplier = ((BasePlugin)this).Config.Bind<float>("SpinWheel", "Token Multiplier", 1f, "Multiplier for token rewards collected by Auto Coin Collect. \nExample: 1.0 = normal, 2.0 = double tokens, 0.5 = half tokens. \nWorks only if the host has Auto Coin Collect enabled.");
spinDuration = ((BasePlugin)this).Config.Bind<float>("SpinWheel", "Spin Duration", 4f, "Duration of the spin animation in seconds. \nLower values make the wheel finish faster. \nGame default: 4.0 seconds.");
spinCost = ((BasePlugin)this).Config.Bind<int>("SpinWheel", "Spin Cost", 5, "Amount of tokens required for each spin. \nGame default: 5 tokens. \n ");
}
}
}
namespace SpinWheelCustomizer.Patches
{
[HarmonyPatch(typeof(SpinWheelManager))]
internal static class SpinWheelRewardPatch
{
private static int rewardTokens;
private static float lastTokenSpawnAt;
private const float tokenPayoutDelay = 0.25f;
[HarmonyPatch("Rpc_SpawnToken")]
[HarmonyPrefix]
private static bool SpawnTokenPrefix(SpinWheelManager __instance)
{
if ((Object)(object)__instance == (Object)null || (Object)(object)((SimulationBehaviour)__instance).Object == (Object)null || !Plugin.autoCoinCollect.Value || !((SimulationBehaviour)__instance).Object.HasStateAuthority)
{
return true;
}
rewardTokens++;
lastTokenSpawnAt = Time.unscaledTime;
return false;
}
[HarmonyPatch("Update")]
[HarmonyPostfix]
private static void UpdatePostfix(SpinWheelManager __instance)
{
if (!((Object)(object)__instance == (Object)null) && !((Object)(object)((SimulationBehaviour)__instance).Object == (Object)null) && Plugin.autoCoinCollect.Value && ((SimulationBehaviour)__instance).Object.HasStateAuthority && rewardTokens > 0 && !(Time.unscaledTime - lastTokenSpawnAt < 0.25f))
{
int num = Mathf.RoundToInt((float)rewardTokens * Plugin.tokenMultiplier.Value);
if (num > 0)
{
StoreManager.Instance.ChangeTokenBalance(num);
}
rewardTokens = 0;
}
}
}
[HarmonyPatch(typeof(SpinWheelManager))]
internal static class SpinWheelSpinPatch
{
private static bool setSpinDuration = true;
private static bool spinPayment;
internal static bool IsSpinPayment => spinPayment;
[HarmonyPatch("PressButton")]
[HarmonyPrefix]
private static void PressButtonPrefix(SpinWheelManager __instance)
{
if (!((Object)(object)__instance == (Object)null) && setSpinDuration)
{
__instance.spinDuration = Plugin.spinDurationValue;
setSpinDuration = false;
}
}
[HarmonyPatch("Rpc_CMD_Spin")]
[HarmonyPrefix]
private static void RpcCMDSpinPrefix()
{
spinPayment = true;
}
[HarmonyPatch("Rpc_CMD_Spin")]
[HarmonyPostfix]
private static void RpcCMDSpinPostfix()
{
spinPayment = false;
}
}
[HarmonyPatch(typeof(StoreManager))]
internal static class StoreManagerTokenPatch
{
[HarmonyPatch("ChangeTokenBalance")]
[HarmonyPrefix]
private static void ChangeTokenBalancePrefix(ref int change)
{
if (SpinWheelSpinPatch.IsSpinPayment && Plugin.spinCostValue > 0)
{
change = -Plugin.spinCostValue;
}
}
}
}