Decompiled source of CaseOpening 1 0 33 v1.0.20
plugins/Games/CaseOpening/CaseOpening.dll
Decompiled 3 hours 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.Globalization; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using CaseOpeningMod; using FMOD; using FMOD.Studio; using FMODUnity; using Microsoft.CodeAnalysis; using Mirror; using TMPro; using UnityEngine; using UnityEngine.TextCore; using UnityEngine.UI; [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("CaseOpening")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.20.0")] [assembly: AssemblyInformationalVersion("1.0.20+cce0d2d185e51c82e3fa21fb344b2863b6e089cd")] [assembly: AssemblyProduct("CaseOpening")] [assembly: AssemblyTitle("CaseOpening")] [assembly: AssemblyVersion("1.0.20.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 CaseOpeningMod { [BepInPlugin("com.Syd4r.caseopening", "Case Opening", "1.0.20")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class CaseOpeningPlugin : BaseUnityPlugin { private void Awake() { ((BaseUnityPlugin)this).Logger.LogInfo((object)"Case Opening Assembly loaded by BepInEx! Waiting for Base Loader..."); } } internal sealed class CaseAudio : IDisposable { private readonly Transform owner; private readonly Dictionary<string, Sound> sounds = new Dictionary<string, Sound>(); private readonly List<Channel> channels = new List<Channel>(); private readonly Dictionary<string, Channel> activeCues = new Dictionary<string, Channel>(); private ChannelGroup group; private bool failed; private bool disposed; internal CaseAudio(Transform owner) { this.owner = owner; } internal void Play(string name) { //IL_001f: 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_0033: 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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0102: 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_0116: 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_0155: Unknown result type (might be due to invalid IL or missing references) if (failed || disposed) { return; } try { System coreSystem; if (!((ChannelGroup)(ref group)).hasHandle()) { coreSystem = RuntimeManager.CoreSystem; Check(((System)(ref coreSystem)).createChannelGroup("CaseOpening", ref group)); coreSystem = RuntimeManager.CoreSystem; ChannelGroup val = default(ChannelGroup); Check(((System)(ref coreSystem)).getMasterChannelGroup(ref val)); Check(((ChannelGroup)(ref val)).addGroup(group, true)); } Update(); if (failed) { return; } if (!sounds.TryGetValue(name, out var value)) { using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("CaseOpening.Audio." + name + ".wav")) { if (stream == null) { throw new InvalidOperationException("Missing embedded sound: " + name); } using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); byte[] array = memoryStream.ToArray(); CREATESOUNDEXINFO val2 = new CREATESOUNDEXINFO { cbsize = Marshal.SizeOf(typeof(CREATESOUNDEXINFO)), length = (uint)array.Length }; coreSystem = RuntimeManager.CoreSystem; Check(((System)(ref coreSystem)).createSound(array, (MODE)2623505, ref val2, ref value)); } sounds.Add(name, value); Check(((Sound)(ref value)).set3DMinMaxDistance(1.5f, 15f)); } if (activeCues.TryGetValue(name, out var value2)) { ((Channel)(ref value2)).stop(); } coreSystem = RuntimeManager.CoreSystem; Channel val3 = default(Channel); Check(((System)(ref coreSystem)).playSound(value, group, true, ref val3)); activeCues[name] = val3; Check(((Channel)(ref val3)).setVolume(CueVolume(name))); channels.Add(val3); SetPosition(val3); Check(((Channel)(ref val3)).setPaused(false)); } catch (Exception error) { Fail(error); } } internal void Update() { //IL_003c: 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_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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Invalid comparison between Unknown and I4 //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Invalid comparison between Unknown and I4 //IL_0085: 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) if (failed || disposed || !((ChannelGroup)(ref group)).hasHandle()) { return; } try { float volume = ReadVolume("Master") * ReadVolume("SFX"); Check(((ChannelGroup)(ref group)).setVolume(volume)); bool flag = default(bool); for (int num = channels.Count - 1; num >= 0; num--) { Channel val = channels[num]; RESULT val2 = ((Channel)(ref val)).isPlaying(ref flag); if ((int)val2 == 30 || (int)val2 == 3) { channels.RemoveAt(num); } else { Check(val2); if (!flag) { channels.RemoveAt(num); } else { SetPosition(channels[num]); } } } } catch (Exception error) { Fail(error); } } private static float CueVolume(string name) { switch (name) { case "open": return 0.5f; case "tick": case "reveal_purple": return 0.2f; default: return 0.3f; } } private static float ReadVolume(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_000b: 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_0020: 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_0030: Unknown result type (might be due to invalid IL or missing references) System studioSystem = RuntimeManager.StudioSystem; PARAMETER_DESCRIPTION val = default(PARAMETER_DESCRIPTION); Check(((System)(ref studioSystem)).getParameterDescriptionByName(name, ref val)); studioSystem = RuntimeManager.StudioSystem; float num = default(float); Check(((System)(ref studioSystem)).getParameterByName(name, ref num)); return Mathf.InverseLerp(val.minimum, val.maximum, num); } private void SetPosition(Channel channel) { //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_000e: 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_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0030: 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_003c: 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_004b: Unknown result type (might be due to invalid IL or missing references) Vector3 position = owner.position; VECTOR val = new VECTOR { x = position.x, y = position.y, z = position.z }; VECTOR val2 = default(VECTOR); Check(((Channel)(ref channel)).set3DAttributes(ref val, ref val2)); } private unsafe static void Check(RESULT result) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) if ((int)result != 0) { throw new InvalidOperationException("FMOD: " + ((object)(*(RESULT*)(&result))/*cast due to .constrained prefix*/).ToString()); } } private void Fail(Exception error) { failed = true; Debug.LogWarning((object)("[CaseOpening] Audio disabled for this spin: " + error.Message)); Dispose(); } public void Dispose() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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) if (disposed) { return; } disposed = true; if (((ChannelGroup)(ref group)).hasHandle()) { ((ChannelGroup)(ref group)).stop(); } channels.Clear(); activeCues.Clear(); foreach (Sound value in sounds.Values) { Sound current = value; ((Sound)(ref current)).release(); } sounds.Clear(); if (((ChannelGroup)(ref group)).hasHandle()) { ((ChannelGroup)(ref group)).release(); } ((ChannelGroup)(ref group)).clearHandle(); } } internal sealed class CaseCatalog { internal sealed class Item { internal string Id; internal string Name; internal string Weapon; internal string Paint; internal string Phase; internal string Collection; internal string Description; internal int Rarity; internal bool StatTrak; internal int[] Wears; internal bool HasWear => Wears.Length != 0; } internal sealed class WeaponCase { internal string Id; internal string Name; internal int[][] Pools; } internal readonly Item[] Items; internal readonly WeaponCase[] Cases; private static CaseCatalog shared; private CaseCatalog() { List<Item> list = new List<Item>(); foreach (string item in ReadLines("items.tsv")) { string[] array = item.Split('\t'); list.Add(new Item { Id = array[0], Name = array[1], Rarity = int.Parse(array[2], CultureInfo.InvariantCulture), Weapon = array[3], Paint = array[4], Phase = array[7], Collection = array[8], Description = array[9].Replace("\\\"", "\""), StatTrak = (array[5] == "1"), Wears = ParseIndices(array[6]) }); } Items = list.ToArray(); List<WeaponCase> list2 = new List<WeaponCase>(); foreach (string item2 in ReadLines("cases.tsv")) { string[] array2 = item2.Split('\t'); int[][] array3 = new int[5][]; for (int i = 0; i < 5; i++) { array3[i] = ParseIndices(array2[i + 2]); if (array3[i].Length == 0) { throw new InvalidDataException("Empty case rarity pool: " + array2[0]); } int[] array4 = array3[i]; foreach (int num in array4) { if (num < 0 || num >= Items.Length || Items[num].Rarity != i) { throw new InvalidDataException("Invalid case item: " + array2[0]); } } } list2.Add(new WeaponCase { Id = array2[0], Name = array2[1], Pools = array3 }); } Cases = list2.ToArray(); if (Cases.Length == 0) { throw new InvalidDataException("Empty weapon-case catalog"); } } internal static CaseCatalog Load() { return shared ?? (shared = new CaseCatalog()); } private static int[] ParseIndices(string text) { if (text.Length == 0) { return Array.Empty<int>(); } return Array.ConvertAll(text.Split(','), (string s) => int.Parse(s, CultureInfo.InvariantCulture)); } private static IEnumerable<string> ReadLines(string name) { using Stream stream = Open(name); using StreamReader reader = new StreamReader(stream); string text; while ((text = reader.ReadLine()) != null) { if (text.Length > 0) { yield return text; } } } internal static Stream Open(string name) { return typeof(CaseCatalog).Assembly.GetManifestResourceStream("CaseOpening.Catalog." + name) ?? throw new InvalidDataException("Missing embedded catalog resource: " + name); } internal bool Contains(int caseIndex, int rarity, int itemIndex) { if (caseIndex >= 0 && caseIndex < Cases.Length && rarity >= 0 && rarity < 5) { return Array.IndexOf(Cases[caseIndex].Pools[rarity], itemIndex) >= 0; } return false; } internal static GameObject CreateTemplate(Item item) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Expected O, but got Unknown //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007c: 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_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: 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_00e8: Expected O, but got Unknown Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); try { using (Stream stream = Open(item.Id + ".png")) { using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); if (!ImageConversion.LoadImage(val, memoryStream.ToArray(), false)) { throw new InvalidDataException("Invalid artwork: " + item.Id); } } GameObject val2 = new GameObject(item.Name); val2.SetActive(false); val2.transform.localScale = new Vector3(0.06f, 0.08f, 1f); val2.AddComponent<SpriteRenderer>().sprite = Sprite.Create(val, VisibleRect(val.GetPixels32(), ((Texture)val).width, ((Texture)val).height), new Vector2(0.5f, 0.5f), (float)((Texture)val).width / 5.666667f); val.Apply(false, true); return val2; } catch { Object.Destroy((Object)(object)val); throw; } } internal static Rect VisibleRect(Color32[] pixels, int width, int height) { //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) int num = width; int num2 = height; int num3 = -1; int num4 = -1; for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { if (pixels[i * width + j].a > 8) { num = Math.Min(num, j); num3 = Math.Max(num3, j); num2 = Math.Min(num2, i); num4 = Math.Max(num4, i); } } } if (num3 < num) { return new Rect(0f, 0f, (float)width, (float)height); } num = Math.Max(0, num - 2); num2 = Math.Max(0, num2 - 2); num3 = Math.Min(width - 1, num3 + 2); num4 = Math.Min(height - 1, num4 + 2); return new Rect((float)num, (float)num2, (float)(num3 - num + 1), (float)(num4 - num2 + 1)); } internal static void DestroyTemplate(GameObject template) { Sprite sprite = template.GetComponent<SpriteRenderer>().sprite; Object.Destroy((Object)(object)template); Object.Destroy((Object)(object)sprite.texture); Object.Destroy((Object)(object)sprite); } } internal sealed class CaseDisplay { private sealed class ReelCard { internal Transform Root; internal SpriteRenderer[] Renderers; internal Color[] Colors; } internal readonly Transform Root; internal readonly TextMeshPro ItemName; internal readonly TextMeshPro StatTrak; internal readonly TextMeshPro Wear; internal readonly TextMeshPro Pattern; internal readonly TextMeshPro Total; internal readonly TextMeshPro CaseName; internal readonly TextMeshPro Metadata; internal readonly TextMeshPro Description; private readonly TextMeshPro status; private readonly TextMeshPro idle; private readonly TextMeshPro title; private readonly GameObject marker; private readonly GameObject payoutBackdrop; private readonly GameObject payoutGlow; private readonly GameObject spinStage; private readonly GameObject spinFooter; private readonly GameObject revealDivider; private readonly GameObject rarityDivider; private readonly GameObject footerShade; private readonly SpriteRenderer rewardLight; private readonly SpriteRenderer payoutLight; private readonly SpriteRenderer burstLight; private readonly SpriteRenderer burstRing; private readonly Sprite lightSprite; private readonly Sprite ringSprite; private readonly Sprite cardGradient; private readonly Sprite focusSprite; private readonly SpriteRenderer caseImage; private readonly SpriteRenderer idleBackground; private readonly SpriteRenderer introBackground; private readonly SpriteRenderer blurredBackground; private readonly SpriteRenderer rewardBackground; private readonly SpriteRenderer spinner; private readonly GameObject focus; internal const float IntroDuration = 0.85f; internal const float ScrollDuration = 6.6f; internal const float WinnerHold = 0.3f; internal const float ReelZoomDuration = 0.55f; private readonly TextMeshPro footerCase; private readonly CaseDisplayLifetime lifetime; private string selectedCase = "Weapon Cases"; private string selectedCaseId; private readonly List<ReelCard> reelCards = new List<ReelCard>(); internal const float CardWidth = 0.333f; internal const float CardHeight = 0.25f; internal const float CardSpacing = 0.353f; internal const float ReelCenterY = 0f; private bool revealing; private int revealTier; private float pulseTime; private float revealAge; private readonly Material artworkMaterial; internal const float ArtBrightness = 1.2f; private static readonly Color[] PayoutColors = (Color[])(object)new Color[4] { new Color(0.53f, 0.68f, 0.82f), new Color(0.31f, 0.92f, 0.75f), new Color(1f, 0.77f, 0.31f), new Color(0.84f, 0.67f, 1f) }; private static readonly string[] PayoutLabels = new string[4] { "ITEM RECEIVED", "WIN", "BIG WIN", "JACKPOT" }; private readonly Sprite panelSprite; private readonly Material textMaterial; internal readonly float Width; internal const float ArtCenterY = 0.01f; internal const float ArtWidth = 1.22f; internal const float ArtHeight = 0.38f; private static readonly Color Muted = new Color(0.77f, 0.81f, 0.85f); private static readonly Color Ink = new Color(1f, 1f, 1f); internal CaseDisplay(Camera camera, TextMeshPro fontSource, int layer) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //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_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: 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_00d5: 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) //IL_00e5: 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_0110: Unknown result type (might be due to invalid IL or missing references) //IL_011f: 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) //IL_0144: Expected O, but got Unknown //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Expected O, but got Unknown //IL_0384: Unknown result type (might be due to invalid IL or missing references) //IL_0393: Unknown result type (might be due to invalid IL or missing references) //IL_03ba: Unknown result type (might be due to invalid IL or missing references) //IL_03c4: Expected O, but got Unknown //IL_03de: Unknown result type (might be due to invalid IL or missing references) //IL_040b: Unknown result type (might be due to invalid IL or missing references) //IL_0554: Unknown result type (might be due to invalid IL or missing references) //IL_055e: Expected O, but got Unknown //IL_05b6: Unknown result type (might be due to invalid IL or missing references) //IL_0606: Unknown result type (might be due to invalid IL or missing references) //IL_0669: Unknown result type (might be due to invalid IL or missing references) //IL_06ab: Unknown result type (might be due to invalid IL or missing references) //IL_06f7: Unknown result type (might be due to invalid IL or missing references) //IL_0743: Unknown result type (might be due to invalid IL or missing references) //IL_078f: Unknown result type (might be due to invalid IL or missing references) //IL_07db: Unknown result type (might be due to invalid IL or missing references) //IL_0827: Unknown result type (might be due to invalid IL or missing references) //IL_087d: Unknown result type (might be due to invalid IL or missing references) //IL_08db: Unknown result type (might be due to invalid IL or missing references) //IL_0981: Unknown result type (might be due to invalid IL or missing references) //IL_09bd: Unknown result type (might be due to invalid IL or missing references) //IL_09e3: Unknown result type (might be due to invalid IL or missing references) //IL_09ed: Expected O, but got Unknown //IL_0a39: Unknown result type (might be due to invalid IL or missing references) //IL_0a69: Unknown result type (might be due to invalid IL or missing references) //IL_0aa0: Unknown result type (might be due to invalid IL or missing references) //IL_0ad7: Unknown result type (might be due to invalid IL or missing references) //IL_0aff: Unknown result type (might be due to invalid IL or missing references) //IL_0b09: Expected O, but got Unknown //IL_0b55: Unknown result type (might be due to invalid IL or missing references) //IL_0b85: Unknown result type (might be due to invalid IL or missing references) //IL_0b9b: Unknown result type (might be due to invalid IL or missing references) //IL_0ba5: Expected O, but got Unknown //IL_0c25: Unknown result type (might be due to invalid IL or missing references) //IL_0c5d: Unknown result type (might be due to invalid IL or missing references) //IL_0cb3: Unknown result type (might be due to invalid IL or missing references) //IL_0d1e: Unknown result type (might be due to invalid IL or missing references) //IL_0d46: Unknown result type (might be due to invalid IL or missing references) //IL_0d50: Expected O, but got Unknown //IL_0d9c: Unknown result type (might be due to invalid IL or missing references) //IL_0ddf: Unknown result type (might be due to invalid IL or missing references) //IL_0e23: Unknown result type (might be due to invalid IL or missing references) Width = camera.aspect; GameObject val = new GameObject("CS2 Case Display"); val.layer = layer; Root = val.transform; Root.SetParent(((Component)camera).transform, false); Vector3 lossyScale = ((Component)camera).transform.lossyScale; float num = (camera.orthographic ? (camera.orthographicSize * 2f) : (10f * Mathf.Tan(camera.fieldOfView * (MathF.PI / 180f) * 0.5f))); Root.localPosition = new Vector3(0f, 0f, 5f / lossyScale.z); Root.localRotation = Quaternion.identity; Root.localScale = new Vector3(num / lossyScale.x, num / lossyScale.y, num / lossyScale.z); panelSprite = Sprite.Create(Texture2D.whiteTexture, new Rect(0f, 0f, 1f, 1f), new Vector2(0.5f, 0.5f), 1f); textMaterial = new Material(((TMP_Text)fontSource).fontSharedMaterial); textMaterial.DisableKeyword("OUTLINE_ON"); textMaterial.DisableKeyword("GLOW_ON"); textMaterial.DisableKeyword("UNDERLAY_ON"); textMaterial.DisableKeyword("UNDERLAY_INNER"); textMaterial.SetFloat(ShaderUtilities.ID_OutlineWidth, 0f); if (textMaterial.HasProperty("_GlowPower")) { textMaterial.SetFloat("_GlowPower", 0f); } if (textMaterial.HasProperty("_OutlineSoftness")) { textMaterial.SetFloat("_OutlineSoftness", 0f); } if (textMaterial.HasProperty("_UnderlaySoftness")) { textMaterial.SetFloat("_UnderlaySoftness", 0f); } if (textMaterial.HasProperty("_PerspectiveFilter")) { textMaterial.SetFloat("_PerspectiveFilter", 0f); } if (textMaterial.HasProperty("_Sharpness")) { textMaterial.SetFloat("_Sharpness", 0.25f); } lifetime = val.AddComponent<CaseDisplayLifetime>(); lifetime.PanelSprite = panelSprite; lifetime.TextMaterial = textMaterial; GameObject val2 = Rectangle(Root, "Background", 0f, 0f, Width, 1f, Color.white, -10); Texture2D val3 = new Texture2D(2, 2, (TextureFormat)4, false); using (Stream stream = typeof(CaseDisplay).Assembly.GetManifestResourceStream("CaseOpening.Display.backdrop.png")) { using MemoryStream memoryStream = new MemoryStream(); if (stream == null) { throw new InvalidDataException("Missing embedded display backdrop"); } stream.CopyTo(memoryStream); if (!ImageConversion.LoadImage(val3, memoryStream.ToArray(), true)) { throw new InvalidDataException("Invalid embedded display backdrop"); } } float num2 = Mathf.Min((float)((Texture)val3).width, (float)((Texture)val3).height * Width); float num3 = num2 / Width; Sprite val4 = Sprite.Create(val3, new Rect(((float)((Texture)val3).width - num2) * 0.5f, ((float)((Texture)val3).height - num3) * 0.5f, num2, num3), new Vector2(0.5f, 0.5f), num3); val2.GetComponent<SpriteRenderer>().sprite = val4; artworkMaterial = new Material(((Renderer)val2.GetComponent<SpriteRenderer>()).sharedMaterial); artworkMaterial.SetColor("_Color", new Color(1.2f, 1.2f, 1.2f)); lifetime.ArtworkMaterial = artworkMaterial; idleBackground = val2.GetComponent<SpriteRenderer>(); val2.transform.localScale = Vector3.one; lifetime.BackdropSprite = val4; lifetime.BackdropTexture = val3; Texture2D val5 = LoadSceneTexture("warehouse-intro.png"); introBackground = Backplate("Intro background", val5, -9); blurredBackground = Backplate("Defocused opening background", Defocus(val5), -8); val5.Apply(false, true); Texture2D val6 = LoadSceneTexture("warehouse-reward.png"); rewardBackground = Backplate("Reward background", val6, -7); val6.Apply(false, true); lifetime.SceneSprites = (Sprite[])(object)new Sprite[3] { introBackground.sprite, blurredBackground.sprite, rewardBackground.sprite }; lightSprite = LightSprite(ring: false); ringSprite = LightSprite(ring: true); lifetime.LightSprite = lightSprite; lifetime.RingSprite = ringSprite; cardGradient = SurfaceSprite(gradient: true); focusSprite = SurfaceSprite(gradient: false); lifetime.CardGradient = cardGradient; lifetime.FocusSprite = focusSprite; spinStage = new GameObject("Opening stage"); spinStage.layer = ((Component)Root).gameObject.layer; spinStage.transform.SetParent(Root, false); caseImage = Rectangle(spinStage.transform, "Selected case", 0f, 0.015f, 1f, 1f, Color.white, -6).GetComponent<SpriteRenderer>(); focus = Rectangle(spinStage.transform, "Reel focus", 0f, 0f, 0.67f, 0.67f, new Color(0.015f, 0.02f, 0.03f, 0.48f), -5); focus.GetComponent<SpriteRenderer>().sprite = focusSprite; footerShade = ((Component)Light(Root, "Footer shade", 0f, -0.55f, Width * 1.8f, 0.9f, new Color(0.015f, 0.02f, 0.03f, 0.94f), -4)).gameObject; title = Label("Brand", "Unlock Container", 0f, 0.43f, Width - 0.18f, 0.09f, 0.72f, Ink, fontSource); ((TMP_Text)title).alignment = (TextAlignmentOptions)4098; CaseName = Label("Case name", "", 0f, 0.388f, Width - 0.18f, 0.055f, 0.54f, Ink, fontSource); ((TMP_Text)CaseName).alignment = (TextAlignmentOptions)4098; status = Label("Status", "", 0f, 0.355f, Width - 0.18f, 0.04f, 0.52f, Muted, fontSource); ((TMP_Text)status).alignment = (TextAlignmentOptions)4098; idle = Label("Idle", "PLACE A BET AND PRESS PLAY", 0f, 0.01f, Width - 0.2f, 0.14f, 0.72f, Ink, fontSource); ((TMP_Text)idle).alignment = (TextAlignmentOptions)4098; ItemName = Label("Item name", "", 0f, 0.43f, Width - 0.18f, 0.085f, 0.9f, Ink, fontSource); ((TMP_Text)ItemName).alignment = (TextAlignmentOptions)4098; Metadata = Label("Item metadata", "", 0f, 0.2875f, Width - 0.18f, 0.04f, 0.48f, Muted, fontSource); ((TMP_Text)Metadata).alignment = (TextAlignmentOptions)4098; Description = Label("Item description", "", 0f, -0.275f, Mathf.Min(Width - 0.2f, 1.2f), 0.09f, 0.32f, Muted, fontSource); ((TMP_Text)Description).textWrappingMode = (TextWrappingModes)1; ((TMP_Text)Description).fontSizeMin = 0.16f; rarityDivider = Rectangle(Root, "Reward rarity line", 0f, 0.325f, Mathf.Min(Width - 0.2f, 0.64f), 0.003f, Ink, 0); float num4 = (Width - 0.24f) / 3f; StatTrak = Attribute("StatTrak", 0f - num4, num4, fontSource); Wear = Attribute("Wear", 0f, num4, fontSource); Pattern = Attribute("Pattern", num4, num4, fontSource); revealDivider = Rectangle(Root, "Footer divider", 0f, -0.398f, Width - 0.24f, 0.0015f, new Color(1f, 1f, 1f, 0.3f), 0); Total = Label("Payout", "", 0f, -0.4425f, Width - 0.24f, 0.085f, 1f, Ink, fontSource); ((TMP_Text)Total).alignment = (TextAlignmentOptions)4098; payoutBackdrop = new GameObject("Payout backdrop"); payoutBackdrop.layer = ((Component)Root).gameObject.layer; payoutBackdrop.transform.SetParent(Root, false); payoutBackdrop.transform.localPosition = new Vector3(0f, 0.01f, 0f); rewardLight = Light(payoutBackdrop.transform, "Reward glow", 0f, 0f, 1.1f, 0.46f, Color.white, 10); burstLight = Light(payoutBackdrop.transform, "Reveal burst", 0f, 0f, 1.1f, 0.46f, Color.white, 11); burstRing = Light(payoutBackdrop.transform, "Reveal ring", 0f, 0f, 0.6f, 0.36f, Color.white, 12); burstRing.sprite = ringSprite; payoutGlow = new GameObject("Payout glow"); payoutGlow.layer = ((Component)Root).gameObject.layer; payoutGlow.transform.SetParent(Root, false); payoutGlow.transform.localPosition = new Vector3(0f, -0.4425f, 0f); payoutLight = Light(payoutGlow.transform, "Payout halo", 0f, 0f, 1.1f, 0.1f, Color.white, -1); spinFooter = new GameObject("Opening footer"); spinFooter.layer = ((Component)Root).gameObject.layer; spinFooter.transform.SetParent(Root, false); float num5 = Mathf.Min(Width - 0.16f, 0.9f); Rectangle(spinFooter.transform, "Opening footer divider", 0f, -0.425f, num5, 0.001f, new Color(1f, 1f, 1f, 0.3f), 0); footerCase = Label("Opening case", "", (0f - num5) * 0.14f, -0.465f, num5 * 0.72f, 0.045f, 0.38f, Ink, fontSource); footerCase.transform.SetParent(spinFooter.transform, false); TextMeshPro obj = Label("Opening progress", "OPENING...", num5 * 0.4f, -0.465f, num5 * 0.2f, 0.045f, 0.35f, Ink, fontSource); ((TMP_Text)obj).alignment = (TextAlignmentOptions)4100; obj.transform.SetParent(spinFooter.transform, false); Sprite val7 = LightSprite(ring: true, spinner: true); lifetime.SpinnerSprite = val7; spinner = Rectangle(spinFooter.transform, "Opening spinner", num5 * 0.2f, -0.465f, 0.028f, 0.028f, Ink, 1).GetComponent<SpriteRenderer>(); spinner.sprite = val7; marker = new GameObject("Reel marker"); marker.layer = ((Component)Root).gameObject.layer; marker.transform.SetParent(Root, false); marker.transform.localPosition = new Vector3(0f, 0f, -0.18f); Rectangle(marker.transform, "Marker outline", 0f, 0f, 0.006f, 0.25f, new Color(0.08f, 0.07f, 0.01f, 0.65f), 300); Rectangle(marker.transform, "Winning center line", 0f, 0f, 0.003f, 0.25f, new Color(1f, 0.86f, 0.12f), 301); Reset(); } private static Sprite LightSprite(bool ring, bool spinner = false) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(256, 256, (TextureFormat)4, false); ((Texture)val).filterMode = (FilterMode)1; ((Texture)val).wrapMode = (TextureWrapMode)1; Color[] array = (Color[])(object)new Color[65536]; for (int i = 0; i < 256; i++) { for (int j = 0; j < 256; j++) { float num = ((float)j + 0.5f) / 256f * 2f - 1f; float num2 = ((float)i + 0.5f) / 256f * 2f - 1f; float num3 = Mathf.Sqrt(num * num + num2 * num2); float num4 = (ring ? Mathf.Exp(0f - Mathf.Pow((num3 - 0.68f) / 0.055f, 2f)) : Mathf.Pow(Mathf.Clamp01(1f - num3 * num3), 3f)); if (spinner) { num4 *= (Mathf.Atan2(num2, num) + MathF.PI) / (MathF.PI * 2f); } array[i * 256 + j] = new Color(1f, 1f, 1f, num4); } } val.SetPixels(array); val.Apply(false, true); return Sprite.Create(val, new Rect(0f, 0f, 256f, 256f), new Vector2(0.5f, 0.5f), 256f); } private static Texture2D LoadSceneTexture(string name) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Expected O, but got Unknown Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); using Stream stream = typeof(CaseDisplay).Assembly.GetManifestResourceStream("CaseOpening.Display." + name); using MemoryStream memoryStream = new MemoryStream(); if (stream == null) { throw new InvalidDataException("Missing scene: " + name); } stream.CopyTo(memoryStream); if (!ImageConversion.LoadImage(val, memoryStream.ToArray(), false)) { throw new InvalidDataException("Invalid scene: " + name); } return val; } private SpriteRenderer Backplate(string name, Texture2D texture, int order) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Min((float)((Texture)texture).width, (float)((Texture)texture).height * Width); float num2 = num / Width; Sprite sprite = Sprite.Create(texture, new Rect(((float)((Texture)texture).width - num) / 2f, ((float)((Texture)texture).height - num2) / 2f, num, num2), new Vector2(0.5f, 0.5f), num2); SpriteRenderer component = Rectangle(Root, name, 0f, 0f, 1f, 1f, Color.white, order).GetComponent<SpriteRenderer>(); component.sprite = sprite; return component; } private static Texture2D Defocus(Texture2D source) { //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Expected O, but got Unknown //IL_0120: 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_00b3: 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_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: 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) int num = Mathf.Max(1, (int)(256f * (float)((Texture)source).height / (float)((Texture)source).width)); Color32[] pixels = source.GetPixels32(); Color[] array = (Color[])(object)new Color[256 * num]; for (int i = 0; i < num; i++) { for (int j = 0; j < 256; j++) { float num2 = 0f; float num3 = 0f; float num4 = 0f; for (int k = -2; k <= 2; k++) { for (int l = -2; l <= 2; l++) { int num5 = Math.Clamp((j + l) * ((Texture)source).width / 256, 0, ((Texture)source).width - 1); int num6 = Math.Clamp((i + k) * ((Texture)source).height / num, 0, ((Texture)source).height - 1); Color32 val = pixels[num6 * ((Texture)source).width + num5]; num2 += (float)(int)val.r; num3 += (float)(int)val.g; num4 += (float)(int)val.b; } } array[i * 256 + j] = new Color(num2 / 6375f, num3 / 6375f, num4 / 6375f); } } Texture2D val2 = new Texture2D(256, num, (TextureFormat)4, false) { filterMode = (FilterMode)1, wrapMode = (TextureWrapMode)1 }; val2.SetPixels(array); val2.Apply(false, true); return val2; } internal void OpeningFrame(float elapsed, Transform reel = null) { //IL_0077: 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_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) bool active = elapsed >= 0.85f; float num = Mathf.SmoothStep(0f, 1f, (elapsed - 0.85f) / 0.55f); marker.SetActive(active); focus.SetActive(active); focus.transform.localScale = new Vector3(0.67f * (0.4f + 0.6f * num), 0.67f * (0.1f + 0.9f * num), 1f); blurredBackground.color = new Color(1f, 1f, 1f, num); ((Component)caseImage).transform.localPosition = new Vector3(0f, 0.08f, 0.1f); caseImage.color = new Color(1f, 1f, 1f, 1f - 0.4f * num); ((Component)spinner).transform.localRotation = Quaternion.Euler(0f, 0f, (0f - elapsed) * 300f); if ((Object)(object)reel != (Object)null) { ((Component)reel).gameObject.SetActive(active); reel.localScale = new Vector3(0.75f + 0.25f * num, 0.12f + 0.88f * num, 1f); } } private static Sprite SurfaceSprite(bool gradient) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_0122: 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_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) Texture2D val = new Texture2D(128, 128, (TextureFormat)4, false); ((Texture)val).filterMode = (FilterMode)1; ((Texture)val).wrapMode = (TextureWrapMode)1; Color[] array = (Color[])(object)new Color[16384]; for (int i = 0; i < 128; i++) { for (int j = 0; j < 128; j++) { float num = ((float)j + 0.5f) / 128f * 2f - 1f; float num2 = ((float)i + 0.5f) / 128f * 2f - 1f; float num3 = (gradient ? (Mathf.Pow(1f - (float)i / 127f, 3f) * 0.85f) : (1f - Mathf.SmoothStep(0.96f, 1f, Mathf.Sqrt(num * num + num2 * num2)))); array[i * 128 + j] = new Color(1f, 1f, 1f, num3); } } val.SetPixels(array); val.Apply(false, true); return Sprite.Create(val, new Rect(0f, 0f, 128f, 128f), new Vector2(0.5f, 0.5f), 128f); } private void SelectCase(string id) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: 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) if (string.IsNullOrEmpty(id)) { ((Component)caseImage).gameObject.SetActive(false); return; } if (selectedCaseId != id) { Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); using (Stream stream = CaseCatalog.Open("case-" + id + ".png")) { using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); if (!ImageConversion.LoadImage(val, memoryStream.ToArray(), false)) { throw new InvalidDataException("Invalid case artwork: " + id); } } Sprite val2 = Sprite.Create(val, CaseCatalog.VisibleRect(val.GetPixels32(), ((Texture)val).width, ((Texture)val).height), new Vector2(0.5f, 0.5f), (float)((Texture)val).width); val.Apply(false, true); if ((Object)(object)lifetime.CaseSprite != (Object)null) { Object.Destroy((Object)(object)lifetime.CaseSprite.texture); Object.Destroy((Object)(object)lifetime.CaseSprite); } lifetime.CaseSprite = val2; caseImage.sprite = val2; ((Component)caseImage).transform.localScale = Fit(val2, 0.54f, 0.6f); selectedCaseId = id; } ((Component)caseImage).gameObject.SetActive(true); } private SpriteRenderer Light(Transform parent, string name, float x, float y, float width, float height, Color color, int order) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) SpriteRenderer component = Rectangle(parent, name, x, y, width, height, color, order).GetComponent<SpriteRenderer>(); component.sprite = lightSprite; return component; } private TextMeshPro Attribute(string name, float x, float width, TextMeshPro source) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) TextMeshPro obj = Label(name, "", x, -0.365f, width - 0.04f, 0.055f, 0.52f, Muted, source); ((TMP_Text)obj).alignment = (TextAlignmentOptions)4098; return obj; } private TextMeshPro Label(string name, string value, float x, float y, float width, float height, float fontSize, Color color, TextMeshPro source) { //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_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0054: 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_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0157: 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) GameObject val = new GameObject(name) { layer = ((Component)Root).gameObject.layer }; val.transform.SetParent(Root, false); TextMeshPro obj = val.AddComponent<TextMeshPro>(); ((TMP_Text)obj).font = ((TMP_Text)source).font; ((TMP_Text)obj).fontSharedMaterial = textMaterial; ((TMP_Text)obj).text = value; ((Graphic)obj).color = color; ((TMP_Text)obj).fontSize = fontSize; float num = 0.2f; if ((Object)(object)((TMP_Text)source).font != (Object)null) { FaceInfo faceInfo = ((TMP_Asset)((TMP_Text)source).font).faceInfo; num = (((FaceInfo)(ref faceInfo)).ascentLine - ((FaceInfo)(ref faceInfo)).descentLine) / Mathf.Max(1f, ((FaceInfo)(ref faceInfo)).pointSize) * ((FaceInfo)(ref faceInfo)).scale * 0.1f; } ((TMP_Text)obj).isOrthographic = false; ((TMP_Text)obj).fontSizeMin = Mathf.Min(fontSize * 0.65f, height * 0.75f / Mathf.Max(0.01f, num)); ((TMP_Text)obj).fontSizeMax = fontSize; ((TMP_Text)obj).enableAutoSizing = true; ((TMP_Text)obj).textWrappingMode = (TextWrappingModes)0; ((TMP_Text)obj).overflowMode = (TextOverflowModes)1; ((TMP_Text)obj).alignment = (TextAlignmentOptions)4097; ((TMP_Text)obj).rectTransform.pivot = new Vector2(0.5f, 0.5f); ((TMP_Text)obj).rectTransform.sizeDelta = new Vector2(width, height); obj.transform.localPosition = new Vector3(x, y, -0.05f); obj.transform.localScale = Vector3.one; ((Renderer)((Component)obj).GetComponent<MeshRenderer>()).sortingOrder = 200; return obj; } private GameObject Rectangle(Transform parent, string name, float x, float y, float width, float height, Color color, int order) { //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_001c: 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_0037: 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_0050: 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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Expected O, but got Unknown GameObject val = new GameObject(name) { layer = ((Component)Root).gameObject.layer }; val.transform.SetParent(parent, false); val.transform.localPosition = new Vector3(x, y, 0.1f); val.transform.localScale = new Vector3(width, height, 1f); SpriteRenderer obj = val.AddComponent<SpriteRenderer>(); obj.sprite = panelSprite; obj.color = color; ((Renderer)obj).sortingOrder = order; return val; } internal void Card(Transform parent, Color rarity) { //IL_002f: 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_0088: Unknown result type (might be due to invalid IL or missing references) Rectangle(parent, "Card", 0f, 0f, 0.333f, 0.25f, new Color(0.36f, 0.37f, 0.41f, 0.62f), 1); Rectangle(parent, "Rarity gradient", 0f, 0f, 0.333f, 0.25f, rarity, 2).GetComponent<SpriteRenderer>().sprite = cardGradient; Rectangle(parent, "Rarity", 0f, -0.119f, 0.333f, 0.012f, rarity, 8); } internal static Color ReelColor(int rarity) { //IL_0072: 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_0048: 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_001e: Unknown result type (might be due to invalid IL or missing references) return (Color)(rarity switch { 3 => new Color(0.92f, 0.29f, 0.29f), 2 => new Color(0.83f, 0.17f, 0.9f), 1 => new Color(0.53f, 0.28f, 1f), 0 => new Color(0.16f, 0.22f, 1f), _ => new Color(1f, 0.82f, 0.04f), }); } internal void TrackCard(Transform root) { //IL_001f: 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) SpriteRenderer[] componentsInChildren = ((Component)root).gameObject.GetComponentsInChildren<SpriteRenderer>(true); Color[] array = (Color[])(object)new Color[componentsInChildren.Length]; for (int i = 0; i < array.Length; i++) { array[i] = componentsInChildren[i].color; } reelCards.Add(new ReelCard { Root = root, Renderers = componentsInChildren, Colors = array }); } internal void UpdateReel(float offset) { //IL_0032: 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_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) float num = Width * 0.5f - 0.06f; foreach (ReelCard reelCard in reelCards) { float num2 = Math.Abs(reelCard.Root.localPosition.x + offset); float num3 = Mathf.Pow(Mathf.Clamp01((num - num2) / 0.35f), 2f); float num4 = 1f - 0.16f * Mathf.Clamp01(num2 / 0.75f); reelCard.Root.localScale = new Vector3(num4, num4, 1f); for (int i = 0; i < reelCard.Renderers.Length; i++) { Color color = reelCard.Colors[i]; color.a *= num3; reelCard.Renderers[i].color = color; } } } internal static Vector3 Fit(Sprite sprite, float width, float height) { //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_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_0010: 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_002a: Unknown result type (might be due to invalid IL or missing references) Bounds bounds = sprite.bounds; Vector3 size = ((Bounds)(ref bounds)).size; float num = Mathf.Min(width / size.x, height / size.y); return new Vector3(num, num, 1f); } internal void Reset() { //IL_0121: Unknown result type (might be due to invalid IL or missing references) revealing = false; ((Component)title).gameObject.SetActive(false); ((Component)status).gameObject.SetActive(false); ((Component)CaseName).gameObject.SetActive(false); footerShade.SetActive(false); rarityDivider.SetActive(false); ((Component)idleBackground).gameObject.SetActive(true); ((Component)introBackground).gameObject.SetActive(false); ((Component)blurredBackground).gameObject.SetActive(false); ((Component)rewardBackground).gameObject.SetActive(false); revealDivider.SetActive(false); reelCards.Clear(); spinStage.SetActive(false); ((Component)caseImage).gameObject.SetActive(false); spinFooter.SetActive(false); marker.SetActive(false); payoutBackdrop.SetActive(false); payoutGlow.SetActive(false); ((Component)idle).gameObject.SetActive(false); ((TMP_Text)status).text = "i One item is revealed per opening"; ((Graphic)status).color = Ink; ((TMP_Text)CaseName).text = "Weapon Cases"; TextMeshPro[] array = (TextMeshPro[])(object)new TextMeshPro[7] { ItemName, Metadata, Description, StatTrak, Wear, Pattern, Total }; for (int i = 0; i < array.Length; i++) { ((Component)array[i]).gameObject.SetActive(false); } } internal void Begin(string name, string caseId = null) { //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) revealing = false; revealDivider.SetActive(false); TextMeshPro[] array = (TextMeshPro[])(object)new TextMeshPro[7] { ItemName, Metadata, Description, StatTrak, Wear, Pattern, Total }; for (int i = 0; i < array.Length; i++) { ((Component)array[i]).gameObject.SetActive(false); } ((Component)idle).gameObject.SetActive(false); payoutBackdrop.SetActive(false); payoutGlow.SetActive(false); marker.SetActive(true); ((Component)CaseName).gameObject.SetActive(true); footerShade.SetActive(true); selectedCase = name; spinStage.SetActive(true); spinFooter.SetActive(true); SelectCase(caseId); CaseName.transform.localPosition = new Vector3(0f, 0.388f, -0.05f); ((TMP_Text)CaseName).text = "Unlock <b>" + name + "</b>"; ((TMP_Text)status).text = "i One item is revealed per opening"; ((Graphic)status).color = Ink; ((TMP_Text)footerCase).text = "Opening " + name; ((Component)title).gameObject.SetActive(true); ((Component)status).gameObject.SetActive(true); rarityDivider.SetActive(false); ((Component)idleBackground).gameObject.SetActive(false); ((Component)introBackground).gameObject.SetActive(true); ((Component)blurredBackground).gameObject.SetActive(true); ((Component)rewardBackground).gameObject.SetActive(false); OpeningFrame(0f); } internal static int PayoutTier(float multiplier) { if (!(multiplier >= 50f)) { if (!(multiplier >= 10f)) { return (multiplier >= 1f) ? 1 : 0; } return 2; } return 3; } internal void StyleArtwork(SpriteRenderer renderer) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) ((Renderer)renderer).sharedMaterial = artworkMaterial; renderer.color = Color.white; } internal void Reveal(Color rarity, float multiplier) { //IL_0086: 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_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) ((Component)CaseName).gameObject.SetActive(true); footerShade.SetActive(true); marker.SetActive(false); spinStage.SetActive(false); spinFooter.SetActive(false); revealDivider.SetActive(true); ((Component)title).gameObject.SetActive(false); ((Component)status).gameObject.SetActive(false); rarityDivider.SetActive(true); rarityDivider.GetComponent<SpriteRenderer>().color = rarity; ((Component)rewardBackground).gameObject.SetActive(true); CaseName.transform.localPosition = new Vector3(0f, 0.3675f, -0.05f); ((TMP_Text)CaseName).text = selectedCase.ToUpperInvariant(); payoutBackdrop.SetActive(true); payoutGlow.SetActive(true); revealing = true; pulseTime = (revealAge = 0f); revealTier = PayoutTier(multiplier); Color color = PayoutColors[revealTier]; ((TMP_Text)status).text = PayoutLabels[revealTier]; ((Graphic)status).color = color; ((Graphic)Total).color = color; ((TMP_Text)Total).text = "PAYOUT " + multiplier.ToString("0.##", CultureInfo.InvariantCulture) + "x"; ((Component)Total).gameObject.SetActive(true); Tick(0f); ((Graphic)ItemName).color = Ink; } internal void Tick(float deltaTime) { //IL_0073: 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_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0160: 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_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: 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_021a: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) if (revealing) { float num = Mathf.Max(0f, deltaTime); pulseTime = (pulseTime + num) % 2.4f; revealAge = Mathf.Min(revealAge + num, 3f); float num2 = Mathf.SmoothStep(0f, 1f, revealAge / 0.35f); rewardBackground.color = new Color(1f, 1f, 1f, num2); blurredBackground.color = Color.white; ((Component)introBackground).gameObject.SetActive(false); ((Component)blurredBackground).gameObject.SetActive(num2 < 1f); Color val = PayoutColors[revealTier]; float num3 = 0.5f + 0.5f * Mathf.Sin(pulseTime / 2.4f * MathF.PI * 2f); float num4 = 0.2f + (float)revealTier * 0.1f; rewardLight.color = new Color(val.r, val.g, val.b, num4 * (0.65f + num3 * 0.35f)); payoutLight.color = new Color(val.r, val.g, val.b, num4 * (0.45f + num3 * 0.35f)); bool flag = revealTier >= 2 && revealAge < 1.4f; ((Component)burstLight).gameObject.SetActive(flag); ((Component)burstRing).gameObject.SetActive(flag); if (flag) { float num5 = Mathf.Clamp01(revealAge / 1.4f); float num6 = (1f - num5) * (1f - num5); float num7 = ((revealTier == 3) ? 0.95f : 0.6f); burstLight.color = new Color(val.r, val.g, val.b, num6 * num7); burstRing.color = new Color(val.r, val.g, val.b, num6 * num7); ((Component)burstRing).transform.localScale = new Vector3(0.6f + num5 * 0.65f, 0.36f + num5 * 0.3f, 1f); } } } } internal sealed class CaseDisplayLifetime : MonoBehaviour { internal Sprite PanelSprite; internal Sprite LightSprite; internal Sprite RingSprite; internal Sprite CardGradient; internal Sprite FocusSprite; internal Sprite CaseSprite; internal Sprite SpinnerSprite; internal Sprite[] SceneSprites; internal Material TextMaterial; internal Material ArtworkMaterial; internal Sprite BackdropSprite; internal Texture2D BackdropTexture; private void OnDestroy() { Object.Destroy((Object)(object)BackdropSprite); Object.Destroy((Object)(object)BackdropTexture); Object.Destroy((Object)(object)LightSprite.texture); Object.Destroy((Object)(object)RingSprite.texture); Object.Destroy((Object)(object)LightSprite); Object.Destroy((Object)(object)RingSprite); if ((Object)(object)CaseSprite != (Object)null) { Object.Destroy((Object)(object)CaseSprite.texture); Object.Destroy((Object)(object)CaseSprite); } Object.Destroy((Object)(object)CardGradient.texture); Object.Destroy((Object)(object)CardGradient); Object.Destroy((Object)(object)FocusSprite.texture); Object.Destroy((Object)(object)FocusSprite); Object.Destroy((Object)(object)SpinnerSprite.texture); Object.Destroy((Object)(object)SpinnerSprite); Sprite[] sceneSprites = SceneSprites; foreach (Sprite obj in sceneSprites) { Object.Destroy((Object)(object)obj.texture); Object.Destroy((Object)(object)obj); } Object.Destroy((Object)(object)PanelSprite); Object.Destroy((Object)(object)TextMaterial); Object.Destroy((Object)(object)ArtworkMaterial); } } internal sealed class CaseScreen : MonoBehaviour { private sealed class Binding { internal Renderer Renderer; internal Material[] Originals; internal Material[] Copies; } private readonly List<Binding> bindings = new List<Binding>(); private readonly List<KeyValuePair<Material, string>> textureSlots = new List<KeyValuePair<Material, string>>(); private Camera view; private RenderTexture original; private RenderTexture target; private float aspect; private int screenWidth; private int screenHeight; internal static CaseScreen Attach(GameObject machine, Camera camera) { if ((Object)(object)camera == (Object)null || (Object)(object)camera.targetTexture == (Object)null) { return null; } CaseScreen caseScreen = machine.GetComponent<CaseScreen>(); if ((Object)(object)caseScreen == (Object)null) { caseScreen = machine.AddComponent<CaseScreen>(); } if ((Object)(object)caseScreen.view != (Object)null) { return caseScreen; } caseScreen.Initialize(machine, camera); return caseScreen; } private void Initialize(GameObject machine, Camera camera) { //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Expected O, but got Unknown original = camera.targetTexture; Renderer[] componentsInChildren = machine.GetComponentsInChildren<Renderer>(true); foreach (Renderer val in componentsInChildren) { Material[] sharedMaterials = val.sharedMaterials; Material[] array = null; for (int j = 0; j < sharedMaterials.Length; j++) { Material val2 = sharedMaterials[j]; if ((Object)(object)val2 == (Object)null) { continue; } string[] texturePropertyNames = val2.GetTexturePropertyNames(); foreach (string text in texturePropertyNames) { if (!((Object)(object)val2.GetTexture(text) != (Object)(object)original)) { if (array == null) { array = (Material[])sharedMaterials.Clone(); } if ((Object)(object)array[j] == (Object)(object)val2) { array[j] = new Material(val2); } textureSlots.Add(new KeyValuePair<Material, string>(array[j], text)); } } } if (array != null) { bindings.Add(new Binding { Renderer = val, Originals = sharedMaterials, Copies = array }); val.sharedMaterials = array; } } if (textureSlots.Count == 0) { Debug.LogWarning((object)"[CaseOpening] Screen material not found; render target left unchanged."); return; } view = camera; aspect = (float)((Texture)original).width / (float)((Texture)original).height; Refresh(); } internal static Vector2Int TargetSize(int originalWidth, int originalHeight, int gameWidth, int gameHeight, int maximum) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Max(1f, Mathf.Max((float)gameWidth / (float)originalWidth, (float)gameHeight / (float)originalHeight)); num = Mathf.Min(num, (float)maximum / (float)Mathf.Max(originalWidth, originalHeight)); return new Vector2Int(Mathf.Max(1, Mathf.CeilToInt((float)originalWidth * num)), Mathf.Max(1, Mathf.CeilToInt((float)originalHeight * num))); } private void Update() { Refresh(); } internal void Refresh() { //IL_005d: 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_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: 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_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Expected O, but got Unknown if ((Object)(object)view == (Object)null || ((Object)(object)target != (Object)null && screenWidth == Screen.width && screenHeight == Screen.height)) { return; } Vector2Int val = TargetSize(((Texture)original).width, ((Texture)original).height, Screen.width, Screen.height, SystemInfo.maxTextureSize); if ((Object)(object)target != (Object)null && ((Texture)target).width == ((Vector2Int)(ref val)).x && ((Texture)target).height == ((Vector2Int)(ref val)).y) { screenWidth = Screen.width; screenHeight = Screen.height; return; } RenderTextureDescriptor descriptor = original.descriptor; ((RenderTextureDescriptor)(ref descriptor)).width = ((Vector2Int)(ref val)).x; ((RenderTextureDescriptor)(ref descriptor)).height = ((Vector2Int)(ref val)).y; ((RenderTextureDescriptor)(ref descriptor)).msaaSamples = 1; ((RenderTextureDescriptor)(ref descriptor)).useMipMap = false; ((RenderTextureDescriptor)(ref descriptor)).autoGenerateMips = false; ((RenderTextureDescriptor)(ref descriptor)).useDynamicScale = false; RenderTexture val2 = new RenderTexture(descriptor); ((Object)val2).name = "CaseOpening screen " + ((Vector2Int)(ref val)).x + "x" + ((Vector2Int)(ref val)).y; ((Texture)val2).filterMode = (FilterMode)1; ((Texture)val2).wrapMode = (TextureWrapMode)1; ((Texture)val2).anisoLevel = 1; if (!val2.Create()) { Object.Destroy((Object)(object)val2); throw new InvalidOperationException("Could not allocate the CaseOpening screen render target."); } foreach (KeyValuePair<Material, string> textureSlot in textureSlots) { textureSlot.Key.SetTexture(textureSlot.Value, (Texture)(object)val2); } view.targetTexture = val2; view.aspect = aspect; RenderTexture val3 = target; target = val2; screenWidth = Screen.width; screenHeight = Screen.height; if ((Object)(object)val3 != (Object)null) { val3.Release(); Object.Destroy((Object)(object)val3); } Debug.Log((object)("[CaseOpening] Screen " + ((Texture)original).width + "x" + ((Texture)original).height + " -> " + ((Vector2Int)(ref val)).x + "x" + ((Vector2Int)(ref val)).y + " (game " + screenWidth + "x" + screenHeight + ")")); } private void OnDestroy() { if ((Object)(object)view != (Object)null) { view.targetTexture = original; } foreach (Binding binding in bindings) { if ((Object)(object)binding.Renderer != (Object)null) { binding.Renderer.sharedMaterials = binding.Originals; } for (int i = 0; i < binding.Copies.Length; i++) { if ((Object)(object)binding.Copies[i] != (Object)(object)binding.Originals[i]) { Object.Destroy((Object)(object)binding.Copies[i]); } } } if ((Object)(object)target != (Object)null) { target.Release(); Object.Destroy((Object)(object)target); } } } internal sealed class CaseWorldEffects { private readonly Transform machine; private GameObject activeEffect; private bool warned; internal CaseWorldEffects(Transform machine) { this.machine = machine; } internal void Play(float multiplier) { //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: 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) Clear(); GameObject val = Resources.Load<GameObject>("WheelOfFortune CasinoGame"); if ((Object)(object)val == (Object)null) { val = Resources.Load<GameObject>("MoneyWheel CasinoGame"); } string text = ((multiplier > 1f) ? "GameWinVFX" : ((multiplier < 1f) ? "GameLoseVFX" : "GameTieVFX")); Transform val2 = (((Object)(object)val == (Object)null) ? null : val.transform.Find("Feedbacks/" + text)); if ((Object)(object)val2 == (Object)null) { if (!warned) { Debug.LogWarning((object)"Case Opening: native wheel result VFX unavailable; screen reveal remains active."); } warned = true; return; } activeEffect = Object.Instantiate<GameObject>(((Component)val2).gameObject, machine, false); activeEffect.transform.localPosition = val2.localPosition; activeEffect.transform.localRotation = val2.localRotation; activeEffect.transform.localScale = val2.localScale; activeEffect.SetActive(true); ParticleSystem[] componentsInChildren = activeEffect.GetComponentsInChildren<ParticleSystem>(true); foreach (ParticleSystem obj in componentsInChildren) { obj.Stop(false, (ParticleSystemStopBehavior)0); MainModule main = obj.main; ((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(ResultColor(multiplier)); } activeEffect.GetComponent<ParticleSystem>().Play(true); } internal static Color ResultColor(float multiplier) { //IL_0017: 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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) if (multiplier >= 4f) { return new Color(0.49349895f, 0.17647058f, 1f); } if (multiplier >= 3f) { return new Color(0.1273585f, 1f, 0.96583235f); } if (multiplier >= 2f) { return new Color(0.528569f, 1f, 0.23113209f); } if (multiplier >= 1f) { return new Color(1f, 0.96215194f, 0.2216981f); } if (multiplier >= 0.01f) { return new Color(1f, 0.549705f, 0.1462264f); } return new Color(1f, 0.16509432f, 0.25624812f); } internal void Clear() { if (!((Object)(object)activeEffect == (Object)null)) { ParticleSystem[] componentsInChildren = activeEffect.GetComponentsInChildren<ParticleSystem>(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].Stop(false, (ParticleSystemStopBehavior)0); } activeEffect.SetActive(false); Object.Destroy((Object)(object)activeEffect); activeEffect = null; } } } } namespace MoreGamesBase { public class CaseOpening : GameBase { public enum Rarity { Blue, Purple, Pink, Red, Gold } public enum Wear { FactoryNew, MinimalWear, FieldTested, WellWorn, BattleScarred } [Header("Scene References")] public Camera externalCamera; public Transform backgroundParent; public GameObject itemPrefab; public GameObject centerLinePrefab; public GameObject openCase; [Header("Text Reveals (Assign in Unity)")] public TextMeshPro revealTextBase; public TextMeshPro revealTextStatTrak; public TextMeshPro revealTextWear; public TextMeshPro revealTextPattern; public TextMeshPro revealTextTotal; [Header("Item Pools")] public GameObject[] blueItems; public GameObject[] purpleItems; public GameObject[] pinkItems; public GameObject[] redItems; public GameObject goldIcon; public GameObject[] goldItems; private readonly float spinDuration = 6.6f; private const float RevealDuration = 1.9f; private readonly float itemSpacing = 0.353f; private readonly int itemsInStrip = 40; private readonly int winningSlotIndex = 35; private readonly Color colBlue = new Color(0.48f, 0.62f, 1f); private readonly Color colPurple = new Color(0.72f, 0.52f, 1f); private readonly Color colPink = new Color(0.96f, 0.45f, 0.96f); private readonly Color colRed = new Color(1f, 0.5f, 0.48f); private readonly Color colGold = new Color(1f, 0.79f, 0.36f); private List<GameObject> activeRewards = new List<GameObject>(); private Transform stripContainer; private GameObject winningItemInstance; private GameObject activeCenterLine; private static int nextAvailableLayer = 31; private int instanceLayer = -1; private bool isSpinning; private Coroutine revealRoutine; private Coroutine serverRoutine; private bool serverRoundActive; private bool payoutAttempted; private float pendingMultiplier; private int lastTickSlot; private CaseDisplay display; private CaseCatalog catalog; private int catalogCase = -1; private readonly Dictionary<int, GameObject> catalogTemplates = new Dictionary<int, GameObject>(); private CaseAudio audio; private CaseWorldEffects worldEffects; private float spinTimer; private float startX; private float targetX; private void Start() { catalog = CaseCatalog.Load(); CaseScreen.Attach(((Component)this).gameObject, externalCamera); IsolateCameraAndAssets(); HideRevealText(); if ((Object)(object)externalCamera != (Object)null && (Object)(object)revealTextBase != (Object)null) { display = new CaseDisplay(externalCamera, revealTextBase, instanceLayer); if ((Object)(object)backgroundParent != (Object)null) { ((Component)backgroundParent).gameObject.SetActive(false); } if ((Object)(object)openCase != (Object)null) { openCase.SetActive(false); } backgroundParent = display.Root; revealTextBase = display.ItemName; revealTextStatTrak = display.StatTrak; revealTextWear = display.Wear; revealTextPattern = display.Pattern; revealTextTotal = display.Total; } } private void IsolateCameraAndAssets() { if ((Object)(object)externalCamera == (Object)null) { return; } instanceLayer = nextAvailableLayer--; if (nextAvailableLayer < 15) { nextAvailableLayer = 31; } externalCamera.cullingMask = 1 << instanceLayer; if ((Object)(object)backgroundParent != (Object)null) { SetLayerRecursively(((Component)backgroundParent).gameObject); } if ((Object)(object)openCase != (Object)null) { SetLayerRecursively(openCase); } TextMeshPro[] array = (TextMeshPro[])(object)new TextMeshPro[5] { revealTextBase, revealTextStatTrak, revealTextWear, revealTextPattern, revealTextTotal }; foreach (TextMeshPro val in array) { if ((Object)(object)val != (Object)null) { SetLayerRecursively(((Component)val).gameObject); } } } private void SetLayerRecursively(GameObject obj) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown if (instanceLayer < 0) { return; } obj.layer = instanceLayer; foreach (Transform item in obj.transform) { Transform val = item; SetLayerRecursively(((Component)val).gameObject); } } public override bool Weaved() { return true; } public void BroadcastSpinSequence(string text) { if (NetworkServer.active) { string text2 = "System.Void MoreGamesBase.CaseOpening::UserRpcSpinSequence(System.String)"; int stableHashCode = Extensions.GetStableHashCode(text2); NetworkWriterPooled val = NetworkWriterPool.Get(); NetworkWriterExtensions.WriteString((NetworkWriter)(object)val, text); ((NetworkBehaviour)this).SendRPCInternal(text2, stableHashCode, (NetworkWriter)(object)val, 0, true); NetworkWriterPool.Return(val); } } public void BroadcastClearStrip(string text) { if (NetworkServer.active) { string text2 = "System.Void MoreGamesBase.CaseOpening::UserRpcClearStrip(System.String)"; int stableHashCode = Extensions.GetStableHashCode(text2); NetworkWriterPooled val = NetworkWriterPool.Get(); NetworkWriterExtensions.WriteString((NetworkWriter)(object)val, text); ((NetworkBehaviour)this).SendRPCInternal(text2, stableHashCode, (NetworkWriter)(object)val, 0, true); NetworkWriterPool.Return(val); } } protected override void StartGame() { if (((NetworkBehaviour)this).isServer && NetworkServer.active && !serverRoundActive) { ((GameBase)this).StartGame(); serverRoundActive = true; payoutAttempted = false; BroadcastClearStrip("clear"); if (catalog != null) { catalogCase = Random.Range(0, catalog.Cases.Length); } Rarity randomRarity = GetRandomRarity(); int randomIndexForRarity = GetRandomIndexForRarity(randomRarity); Wear wear = GetRandomWear(randomRarity); bool flag = Random.value <= 0.1f; if (catalog != null) { CaseCatalog.Item item = catalog.Items[randomIndexForRarity]; flag &= item.StatTrak; wear = GetCatalogWear(item, wear); } int num = Random.Range(1, 1001); float num2 = itemSpacing / 2f * 0.8f; float num3 = Random.Range(0f - num2, num2); int num4 = Random.Range(1, int.MaxValue); string text = string.Format(CultureInfo.InvariantCulture, "{0},{1},{2},{3},{4},{5:F3},{6}", (int)randomRarity, randomIndexForRarity, (int)wear, flag ? 1 : 0, num, num3, num4); if (catalog != null) { text = text + "," + catalogCase.ToString(CultureInfo.InvariantCulture); } pendingMultiplier = CalculateFinalMultiplier(randomRarity, randomIndexForRarity, wear, flag, num); serverRoutine = ((MonoBehaviour)this).StartCoroutine(ServerResolveSpin()); BroadcastSpinSequence(text); } } private Rarity GetRandomRarity() { float num = Random.Range(0f, 100f); if (num <= 1f) { return Rarity.Gold; } if (num <= 4f) { return Rarity.Red; } if (num <= 12f) { return Rarity.Pink; } if (num <= 35f) { return Rarity.Purple; } return Rarity.Blue; } private int GetRandomIndexForRarity(Rarity rarity) { if (catalog != null) { int[] array = catalog.Cases[catalogCase].Pools[(int)rarity]; return array[Random.Range(0, array.Length)]; } return rarity switch { Rarity.Blue => Random.Range(0, blueItems.Length), Rarity.Purple => Random.Range(0, purpleItems.Length), Rarity.Pink => Random.Range(0, pinkItems.Length), Rarity.Red => Random.Range(0, redItems.Length), Rarity.Gold => Random.Range(0, goldItems.Length), _ => 0, }; } private Wear GetRandomWear(Rarity rarity) { float num = Random.Range(0f, 1f); if (num < 0.05f) { return Wear.FactoryNew; } if (num < 0.15f) { return Wear.MinimalWear; } if (num < 0.4f) { return Wear.FieldTested; } if (num < 0.7f) { return Wear.WellWorn; } return Wear.BattleScarred; } private Wear GetCatalogWear(CaseCatalog.Item item, Wear rolled) { if (!item.HasWear) { return Wear.FieldTested; } if (Array.IndexOf(item.Wears, (int)rolled) >= 0) { return rolled; } return (Wear)item.Wears[Random.Range(0, item.Wears.Length)]; } private IEnumerator ServerResolveSpin() { yield return (object)new WaitForSeconds(0.85f + spinDuration); SettleSpin(); yield return (object)new WaitForSeconds(1.9f); ((GameBase)this).ResetGame(); serverRoundActive = false; serverRoutine = null; } private void SettleSpin() { if (NetworkServer.active && serverRoundActive && !payoutAttempted) { payoutAttempted = true; ((GameBase)this).Payout((double)pendingMultiplier, (ChangeType)1, (Dictionary<string, object>)null, (BigNumber?)null); } } protected override void OnDisable() { CancelClientPresentation(); if (serverRoutine != null) { ((MonoBehaviour)this).StopCoroutine(serverRoutine); } serverRoutine = null; if (serverRoundActive && payoutAttempted && NetworkServer.active) { if ((Object)(object)base.keypad != (Object)null) { ((GameBase)this).ResetGame(); } else { base.isPlaying = false; } } serverRoundActive = false; ReleaseCatalogTemplates(); ((GameBase)this).OnDisable(); } private void CancelClientPresentation() { if (revealRoutine != null) { ((MonoBehaviour)this).StopCoroutine(revealRoutine); } revealRoutine = null; isSpinning = false; if (worldEffects != null) { worldEffects.Clear(); } if (audio != null) { audio.Dispose(); } audio = null; } private bool IsBlueGem(Rarity rarity, int itemIndex, int pattern) { bool num; if (catalog == null) { if (rarity == Rarity.Red) { num = itemIndex == 0; goto IL_0052; } } else if (catalog.Items[itemIndex].Weapon == "weapon_ak47") { num = catalog.Items[itemIndex].Paint == "44"; goto IL_0052; } goto IL_007f; IL_0052: if (num) { if (pattern != 661 && pattern != 151 && pattern != 955 && pattern != 321) { return pattern == 387; } return true; } goto IL_007f; IL_007f: return false; } private float CalculateFinalMultiplier(Rarity rarity, int itemIndex, Wear wear, bool isStatTrak, int pattern) { float num = 0f; if (rarity == Rarity.Blue) { num = 0.1f; } if (rarity == Rarity.Purple) { num = 0.5f; } if (rarity == Rarity.Pink) { num = 2f; } if (rarity == Rarity.Red) { num = 8f; } if (rarity == Rarity.Gold) { if (catalog != null) { num = 12f; } else { float[] array = new float[10] { 23f, 15f, 15f, 17f, 35f, 12f, 12f, 10f, 4f, 12f }; num = ((itemIndex < 0 || itemIndex >= array.Length) ? 50f : array[itemIndex]); } } if (catalog == null || catalog.Items[itemIndex].HasWear) { if (wear == Wear.FactoryNew) { num *= 2f; } if (wear == Wear.MinimalWear) { num *= 1.5f; } if (wear == Wear.FieldTested) { num *= 1f; } if (wear == Wear.WellWorn) { num *= 0.8f; } if (wear == Wear.BattleScarred) { num *= 0.5f; } } if (isStatTrak) { num *= 1.5f; } if (IsBlueGem(rarity, itemIndex, pattern)) { num *= 50f; } return num; } public void UserRpcClearStrip(string networkText) { if (!NetworkClient.active) { return; } CancelClientPresentation(); if ((Object)(object)openCase != (Object)null && openCase.activeSelf) { openCase.SetActive(false); } if ((Object)(object)activeCenterLine != (Object)null) { Object.Destroy((Object)(object)activeCenterLine); activeCenterLine = null; } foreach (GameObject activeReward in activeRewards) { if ((Object)(object)activeReward != (Object)null) { Object.Destroy((Object)(object)activeReward); } } activeRewards.Clear(); winningItemInstance = null; if ((Object)(object)stripContainer != (Object)null) { Object.Destroy((Object)(object)((Component)stripContainer).gameObject); stripContainer = null; } HideRevealText(); if (display != null) { display.Reset(); } ReleaseCatalogTemplates(); isSpinning = false; } private void ReleaseCatalogTemplates() { foreach (GameObject value in catalogTemplates.Values) { CaseCatalog.DestroyTemplate(value); } catalogTemplates.Clear(); } public void UserRpcSpinSequence(string networkText) { //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) if (!NetworkClient.active) { return; } string[] array = networkText.Split(','); if (array.Length != ((catalog == null) ? 7 : 8)) { return; } int result = -1; if (!int.TryParse(array[0], out var result2) || result2 < 0 || result2 > 4 || !int.TryParse(array[1], out var result3) || !int.TryParse(array[2], out var result4) || result4 < 0 || result4 > 4 || !int.TryParse(array[3], out var result5) || result5 < 0 || result5 > 1 || !int.TryParse(array[4], out var result6) || result6 < 1 || result6 > 1000 || !float.TryParse(array[5], NumberStyles.Float, CultureInfo.InvariantCulture, out var result7) || float.IsNaN(result7) || Math.Abs(result7) > itemSpacing * 0.4f || !int.TryParse(array[6], out var result8) || (catalog != null && (!int.TryParse(array[7], out result) || !catalog.Contains(result, result2, result3)))) { return; } Rarity rarity = (Rarity)result2; Wear wear = (Wear)result4; bool flag = result5 == 1; if (catalog != null) { CaseCatalog.Item item = catalog.Items[result3]; if ((flag && !item.StatTrak) || (item.HasWear && Array.IndexOf(item.Wears, result4) < 0)) { return; } } UserRpcClearStrip("clear"); catalogCase = result; if (display != null) { display.Begin(catalog.Cases[result].Name, catalog.Cases[result].Id); } GenerateVisualStrip(rarity, result3, result8); if (display != null) { display.OpeningFrame(0f, stripContainer); } if (display == null && (Object)(object)centerLinePrefab != (Object)null) { activeCenterLine = Object.Instantiate<GameObject>(centerLinePrefab, backgroundParent, false); activeCenterLine.transform.localPosition = new Vector3(0f, 0f, 3f); activeCenterLine.transform.localScale = new Vector3(0.004f, 0.37f, 1f); SetLayerRecursively(activeCenterLine); } startX = 0f; targetX = 0f - (float)winningSlotIndex * itemSpacing + result7; spinTimer = 0f; isSpinning = true; lastTickSlot = 0; audio = new CaseAudio(((Component)this).transform); audio.Play("open"); revealRoutine = ((MonoBehaviour)this).StartCoroutine(WaitAndReveal(rarity, result3, wear, flag, result6)); } private void GenerateVisualStrip(Rarity winRarity, int winIndex, int seed) { //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_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Expected O, but got Unknown //IL_00dd: 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_0319: 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_0180: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_022a: 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_02c6: Unknown result type (might be due to invalid IL or missing references) State state = Random.state; Random.InitState(seed); GameObject val = new GameObject("StripContainer"); stripContainer = val.transform; stripContainer.SetParent(backgroundParent, false); stripContainer.localPosition = new Vector3(0f, (display == null) ? 0f : 0f, 0f); stripContainer.localScale = Vector3.one; for (int i = -15; i < itemsInStrip; i++) { Rarity rarity = winRarity; int index = winIndex; if (i != winningSlotIndex) { rarity = GetRandomRarity(); index = GetRandomIndexForRarity(rarity); } GameObject val2 = new GameObject($"Slot_{i}"); val2.transform.SetParent(stripContainer, false); val2.transform.localPosition = new Vector3((float)i * itemSpacing, 0f, 0f); val2.transform.localScale = Vector3.one; if (i == winningSlotIndex) { winningItemInstance = val2; } if (display != null) { display.Card(val2.transform, CaseDisplay.ReelColor((int)rarity)); } else { GameObject obj = Object.Instantiate<GameObject>(itemPrefab); obj.transform.SetParent(val2.transform, false); obj.transform.localPosition = new Vector3(0f, -0.17f, 0.1f); obj.transform.localScale = new Vector3(0.38f, 0.022f, 1f); Transform val3 = obj.transform.Find("itemBar"); if ((Object)(object)val3 != (Object)null) { SpriteRenderer component = ((Component)val3).GetComponent<SpriteRenderer>(); if ((Object)(object)component != (Object)null) { component.color = GetColorForRarity(rarity); ((Renderer)component).sortingOrder = 2; } } } GameObject prefabRef = GetPrefabRef(rarity, index, isSpinningView: true); if ((Object)(object)prefabRef != (Object)null) { GameObject val4 = Object.Instantiate<GameObject>(prefabRef); if (catalog != null) { val4.SetActive(true); } val4.transform.SetParent(val2.transform, false); val4.transform.localPosition = new Vector3(0f, 0f, 0.2f); val4.transform.localScale = new Vector3(0.06f, 0.08f, 1f); SpriteRenderer val5 = val4.GetComponent<SpriteRenderer>(); if ((Object)(object)val5 == (Object)null) { val5 = val4.GetComponentInChildren<SpriteRenderer>(); } if ((Object)(object)val5 != (Object)null) { ((Renderer)val5).sortingOrder = 5; if (display != null) { display.StyleArtwork(val5); } if (display != null && (Object)(object)val5.sprite != (Object)null) { val4.transform.localScale = CaseDisplay.Fit(val5.sprite, 0.3f, 0.215f); } } } if (display != null) { display.TrackCard(val2.transform); } } if (display != null) { display.UpdateReel(0f); } SetLayerRecursively(val); Random.state = state; } private IEnumerator WaitAndReveal(Rarity rarity, int itemIndex, Wear wear, bool isStatTrak, int pattern) { yield return (object)new WaitForSeconds(0.85f + spinDuration + 0.3f); if ((Object)(object)activeCenterLine != (Object)null) { Object.Destroy((Object)(object)activeCenterLine); activeCenterLine = null; } if ((Object)(object)winningItemInstance == (Object)null) { yield break; } float finalMult = CalculateFinalMultiplier(rarity, itemIndex, wear, isStatTrak, pattern); if (worldEffects == null) { worldEffects = new CaseWorldEffects(((Component)this).transform); } worldEffects.Play(finalMult); if (display != null) { display.Reveal(GetColorForRarity(rarity), finalMult); } PopulateRevealDetails(rarity, itemIndex, wear, isStatTrak, pattern, finalMult); if (audio != null) { audio.Play("reveal_" + rarity.ToString().ToLowerInvariant()); } Vector3 position = winningItemInstance.transform.position; if ((Object)(object)stripContainer != (Object)null) { ((Component)stripContainer).gameObject.SetActive(false); } GameObject prefabRef = GetPrefabRef(rarity, itemIndex, isSpinningView: false); GameObject finalSpriteObj = Object.Instantiate<GameObject>(prefabRef); if (catalog != null) { finalSpriteObj.SetActive(true); } finalSpriteObj.transform.SetParent(backgroundParent, true); finalSpriteObj.transform.position = position; finalSpriteObj.transform.localRotation = Quaternion.identity; SetLayerRecursively(finalSpriteObj); activeRewards.Add(finalSpriteObj); SpriteRenderer finalSr = finalSpriteObj.GetComponentInChildren<SpriteRenderer>(); if ((Object)(object)finalSr != (Object)null) { ((Renderer)finalSr).sortingOrder = 50; if (display != null) { display.StyleArtwork(finalSr); } } Vector3 startLocalPos = finalSpriteObj.transform.localPosition; Vector3 targetLocalPos = ((display == null) ? new Vector3(0.2f, 0f, 1.5f) : new Vector3(0f, 0.01f, -0.02f)); Vector3 startScale = finalSpriteObj.transform.localScale; Vector3 targetScale = startScale * 1.7f; if (rarity == Rarity.Gold) { targetScale = startScale * 2.3f; } if (display != null && (Object)(object)finalSr != (Object)null && (Object)(object)finalSr.sprite != (Object)null) { targetScale = CaseDisplay.Fit(finalSr.sprite, 1.22f, 0.38f); } float animTime = 0f; float animDuration = ((display != null && finalMult >= 10f) ? 0.85f : 0.45f); if (display != null) { startLocalPos = targetLocalPos; startScale = targetScale * 0.92f; } while (animTime < animDuration) { animTime += Time.deltaTime; float num = Mathf.SmoothStep(0f, 1f, animTime / animDuration); finalSpriteObj.transform.localPosition = Vector3.Lerp(startLocalPos, targetLocalPos, num); float num2 = ((display != null && finalMult >= 10f) ? (1f + 0.06f * Mathf.Sin(num * MathF.PI)) : 1f); finalSpriteObj.transform.localScale = Vector3.Lerp(startScale, targetScale, num) * num2; if (display != null && (Object)(object)finalSr != (Object)null) { finalSr.color = new Color(1f, 1f, 1f, Mathf.Clamp01(animTime / 0.35f)); } yield return null; } finalSpriteObj.transform.localPosition = targetLocalPos; finalSpriteObj.transform.localScale = targetScale; revealRoutine = null; } private void PopulateRevealDetails(Rarity rarity, int itemIndex, Wear wear, bool isStatTrak, int pattern, float finalMult) { if ((Object)(object)revealTextBase != (Object)null) { ((TMP_Text)revealTextBase).text = ((display != null) ? catalog.Items[itemIndex].Name.TrimStart('★', ' ') : ((catalog == null) ? ("Rarity Multiplier: " + GetBaseMultString(rarity)) : (catalog.Cases[catalogCase].Name + "\n" + catalog.Items[itemIndex].Name + "\nRarity Multiplier: " + GetBaseMultString(rarity)))); ((Component)revealTextBase).gameObject.SetActive(true); } if ((Object)(object)revealTextStatTrak != (Object)null) { if (isStatTrak) { ((TMP_Text)revealTextStatTrak).text = "<color=#FFB54A>StatTrak™</color>"; } else { ((TMP_Text)revealTextStatTrak).text = "STANDARD"; } ((Component)revealTextStatTrak).gameObject.SetActive(true); } if ((Object)(object)revealTextWear != (Object)null) { ((TMP_Text)revealTextWear).text = ((catalog != null && !catalog.Items[itemIndex].HasWear) ? "WEAR / N/A" : GetWearString(wear)); ((Component)revealTextWear).gameObject.SetActive(true); } if ((Object)(object)revealTextPattern != (Object)null) { if (IsBlueGem(rarity, itemIndex, pattern)) { ((TMP_Text)revealTextPattern).text = $"<color=#7A9EFF>{pattern} / BLUE GEM!</color>"; } else { ((TMP_Text)revealTextPattern).text = $"SEED / {pattern}"; } ((Component)revealTextPattern).gameObject.SetActive(true); } string text = "<color=#F3A33B>" + finalMult.ToString("0.##", CultureInfo.InvariantCulture) + "x</color>"; if ((Object)(object)revealTextTotal != (Object)null) { ((TMP_Text)revealTextTotal).text = ((display != null) ? ("PAYOUT " + finalMult.ToString("0.##", CultureInfo.InvariantCulture) + "x") : ("PAYOUT " + text)); ((Component)revealTextTotal).gameObject.SetActive(true); } if (display != null && catalog != null) { CaseCatalog.Item item = catalog.Items[itemIndex]; string text2 = rarity switch { Rarity.Red => "COVERT", Rarity.Pink => "CLASSIFIED", Rarity.Purple => "RESTRICTED", Rarity.Blue => "MIL-SPEC", _ => "RARE SPECIAL", }; ((TMP_Text)display.CaseName).text = item.Collection; ((TMP_Text)display.Description).text = item.Description; ((Component)display.Description).gameObject.SetActive(true); ((TMP_Text)display.Metadata).text = text2 + " / " + (string.IsNullOrEmpty(item.Paint) ? "VANILLA FINISH" : ("PAINT " + item.Paint)) + (string.IsNullOrEmpty(item.Phase) ? "" : (" / " + item.Phase.ToUpperInvariant())); ((Component)display.Metadata).gameObject.SetActive(true); } } private string GetWearString(Wear w) { return w switch { Wear.FactoryNew => "FACTORY NEW", Wear.MinimalWear => "MINIMAL WEAR", Wear.FieldTested => "FIELD-TESTED", Wear.WellWorn => "WELL-WORN", Wear.BattleScarred => "BATTLE-SCARRED", _ => "", }; } private GameObject GetPrefabRef(Rarity r, int index, bool isSpinningView) { if (catalog != null && !(r == Rarity.Gold && isSpinningView)) { if (!catalogTemplates.TryGetValue(index, out var value)) { value = CaseCatalog.CreateTemplate(catalog.Items[index]); catalogTemplates.Add(index, value); } return value; } switch (r) { case Rarity.Gold: if (!isSpinningView) { return goldItems[index]; } return goldIcon; case Rarity.Blue: return blueItems[index]; case Rarity.Purple: return purpleItems[index]; case Rarity.Pink: return pinkItems[index]; case Rarity.Red: return redItems[index]; default: return null; } } private Color GetColorForRarity(Rarity r) { //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_002b: 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_0039: 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) return (Color)(r switch { Rarity.Blue => colBlue, Rarity.Purple => colPurple, Rarity.Pink => colPink, Rarity.Red => colRed, Rarity.Gold => colGold, _ => Color.white, }); } private void Update() { //IL_0110: 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_012a: Unknown result type (might be due to invalid IL or missing references) if (audio != null) { audio.Update(); } if (display != null) { display.Tick(Time.unscaledDeltaTime); } if (!isSpinning || (Object)(object)stripContainer == (Object)null) { return; } spinTimer += Time.deltaTime; float num = Mathf.Clamp01((spinTimer - 0.85f) / spinDuration); if (display != null) { display.OpeningFrame(spinTimer, stripContainer); } if (num >= 1f) { isSpinning = false; } float num2 = 1f - Mathf.Pow(1f - num, 3f); float num3 = Mathf.Lerp(startX, targetX, num2); int num4 = Mathf.FloorToInt((0f - num3) / itemSpacing + 0.5f); if (num4 > lastTickSlot) { if (audio != null) { audio.Play("tick"); } lastTickSlot = num4; } stripContainer.localPosition = new Vector3(num3, stripContainer.localPosition.y, stripContainer.localPosition.z); if (display != null) { display.UpdateReel(num3); } } private string GetBaseMultString(Rarity r) { switch (r) { case Rarity.Blue: return "<color=#ff0000>0.1x</color>"; case Rarity.Purple: return "<color=#ff0000>0.5x</color>"; case Rarity.Pink: return "<color=#00ff00>2.0x</color