using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
[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.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("GWFAutoSlotsMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("GWFAutoSlotsMod")]
[assembly: AssemblyTitle("GWFAutoSlotsMod")]
[assembly: AssemblyVersion("1.0.0.0")]
[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;
}
}
}
[BepInPlugin("d3stroy3d.autoslots", "Auto Slots", "1.0.0")]
public class AutoSlotsPlugin : BaseUnityPlugin
{
public class SlotAutoState
{
public bool Enabled = false;
public bool Waiting = false;
public bool SuppressNextAutoStart = false;
public float LastSpinPressTime = -999f;
public PlayerInteract PlayerInteract;
public GameObject LabelObject;
public TextMeshPro LabelText;
}
public static AutoSlotsPlugin Instance;
public static ManualLogSource Log;
public static float DelaySeconds = 0.15f;
private static readonly Dictionary<Slots, SlotAutoState> States = new Dictionary<Slots, SlotAutoState>();
private void Awake()
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
Instance = this;
Log = ((BaseUnityPlugin)this).Logger;
new Harmony("d3stroy3d.autoslots").PatchAll();
((MonoBehaviour)this).StartCoroutine(LabelScanner());
((BaseUnityPlugin)this).Logger.LogInfo((object)"AutoSlots 1.0.0 geladen. Doppel-Spin Toggle aktiv.");
}
private IEnumerator LabelScanner()
{
while (true)
{
Slots[] allSlots = Object.FindObjectsOfType<Slots>();
Slots[] array = allSlots;
foreach (Slots slots in array)
{
EnsureLabel(slots);
UpdateLabel(slots);
}
yield return (object)new WaitForSeconds(2f);
}
}
public static SlotAutoState GetState(Slots slots)
{
if (!States.TryGetValue(slots, out var value))
{
value = new SlotAutoState();
States[slots] = value;
}
return value;
}
public IEnumerator StartNextSpinDelayed(Slots slots)
{
SlotAutoState state = GetState(slots);
if (!state.Waiting)
{
state.Waiting = true;
yield return (object)new WaitForSeconds(DelaySeconds);
state.Waiting = false;
if (state.Enabled && !((Object)(object)slots == (Object)null) && !((Object)(object)state.PlayerInteract == (Object)null))
{
Log.LogInfo((object)"AutoSpin versucht nächsten Spin über TryStartGame...");
((GameBase)slots).TryStartGame(state.PlayerInteract);
}
}
}
public static void EnsureLabel(Slots slots)
{
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Expected O, but got Unknown
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)slots == (Object)null)
{
return;
}
SlotAutoState state = GetState(slots);
if (!((Object)(object)state.LabelObject != (Object)null))
{
GameObject val = new GameObject("AutoSlots_3D_Label");
val.transform.SetParent(((Component)slots).transform, false);
val.transform.localPosition = new Vector3(0f, 2.395f, -0.04f);
val.transform.localRotation = Quaternion.Euler(0f, 180f, 0f);
val.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f);
TextMeshPro val2 = val.AddComponent<TextMeshPro>();
((TMP_Text)val2).richText = true;
((TMP_Text)val2).alignment = (TextAlignmentOptions)514;
((TMP_Text)val2).fontSize = 8f;
((TMP_Text)val2).lineSpacing = -70f;
((Graphic)val2).color = Color.white;
state.LabelObject = val;
state.LabelText = val2;
UpdateLabel(slots);
ManualLogSource log = Log;
if (log != null)
{
log.LogInfo((object)"AutoSlots Label erstellt.");
}
}
}
public static void UpdateLabel(Slots slots)
{
SlotAutoState state = GetState(slots);
if (!((Object)(object)state.LabelText == (Object)null))
{
if (state.Enabled)
{
((TMP_Text)state.LabelText).text = "<color=#00FFFF>AUTO</color>\n<color=#00FF00>ON</color>";
}
else
{
((TMP_Text)state.LabelText).text = "<color=#00FFFF>AUTO</color>\n<color=#FF3333>OFF</color>";
}
}
}
}
[HarmonyPatch(typeof(GameBase), "TryStartGame")]
public static class GameBaseTryStartGamePatch
{
private static bool Prefix(GameBase __instance, PlayerInteract playerInteract)
{
Slots val = (Slots)(object)((__instance is Slots) ? __instance : null);
if (val != null)
{
AutoSlotsPlugin.EnsureLabel(val);
AutoSlotsPlugin.SlotAutoState state = AutoSlotsPlugin.GetState(val);
state.PlayerInteract = playerInteract;
float time = Time.time;
bool flag = time - state.LastSpinPressTime <= 1f;
state.LastSpinPressTime = time;
if (flag)
{
state.Enabled = !state.Enabled;
state.Waiting = false;
state.SuppressNextAutoStart = false;
AutoSlotsPlugin.UpdateLabel(val);
ManualLogSource log = AutoSlotsPlugin.Log;
if (log != null)
{
log.LogInfo((object)("AutoSpin per Doppel-Spin umgeschaltet: " + (state.Enabled ? "AN" : "AUS")));
}
return true;
}
ManualLogSource log2 = AutoSlotsPlugin.Log;
if (log2 != null)
{
log2.LogInfo((object)"Slots PlayerInteract gespeichert.");
}
}
return true;
}
}
[HarmonyPatch(typeof(Slots), "ResetGame")]
public static class SlotsResetGamePatch
{
private static void Postfix(Slots __instance)
{
AutoSlotsPlugin.EnsureLabel(__instance);
AutoSlotsPlugin.SlotAutoState state = AutoSlotsPlugin.GetState(__instance);
if (state.SuppressNextAutoStart)
{
state.SuppressNextAutoStart = false;
AutoSlotsPlugin.UpdateLabel(__instance);
return;
}
if ((Object)(object)AutoSlotsPlugin.Instance != (Object)null && state.Enabled)
{
((MonoBehaviour)AutoSlotsPlugin.Instance).StartCoroutine(AutoSlotsPlugin.Instance.StartNextSpinDelayed(__instance));
}
AutoSlotsPlugin.UpdateLabel(__instance);
}
}