Decompiled source of GamblingAddiction v1.0.0
GamblingAddiction.dll
Decompiled an hour ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.Audio; using UnityEngine.Events; using UnityEngine.Rendering; using UnityEngine.SceneManagement; [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("GamblingAddiction")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("GamblingAddiction")] [assembly: AssemblyTitle("GamblingAddiction")] [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; } } } namespace WhiteGamble { internal static class ExtraPrizes { public const string DefaultList = "Item_Trinket_Beta=30, Item_Trinket_CalmingBuddy=30, Item_Trinket_Carabiner=30, Item_Trinket_Chalk=30, Item_Trinket_ClimbingShoes=30, Item_Trinket_EmployeeID=30, Item_Trinket_Headlamp=30, Item_Trinket_Helmet=30, Item_Trinket_MassDamper=30, Item_Trinket_MoonRock=30, Item_Trinket_Nugget=30, Item_Trinket_PhotoOfHome=30, Item_Trinket_Pouch=30, Item_Artifact_EVAGlove=50, Item_Artifact_Rapier=50, Item_Artifact_Rebar_Return=50, Item_Artifact_Remote=50, Item_Artifact_Timepiece=50, Item_Artifact_Translocator=50"; private static List<Purchase> cache; private static string cachedFor; public static List<Purchase> Get() { //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Expected O, but got Unknown //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Expected O, but got Unknown string text = Plugin.ExtraPrizeList.Value ?? ""; if (cache != null && cachedFor == text) { return cache; } List<Purchase> list = new List<Purchase>(); List<string> list2 = new List<string>(); string[] array = text.Split(new char[2] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries); foreach (string text2 in array) { string[] array2 = text2.Split('='); string text3 = array2[0].Trim(); if (text3.Length == 0) { continue; } if (array2.Length < 2 || !int.TryParse(array2[1].Trim(), out var result) || result < 1) { Plugin.Log.LogWarning((object)("ExtraPrizes: '" + text2.Trim() + "' needs the form Item_Name=value; skipped.")); continue; } Item_Object val = FindItem(text3); if ((Object)(object)val == (Object)null) { list2.Add(text3); continue; } list.Add(new Purchase { name = val.itemData.prefabName, chance = 1f, spawnSettings = new SpawnSettings(), itemObject = val, price = result, purchaseSprite = (ModAssets.Icon(val.itemData.prefabName) ?? val.itemData.normalSprite), requiredItemTag = "", competitive = true }); } if (list2.Count > 0) { Plugin.Log.LogWarning((object)("ExtraPrizes: no such item(s): " + string.Join(", ", list2))); } if (list2.Count == 0 || DatabaseReady()) { cache = list; cachedFor = text; } return list; } private static bool DatabaseReady() { return (Object)(object)CL_AssetManager.baseDatabase != (Object)null; } private static Item_Object FindItem(string id) { try { Item_Object itemObjectPrefab = CL_AssetManager.GetItemObjectPrefab(id, ""); if ((Object)(object)itemObjectPrefab != (Object)null) { return itemObjectPrefab; } } catch { } List<WKAssetDatabase> list = Resources.FindObjectsOfTypeAll<WKAssetDatabase>().ToList(); if ((Object)(object)CL_AssetManager.baseDatabase != (Object)null) { list.Insert(0, CL_AssetManager.baseDatabase); } foreach (WKAssetDatabase item in list) { foreach (GameObject itemPrefab in item.itemPrefabs) { Item_Object val = (((Object)(object)itemPrefab != (Object)null) ? itemPrefab.GetComponent<Item_Object>() : null); if (val?.itemData != null && string.Equals(val.itemData.prefabName, id, StringComparison.OrdinalIgnoreCase)) { return val; } } } return null; } } internal static class Jackpot { private class Particle { public Transform t; public SpriteRenderer r; public Vector3 velocity; public float life; public float maxLife; public float spin; public float size; } private static readonly Color[] ConfettiColors = (Color[])(object)new Color[5] { new Color(1f, 0.83f, 0.25f), new Color(1f, 0.95f, 0.7f), new Color(0.86f, 0.25f, 0.2f), new Color(1f, 1f, 1f), new Color(0.98f, 0.6f, 0.2f) }; public static IEnumerator Celebrate(MonoBehaviour host, Vector3 origin, Vector3 front, Vector3 up, Material spriteMaterial, ReelView[] views, float duration) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) AudioClip val = ModAssets.BigWinClip(); if ((Object)(object)val != (Object)null) { AudioManager.PlaySound(val, origin, Plugin.BigWinVolume.Value, 1f, 1f, false, 1f, (AudioMixerGroup)null, ""); } try { CL_CameraControl.ShakeAtPosition(origin, 0.08f, 20f); } catch { } GameObject lightGo = new GameObject("WhiteGamble_JackpotLight"); lightGo.transform.position = origin + front * 0.6f; Light light = lightGo.AddComponent<Light>(); light.type = (LightType)2; light.color = new Color(1f, 0.8f, 0.35f); light.range = 6f; light.intensity = 0f; light.shadows = (LightShadows)0; List<Particle> particles = new List<Particle>(); SpawnBurst(particles, origin, front, up, spriteMaterial, 70); Camera cam = Camera.main; float t = 0f; bool secondBurst = false; while (t < duration) { float deltaTime = Time.deltaTime; t += deltaTime; if (!secondBurst && t > 0.7f) { secondBurst = true; SpawnBurst(particles, origin, front, up, spriteMaterial, 50); try { CL_CameraControl.ShakeAtPosition(origin, 0.05f, 20f); } catch { } } light.intensity = 2.5f * Mathf.Abs(Mathf.Sin(t * 14f)) * Mathf.Clamp01((duration - t) / 0.4f); bool flag = Mathf.Repeat(t, 0.16f) < 0.08f; for (int i = 0; i < views.Length; i++) { bool flag2 = flag ^ (i % 2 == 1); views[i].Tint = (Color)(flag2 ? new Color(1f, 0.85f, 0.35f) : Color.white); views[i].Pulse = 1f + 0.25f * Mathf.Abs(Mathf.Sin(t * 9f + (float)i * 0.9f)); views[i].Apply(); } Step(particles, deltaTime, cam); yield return null; } for (int j = 0; j < views.Length; j++) { views[j].Tint = Color.white; views[j].Pulse = 1f; views[j].Apply(); } Object.Destroy((Object)(object)lightGo); host.StartCoroutine(FinishParticles(particles, cam)); } private static void SpawnBurst(List<Particle> particles, Vector3 origin, Vector3 front, Vector3 up, Material mat, int count) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) Sprite sprite = ModAssets.Spark(); Vector3 val = Vector3.Cross(up, front); Vector3 normalized = ((Vector3)(ref val)).normalized; for (int i = 0; i < count; i++) { GameObject val2 = new GameObject("WhiteGamble_Confetti"); val2.transform.position = origin + normalized * Random.Range(-0.25f, 0.25f) + up * Random.Range(-0.1f, 0.15f); SpriteRenderer val3 = val2.AddComponent<SpriteRenderer>(); val3.sprite = sprite; if ((Object)(object)mat != (Object)null) { ((Renderer)val3).sharedMaterial = mat; } val3.color = ConfettiColors[Random.Range(0, ConfettiColors.Length)]; float num = Random.Range(0.6f, 1.4f); val2.transform.localScale = Vector3.one * num; particles.Add(new Particle { t = val2.transform, r = val3, velocity = front * Random.Range(1.5f, 3.5f) + up * Random.Range(1.5f, 4f) + normalized * Random.Range(-2f, 2f), life = 0f, maxLife = Random.Range(1.2f, 2.2f), spin = Random.Range(-720f, 720f), size = num }); } } private static void Step(List<Particle> particles, float dt, Camera cam) { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0090: 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_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: 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_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) for (int num = particles.Count - 1; num >= 0; num--) { Particle particle = particles[num]; if ((Object)(object)particle.t == (Object)null) { particles.RemoveAt(num); } else { particle.life += dt; if (particle.life >= particle.maxLife) { Object.Destroy((Object)(object)((Component)particle.t).gameObject); particles.RemoveAt(num); } else { particle.velocity += Vector3.down * 6f * dt; particle.velocity *= 1f - 1.2f * dt; Transform t = particle.t; t.position += particle.velocity * dt; if ((Object)(object)cam != (Object)null) { particle.t.rotation = Quaternion.LookRotation(particle.t.position - ((Component)cam).transform.position) * Quaternion.Euler(0f, 0f, particle.spin * particle.life); } float num2 = Mathf.Clamp01((particle.maxLife - particle.life) / 0.4f); bool flag = Mathf.Repeat(particle.life * 12f + (float)num, 2f) < 0.4f; particle.t.localScale = Vector3.one * particle.size * num2 * (flag ? 0.6f : 1f); } } } } private static IEnumerator FinishParticles(List<Particle> particles, Camera cam) { while (particles.Count > 0) { Step(particles, Time.deltaTime, cam); yield return null; } } } internal static class LowPoly { private class Builder { private readonly List<Vector3> verts = new List<Vector3>(); private readonly List<Vector3> normals = new List<Vector3>(); private readonly List<Vector2> uvs = new List<Vector2>(); private readonly List<int> tris = new List<int>(); public void Quad(Vector3 a, Vector3 b, Vector3 c, Vector3 d, Vector3 inside) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: 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_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: 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_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Vector3.Cross(b - a, d - a); if (((Vector3)(ref val)).sqrMagnitude < 1E-12f) { val = Vector3.Cross(c - b, d - b); } ((Vector3)(ref val)).Normalize(); Vector3 val2 = (a + b + c + d) * 0.25f; bool flag = Vector3.Dot(val, val2 - inside) < 0f; if (flag) { val = -val; } Vector3 val3 = b - a; float magnitude = ((Vector3)(ref val3)).magnitude; val3 = c - d; float num = Mathf.Max(magnitude, ((Vector3)(ref val3)).magnitude) / 0.256f; val3 = d - a; float magnitude2 = ((Vector3)(ref val3)).magnitude; val3 = c - b; float num2 = Mathf.Max(magnitude2, ((Vector3)(ref val3)).magnitude) / 0.256f; int count = verts.Count; verts.Add(a); verts.Add(b); verts.Add(c); verts.Add(d); for (int i = 0; i < 4; i++) { normals.Add(val); } uvs.Add(new Vector2(0f, 0f)); uvs.Add(new Vector2(num, 0f)); uvs.Add(new Vector2(num, num2)); uvs.Add(new Vector2(0f, num2)); if (!flag) { tris.Add(count); tris.Add(count + 1); tris.Add(count + 2); tris.Add(count); tris.Add(count + 2); tris.Add(count + 3); } else { tris.Add(count); tris.Add(count + 2); tris.Add(count + 1); tris.Add(count); tris.Add(count + 3); tris.Add(count + 2); } } public Mesh Build(string name) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown Mesh val = new Mesh { name = name }; val.SetVertices(verts); val.SetNormals(normals); val.SetUVs(0, uvs); val.SetTriangles(tris, 0); val.RecalculateBounds(); return val; } } public const float TexelSize = 0.016f; private const int TextureSize = 16; private const float Tile = 0.256f; public static Mesh Box(Vector3 size) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_008c: 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_00b8: 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_00ef: 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_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) Vector3 e = size * 0.5f; Builder builder = new Builder(); builder.Quad(P(-1f, -1f, 1f), P(1f, -1f, 1f), P(1f, 1f, 1f), P(-1f, 1f, 1f), Vector3.zero); builder.Quad(P(1f, -1f, -1f), P(-1f, -1f, -1f), P(-1f, 1f, -1f), P(1f, 1f, -1f), Vector3.zero); builder.Quad(P(1f, -1f, 1f), P(1f, -1f, -1f), P(1f, 1f, -1f), P(1f, 1f, 1f), Vector3.zero); builder.Quad(P(-1f, -1f, -1f), P(-1f, -1f, 1f), P(-1f, 1f, 1f), P(-1f, 1f, -1f), Vector3.zero); builder.Quad(P(-1f, 1f, 1f), P(1f, 1f, 1f), P(1f, 1f, -1f), P(-1f, 1f, -1f), Vector3.zero); builder.Quad(P(-1f, -1f, -1f), P(1f, -1f, -1f), P(1f, -1f, 1f), P(-1f, -1f, 1f), Vector3.zero); return builder.Build("WhiteGamble_Box"); Vector3 P(float x, float y, float z) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) return new Vector3(x * e.x, y * e.y, z * e.z); } } public static Mesh Ball(float radius, int segments, int rings) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) Builder builder = new Builder(); for (int i = 0; i < rings; i++) { for (int j = 0; j < segments; j++) { builder.Quad(P(i + 1, j), P(i + 1, j + 1), P(i, j + 1), P(i, j), Vector3.zero); } } return builder.Build("WhiteGamble_Ball"); Vector3 P(int ring, int seg) { //IL_0042: 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) float num = MathF.PI * (float)ring / (float)rings; float num2 = MathF.PI * 2f * (float)seg / (float)segments; return new Vector3(Mathf.Sin(num) * Mathf.Cos(num2), Mathf.Cos(num), Mathf.Sin(num) * Mathf.Sin(num2)) * radius; } } public static Texture2D PixelTexture(Color32 baseColor, Color32 dark, Color32 accent, int seed) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: 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_0063: 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) Random random = new Random(seed); Texture2D val = new Texture2D(16, 16, (TextureFormat)4, false) { name = "WhiteGamble_Pixels", filterMode = (FilterMode)0, wrapMode = (TextureWrapMode)0 }; Color32[] array = (Color32[])(object)new Color32[256]; for (int i = 0; i < array.Length; i++) { double num = random.NextDouble(); Color32 val2 = ((num < 0.22) ? dark : ((num < 0.36) ? accent : baseColor)); float num2 = 0.9f + (float)random.NextDouble() * 0.2f; array[i] = new Color32((byte)Mathf.Clamp((float)(int)val2.r * num2, 0f, 255f), (byte)Mathf.Clamp((float)(int)val2.g * num2, 0f, 255f), (byte)Mathf.Clamp((float)(int)val2.b * num2, 0f, 255f), byte.MaxValue); } val.SetPixels32(array); val.Apply(false, false); return val; } } internal static class ModAssets { private const string IconPrefix = "WhiteGamble.icons."; private static Dictionary<string, Sprite> icons; private static AudioClip bigWin; private static bool bigWinLoaded; private static Sprite spark; public static Sprite Icon(string prefabName) { if (icons == null) { LoadIcons(); } if (prefabName == null || !icons.TryGetValue(prefabName, out var value)) { return null; } return value; } private static void LoadIcons() { //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Expected O, but got Unknown //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) icons = new Dictionary<string, Sprite>(StringComparer.OrdinalIgnoreCase); Assembly assembly = typeof(ModAssets).Assembly; string[] manifestResourceNames = assembly.GetManifestResourceNames(); foreach (string text in manifestResourceNames) { if (text.StartsWith("WhiteGamble.icons.") && text.EndsWith(".png")) { string text2 = text.Substring("WhiteGamble.icons.".Length, text.Length - "WhiteGamble.icons.".Length - 4); try { Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false) { name = "WhiteGamble_" + text2 }; ImageConversion.LoadImage(val, Read(assembly, text)); ((Texture)val).filterMode = (FilterMode)0; ((Texture)val).wrapMode = (TextureWrapMode)1; Sprite val2 = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f); ((Object)val2).name = "WhiteGamble_" + text2; icons[text2] = val2; } catch (Exception ex) { Plugin.Log.LogWarning((object)("Could not load icon " + text2 + ": " + ex.Message)); } } } Plugin.Log.LogInfo((object)$"Loaded {icons.Count} slot icons."); } public static AudioClip BigWinClip() { if (bigWinLoaded) { return bigWin; } bigWinLoaded = true; try { bigWin = ParseWav(Read(typeof(ModAssets).Assembly, "WhiteGamble.sounds.bigwin.wav"), "WhiteGamble_BigWin"); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Could not load the big-win sound: " + ex.Message)); } return bigWin; } public static Sprite Spark() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: 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_0096: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)spark != (Object)null) { return spark; } Texture2D val = new Texture2D(4, 4, (TextureFormat)4, false) { filterMode = (FilterMode)0, name = "WhiteGamble_Spark" }; Color32[] array = (Color32[])(object)new Color32[16]; for (int i = 0; i < array.Length; i++) { array[i] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue); } val.SetPixels32(array); val.Apply(); spark = Sprite.Create(val, new Rect(0f, 0f, 4f, 4f), new Vector2(0.5f, 0.5f), 100f); return spark; } private static byte[] Read(Assembly asm, string resource) { using Stream stream = asm.GetManifestResourceStream(resource); if (stream == null) { throw new FileNotFoundException("missing embedded resource " + resource); } MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); return memoryStream.ToArray(); } private static AudioClip ParseWav(byte[] b, string name) { int num = 1; int num2 = 44100; int num3 = 16; int num4 = -1; int num5 = 0; int num6; for (int i = 12; i + 8 <= b.Length; i += 8 + num6 + (num6 & 1)) { string text = Encoding.ASCII.GetString(b, i, 4); num6 = BitConverter.ToInt32(b, i + 4); if (text == "fmt ") { num = BitConverter.ToInt16(b, i + 10); num2 = BitConverter.ToInt32(b, i + 12); num3 = BitConverter.ToInt16(b, i + 22); } else if (text == "data") { num4 = i + 8; num5 = Math.Min(num6, b.Length - num4); break; } } if (num4 < 0 || num3 != 16) { throw new InvalidDataException("expected 16-bit PCM WAV"); } int num7 = num5 / 2; float[] array = new float[num7]; for (int j = 0; j < num7; j++) { array[j] = (float)BitConverter.ToInt16(b, num4 + j * 2) / 32768f; } AudioClip obj = AudioClip.Create(name, num7 / num, num, num2, false); obj.SetData(array, 0); return obj; } } public static class Odds { public static float[] WinChances(IList<int> prices, int spinCost, float returnToPlayer, float maxTotalWinChance) { int count = prices.Count; float[] array = new float[count]; if (count == 0 || spinCost <= 0) { return array; } float num = 0f; for (int i = 0; i < count; i++) { int num2 = ((prices[i] < 1) ? 1 : prices[i]); array[i] = returnToPlayer * (float)spinCost / ((float)count * (float)num2); num += array[i]; } if (num > maxTotalWinChance && num > 0f) { float num3 = maxTotalWinChance / num; for (int j = 0; j < count; j++) { array[j] *= num3; } } return array; } public static float[] WithJackpot(IList<int> prices, IList<bool> isJackpot, int spinCost, float returnToPlayer, float maxTotalWinChance, float jackpotChance) { int count = prices.Count; float[] array = new float[count]; List<int> list = new List<int>(); List<int> list2 = new List<int>(); for (int i = 0; i < count; i++) { (isJackpot[i] ? list2 : list).Add(i); } float[] array2 = WinChances(list.Select((int index) => prices[index]).ToList(), spinCost, returnToPlayer, maxTotalWinChance); float num = 0f; for (int num2 = 0; num2 < list.Count; num2++) { array[list[num2]] = array2[num2]; num += array2[num2]; } if (list2.Count == 0 || spinCost <= 0) { return array; } float num3 = Math.Max(0f, Math.Min(jackpotChance, 1f - num)); float num4 = list2.Sum((int index) => 1f / (float)Math.Max(1, prices[index])); foreach (int item in list2) { array[item] = num3 * (1f / (float)Math.Max(1, prices[item])) / num4; } return array; } public static int Roll(float[] chances, float roll) { float num = 0f; for (int i = 0; i < chances.Length; i++) { num += chances[i]; if (roll < num) { return i; } } return -1; } } [BepInPlugin("com.gamblingaddiction.slotmachines", "Gambling Addiction", "1.0.0")] public class Plugin : BaseUnityPlugin { public const string Guid = "com.gamblingaddiction.slotmachines"; public const string Name = "Gambling Addiction"; public const string Version = "1.0.0"; internal static ManualLogSource Log; internal static ConfigEntry<bool> Enabled; internal static ConfigEntry<float> ReplaceChance; internal static ConfigEntry<int> SpinCost; internal static ConfigEntry<float> ReturnToPlayer; internal static ConfigEntry<float> MaxWinChance; internal static ConfigEntry<float> SpinDuration; internal static ConfigEntry<string> TintColor; internal static ConfigEntry<bool> LogOdds; internal static ConfigEntry<string> ExtraPrizeList; internal static ConfigEntry<int> BigWinMinValue; internal static ConfigEntry<float> JackpotChance; internal static ConfigEntry<float> BigWinVolume; private void Awake() { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Expected O, but got Unknown //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Expected O, but got Unknown //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Expected O, but got Unknown //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Expected O, but got Unknown //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Expected O, but got Unknown //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Expected O, but got Unknown //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Expected O, but got Unknown //IL_026e: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Replace vending machines with slot machines."); ReplaceChance = ((BaseUnityPlugin)this).Config.Bind<float>("General", "ReplaceChance", 1f, new ConfigDescription("Chance that a vending machine becomes a slot machine. 1 replaces every vending machine.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); SpinCost = ((BaseUnityPlugin)this).Config.Bind<int>("Odds", "SpinCost", 1, new ConfigDescription("Roaches taken per pull of the handle.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 20), Array.Empty<object>())); ReturnToPlayer = ((BaseUnityPlugin)this).Config.Bind<float>("Odds", "ReturnToPlayer", 0.9f, new ConfigDescription("Average value paid out per roach spent. 1.0 is break-even with buying from the vending machine, lower favours the house. Win chance of an item = ReturnToPlayer * SpinCost / (number of prizes * item price).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.05f, 3f), Array.Empty<object>())); MaxWinChance = ((BaseUnityPlugin)this).Config.Bind<float>("Odds", "MaxWinChance", 0.9f, new ConfigDescription("Upper limit for the total chance that a spin wins anything.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 1f), Array.Empty<object>())); ExtraPrizeList = ((BaseUnityPlugin)this).Config.Bind<string>("Odds", "ExtraPrizes", "Item_Trinket_Beta=30, Item_Trinket_CalmingBuddy=30, Item_Trinket_Carabiner=30, Item_Trinket_Chalk=30, Item_Trinket_ClimbingShoes=30, Item_Trinket_EmployeeID=30, Item_Trinket_Headlamp=30, Item_Trinket_Helmet=30, Item_Trinket_MassDamper=30, Item_Trinket_MoonRock=30, Item_Trinket_Nugget=30, Item_Trinket_PhotoOfHome=30, Item_Trinket_Pouch=30, Item_Artifact_EVAGlove=50, Item_Artifact_Rapier=50, Item_Artifact_Rebar_Return=50, Item_Artifact_Remote=50, Item_Artifact_Timepiece=50, Item_Artifact_Translocator=50", "Prizes added to every slot machine on top of its vending stock, as Item_Prefab_Name=value pairs separated by commas. The value is used like a vending price in the odds (higher = rarer). Leave empty for vending stock only."); JackpotChance = ((BaseUnityPlugin)this).Config.Bind<float>("Odds", "JackpotChance", 0.01f, new ConfigDescription("Chance per spin of winning a jackpot prize (any prize worth BigWinMinValue or more). Which one is picked is weighted by 1/value, so pricier ones are rarer. Regular prizes keep the odds they would have without jackpots.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 0.5f), Array.Empty<object>())); BigWinMinValue = ((BaseUnityPlugin)this).Config.Bind<int>("Presentation", "BigWinMinValue", 20, new ConfigDescription("Prizes worth at least this much are jackpot prizes: they use JackpotChance and trigger the fanfare and effects.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 1000), Array.Empty<object>())); BigWinVolume = ((BaseUnityPlugin)this).Config.Bind<float>("Presentation", "BigWinVolume", 1f, new ConfigDescription("Volume of the jackpot fanfare.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 2f), Array.Empty<object>())); SpinDuration = ((BaseUnityPlugin)this).Config.Bind<float>("Presentation", "SpinDuration", 2.6f, new ConfigDescription("Seconds until the last reel stops.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 8f), Array.Empty<object>())); TintColor = ((BaseUnityPlugin)this).Config.Bind<string>("Presentation", "TintColor", "#FFE2A8", "HTML colour multiplied onto the slot machine's body. Use #FFFFFF for no tint."); LogOdds = ((BaseUnityPlugin)this).Config.Bind<bool>("Presentation", "LogOdds", true, "Write each slot machine's prize table and win chances to the BepInEx log when it spawns."); try { new Harmony("com.gamblingaddiction.slotmachines").PatchAll(typeof(Plugin).Assembly); Log.LogInfo((object)"Gambling Addiction 1.0.0 loaded."); ((MonoBehaviour)this).StartCoroutine(SelfCheck()); } catch (Exception ex) { Log.LogError((object)("Failed to apply patches, slot machines will not appear: " + ex)); } } private IEnumerator SelfCheck() { float waited = 0f; while ((Object)(object)CL_AssetManager.baseDatabase == (Object)null && waited < 120f) { waited += 1f; yield return (object)new WaitForSecondsRealtime(1f); } try { ModAssets.Icon(""); Log.LogInfo((object)("Big-win sound " + (((Object)(object)ModAssets.BigWinClip() != (Object)null) ? ("loaded (" + ModAssets.BigWinClip().length.ToString("0.0") + " s).") : "MISSING."))); List<Purchase> list = ExtraPrizes.Get(); int num = 0; foreach (Purchase item in list) { if ((Object)(object)item.purchaseSprite != (Object)null && ((Object)item.purchaseSprite).name.StartsWith("WhiteGamble_")) { num++; } } Log.LogInfo((object)$"Extra prizes: {list.Count} resolved, {num} with slot icons."); } catch (Exception ex) { Log.LogError((object)("Self-check failed: " + ex)); } } } [HarmonyPatch(typeof(ENV_VendingMachine), "Start")] internal static class VendingMachineStartPatch { private static void Postfix(ENV_VendingMachine __instance) { try { if (!((Object)(object)__instance == (Object)null) && !((Object)(object)((Component)__instance).GetComponent<SlotMachine>() != (Object)null)) { SlotSpawner.CaptureTemplate(__instance); SlotSpawner.Convert(__instance); } } catch (Exception ex) { Plugin.Log.LogError((object)("Slot machine conversion failed: " + ex)); } } } [HarmonyPatch(typeof(ENV_VendingMachine), "GenerateOptions")] internal static class VendingMachineRestockPatch { private static bool Prefix(ENV_VendingMachine __instance) { return (Object)(object)((Component)__instance).GetComponent<SlotMachine>() == (Object)null; } } [HarmonyPatch(typeof(CL_GameManager), "InitializeCommands")] internal static class ConsoleCommandPatch { internal const string Command = "spawnslotmachine"; internal const string JackpotCommand = "slotjackpot"; private static void Postfix() { try { CommandConsole.RemoveCommand("spawnslotmachine"); CommandBuilder val = CommandConsole.BuildCommand("spawnslotmachine", (Action<string[]>)Run); if (val == null) { Plugin.Log.LogWarning((object)"Console not ready; 'spawnslotmachine' was not registered."); return; } val.Description(": Spawn a Gambling Addiction slot machine in front of the player"); CommandConsole.RemoveCommand("slotjackpot"); CommandBuilder obj = CommandConsole.BuildCommand("slotjackpot", (Action<string[]>)RunJackpot); if (obj != null) { obj.Description(": The next slot machine pull wins a jackpot prize (for testing)"); } } catch (Exception ex) { Plugin.Log.LogError((object)("Could not register console command: " + ex)); } } private static void RunJackpot(string[] args) { SlotMachine.ForceJackpot = true; CommandConsole.Log("The next slot machine pull will win a jackpot prize."); } private static void Run(string[] args) { try { CommandConsole.Log(SlotSpawner.SpawnNearPlayer()); } catch (Exception ex) { Plugin.Log.LogError((object)("spawnslotmachine failed: " + ex)); CommandConsole.Log("Slot machine spawn failed - see the BepInEx log."); } } } [HarmonyPatch(typeof(ENV_VendingMachine), "Buy", new Type[] { typeof(int), typeof(bool), typeof(bool) })] internal static class VendingMachineBuyPatch { private static bool Prefix(ENV_VendingMachine __instance, bool force) { if (force) { return true; } return (Object)(object)((Component)__instance).GetComponent<SlotMachine>() == (Object)null; } } internal class ReelView { private readonly SpriteRenderer current; private readonly SpriteRenderer incoming; private readonly Vector3 restPos; private readonly Vector3 restScale; private readonly Vector3 axis; private float radius; private Sprite curSprite; private Sprite nextSprite; public float Roll; public float Pulse = 1f; public Color Tint = Color.white; public ReelView(SpriteRenderer source, Sprite sizeReference) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown //IL_008d: 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_00af: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) current = source; Transform transform = ((Component)source).transform; restPos = transform.localPosition; restScale = transform.localScale; axis = transform.localRotation * Vector3.up; GameObject val = new GameObject("WhiteGamble_ReelNext"); val.layer = ((Component)source).gameObject.layer; val.transform.SetParent(transform.parent, false); val.transform.localPosition = restPos; val.transform.localRotation = transform.localRotation; val.transform.localScale = restScale; incoming = val.AddComponent<SpriteRenderer>(); ((Renderer)incoming).sharedMaterial = ((Renderer)source).sharedMaterial; ((Renderer)incoming).sortingLayerID = ((Renderer)source).sortingLayerID; ((Renderer)incoming).sortingOrder = ((Renderer)source).sortingOrder; incoming.flipX = source.flipX; incoming.flipY = source.flipY; incoming.maskInteraction = source.maskInteraction; ((Renderer)incoming).renderingLayerMask = ((Renderer)source).renderingLayerMask; Sprite val2 = (((Object)(object)source.sprite != (Object)null) ? source.sprite : sizeReference); float num; if (!((Object)(object)val2 != (Object)null)) { num = 1f; } else { Bounds bounds = val2.bounds; num = ((Bounds)(ref bounds)).size.y; } float num2 = num * Mathf.Abs(restScale.y); radius = num2 * 0.6f; } public void Show(Sprite sprite) { curSprite = sprite; nextSprite = null; Roll = 0f; Apply(); } public void SetNext(Sprite sprite) { nextSprite = sprite; } public void Advance(Sprite newNext) { curSprite = nextSprite; nextSprite = newNext; } public void Apply() { float num = Mathf.Clamp01(Roll) * MathF.PI * 0.5f; float num2 = Mathf.Sin(num); float num3 = Mathf.Cos(num); Place(current, curSprite, 0f - num2, num3); Place(incoming, nextSprite, num3, num2); } private void Place(SpriteRenderer r, Sprite sprite, float offset, float facing) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) if (((Renderer)r).enabled = (Object)(object)sprite != (Object)null && facing > 0.03f) { r.sprite = sprite; ((Component)r).transform.localPosition = restPos + axis * (radius * offset); ((Component)r).transform.localScale = new Vector3(restScale.x * Pulse, restScale.y * facing * Pulse, restScale.z); float num = 0.35f + 0.65f * facing; r.color = new Color(Tint.r * num, Tint.g * num, Tint.b * num, Tint.a); } } } public class SlotHandle : MonoBehaviour, Clickable { public SlotMachine machine; public ObjectTagger tagger; public void Interact(InteractionInfo info) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)machine != (Object)null) { machine.GrabLever(info?.interactionPoint ?? ((Component)this).transform.position); } } public bool CanInteract(Interaction info) { if ((Object)(object)machine != (Object)null) { return ((Behaviour)machine).isActiveAndEnabled; } return false; } public void StartInteract(ENT_Player p, string s) { } public void StopInteract(ENT_Player p, string s) { if ((Object)(object)machine != (Object)null) { machine.ReleaseLever(); } } public void StopInteract(ENT_Player p, Hand hand, string s) { if ((Object)(object)machine != (Object)null) { machine.ReleaseLever(); } } public ObjectTagger GetTagger() { return tagger; } public GameObject GetGameObject() { return ((Component)this).gameObject; } public Sprite GetSprite() { return null; } } public class SlotMachine : MonoBehaviour { private const float PullAngle = 80f; private const float TriggerFraction = 0.92f; private const float ReelSpeed = 9f; private const float BounceTime = 0.2f; private static readonly FieldRef<ENV_VendingMachine, bool> DeadRef = AccessTools.FieldRefAccess<ENV_VendingMachine, bool>("dead"); private static readonly FieldRef<ENV_VendingMachine, bool> BlockedRef = AccessTools.FieldRefAccess<ENV_VendingMachine, bool>("isBlocked"); private ENV_VendingMachine vm; private UT_AudioClipHandler sounds; private List<Purchase> pool; private float[] chances; private VendingButton[] reels; private Purchase[] fakes; private ReelView[] views; private Sprite[] shown; private Transform handleMount; private Transform handlePivot; private float leverLength; private float armOffset; private bool held; private bool leverArmed = true; private float leverAngle; private float lastClickAngle; private float grabRadius; private bool ready; private bool spinning; private int paid; internal static bool ForceJackpot; private Material spriteMaterial; private Vector3 reelCenter; private Vector3 frontDir; private Vector3 upDir; public bool Spinning => spinning; private void OnDisable() { //IL_0063: Unknown result type (might be due to invalid IL or missing references) if (spinning && paid > 0) { CL_GameManager.AddRoaches(paid, false); } paid = 0; spinning = false; held = false; leverAngle = 0f; lastClickAngle = 0f; leverArmed = true; if ((Object)(object)handlePivot != (Object)null) { handlePivot.localRotation = Quaternion.identity; } if (ready) { ShowIdleReels(); } } private void Update() { //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) if (!ready) { return; } UpdateLever(); for (int i = 0; i < reels.Length; i++) { if (reels[i].purchase != fakes[i]) { reels[i].purchase = fakes[i]; reels[i].available = true; if ((Object)(object)reels[i].text != (Object)null) { reels[i].text.text = ""; } } } if (!spinning) { bool flag = DeadRef.Invoke(vm) || BlockedRef.Invoke(vm); Color tint = ((flag || CL_GameManager.GetRoaches(false) < Plugin.SpinCost.Value) ? vm.unaffordableColor : vm.availableColor); for (int j = 0; j < views.Length; j++) { views[j].Tint = tint; views[j].Pulse = 1f; views[j].Show(flag ? vm.destroyedButtonSprite : shown[j]); } } } internal bool Setup(ENV_VendingMachine machine, MachineFrame frame, Vector3 outward, ENV_VendingMachine poolSource, bool isCopy) { //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) vm = machine; if ((Object)(object)vm == (Object)null) { return false; } sounds = ((Component)this).GetComponent<UT_AudioClipHandler>(); ENV_VendingMachine val = (((Object)(object)poolSource != (Object)null && poolSource.purchaseList != null) ? poolSource : vm); pool = SlotSpawner.BuildPool(val); if (pool.Count == 0) { Plugin.Log.LogInfo((object)("'" + ((Object)this).name + "' has no winnable items; it stays a vending machine.")); return false; } if (!vm.buttons.Any((VendingButton b) => b != null && (Object)(object)b.sprite != (Object)null && (Object)(object)b.text != (Object)null)) { Plugin.Log.LogWarning((object)("'" + ((Object)this).name + "' has no usable button displays; it stays a vending machine.")); return false; } chances = Odds.WithJackpot(pool.Select((Purchase p) => p.price).ToList(), pool.Select(IsBig).ToList(), Plugin.SpinCost.Value, Plugin.ReturnToPlayer.Value, Plugin.MaxWinChance.Value, Plugin.JackpotChance.Value); frontDir = frame.front; upDir = frame.up; if ((Object)(object)val != (Object)(object)vm) { vm.purchaseList = new List<Purchase>(val.purchaseList); } vm.randomGeneration = false; if (isCopy) { vm.vendorId = ""; } Material bodyMaterial = FindBodyMaterial(); SetupReels(frame); int preferred = DisablePurchaseButtons(); if (isCopy) { FixLighting(); } Tint(); BuildHandle(frame, outward, ResolveInteractLayer(preferred), bodyMaterial); ready = true; ShowIdleReels(); if (Plugin.LogOdds.Value) { LogOddsTable(); } return true; } private int DisablePurchaseButtons() { int num = -1; CL_Button[] componentsInChildren = ((Component)this).GetComponentsInChildren<CL_Button>(true); foreach (CL_Button val in componentsInChildren) { bool flag = false; if (val.activeEvent != null) { for (int j = 0; j < ((UnityEventBase)val.activeEvent).GetPersistentEventCount(); j++) { if (((UnityEventBase)val.activeEvent).GetPersistentTarget(j) is ENV_VendingMachine && ((UnityEventBase)val.activeEvent).GetPersistentMethodName(j) == "Buy") { flag = true; break; } } } if (flag) { if (num < 0) { num = ((Component)val).gameObject.layer; } Collider[] components = ((Component)val).GetComponents<Collider>(); for (int k = 0; k < components.Length; k++) { components[k].enabled = false; } Object.Destroy((Object)(object)val); } } return num; } private static int ResolveInteractLayer(int preferred) { int num = ((preferred >= 0) ? preferred : LayerMask.NameToLayer("Interactable")); ENT_Player val = null; try { val = ENT_Player.GetPlayer(); } catch { } if ((Object)(object)val != (Object)null) { int value = ((LayerMask)(ref val.interactMask)).value; if (num < 0 || (value & (1 << num)) == 0) { int num2 = LayerMask.NameToLayer("Interactable"); if (num2 >= 0 && (value & (1 << num2)) != 0) { num = num2; } else { for (int i = 0; i < 32; i++) { if ((value & (1 << i)) != 0) { num = i; break; } } } Plugin.Log.LogInfo((object)$"Handle uses layer {num} ({LayerMask.LayerToName(num)}) from the player's interact mask."); } } if (num >= 0) { return num; } return 0; } private void SetupReels(MachineFrame frame) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02aa: Expected O, but got Unknown List<VendingButton> source = vm.buttons.Where((VendingButton b) => b != null && (Object)(object)b.sprite != (Object)null && (Object)(object)b.text != (Object)null).ToList(); Vector3 viewerRight = -frame.right; float top = ((IEnumerable<VendingButton>)source).Max((Func<VendingButton, float>)Height); List<VendingButton> list = source.Where((VendingButton b) => top - Height(b) < 0.06f).OrderBy(Across).ToList(); List<VendingButton> list2 = ((list.Count >= 3) ? list.Take(3).ToList() : source.OrderByDescending(Height).Take(3).OrderBy(Across) .ToList()); VendingButton[] buttons = vm.buttons; foreach (VendingButton val in buttons) { if (val != null && !list2.Contains(val)) { if ((Object)(object)val.sprite != (Object)null) { ((Renderer)val.sprite).enabled = false; } if ((Object)(object)val.text != (Object)null) { ((Behaviour)val.text).enabled = false; } } } GameObject val2 = new GameObject("WhiteGamble_ButtonStandIn"); val2.transform.SetParent(((Component)this).transform, false); SpriteRenderer val3 = val2.AddComponent<SpriteRenderer>(); ((Renderer)val3).enabled = false; Sprite sizeReference = pool.Select(SymbolSprite).FirstOrDefault((Func<Sprite, bool>)((Sprite s) => (Object)(object)s != (Object)null)); spriteMaterial = ((Renderer)list2[0].sprite).sharedMaterial; reelCenter = list2.Aggregate(Vector3.zero, (Vector3 sum, VendingButton b) => sum + ((Component)b.sprite).transform.position) / (float)list2.Count; views = new ReelView[list2.Count]; shown = (Sprite[])(object)new Sprite[list2.Count]; for (int num2 = 0; num2 < list2.Count; num2++) { VendingButton val4 = list2[num2]; views[num2] = new ReelView(val4.sprite, sizeReference); val4.sprite = val3; val4.available = true; val4.purchase = new Purchase { name = "whitegamble-reel", chance = 1f, price = 0, requiredItemTag = "", competitive = true }; } reels = list2.ToArray(); fakes = reels.Select((VendingButton r) => r.purchase).ToArray(); vm.buttons = reels; float Across(VendingButton b) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) return Vector3.Dot(((Component)b.sprite).transform.position, viewerRight); } float Height(VendingButton b) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) return Vector3.Dot(((Component)b.sprite).transform.position, frame.up); } } private void FixLighting() { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) bool flag = false; MeshRenderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<MeshRenderer>(true); foreach (MeshRenderer val in componentsInChildren) { if (!((Object)(object)((Component)val).GetComponent<TMP_Text>() != (Object)null)) { if (!flag && Plugin.LogOdds.Value) { flag = true; Material sharedMaterial = ((Renderer)val).sharedMaterial; Plugin.Log.LogInfo((object)($"Lighting before fix on '{((Object)val).name}': lightmapIndex={((Renderer)val).lightmapIndex}, scaleOffset={((Renderer)val).lightmapScaleOffset}, " + $"probes={((Renderer)val).lightProbeUsage}, static={((Component)val).gameObject.isStatic}, vertexStreams={(Object)(object)val.additionalVertexStreams != (Object)null}, " + string.Format("propertyBlock={0}, shader='{1}', ", ((Renderer)val).HasPropertyBlock(), ((Object)(object)sharedMaterial != (Object)null) ? ((Object)sharedMaterial.shader).name : "none") + "keywords=[" + (((Object)(object)sharedMaterial != (Object)null) ? string.Join(",", sharedMaterial.shaderKeywords) : "") + "]")); } ((Component)val).gameObject.isStatic = false; ((Renderer)val).lightmapIndex = -1; ((Renderer)val).realtimeLightmapIndex = -1; ((Renderer)val).lightProbeUsage = (LightProbeUsage)1; ((Renderer)val).reflectionProbeUsage = (ReflectionProbeUsage)1; } } } private void Tint() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) Color val = default(Color); if (!ColorUtility.TryParseHtmlString(Plugin.TintColor.Value, ref val) || val == Color.white) { return; } MeshRenderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<MeshRenderer>(true); foreach (MeshRenderer val2 in componentsInChildren) { if (!((Object)(object)((Component)val2).GetComponent<TMP_Text>() != (Object)null)) { Material[] materials = ((Renderer)val2).materials; foreach (Material mat in materials) { MultiplyColor(mat, "_Color", val); MultiplyColor(mat, "_BaseColor", val); } } } } private static void MultiplyColor(Material mat, string property, Color tint) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)mat != (Object)null && mat.HasProperty(property)) { mat.SetColor(property, mat.GetColor(property) * tint); } } private Material FindBodyMaterial() { Renderer val = (Renderer)(((Object)(object)vm.meshRenderer != (Object)null) ? ((object)vm.meshRenderer) : ((object)((Component)this).GetComponentInChildren<MeshRenderer>())); if ((Object)(object)val == (Object)null) { return null; } Material[] sharedMaterials = val.sharedMaterials; for (int i = 0; i < sharedMaterials.Length; i++) { if ((Object)(object)sharedMaterials[i] != (Object)null && (sharedMaterials.Length == 1 || i != vm.destroyedMaterialIndex)) { return sharedMaterials[i]; } } return val.sharedMaterial; } private static Material PixelMaterial(Material body, Color32 baseColor, Color32 dark, Color32 accent, int seed) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0053: 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) if ((Object)(object)body == (Object)null) { return null; } Material val = new Material(body); Texture2D val2 = LowPoly.PixelTexture(baseColor, dark, accent, seed); string[] array = new string[2] { "_MainTex", "_BaseMap" }; foreach (string text in array) { if (val.HasProperty(text)) { val.SetTexture(text, (Texture)(object)val2); val.SetTextureScale(text, Vector2.one); val.SetTextureOffset(text, Vector2.zero); } } return val; } private void BuildHandle(MachineFrame f, Vector3 outward, int layer, Material bodyMaterial) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: 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_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_02ba: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Unknown result type (might be due to invalid IL or missing references) //IL_02f3: Unknown result type (might be due to invalid IL or missing references) //IL_030b: Unknown result type (might be due to invalid IL or missing references) //IL_033d: Unknown result type (might be due to invalid IL or missing references) //IL_034e: Unknown result type (might be due to invalid IL or missing references) //IL_0353: Unknown result type (might be due to invalid IL or missing references) //IL_035a: Unknown result type (might be due to invalid IL or missing references) //IL_036c: Unknown result type (might be due to invalid IL or missing references) //IL_0387: Unknown result type (might be due to invalid IL or missing references) //IL_03a8: Unknown result type (might be due to invalid IL or missing references) //IL_03b2: Unknown result type (might be due to invalid IL or missing references) //IL_03c6: Unknown result type (might be due to invalid IL or missing references) float num = SlotSpawner.HandleLength(f); Vector3 val = SlotSpawner.HandlePivot(f, outward); Matrix4x4 worldToLocalMatrix = ((Component)this).transform.worldToLocalMatrix; Matrix4x4 localToWorldMatrix = ((Component)this).transform.localToWorldMatrix; Vector4 column = ((Matrix4x4)(ref localToWorldMatrix)).GetColumn(0); float magnitude = ((Vector4)(ref column)).magnitude; column = ((Matrix4x4)(ref localToWorldMatrix)).GetColumn(1); float num2 = magnitude + ((Vector4)(ref column)).magnitude; column = ((Matrix4x4)(ref localToWorldMatrix)).GetColumn(2); float num3 = (num2 + ((Vector4)(ref column)).magnitude) / 3f; if (num3 < 0.0001f) { num3 = 1f; } Transform transform = new GameObject("WhiteGamble_HandleMount").transform; transform.SetParent(((Component)this).transform, false); transform.localPosition = ((Matrix4x4)(ref worldToLocalMatrix)).MultiplyPoint3x4(val); Vector3 val2 = ((Matrix4x4)(ref worldToLocalMatrix)).MultiplyVector(f.front); Vector3 normalized = ((Vector3)(ref val2)).normalized; val2 = ((Matrix4x4)(ref worldToLocalMatrix)).MultiplyVector(f.up); transform.localRotation = Quaternion.LookRotation(normalized, ((Vector3)(ref val2)).normalized); transform.localScale = Vector3.one / num3; Matrix4x4 localToWorldMatrix2 = transform.localToWorldMatrix; float num4 = Mathf.Sign(Vector3.Dot(((Matrix4x4)(ref localToWorldMatrix2)).MultiplyVector(Vector3.right), outward)); if (num4 == 0f) { num4 = 1f; } handlePivot = new GameObject("WhiteGamble_Handle").transform; handlePivot.SetParent(transform, false); Material mat = PixelMaterial(bodyMaterial, new Color32((byte)92, (byte)88, (byte)90, byte.MaxValue), new Color32((byte)50, (byte)46, (byte)48, byte.MaxValue), new Color32((byte)142, (byte)64, (byte)54, byte.MaxValue), 7); Material mat2 = PixelMaterial(bodyMaterial, new Color32((byte)58, (byte)54, (byte)56, byte.MaxValue), new Color32((byte)34, (byte)31, (byte)33, byte.MaxValue), new Color32((byte)110, (byte)52, (byte)46, byte.MaxValue), 11); Material mat3 = PixelMaterial(bodyMaterial, new Color32((byte)196, (byte)70, (byte)62, byte.MaxValue), new Color32((byte)132, (byte)38, (byte)40, byte.MaxValue), new Color32((byte)234, (byte)138, (byte)118, byte.MaxValue), 3); float num5 = num4 * 0.115f; handleMount = transform; leverLength = num; armOffset = num5; AddPart(transform, "Housing", LowPoly.Box(new Vector3(0.12f, 0.36f, 0.3f)), new Vector3(num4 * 0.01f, 0f, 0f), mat); AddPart(transform, "Slot", LowPoly.Box(new Vector3(0.02f, 0.28f, 0.2f)), new Vector3(num4 * 0.075f, 0f, 0f), mat2); AddPart(handlePivot, "Hub", LowPoly.Box(new Vector3(0.07f, 0.15f, 0.15f)), new Vector3(num5, 0f, 0f), mat2); AddPart(handlePivot, "Arm", LowPoly.Box(new Vector3(0.075f, num, 0.075f)), new Vector3(num5, num * 0.5f, 0f), mat); AddPart(handlePivot, "Knob", LowPoly.Ball(0.12f, 6, 4), new Vector3(num5, num + 0.072000004f, 0f), mat3); GameObject val3 = new GameObject("WhiteGamble_HandleGrab") { layer = layer }; val3.transform.SetParent(handlePivot, false); BoxCollider obj = val3.AddComponent<BoxCollider>(); obj.center = new Vector3(num5, (num + 0.192f) * 0.5f, 0f); obj.size = new Vector3(0.28f, num + 0.192f + 0.1f, 0.28f); ObjectTagger val4 = val3.AddComponent<ObjectTagger>(); val4.AddTag("HoldButton"); SlotHandle slotHandle = val3.AddComponent<SlotHandle>(); slotHandle.machine = this; slotHandle.tagger = val4; int value = Plugin.SpinCost.Value; val3.AddComponent<UT_HoverInfo>().infoText = "SLOT MACHINE - hold the lever and pull it down (" + value + ((value == 1) ? " roach)" : " roaches)"); } private void AddPart(Transform parent, string partName, Mesh mesh, Vector3 localPos, Material mat) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(partName) { layer = ((Component)this).gameObject.layer }; val.transform.SetParent(parent, false); val.transform.localPosition = localPos; val.AddComponent<MeshFilter>().sharedMesh = mesh; MeshRenderer val2 = val.AddComponent<MeshRenderer>(); if ((Object)(object)mat != (Object)null) { ((Renderer)val2).sharedMaterial = mat; } } private void LogOddsTable() { StringBuilder stringBuilder = new StringBuilder(); float num = chances.Sum(); stringBuilder.Append($"Slot odds ({pool.Count} prizes, {Plugin.SpinCost.Value} per spin, any win {num:P1}):"); for (int i = 0; i < pool.Count; i++) { stringBuilder.Append($"\n {PrizeName(pool[i]),-28} price {pool[i].price,2} -> {chances[i]:P2} per spin"); } Plugin.Log.LogInfo((object)stringBuilder.ToString()); } private static string PrizeName(Purchase p) { if (!string.IsNullOrEmpty(p.name)) { return p.name; } if ((Object)(object)p.itemObject != (Object)null) { return ((Object)p.itemObject).name; } if (p.spawnAssets == null || p.spawnAssets.Count <= 0 || !((Object)(object)p.spawnAssets[0] != (Object)null)) { return "?"; } return ((Object)p.spawnAssets[0]).name; } private static Sprite SymbolSprite(Purchase p) { if (p == null) { return null; } if ((Object)(object)p.purchaseSprite != (Object)null) { return p.purchaseSprite; } if (!((Object)(object)p.itemObject != (Object)null) || p.itemObject.itemData == null) { return null; } return p.itemObject.itemData.normalSprite; } private void SetResting(int reel, Purchase symbol) { shown[reel] = SymbolSprite(symbol); Purchase val = fakes[reel]; reels[reel].purchase = val; Purchase val2 = symbol ?? pool[0]; val.purchaseSprite = shown[reel]; val.itemObject = val2.itemObject; val.spawnAssets = val2.spawnAssets; val.spawnSettings = val2.spawnSettings; } private Purchase RandomSymbol() { int num = ((pool.Count < 3) ? 1 : 0); int num2 = Random.Range(0, pool.Count + num); if (num2 >= pool.Count) { return null; } return pool[num2]; } private Purchase[] LosingCombo() { Purchase[] combo = (Purchase[])(object)new Purchase[reels.Length]; if (reels.Length == 1) { combo[0] = null; return combo; } for (int i = 0; i < 20; i++) { for (int j = 0; j < combo.Length; j++) { combo[j] = RandomSymbol(); } if (combo.Length >= 3 && Random.value < 0.3f) { combo[1] = combo[0]; } if (combo.Any((Purchase s) => s != combo[0])) { return combo; } } combo[combo.Length - 1] = null; if (combo[0] == null) { combo[0] = pool[0]; } return combo; } private void ShowIdleReels() { Purchase[] array = LosingCombo(); for (int i = 0; i < reels.Length; i++) { SetResting(i, array[i]); views[i].Pulse = 1f; views[i].Show(shown[i]); } } private void Play(string sound, float volume = 1f) { if ((Object)(object)sounds != (Object)null) { sounds.PlaySound(sound, volume); } } private void Pull() { if (!ready || spinning || !((Behaviour)this).isActiveAndEnabled) { return; } if (DeadRef.Invoke(vm) || BlockedRef.Invoke(vm)) { Play("vending:broken"); return; } int value = Plugin.SpinCost.Value; if (CL_GameManager.GetRoaches(false) < value) { Play("vending:deny"); return; } CL_GameManager.AddRoaches(-value, false); paid = value; Play("vending:kaching"); int num = Odds.Roll(chances, Random.value); if (ForceJackpot) { ForceJackpot = false; List<int> list = (from i in Enumerable.Range(0, pool.Count) where IsBig(pool[i]) select i).ToList(); if (list.Count > 0) { num = list[Random.Range(0, list.Count)]; } } Purchase[] result = ((num >= 0) ? Enumerable.Repeat<Purchase>(pool[num], reels.Length).ToArray() : LosingCombo()); ((MonoBehaviour)this).StartCoroutine(Spin(num, result)); } public void GrabLever(Vector3 worldGrabPoint) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) if (ready && !((Object)(object)handleMount == (Object)null)) { held = true; Matrix4x4 worldToLocalMatrix = handleMount.worldToLocalMatrix; Vector3 val = ((Matrix4x4)(ref worldToLocalMatrix)).MultiplyPoint3x4(worldGrabPoint); Vector2 val2 = new Vector2(val.y, val.z); grabRadius = Mathf.Clamp(((Vector2)(ref val2)).magnitude, 0.2f, leverLength + 0.15f); } } public void ReleaseLever() { held = false; } private float AimAngle() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: 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_0098: Unknown result type (might be due to invalid IL or missing references) //IL_0099: 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_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) Camera main = Camera.main; if ((Object)(object)main == (Object)null) { return 80f; } Matrix4x4 worldToLocalMatrix = handleMount.worldToLocalMatrix; Vector3 val = ((Matrix4x4)(ref worldToLocalMatrix)).MultiplyPoint3x4(((Component)main).transform.position); Vector3 val2 = ((Matrix4x4)(ref worldToLocalMatrix)).MultiplyVector(((Component)main).transform.forward); Vector3 normalized = ((Vector3)(ref val2)).normalized; float result = 0f; float num = float.MaxValue; for (float num2 = 0f; num2 <= 80f; num2 += 1f) { float num3 = num2 * (MathF.PI / 180f); val2 = Vector3.Cross(new Vector3(armOffset, Mathf.Cos(num3) * grabRadius, Mathf.Sin(num3) * grabRadius) - val, normalized); float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; result = num2; } } return result; } private void UpdateLever() { //IL_008e: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)handlePivot == (Object)null)) { float deltaTime = Time.deltaTime; if (held) { leverAngle = Mathf.MoveTowards(leverAngle, AimAngle(), 420f * deltaTime); } else if (leverAngle > 0f) { leverAngle = Mathf.MoveTowards(leverAngle, 0f, Mathf.Max(90f, leverAngle * 7f) * deltaTime); } handlePivot.localRotation = Quaternion.Euler(leverAngle, 0f, 0f); if (Mathf.Abs(leverAngle - lastClickAngle) >= 15f) { lastClickAngle = leverAngle; Play("vending:ticker", 0.35f); } if (!leverArmed && leverAngle <= 16f) { leverArmed = true; } if (leverArmed && held && leverAngle >= 73.6f) { leverArmed = false; Pull(); } } } private IEnumerator Spin(int win, Purchase[] result) { spinning = true; int n = views.Length; float value = Plugin.SpinDuration.Value; float[] stopAt = new float[n]; int[] phase = new int[n]; float[] settle = new float[n]; for (int i = 0; i < n; i++) { stopAt[i] = ((n == 1) ? value : (value * (0.5f + 0.5f * (float)i / (float)(n - 1)))); views[i].Tint = vm.availableColor; views[i].Pulse = 1f; views[i].SetNext(SymbolSprite(RandomSymbol())); } float t = 0f; float tickCooldown = 0f; int stopped = 0; while (stopped < n) { float deltaTime = Time.deltaTime; t += deltaTime; tickCooldown -= deltaTime; float num = Mathf.Lerp(2.5f, 9f, t / 0.4f); bool flag = false; for (int j = 0; j < n; j++) { ReelView reelView = views[j]; if (phase[j] <= 1) { reelView.Roll += num * deltaTime; if (reelView.Roll >= 1f) { flag = true; if (phase[j] == 1) { reelView.Advance(SymbolSprite(RandomSymbol())); reelView.Roll = 0f; phase[j] = 2; SetResting(j, result[j]); Play("vending:ticker"); } else { reelView.Roll -= 1f; if (t >= stopAt[j]) { reelView.Advance(SymbolSprite(result[j])); phase[j] = 1; } else { reelView.Advance(SymbolSprite(RandomSymbol())); } } } } else if (phase[j] == 2) { settle[j] += deltaTime; if (settle[j] >= 0.2f) { reelView.Roll = 0f; phase[j] = 3; stopped++; } else { reelView.Roll = 0.14f * Mathf.Sin(MathF.PI * settle[j] / 0.2f); } } reelView.Apply(); } if (flag && tickCooldown <= 0f) { Play("vending:ticker", 0.45f); tickCooldown = 0.09f; } yield return null; } for (int k = 0; k < n; k++) { views[k].Show(shown[k]); } if (win >= 0 && !DeadRef.Invoke(vm) && IsBig(pool[win])) { Play("vending:approve"); Plugin.Log.LogInfo((object)("JACKPOT: " + PrizeName(pool[win]))); yield return Jackpot.Celebrate((MonoBehaviour)(object)this, reelCenter + frontDir * 0.15f, frontDir, upDir, spriteMaterial, views, 1.9f); Dispense(pool[win]); Play("vending:kaching"); } else if (win >= 0 && !DeadRef.Invoke(vm)) { Play("vending:approve"); for (float p = 0f; p < 0.7f; p += Time.deltaTime) { float pulse = 1f + 0.22f * Mathf.Abs(Mathf.Sin(MathF.PI * p / 0.35f)); for (int l = 0; l < n; l++) { views[l].Pulse = pulse; views[l].Apply(); } yield return null; } Dispense(pool[win]); } else { yield return (object)new WaitForSeconds(0.15f); Play("vending:deny", 0.5f); } paid = 0; spinning = false; } private static bool IsBig(Purchase p) { if (p != null) { return p.price >= Plugin.BigWinMinValue.Value; } return false; } private void Dispense(Purchase prize) { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: 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) List<GameObject> list = new List<GameObject>(); if (prize.spawnAssets == null || prize.spawnAssets.Count == 0) { list.Add(((Component)prize.itemObject).gameObject); } else { list.AddRange(prize.spawnAssets); } Transform spawnSpot = vm.spawnSpot; foreach (GameObject item in list) { if (!((Object)(object)item == (Object)null)) { GameObject obj = Object.Instantiate<GameObject>(item, spawnSpot.position, spawnSpot.rotation, ((Component)this).transform.parent); ObjectTagger component = obj.GetComponent<ObjectTagger>(); if ((Object)(object)component != (Object)null) { component.AddTag("Vended"); } Rigidbody component2 = obj.GetComponent<Rigidbody>(); if ((Object)(object)component2 != (Object)null) { component2.isKinematic = false; component2.linearVelocity = spawnSpot.forward * 5f; } } } Plugin.Log.LogInfo((object)("Slot machine paid out: " + PrizeName(prize))); } } internal class MachineFrame { public Vector3 center; public Vector3 up; public Vector3 front; public Vector3 right; public float width; public float height; public float depth; private static readonly Vector3[] Corners = (Vector3[])(object)new Vector3[8] { new Vector3(-1f, -1f, -1f), new Vector3(-1f, -1f, 1f), new Vector3(-1f, 1f, -1f), new Vector3(-1f, 1f, 1f), new Vector3(1f, -1f, -1f), new Vector3(1f, -1f, 1f), new Vector3(1f, 1f, -1f), new Vector3(1f, 1f, 1f) }; public MachineFrame Shifted(Vector3 offset) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) MachineFrame obj = (MachineFrame)MemberwiseClone(); obj.center += offset; return obj; } public static MachineFrame Compute(ENV_VendingMachine vm) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //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_0099: 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_0129: 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_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_02d1: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0368: Unknown result type (might be due to invalid IL or missing references) //IL_036d: Unknown result type (might be due to invalid IL or missing references) //IL_0372: Unknown result type (might be due to invalid IL or missing references) //IL_0374: Unknown result type (might be due to invalid IL or missing references) //IL_0389: Unknown result type (might be due to invalid IL or missing references) //IL_0392: Unknown result type (might be due to invalid IL or missing references) //IL_03bd: Unknown result type (might be due to invalid IL or missing references) //IL_03c6: Unknown result type (might be due to invalid IL or missing references) //IL_035a: Unknown result type (might be due to invalid IL or missing references) //IL_035f: Unknown result type (might be due to invalid IL or missing references) //IL_0361: Unknown result type (might be due to invalid IL or missing references) //IL_034d: Unknown result type (might be due to invalid IL or missing references) //IL_030c: Unknown result type (might be due to invalid IL or missing references) //IL_031a: Unknown result type (might be due to invalid IL or missing references) //IL_031f: Unknown result type (might be due to invalid IL or missing references) //IL_0324: Unknown result type (might be due to invalid IL or missing references) //IL_0415: Unknown result type (might be due to invalid IL or missing references) //IL_043e: Unknown result type (might be due to invalid IL or missing references) //IL_0445: Unknown result type (might be due to invalid IL or missing references) //IL_044a: Unknown result type (might be due to invalid IL or missing references) //IL_0452: Unknown result type (might be due to invalid IL or missing references) //IL_0454: Unknown result type (might be due to invalid IL or missing references) //IL_045a: Unknown result type (might be due to invalid IL or missing references) //IL_045c: Unknown result type (might be due to invalid IL or missing references) //IL_0462: Unknown result type (might be due to invalid IL or missing references) //IL_0464: Unknown result type (might be due to invalid IL or missing references) //IL_046a: Unknown result type (might be due to invalid IL or missing references) //IL_046c: Unknown result type (might be due to invalid IL or missing references) //IL_046e: Unknown result type (might be due to invalid IL or missing references) //IL_0473: Unknown result type (might be due to invalid IL or missing references) //IL_0477: Unknown result type (might be due to invalid IL or missing references) //IL_047c: Unknown result type (might be due to invalid IL or missing references) Matrix4x4 localToWorldMatrix = ((Component)vm).transform.localToWorldMatrix; Vector3[] array = new Vector3[3]; Vector3 val = ((Matrix4x4)(ref localToWorldMatrix)).MultiplyVector(Vector3.right); array[0] = ((Vector3)(ref val)).normalized; val = ((Matrix4x4)(ref localToWorldMatrix)).MultiplyVector(Vector3.up); array[1] = ((Vector3)(ref val)).normalized; val = ((Matrix4x4)(ref localToWorldMatrix)).MultiplyVector(Vector3.forward); array[2] = ((Vector3)(ref val)).normalized; Vector3[] axes = (Vector3[])(object)array; Vector3 min = new Vector3(float.MaxValue, float.MaxValue, float.MaxValue); Vector3 max = new Vector3(float.MinValue, float.MinValue, float.MinValue); bool any = false; if ((Object)(object)vm.meshRenderer != (Object)null) { MeshFilter component = ((Component)vm.meshRenderer).GetComponent<MeshFilter>(); if ((Object)(object)component != (Object)null && (Object)(object)component.sharedMesh != (Object)null) { AddLocalBounds(((Component)component).transform, component.sharedMesh.bounds); } else { Renderer meshRenderer = vm.meshRenderer; SkinnedMeshRenderer val2 = (SkinnedMeshRenderer)(object)((meshRenderer is SkinnedMeshRenderer) ? meshRenderer : null); if (val2 != null) { AddLocalBounds(((Component)val2).transform, ((Renderer)val2).localBounds); } else { AddWorldBounds(vm.meshRenderer.bounds); } } } if (!any) { MeshFilter[] componentsInChildren = ((Component)vm).GetComponentsInChildren<MeshFilter>(); foreach (MeshFilter val3 in componentsInChildren) { if (!((Object)(object)val3.sharedMesh == (Object)null) && !((Object)(object)((Component)val3).GetComponent<TMP_Text>() != (Object)null)) { AddLocalBounds(((Component)val3).transform, val3.sharedMesh.bounds); } } } if (!any) { Collider[] componentsInChildren2 = ((Component)vm).GetComponentsInChildren<Collider>(); foreach (Collider val4 in componentsInChildren2) { if (!val4.isTrigger) { AddWorldBounds(val4.bounds); } } } if (!any) { return null; } Vector3 val5 = max - min; Vector3 val6 = (max + min) * 0.5f; Vector3 val7 = axes[0] * val6.x + axes[1] * val6.y + axes[2] * val6.z; int num = 0; for (int j = 1; j < 3; j++) { if (Mathf.Abs(axes[j].y) > Mathf.Abs(axes[num].y)) { num = j; } } Vector3 val8 = axes[num] * Mathf.Sign(axes[num].y); Vector3 val9 = Vector3.zero; int num2 = 0; if (vm.buttons != null) { VendingButton[] buttons = vm.buttons; foreach (VendingButton val10 in buttons) { if (val10 != null && (Object)(object)val10.sprite != (Object)null) { val9 +=