Please disclose if your mod was created primarily using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of GamblingMachine v1.0.5
GamblingMachine.dll
Decompiled 11 months agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; 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.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using REPOLib.Modules; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.Networking; [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: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("Autodesk.Fbx")] [assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")] [assembly: IgnoresAccessChecksTo("FbxBuildTestAssets")] [assembly: IgnoresAccessChecksTo("Klattersynth")] [assembly: IgnoresAccessChecksTo("Photon3Unity3D")] [assembly: IgnoresAccessChecksTo("PhotonChat")] [assembly: IgnoresAccessChecksTo("PhotonRealtime")] [assembly: IgnoresAccessChecksTo("PhotonUnityNetworking")] [assembly: IgnoresAccessChecksTo("PhotonUnityNetworking.Utilities")] [assembly: IgnoresAccessChecksTo("PhotonVoice.API")] [assembly: IgnoresAccessChecksTo("PhotonVoice")] [assembly: IgnoresAccessChecksTo("PhotonVoice.PUN")] [assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime")] [assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime.Public")] [assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Attributes")] [assembly: IgnoresAccessChecksTo("Sirenix.Serialization.Config")] [assembly: IgnoresAccessChecksTo("Sirenix.Serialization")] [assembly: IgnoresAccessChecksTo("Sirenix.Utilities")] [assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")] [assembly: IgnoresAccessChecksTo("Unity.Formats.Fbx.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")] [assembly: IgnoresAccessChecksTo("Unity.Postprocessing.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")] [assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")] [assembly: IgnoresAccessChecksTo("Unity.Timeline")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Antlr3.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Core")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Flow")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.State")] [assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.UI")] [assembly: IgnoresAccessChecksTo("websocket-sharp")] [assembly: AssemblyCompany("Lluciocc")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.5.0")] [assembly: AssemblyInformationalVersion("1.0.5+db6af9ef4e1fd828f328a3145d721b8c66b4d1e2")] [assembly: AssemblyProduct("GamblingMachine")] [assembly: AssemblyTitle("GamblingMachine")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.5.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] 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; } } [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 GamblingMachine { [BepInPlugin("Lluciocc.GamblingMachine", "GamblingMachine", "2.1.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class GamblingMachine : BaseUnityPlugin { public static ConfigEntry<float> winrate; public static ConfigEntry<int> bet; public static ConfigEntry<float> winMultiplicator; public static ConfigEntry<bool> debug; internal static GamblingMachine Instance { get; private set; } internal static ManualLogSource Logger => Instance._logger; private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger; internal Harmony? Harmony { get; set; } public static GameObject SlotMachinePrefab { get; private set; } private void Awake() { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Expected O, but got Unknown //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Expected O, but got Unknown Instance = this; ((Component)this).gameObject.transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; bet = ((BaseUnityPlugin)this).Config.Bind<int>("Gameplay", "bet", 2, new ConfigDescription("Amount to bet", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); winMultiplicator = ((BaseUnityPlugin)this).Config.Bind<float>("Gameplay", "winMultiplicator", 2f, new ConfigDescription("Multiplicator of your bet when you win", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 5f), Array.Empty<object>())); winrate = ((BaseUnityPlugin)this).Config.Bind<float>("Gameplay", "winrate", 0.5f, new ConfigDescription("Chance to win (0.5 is 50%)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); debug = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "EnableDebug", false, "Enable Debug Mode"); LoadAssetBundle(); Patch(); Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!"); } private void LoadAssetBundle() { string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "slotbundle.machine"); AssetBundle val = AssetBundle.LoadFromFile(text); if ((Object)(object)val == (Object)null) { Logger.LogError((object)"Cannot load AssetBundle !"); return; } SlotMachinePrefab = val.LoadAsset<GameObject>("machine"); if ((Object)(object)SlotMachinePrefab == (Object)null) { Logger.LogError((object)"Prefab 'machine' is unknown in the bundle !"); return; } NetworkPrefabs.RegisterNetworkPrefab(SlotMachinePrefab); Logger.LogInfo((object)"Prefab 'machine' has been loaded and registered with sucess"); } private void Patch() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_0026: Expected O, but got Unknown if (Harmony == null) { Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID); Harmony val2 = val; Harmony = val; } Harmony.PatchAll(); } internal void Unpatch() { Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } } } public class GamblingMachineScript : MonoBehaviour { [CompilerGenerated] private sealed class <JackpotLightEffect>d__24 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public GamblingMachineScript <>4__this; private Color <original>5__1; private Color[] <colors>5__2; private int <i>5__3; private Color[] <>s__4; private int <>s__5; private Color <c>5__6; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <JackpotLightEffect>d__24(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <colors>5__2 = null; <>s__4 = null; <>1__state = -2; } private bool MoveNext() { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: 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_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Expected O, but got Unknown int num = <>1__state; if (num != 0) { if (num != 1) { return false; } <>1__state = -1; <>s__5++; goto IL_0151; } <>1__state = -1; if ((Object)(object)<>4__this.lightComponent != (Object)null) { <original>5__1 = <>4__this.lightComponent.color; <colors>5__2 = (Color[])(object)new Color[7] { Color.red, new Color(1f, 0.5f, 0f), Color.yellow, Color.green, Color.cyan, Color.blue, new Color(0.6f, 0f, 1f) }; <i>5__3 = 0; goto IL_0179; } GamblingMachine.Logger.LogWarning((object)"No lightComponent found!"); goto IL_01bc; IL_01bc: return false; IL_0179: if (<i>5__3 < 3) { <>s__4 = <colors>5__2; <>s__5 = 0; goto IL_0151; } <>4__this.lightComponent.color = <original>5__1; <colors>5__2 = null; goto IL_01bc; IL_0151: if (<>s__5 < <>s__4.Length) { <c>5__6 = <>s__4[<>s__5]; <>4__this.lightComponent.color = <c>5__6; <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 1; return true; } <>s__4 = null; <i>5__3++; goto IL_0179; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <LoadAudioClips>d__18 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public GamblingMachineScript <>4__this; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <LoadAudioClips>d__18(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = ((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.LoadClip("spin.mp3", delegate(AudioClip clip) { <>4__this.spinClip = clip; })); <>1__state = 1; return true; case 1: <>1__state = -1; <>2__current = ((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.LoadClip("win.mp3", delegate(AudioClip clip) { <>4__this.jackpotClip = clip; })); <>1__state = 2; return true; case 2: <>1__state = -1; <>2__current = ((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.LoadClip("loose.mp3", delegate(AudioClip clip) { <>4__this.looseClip = clip; })); <>1__state = 3; return true; case 3: <>1__state = -1; <>2__current = ((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.LoadClip("cancel.mp3", delegate(AudioClip clip) { <>4__this.cancelClip = clip; })); <>1__state = 4; return true; case 4: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <LoadClip>d__19 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public string relativePath; public Action<AudioClip> onLoaded; public GamblingMachineScript <>4__this; private string <path>5__1; private UnityWebRequest <www>5__2; private AudioClip <clip>5__3; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <LoadClip>d__19(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } <path>5__1 = null; <www>5__2 = null; <clip>5__3 = null; <>1__state = -2; } private bool MoveNext() { //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Invalid comparison between Unknown and I4 //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Invalid comparison between Unknown and I4 try { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <path>5__1 = "file://" + Path.Combine(<>4__this.modPath, relativePath); <www>5__2 = UnityWebRequestMultimedia.GetAudioClip(<path>5__1, (AudioType)13); <>1__state = -3; <>2__current = <www>5__2.SendWebRequest(); <>1__state = 1; return true; case 1: <>1__state = -3; if ((int)<www>5__2.result == 2 || (int)<www>5__2.result == 3) { Debug.LogError((object)("Error loading audio: " + <www>5__2.error)); } else { <clip>5__3 = DownloadHandlerAudioClip.GetContent(<www>5__2); onLoaded?.Invoke(<clip>5__3); if (<>4__this.debug) { Debug.Log((object)("Loaded clip from: " + <path>5__1)); } <clip>5__3 = null; } <>m__Finally1(); <www>5__2 = null; return false; } } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<www>5__2 != null) { ((IDisposable)<www>5__2).Dispose(); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <NotEnoughMoney>d__23 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public GamblingMachineScript <>4__this; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <NotEnoughMoney>d__23(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected O, but got Unknown //IL_0077: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; if ((Object)(object)<>4__this.lightComponent != (Object)null) { <>4__this.lightComponent.color = Color.red; <>2__current = (object)new WaitForSeconds(0.5f); <>1__state = 1; return true; } GamblingMachine.Logger.LogWarning((object)"lightComponent not found!"); break; case 1: <>1__state = -1; <>4__this.lightComponent.color = Color.white; break; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <RotateReel>d__28 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public GameObject reel; public float duration; public float endRotation; public GamblingMachineScript <>4__this; private float <timer>5__1; private Vector3 <currentRotation>5__2; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <RotateReel>d__28(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; reel.transform.localEulerAngles = new Vector3(0f, 0f, 0f); <timer>5__1 = 0f; break; case 1: <>1__state = -1; break; } if (<timer>5__1 < duration) { reel.transform.Rotate(Vector3.right * <>4__this.rotationSpeed * Time.deltaTime); <timer>5__1 += Time.deltaTime; <>2__current = null; <>1__state = 1; return true; } <currentRotation>5__2 = reel.transform.localEulerAngles; reel.transform.localEulerAngles = new Vector3(endRotation, <currentRotation>5__2.y, <currentRotation>5__2.z); return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <SpinRoutine>d__27 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public GamblingMachineScript <>4__this; private bool <isJackpot>5__1; private float <finalXRotation>5__2; private int <i>5__3; private float <targetRotation>5__4; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <SpinRoutine>d__27(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Expected O, but got Unknown //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>4__this.isSpinning = true; <isJackpot>5__1 = Random.value < <>4__this.winrate; <finalXRotation>5__2 = (<isJackpot>5__1 ? Random.Range(0f, 360f) : 0f); <i>5__3 = 0; goto IL_0116; case 1: <>1__state = -1; <i>5__3++; goto IL_0116; case 2: { <>1__state = -1; <>4__this.isSpinning = false; if (<isJackpot>5__1) { <>4__this.PlaySound(<>4__this.jackpotClip); ((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.JackpotLightEffect()); SemiFunc.StatSetRunCurrency(SemiFunc.StatGetRunCurrency() + Mathf.RoundToInt((float)<>4__this.prixMachine * <>4__this.winMulti)); } else { <>4__this.PlaySound(<>4__this.looseClip); if (<>4__this.debug) { GamblingMachine.Logger.LogWarning((object)"BIG L"); } } return false; } IL_0116: if (<i>5__3 < <>4__this.reels.Length) { <targetRotation>5__4 = (<isJackpot>5__1 ? <finalXRotation>5__2 : Random.Range(0f, 360f)); ((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.RotateReel(<>4__this.reels[<i>5__3], <>4__this.spinTimePerReel, <targetRotation>5__4)); <>2__current = (object)new WaitForSeconds(0.5f); <>1__state = 1; return true; } <>2__current = (object)new WaitForSeconds(<>4__this.spinTimePerReel + 0.5f); <>1__state = 2; return true; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public GameObject[]? reels; public float spinTimePerReel = 1.5f; public float rotationSpeed = 720f; private bool isSpinning = false; private int prixMachine = GamblingMachine.bet.Value; private float winrate = GamblingMachine.winrate.Value; private float winMulti = GamblingMachine.winMultiplicator.Value; private bool debug = GamblingMachine.debug.Value; private Light? lightComponent; private AudioClip? spinClip; private AudioClip? jackpotClip; private AudioClip? looseClip; private AudioClip? cancelClip; private string? modPath; private AudioSource? audioSource; private int playerId; private void Start() { Init(); } public void Init() { modPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); audioSource = ((Component)this).gameObject.AddComponent<AudioSource>(); audioSource.spatialBlend = 1f; audioSource.volume = 0.5f; GameObject gameObject = ((Component)this).gameObject; if ((Object)(object)gameObject == (Object)null) { GamblingMachine.Logger.LogError((object)"Machine GameObject is not assigned!"); return; } ((MonoBehaviour)this).StartCoroutine(LoadAudioClips()); Transform obj = gameObject.transform.FindDeepInChild("Light"); GameObject val = ((obj != null) ? ((Component)obj).gameObject : null); if ((Object)(object)val != (Object)null) { lightComponent = val.GetComponent<Light>(); } else { GamblingMachine.Logger.LogWarning((object)"SlotMachineLight not found!"); } } [IteratorStateMachine(typeof(<LoadAudioClips>d__18))] private IEnumerator LoadAudioClips() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <LoadAudioClips>d__18(0) { <>4__this = this }; } [IteratorStateMachine(typeof(<LoadClip>d__19))] private IEnumerator LoadClip(string relativePath, Action<AudioClip> onLoaded) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <LoadClip>d__19(0) { <>4__this = this, relativePath = relativePath, onLoaded = onLoaded }; } public void Spin() { if (debug) { GamblingMachine.Logger.LogInfo((object)"Spin() method called!"); } if (SemiFunc.StatGetRunCurrency() >= prixMachine && !isSpinning) { if (SemiFunc.IsMultiplayer()) { PhotonView val = PhotonView.Get((Component)(object)this); val.RPC("RPC_StartSpin", (RpcTarget)0, Array.Empty<object>()); } else { LOCAL_StartSpin(); } } else if (!isSpinning) { PlaySound(cancelClip); ((MonoBehaviour)this).StartCoroutine(NotEnoughMoney()); GamblingMachine.Logger.LogWarning((object)"Not enough money!"); } } [PunRPC] private void RPC_StartSpin() { if (!isSpinning) { if (debug) { Debug.Log((object)"Spin With RPC"); } SemiFunc.StatSetRunCurrency(SemiFunc.StatGetRunCurrency() - prixMachine); PlaySound(spinClip); ((MonoBehaviour)this).StartCoroutine(SpinRoutine()); } } private void LOCAL_StartSpin() { if (!isSpinning) { if (debug) { Debug.Log((object)"Spin With NO RPC"); } SemiFunc.StatSetRunCurrency(SemiFunc.StatGetRunCurrency() - prixMachine); PlaySound(spinClip); ((MonoBehaviour)this).StartCoroutine(SpinRoutine()); } } [IteratorStateMachine(typeof(<NotEnoughMoney>d__23))] private IEnumerator NotEnoughMoney() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <NotEnoughMoney>d__23(0) { <>4__this = this }; } [IteratorStateMachine(typeof(<JackpotLightEffect>d__24))] private IEnumerator JackpotLightEffect() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <JackpotLightEffect>d__24(0) { <>4__this = this }; } public void SetPlayerId(int id) { playerId = id; } public int GetPlayerId() { return playerId; } [IteratorStateMachine(typeof(<SpinRoutine>d__27))] private IEnumerator SpinRoutine() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <SpinRoutine>d__27(0) { <>4__this = this }; } [IteratorStateMachine(typeof(<RotateReel>d__28))] private IEnumerator RotateReel(GameObject reel, float duration, float endRotation) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <RotateReel>d__28(0) { <>4__this = this, reel = reel, duration = duration, endRotation = endRotation }; } private void PlaySound(AudioClip clip) { if ((Object)(object)clip != (Object)null) { if (audioSource.isPlaying) { audioSource.Stop(); } audioSource.clip = clip; audioSource.Play(); } } } [HarmonyPatch(typeof(ShopManager), "ShopInitialize")] public class ShopPatch { public int playerId; private static bool debug = GamblingMachine.debug.Value; private static int bet = GamblingMachine.bet.Value; private static float multi = GamblingMachine.winMultiplicator.Value; private static void Postfix(ShopManager __instance) { //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Expected O, but got Unknown //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Expected O, but got Unknown if ((Object)(object)GamblingMachine.SlotMachinePrefab == (Object)null) { if (debug) { GamblingMachine.Logger.LogWarning((object)"SlotMachinePrefab is null !"); } return; } GameObject val = GameObject.Find("Shop Magazine Holder"); if ((Object)(object)val == (Object)null) { if (debug) { GamblingMachine.Logger.LogWarning((object)"Obj named 'Shop Magazine Holder' not found !"); } return; } Transform parent = val.transform.parent; Vector3 position = val.transform.position; Quaternion val2 = val.transform.rotation * Quaternion.Euler(0f, 180f, 0f); GameObject val3 = null; if (!SemiFunc.IsMultiplayer() || SemiFunc.IsMasterClient()) { if (SemiFunc.IsMultiplayer()) { val3 = PhotonNetwork.Instantiate(((Object)GamblingMachine.SlotMachinePrefab).name, position, val2, (byte)0, (object[])null); SetParent(parent, val3); val3.transform.localScale = Vector3.one * 16f; } else { val3 = Object.Instantiate<GameObject>(GamblingMachine.SlotMachinePrefab, position, val2, parent); } val3.tag = "Phys Grab Object"; val3.layer = LayerMask.NameToLayer("PhysGrabObject"); Transform val4 = val3.transform.FindDeepInChild("ColliderHolder"); if ((Object)(object)val4 == (Object)null) { GamblingMachine.Logger.LogWarning((object)"ColliderHolder not found !"); return; } GameObject gameObject = ((Component)val4).gameObject; BoxCollider component = gameObject.GetComponent<BoxCollider>(); GamblingMachineScript gamblingMachineScript = val3.GetComponent<GamblingMachineScript>() ?? val3.AddComponent<GamblingMachineScript>(); StaticGrabObject val5 = val3.GetComponent<StaticGrabObject>() ?? val3.AddComponent<StaticGrabObject>(); val5.colliderTransform = gameObject.transform; PhysGrabObjectGrabArea val6 = val3.GetComponent<PhysGrabObjectGrabArea>() ?? val3.AddComponent<PhysGrabObjectGrabArea>(); GrabArea val7 = new GrabArea(); val7.grabAreaTransform = gameObject.transform; if ((Object)(object)gamblingMachineScript != (Object)null) { gamblingMachineScript.reels = (GameObject[]?)(object)new GameObject[4] { ((Component)val3.transform.FindDeepInChild("reel 1")).gameObject, ((Component)val3.transform.FindDeepInChild("reel 2")).gameObject, ((Component)val3.transform.FindDeepInChild("reel 3")).gameObject, ((Component)val3.transform.FindDeepInChild("reel 4")).gameObject }; val7.grabAreaEventOnStart.AddListener(new UnityAction(gamblingMachineScript.Spin)); val6.grabAreas.Add(val7); } else { GamblingMachine.Logger.LogWarning((object)"GamblingMachineScript script not found !"); } GameObject gameObject2 = ((Component)val3.transform.FindDeepInChild("TMPTextBet")).gameObject; GameObject gameObject3 = ((Component)val3.transform.FindDeepInChild("TMPTextMulti")).gameObject; TextMeshPro component2 = gameObject2.GetComponent<TextMeshPro>(); TextMeshPro component3 = gameObject3.GetComponent<TextMeshPro>(); if ((Object)(object)component2 != (Object)null) { ((TMP_Text)component2).text = $"Bet amount: {bet}k"; } if ((Object)(object)component3 != (Object)null) { ((TMP_Text)component3).text = $"Bet multiplicator: x{multi:0.##}"; } Object.Destroy((Object)(object)val); GamblingMachine.Logger.LogInfo((object)"GamblingMachine placed in shop !"); } else { val.SetActive(false); if (debug) { GamblingMachine.Logger.LogInfo((object)"Client non-host : objet désactivé."); } } } private static void SetParent(Transform parent, GameObject go) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) go.transform.SetParent(parent); go.transform.localScale = Vector3.one; } } public static class TransformExtensions { public static Transform FindDeepInChild(this Transform parent, string name) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown foreach (Transform item in parent) { Transform val = item; if (((Object)val).name == name) { return val; } Transform val2 = val.FindDeepInChild(name); if ((Object)(object)val2 != (Object)null) { return val2; } } return null; } } }