using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using REPOLib.Modules; using UnityEngine; [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("Empress")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+5f1b735e473ca4ccf3b383128fbebd889cb564da")] [assembly: AssemblyProduct("EmpressSlots")] [assembly: AssemblyTitle("EmpressSlots")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace Empress.REPO.EmpressSlots { internal static class EmpressSlotBundleVisuals { private const string BundleFileName = "empressslots"; private static readonly Dictionary VisualPrefabs = new Dictionary(StringComparer.OrdinalIgnoreCase); private static readonly Dictionary AudioClipsByName = new Dictionary(StringComparer.OrdinalIgnoreCase); private static readonly List AudioClips = new List(); private static ManualLogSource? _log; private static AssetBundle? _bundle; private static bool _loadAttempted; private static bool _audioLoaded; public static void Initialize(string pluginDirectory, ManualLogSource log) { _log = log; if (_loadAttempted) { return; } _loadAttempted = true; string text = Path.Combine(pluginDirectory, "empressslots"); if (!File.Exists(text)) { log.LogWarning((object)("Empress Slots asset bundle was not found at " + text + ". Falling back to procedural visuals.")); return; } try { foreach (AssetBundle allLoadedAssetBundle in AssetBundle.GetAllLoadedAssetBundles()) { if (string.Equals(((Object)allLoadedAssetBundle).name, "empressslots", StringComparison.OrdinalIgnoreCase)) { _bundle = allLoadedAssetBundle; log.LogInfo((object)"Using already-loaded Empress Slots asset bundle: empressslots"); return; } } _bundle = AssetBundle.LoadFromFile(text); if ((Object)(object)_bundle == (Object)null) { log.LogWarning((object)("Unity returned null when loading " + text + ". Falling back to procedural visuals.")); } else { log.LogInfo((object)("Loaded Empress Slots asset bundle: " + text)); } } catch (Exception arg) { log.LogWarning((object)$"Failed to load Empress Slots asset bundle {text}: {arg}"); _bundle = null; } } public static bool TryAttach(Transform parent, EmpressSlotDefinition definition) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) GameObject val = LoadVisualPrefab(definition.PrefabName); if ((Object)(object)val == (Object)null) { return false; } GameObject val2 = Object.Instantiate(val, parent, false); ((Object)val2).name = "EmpressSlotVisual"; val2.transform.localPosition = Vector3.zero; val2.transform.localRotation = Quaternion.identity; val2.transform.localScale = Vector3.one; ((Object)val2).hideFlags = (HideFlags)52; SetLayerRecursively(val2.transform, ((Component)parent).gameObject.layer); Collider[] componentsInChildren = val2.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { Object.Destroy((Object)(object)componentsInChildren[i]); } StripParticleEffects(val2); return true; } public static AudioClip? LoadAudioClip(string name) { LoadAllAudioClips(); if (!AudioClipsByName.TryGetValue(name, out AudioClip value)) { return null; } return value; } private static AudioClip[] LoadAllAudioClips() { //IL_0049: Unknown result type (might be due to invalid IL or missing references) if (_audioLoaded) { return AudioClips.ToArray(); } _audioLoaded = true; if ((Object)(object)_bundle == (Object)null) { return Array.Empty(); } try { AudioClip[] array = _bundle.LoadAllAssets(); foreach (AudioClip val in array) { if (!((Object)(object)val == (Object)null)) { if ((int)val.loadState == 0) { val.LoadAudioData(); } AudioClips.Add(val); AudioClipsByName[((Object)val).name] = val; } } } catch (Exception arg) { ManualLogSource? log = _log; if (log != null) { log.LogWarning((object)$"Failed to load Empress Slots audio clips from bundle: {arg}"); } } return AudioClips.ToArray(); } private static GameObject? LoadVisualPrefab(string prefabName) { if (VisualPrefabs.TryGetValue(prefabName, out GameObject value)) { return value; } if ((Object)(object)_bundle == (Object)null) { VisualPrefabs[prefabName] = null; return null; } try { GameObject val = _bundle.LoadAsset(prefabName); if ((Object)(object)val == (Object)null) { val = _bundle.LoadAsset("Assets/EmpressSlots/Prefabs/" + prefabName + ".prefab"); } if ((Object)(object)val == (Object)null) { ManualLogSource? log = _log; if (log != null) { log.LogWarning((object)("Empress Slots bundle is missing visual prefab '" + prefabName + "'.")); } } VisualPrefabs[prefabName] = val; return val; } catch (Exception arg) { ManualLogSource? log2 = _log; if (log2 != null) { log2.LogWarning((object)$"Failed to load visual prefab '{prefabName}' from Empress Slots bundle: {arg}"); } VisualPrefabs[prefabName] = null; return null; } } private static void SetLayerRecursively(Transform root, int layer) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown ((Component)root).gameObject.layer = layer; foreach (Transform item in root) { SetLayerRecursively(item, layer); } } private static void StripParticleEffects(GameObject root) { ParticleSystem[] componentsInChildren = root.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { Object.Destroy((Object)(object)componentsInChildren[i]); } ParticleSystemRenderer[] componentsInChildren2 = root.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren2.Length; i++) { Object.Destroy((Object)(object)componentsInChildren2[i]); } TrailRenderer[] componentsInChildren3 = root.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren3.Length; i++) { Object.Destroy((Object)(object)componentsInChildren3[i]); } LineRenderer[] componentsInChildren4 = root.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren4.Length; i++) { Object.Destroy((Object)(object)componentsInChildren4[i]); } } } internal sealed class EmpressSlotDefinition { public string PrefabName { get; } public string DisplayName { get; } public Type VolumeType { get; } public int ValueMin { get; } public int ValueMax { get; } public float Fragility { get; } public float Durability { get; } public float Mass { get; } public Color Primary { get; } public Color Secondary { get; } public Color Accent { get; } public Vector3 GrabBoundsCenter { get; } public Vector3 GrabBoundsSize { get; } public EmpressSlotDefinition(string prefabName, string displayName, Type volumeType, int valueMin, int valueMax, float fragility, float durability, float mass, Color primary, Color secondary, Color accent, Vector3 grabBoundsCenter, Vector3 grabBoundsSize) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: 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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) PrefabName = prefabName; DisplayName = displayName; VolumeType = volumeType; ValueMin = valueMin; ValueMax = valueMax; Fragility = fragility; Durability = durability; Mass = mass; Primary = primary; Secondary = secondary; Accent = accent; GrabBoundsCenter = grabBoundsCenter; GrabBoundsSize = grabBoundsSize; } } internal static class EmpressSlotDefinitions { public const string SlotMachinePrefabName = "EmpressSlotMachineVisual"; public static readonly EmpressSlotDefinition SlotMachine = new EmpressSlotDefinition("EmpressSlotMachineVisual", "Empress Slot Machine", (Type)3, 0, 0, 5f, 500f, 100f, C(98, 62, 110), C(227, 184, 75), C(byte.MaxValue, 96, 200), new Vector3(0f, 0.62f, 0f), new Vector3(1.18f, 1.22f, 1.02f)); public static EmpressSlotDefinition? FindByPrefabName(string prefabName) { if (!string.Equals(prefabName, "EmpressSlotMachineVisual", StringComparison.OrdinalIgnoreCase)) { return null; } return SlotMachine; } private static Color C(byte r, byte g, byte b) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) return new Color((float)(int)r / 255f, (float)(int)g / 255f, (float)(int)b / 255f); } } internal static class EmpressSlotFallbackVisuals { public static readonly Type[] VolumeTypes; public static void Build(Transform root, EmpressSlotDefinition definition) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("EmpressSlotProceduralVisual"); val.transform.SetParent(root, false); val.transform.localPosition = Vector3.zero; val.transform.localRotation = Quaternion.identity; val.transform.localScale = Vector3.one; string text = definition.PrefabName.ToLowerInvariant(); if (text.Contains("dog")) { BuildDog(val.transform, definition); } else if (text.Contains("van")) { BuildVan(val.transform, definition); } else { BuildProp(val.transform, definition); } } private static void BuildDog(Transform root, EmpressSlotDefinition definition) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_004f: 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_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0107: 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) Material material = MaterialFor(definition.PrefabName + " Body", definition.Primary); Material material2 = MaterialFor(definition.PrefabName + " Accent", definition.Accent, emission: true); AddSphere(root, "Body", new Vector3(0f, 0.34f, 0f), new Vector3(0.34f, 0.2f, 0.2f), material); AddSphere(root, "Head", new Vector3(0f, 0.5f, -0.24f), new Vector3(0.18f, 0.16f, 0.16f), material); AddCube(root, "Ears", new Vector3(0f, 0.62f, -0.24f), new Vector3(0.34f, 0.06f, 0.08f), material2); AddCylinder(root, "Stand", new Vector3(0f, 0.035f, 0f), Quaternion.identity, new Vector3(0.56f, 0.035f, 0.56f), MaterialFor(definition.PrefabName + " Stand", definition.Secondary)); } private static void BuildVan(Transform root, EmpressSlotDefinition definition) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_010b: 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_0133: 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_0168: 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) Material material = MaterialFor(definition.PrefabName + " Body", definition.Primary); Material material2 = MaterialFor(definition.PrefabName + " Trim", definition.Secondary); Material material3 = MaterialFor(definition.PrefabName + " Lights", definition.Accent, emission: true); AddCube(root, "Body", new Vector3(0f, 0.35f, 0f), new Vector3(0.78f, 0.36f, 0.42f), material); AddCube(root, "Cabin", new Vector3(0.16f, 0.58f, 0f), new Vector3(0.4f, 0.22f, 0.38f), material2); AddCube(root, "Lights", new Vector3(0.4f, 0.36f, -0.22f), new Vector3(0.22f, 0.06f, 0.025f), material3); AddCylinder(root, "Front Wheel", new Vector3(0.26f, 0.14f, -0.25f), Quaternion.Euler(90f, 0f, 0f), new Vector3(0.13f, 0.08f, 0.13f), material2); AddCylinder(root, "Rear Wheel", new Vector3(-0.26f, 0.14f, -0.25f), Quaternion.Euler(90f, 0f, 0f), new Vector3(0.13f, 0.08f, 0.13f), material2); } private static void BuildProp(Transform root, EmpressSlotDefinition definition) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) Material material = MaterialFor(definition.PrefabName + " Primary", definition.Primary); Material material2 = MaterialFor(definition.PrefabName + " Secondary", definition.Secondary); Material material3 = MaterialFor(definition.PrefabName + " Accent", definition.Accent, emission: true); AddCube(root, "Core", new Vector3(0f, 0.36f, 0f), new Vector3(0.5f, 0.52f, 0.38f), material); AddCube(root, "Face", new Vector3(0f, 0.42f, -0.2f), new Vector3(0.42f, 0.2f, 0.025f), material3); AddCylinder(root, "Base", new Vector3(0f, 0.035f, 0f), Quaternion.identity, new Vector3(0.58f, 0.035f, 0.58f), material2); } private static GameObject AddCube(Transform parent, string name, Vector3 localPosition, Vector3 localScale, Material material) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: 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) return AddPrimitive(parent, name, (PrimitiveType)3, localPosition, Quaternion.identity, localScale, material); } private static GameObject AddSphere(Transform parent, string name, Vector3 localPosition, Vector3 localScale, Material material) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: 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) return AddPrimitive(parent, name, (PrimitiveType)0, localPosition, Quaternion.identity, localScale, material); } private static GameObject AddCylinder(Transform parent, string name, Vector3 localPosition, Quaternion localRotation, Vector3 localScale, Material material) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: 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) return AddPrimitive(parent, name, (PrimitiveType)2, localPosition, localRotation, localScale, material); } private static GameObject AddPrimitive(Transform parent, string name, PrimitiveType primitiveType, Vector3 localPosition, Quaternion localRotation, Vector3 localScale, Material material) { //IL_0000: 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_002c: 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) GameObject obj = GameObject.CreatePrimitive(primitiveType); ((Object)obj).name = name; obj.transform.SetParent(parent, false); obj.transform.localPosition = localPosition; obj.transform.localRotation = localRotation; obj.transform.localScale = localScale; Collider component = obj.GetComponent(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } obj.GetComponent().sharedMaterial = material; return obj; } private static Material MaterialFor(string name, Color color, bool emission = false) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) Material val = new Material(Shader.Find("Standard")) { name = name, color = color, hideFlags = (HideFlags)61 }; if (emission) { val.EnableKeyword("_EMISSION"); val.SetColor("_EmissionColor", color * 0.85f); } return val; } static EmpressSlotFallbackVisuals() { Type[] array = new Type[7]; RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); VolumeTypes = (Type[])(object)array; } } internal static class EmpressSlotGrabBounds { private const int MaxColliderTriangles = 40; private const float MinColliderExtent = 0.015f; public static void Add(Transform root, EmpressSlotDefinition definition) { RemoveTemplateColliders(root); if (AddMeshColliders(root) == 0) { AddFallbackBox(root, definition); EmpressSlotsPlugin.Log.LogWarning((object)(definition.DisplayName + " had no usable renderer meshes for grab colliders; using fitted fallback bounds.")); } } private static int AddMeshColliders(Transform root) { int num = 0; Renderer[] componentsInChildren = ((Component)root).GetComponentsInChildren(true); foreach (Renderer val in componentsInChildren) { if (val.enabled && !(val is ParticleSystemRenderer)) { Mesh val2 = CreateCollisionMesh(val); if ((Object)(object)val2 == (Object)null || !HasValidCollisionShape(val2)) { DestroyMesh(val2); continue; } MeshCollider obj = ((Component)val).gameObject.AddComponent(); obj.cookingOptions = (MeshColliderCookingOptions)14; obj.convex = true; ((Collider)obj).isTrigger = false; obj.sharedMesh = val2; ConfigureColliderObject(((Component)val).gameObject); ((Component)val).gameObject.AddComponent(); EmpressSlotsAccess.HideGrabMeshColliderGizmo(((Component)val).gameObject.AddComponent()); num++; } } return num; } private static Mesh? CreateCollisionMesh(Renderer renderer) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown //IL_00a8: Unknown result type (might be due to invalid IL or missing references) Mesh val = null; Mesh val2 = null; SkinnedMeshRenderer val3 = (SkinnedMeshRenderer)(object)((renderer is SkinnedMeshRenderer) ? renderer : null); if (val3 != null && (Object)(object)val3.sharedMesh != (Object)null) { val2 = new Mesh { name = ((Object)renderer).name + "_EmpressSlotGrabCollider", hideFlags = (HideFlags)61 }; try { val3.BakeMesh(val2); val = val2; } catch { val = val3.sharedMesh; } } else { MeshFilter component = ((Component)renderer).GetComponent(); if ((Object)(object)component != (Object)null && (Object)(object)component.sharedMesh != (Object)null) { val = component.sharedMesh; } } Mesh val4 = CreateReducedMesh(val, ((Object)renderer).name + "_EmpressSlotGrabCollider"); if ((Object)(object)val4 == (Object)null && (Object)(object)val != (Object)null) { val4 = CreateBoxMesh(val.bounds, ((Object)renderer).name + "_EmpressSlotGrabCollider"); } DestroyMesh(val2); return val4; } private static Mesh? CreateReducedMesh(Mesh? sourceMesh, string name) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Expected O, but got Unknown //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: 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_00cb: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)sourceMesh == (Object)null) { return null; } if (!sourceMesh.isReadable) { return null; } Vector3[] vertices = sourceMesh.vertices; int[] triangles = sourceMesh.triangles; if (!HasValidVertexSet(vertices, sourceMesh.bounds) || triangles.Length < 3) { return null; } int num = triangles.Length / 3; int num2 = Mathf.Min(num, 40); Vector3[] array = (Vector3[])(object)new Vector3[num2 * 3]; int[] array2 = new int[num2 * 3]; for (int i = 0; i < num2; i++) { int num3 = ((num2 > 1) ? Mathf.RoundToInt((float)i * ((float)num - 1f) / ((float)num2 - 1f)) : 0) * 3; int num4 = i * 3; array[num4] = vertices[triangles[num3]]; array[num4 + 1] = vertices[triangles[num3 + 1]]; array[num4 + 2] = vertices[triangles[num3 + 2]]; array2[num4] = num4; array2[num4 + 1] = num4 + 1; array2[num4 + 2] = num4 + 2; } Mesh val = new Mesh { name = name, hideFlags = (HideFlags)61 }; val.vertices = array; val.triangles = array2; val.RecalculateBounds(); if (!HasValidCollisionShape(val)) { DestroyMesh(val); return null; } return val; } private static Mesh? CreateBoxMesh(Bounds bounds, string name) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004f: 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_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: 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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008b: 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_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: 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_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: 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_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011a: 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_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Expected O, but got Unknown Vector3 size = ((Bounds)(ref bounds)).size; if (Mathf.Max(new float[3] { size.x, size.y, size.z }) < 0.015f) { return null; } Vector3 min = ((Bounds)(ref bounds)).min; Vector3 max = ((Bounds)(ref bounds)).max; Vector3[] vertices = (Vector3[])(object)new Vector3[8] { new Vector3(min.x, min.y, min.z), new Vector3(max.x, min.y, min.z), new Vector3(max.x, max.y, min.z), new Vector3(min.x, max.y, min.z), new Vector3(min.x, min.y, max.z), new Vector3(max.x, min.y, max.z), new Vector3(max.x, max.y, max.z), new Vector3(min.x, max.y, max.z) }; int[] triangles = new int[36] { 0, 2, 1, 0, 3, 2, 4, 5, 6, 4, 6, 7, 0, 1, 5, 0, 5, 4, 2, 3, 7, 2, 7, 6, 1, 2, 6, 1, 6, 5, 3, 0, 4, 3, 4, 7 }; Mesh val = new Mesh { name = name, hideFlags = (HideFlags)61, vertices = vertices, triangles = triangles }; val.RecalculateBounds(); return val; } private static bool HasValidCollisionShape(Mesh mesh) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) if (mesh.isReadable && mesh.vertexCount >= 3) { return HasValidVertexSet(mesh.vertices, mesh.bounds); } return false; } private static bool HasValidVertexSet(IReadOnlyList vertices, Bounds bounds) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0043: 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_004a: 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_006c: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) Vector3 size = ((Bounds)(ref bounds)).size; if (Mathf.Max(new float[3] { size.x, size.y, size.z }) < 0.015f) { return false; } HashSet hashSet = new HashSet(); for (int i = 0; i < vertices.Count; i++) { Vector3 val = vertices[i]; hashSet.Add(new Vector3Int(Mathf.RoundToInt(val.x * 10000f), Mathf.RoundToInt(val.y * 10000f), Mathf.RoundToInt(val.z * 10000f))); if (hashSet.Count >= 3) { return true; } } return false; } private static void AddFallbackBox(Transform root, EmpressSlotDefinition definition) { //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_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: 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_0105: 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_0111: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Expected O, but got Unknown //IL_0136: Unknown result type (might be due to invalid IL or missing references) Bounds val = CalculateVisualBounds(root); GameObject val2 = new GameObject("EmpressSlotFallbackGrabBounds"); val2.transform.SetParent(root, false); val2.transform.localPosition = root.InverseTransformPoint(((Bounds)(ref val)).center); val2.transform.localRotation = Quaternion.identity; val2.transform.localScale = Vector3.one; Vector3 size = ((Bounds)(ref val)).size; Vector3 lossyScale = root.lossyScale; size.x = ((lossyScale.x == 0f) ? definition.GrabBoundsSize.x : (size.x / Mathf.Abs(lossyScale.x))); size.y = ((lossyScale.y == 0f) ? definition.GrabBoundsSize.y : (size.y / Mathf.Abs(lossyScale.y))); size.z = ((lossyScale.z == 0f) ? definition.GrabBoundsSize.z : (size.z / Mathf.Abs(lossyScale.z))); BoxCollider obj = val2.AddComponent(); obj.center = Vector3.zero; obj.size = Vector3.Max(size, Vector3.one * 0.12f); ((Collider)obj).isTrigger = false; ConfigureColliderObject(val2); val2.AddComponent(); EmpressSlotsAccess.HideGrabBoxColliderGizmo(val2.AddComponent()); } private static void ConfigureColliderObject(GameObject gameObject) { gameObject.tag = "Phys Grab Object"; int num = LayerMask.NameToLayer("PhysGrabObject"); if (num >= 0) { gameObject.layer = num; } } private static Bounds CalculateVisualBounds(Transform root) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0019: 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_0056: 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_0048: Unknown result type (might be due to invalid IL or missing references) Renderer[] componentsInChildren = ((Component)root).GetComponentsInChildren(true); Bounds bounds = default(Bounds); ((Bounds)(ref bounds))..ctor(root.position, Vector3.one * 0.3f); bool flag = false; Renderer[] array = componentsInChildren; foreach (Renderer val in array) { if (val.enabled && !(val is ParticleSystemRenderer)) { if (flag) { ((Bounds)(ref bounds)).Encapsulate(val.bounds); continue; } bounds = val.bounds; flag = true; } } return bounds; } private static void RemoveTemplateColliders(Transform root) { PhysGrabObjectCollider[] componentsInChildren = ((Component)root).GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { DestroyComponent((Component)(object)componentsInChildren[i]); } PhysGrabObjectBoxCollider[] componentsInChildren2 = ((Component)root).GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren2.Length; i++) { DestroyComponent((Component)(object)componentsInChildren2[i]); } PhysGrabObjectMeshCollider[] componentsInChildren3 = ((Component)root).GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren3.Length; i++) { DestroyComponent((Component)(object)componentsInChildren3[i]); } Collider[] componentsInChildren4 = ((Component)root).GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren4.Length; i++) { DestroyComponent((Component)(object)componentsInChildren4[i]); } } private static void DestroyComponent(Component component) { if ((Object)(object)component != (Object)null) { Object.DestroyImmediate((Object)(object)component); } } private static void DestroyMesh(Mesh? mesh) { //IL_000a: 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) if ((Object)(object)mesh != (Object)null && (((Object)mesh).hideFlags & 0x3D) != 0) { Object.DestroyImmediate((Object)(object)mesh); } } } internal sealed class EmpressSlotMachineController : MonoBehaviour { private enum Symbol { Cherry, Lemon, Grape, Watermelon, Bell, Seven } private enum Outcome { Jackpot, BigWin, SmallWin, MiniWin, NoWin } private static readonly float[] ReelDurations = new float[3] { 1.35f, 1.75f, 2.15f }; private static readonly string[] LevelUpgradeNames = new string[11] { "Health", "Stamina", "ExtraJump", "Launch", "Speed", "Strength", "Range", "Throw", "CrouchRest", "TumbleWings", "TumbleClimb" }; private EmpressSlotDefinition? _definition; private PhotonView? _photonView; private PhysGrabObject? _physGrabObject; private Rigidbody? _rigidbody; private AudioSource? _audioSource; private Transform? _handle; private Quaternion _handleRestRotation; private Transform[] _rollers = (Transform[])(object)new Transform[3]; private Vector3[] _rollerBaseEuler = (Vector3[])(object)new Vector3[3]; private Vector3 _homePosition; private Quaternion _homeRotation; private bool _homePoseSet; private bool _partsCached; private bool _isSpinning; private float _nextGrabTime; private Coroutine? _spinRoutine; private string? _lastInteractorSteamId; private string? _pendingLevelRewardSteamId; private string? _pendingLevelRewardUpgrade; private int _pendingShopWinAmount; public void ConfigurePrefab(EmpressSlotDefinition definition) { _definition = definition; } internal static void TriggerFrom(PhysGrabObject physGrabObject, string source) { EmpressSlotMachineController empressSlotMachineController = ResolveController(physGrabObject); if (!((Object)(object)empressSlotMachineController == (Object)null)) { empressSlotMachineController.RememberInteractor(EmpressSlotsAccess.GetPrimaryGrabberSteamId(physGrabObject)); empressSlotMachineController.OnGrabbed(source); } } internal static void TriggerFrom(PhysGrabObject physGrabObject, string source, PhysGrabber? grabber) { EmpressSlotMachineController empressSlotMachineController = ResolveController(physGrabObject); if (!((Object)(object)empressSlotMachineController == (Object)null)) { empressSlotMachineController.RememberInteractor(EmpressSlotsAccess.GetGrabberSteamId(grabber)); empressSlotMachineController.OnGrabbed(source); } } internal static void TriggerFrom(PhysGrabObject physGrabObject, string source, int playerPhotonId) { EmpressSlotMachineController empressSlotMachineController = ResolveController(physGrabObject); if (!((Object)(object)empressSlotMachineController == (Object)null)) { empressSlotMachineController.RememberInteractor(EmpressSlotsAccess.GetGrabberSteamId(playerPhotonId)); empressSlotMachineController.OnGrabbed(source); } } public void SetHomePose(Vector3 position, Quaternion rotation) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) _homePosition = position; _homeRotation = rotation; _homePoseSet = true; } public void TeleportHomeImmediate() { //IL_0010: 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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) if (_homePoseSet) { ((Component)this).transform.SetPositionAndRotation(_homePosition, _homeRotation); if ((Object)(object)_rigidbody != (Object)null) { _rigidbody.position = _homePosition; _rigidbody.rotation = _homeRotation; StopRigidbodyMotion(); } } } public int ForceVisibleRenderers() { Transform val = ((Component)this).transform.Find("EmpressSlotVisual"); Transform obj = (((Object)(object)val != (Object)null) ? val : ((Component)this).transform); int num = 0; Renderer[] componentsInChildren = ((Component)obj).GetComponentsInChildren(true); foreach (Renderer val2 in componentsInChildren) { if (!(val2 is ParticleSystemRenderer)) { val2.enabled = true; num++; } } if (num == 0) { CreateFallbackBeacon(); num = 1; } return num; } public void BroadcastHomePose() { //IL_003a: 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) if (_homePoseSet && IsHost() && SemiFunc.IsMultiplayer() && !((Object)(object)_photonView == (Object)null)) { _photonView.RPC("SetHomePoseRPC", (RpcTarget)1, new object[2] { _homePosition, _homeRotation }); } } private void Awake() { if (_definition == null) { _definition = EmpressSlotDefinitions.FindByPrefabName("EmpressSlotMachineVisual"); } _photonView = ((Component)this).GetComponent(); _physGrabObject = ((Component)this).GetComponent(); _rigidbody = ((Component)this).GetComponent(); _audioSource = ((Component)this).GetComponent() ?? ((Component)this).gameObject.AddComponent(); _audioSource.playOnAwake = false; _audioSource.spatialBlend = 1f; _audioSource.rolloffMode = (AudioRolloffMode)1; _audioSource.minDistance = 1.5f; _audioSource.maxDistance = 18f; } private void Start() { //IL_0015: 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) CacheParts(); if (!_homePoseSet) { SetHomePose(((Component)this).transform.position, ((Component)this).transform.rotation); } } private void FixedUpdate() { //IL_005c: 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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) if (IsHost() && _homePoseSet) { if ((Object)(object)_physGrabObject != (Object)null) { _physGrabObject.OverrideGrabForceZero(); } if ((Object)(object)_rigidbody != (Object)null) { _rigidbody.useGravity = false; _rigidbody.constraints = (RigidbodyConstraints)126; StopRigidbodyMotion(); } if (Vector3.Distance(((Component)this).transform.position, _homePosition) > 0.03f || Quaternion.Angle(((Component)this).transform.rotation, _homeRotation) > 1f) { TeleportHomeImmediate(); } } } private void OnGrabbed(string source) { if (!(Time.time < _nextGrabTime)) { _nextGrabTime = Time.time + 1.25f; if (IsHost()) { TryStartSpin(); } } } private void TryStartSpin() { //IL_013c: 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) if (_isSpinning) { return; } bool flag = IsShopScene(); bool flag2 = IsLevelScene(); if (!flag && !flag2) { return; } string text = ResolveInteractorSteamId(); int num = 0; int num2 = 0; _pendingShopWinAmount = 0; _pendingLevelRewardSteamId = null; _pendingLevelRewardUpgrade = null; if (flag) { int num3 = SemiFunc.StatGetRunCurrency(); num = EmpressSlotsConfig.ShopSpinCostK; if (num3 < num) { SendNoMoneyFeedback(); return; } SemiFunc.StatSetRunCurrency(num3 - num); } else if (!TryChargeLevelHealth(text)) { SendNoMoneyFeedback(); return; } Symbol[] array = GenerateSymbols(); Outcome outcome = EvaluateOutcome(array); if (flag) { num2 = GetWinAmount(outcome, num); if (num2 > 0) { _pendingShopWinAmount = num2; } } else if (outcome != Outcome.NoWin) { num2 = 1; _pendingLevelRewardSteamId = text; _pendingLevelRewardUpgrade = PickRandomUpgradeName(); } if (SemiFunc.IsMultiplayer() && (Object)(object)_photonView != (Object)null) { _photonView.RPC("SpinRPC", (RpcTarget)0, new object[6] { (int)array[0], (int)array[1], (int)array[2], num, num2, (int)outcome }); } else { SpinRPC((int)array[0], (int)array[1], (int)array[2], num, num2, (int)outcome); } } private void SendNoMoneyFeedback() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.IsMultiplayer() && (Object)(object)_photonView != (Object)null) { _photonView.RPC("NoMoneyRPC", (RpcTarget)0, Array.Empty()); } else { NoMoneyRPC(); } } [PunRPC] private void SpinRPC(int symbol0, int symbol1, int symbol2, int betAmount, int winAmount, int outcome, PhotonMessageInfo info = default(PhotonMessageInfo)) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) if (!SemiFunc.IsMultiplayer() || SemiFunc.MasterOnlyRPC(info)) { Symbol[] symbols = new Symbol[3] { ClampSymbol(symbol0), ClampSymbol(symbol1), ClampSymbol(symbol2) }; if (_spinRoutine != null) { ((MonoBehaviour)this).StopCoroutine(_spinRoutine); } _spinRoutine = ((MonoBehaviour)this).StartCoroutine(SpinRoutine(symbols, winAmount, (Outcome)Mathf.Clamp(outcome, 0, 4))); } } [PunRPC] private void SetHomePoseRPC(Vector3 position, Quaternion rotation, PhotonMessageInfo info = default(PhotonMessageInfo)) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) if (!SemiFunc.IsMultiplayer() || SemiFunc.MasterOnlyRPC(info)) { SetHomePose(position, rotation); TeleportHomeImmediate(); } } [PunRPC] private void NoMoneyRPC(PhotonMessageInfo info = default(PhotonMessageInfo)) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) if (!SemiFunc.IsMultiplayer() || SemiFunc.MasterOnlyRPC(info)) { if (_spinRoutine != null) { ((MonoBehaviour)this).StopCoroutine(_spinRoutine); } _spinRoutine = ((MonoBehaviour)this).StartCoroutine(NoMoneyRoutine()); } } private IEnumerator SpinRoutine(Symbol[] symbols, int winAmount, Outcome outcome) { _isSpinning = true; CacheParts(); PlayClip("Electronic_Slot_Machine_Pull_Handle_01", 0.9f); ((MonoBehaviour)this).StartCoroutine(PullHandleRoutine()); float[] startAngles = new float[_rollers.Length]; float[] targetAngles = new float[_rollers.Length]; bool[] stopped = new bool[_rollers.Length]; for (int i = 0; i < _rollers.Length; i++) { startAngles[i] = (((Object)(object)_rollers[i] != (Object)null) ? _rollers[i].localEulerAngles.x : 0f); targetAngles[i] = GetSpinTarget(startAngles[i], symbols[Mathf.Min(i, symbols.Length - 1)], i); } float totalDuration = ReelDurations[ReelDurations.Length - 1] + 0.15f; float timer = 0f; while (timer < totalDuration) { timer += Time.deltaTime; for (int j = 0; j < _rollers.Length; j++) { if ((Object)(object)_rollers[j] == (Object)null) { continue; } float num = ReelDurations[Mathf.Min(j, ReelDurations.Length - 1)]; if (timer < num) { float num2 = Mathf.Clamp01(timer / num); float num3 = 1f - Mathf.Pow(1f - num2, 3f); SetReelAngle(j, Mathf.Lerp(startAngles[j], targetAngles[j], num3)); continue; } SetReelAngle(j, SymbolToRotation(symbols[Mathf.Min(j, symbols.Length - 1)])); if (!stopped[j]) { stopped[j] = true; PlayClip("slot_machine_spin_stop_03", 0.75f); } } yield return null; } for (int k = 0; k < _rollers.Length; k++) { if ((Object)(object)_rollers[k] != (Object)null) { SetReelAngle(k, SymbolToRotation(symbols[Mathf.Min(k, symbols.Length - 1)])); } } if (winAmount > 0) { PlayClip("slot_machine_win_07", (outcome == Outcome.Jackpot) ? 1.15f : 0.9f); ((MonoBehaviour)this).StartCoroutine(WinPulseRoutine(outcome)); GrantPendingShopReward(); GrantPendingLevelReward(); } yield return (object)new WaitForSeconds(0.25f); _isSpinning = false; _spinRoutine = null; } private IEnumerator NoMoneyRoutine() { _isSpinning = true; CacheParts(); PlayClip("slot_machine_spin_stop_03", 0.8f); yield return PullHandleRoutine(); yield return (object)new WaitForSeconds(0.35f); _isSpinning = false; _spinRoutine = null; } private IEnumerator PullHandleRoutine() { if (!((Object)(object)_handle == (Object)null)) { Quaternion rest = _handleRestRotation; Quaternion pulled = rest * Quaternion.Euler(-42f, 0f, 0f); float timer2 = 0f; while (timer2 < 0.16f) { timer2 += Time.deltaTime; _handle.localRotation = Quaternion.Slerp(rest, pulled, Mathf.Clamp01(timer2 / 0.16f)); yield return null; } timer2 = 0f; while (timer2 < 0.38f) { timer2 += Time.deltaTime; _handle.localRotation = Quaternion.Slerp(pulled, rest, Mathf.Clamp01(timer2 / 0.38f)); yield return null; } _handle.localRotation = rest; } } private IEnumerator WinPulseRoutine(Outcome outcome) { Color color = (Color)(outcome switch { Outcome.Jackpot => new Color(1f, 0.25f, 0.95f), Outcome.BigWin => new Color(1f, 0.78f, 0.15f), Outcome.SmallWin => new Color(0.25f, 1f, 0.55f), _ => new Color(0.4f, 0.85f, 1f), }); GameObject lightObject = new GameObject("EmpressSlotMachineWinLight") { hideFlags = (HideFlags)61 }; lightObject.transform.SetParent(((Component)this).transform, false); lightObject.transform.localPosition = new Vector3(0f, 1.05f, 0f); Light light = lightObject.AddComponent(); light.type = (LightType)2; light.color = color; light.range = ((outcome == Outcome.Jackpot) ? 4.5f : 2.8f); float timer = 0f; while (timer < 1.25f) { timer += Time.deltaTime; float num = Mathf.Sin(timer * 22f) * 0.5f + 0.5f; light.intensity = Mathf.Lerp(0.5f, (outcome == Outcome.Jackpot) ? 5f : 2.5f, num) * (1f - timer / 1.25f); yield return null; } Object.Destroy((Object)(object)lightObject); } private void CacheParts() { //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_012b: 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_0130: Unknown result type (might be due to invalid IL or missing references) if (_partsCached && _rollers.Length >= 3 && (Object)(object)_rollers[0] != (Object)null && (Object)(object)_rollers[1] != (Object)null && (Object)(object)_rollers[2] != (Object)null) { return; } Transform[] componentsInChildren = ((Component)this).GetComponentsInChildren(true); _handle = FindByName(componentsInChildren, "Handle"); _handleRestRotation = (((Object)(object)_handle != (Object)null) ? _handle.localRotation : Quaternion.identity); List list = new List(3); Transform[] array = componentsInChildren; foreach (Transform val in array) { if (((Object)val).name == "Roller") { list.Add(val); } } list.Sort((Transform left, Transform right) => left.position.x.CompareTo(right.position.x)); for (int j = 0; j < _rollers.Length; j++) { _rollers[j] = ((j < list.Count) ? list[j] : null); _rollerBaseEuler[j] = (((Object)(object)_rollers[j] != (Object)null) ? _rollers[j].localEulerAngles : Vector3.zero); } _partsCached = true; } private void StopRigidbodyMotion() { //IL_0022: 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) if (!((Object)(object)_rigidbody == (Object)null) && !_rigidbody.isKinematic) { _rigidbody.velocity = Vector3.zero; _rigidbody.angularVelocity = Vector3.zero; } } private void CreateFallbackBeacon() { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Expected O, but got Unknown if (!((Object)(object)((Component)this).transform.Find("EmpressSlotMachineFallbackBeacon") != (Object)null)) { GameObject obj = GameObject.CreatePrimitive((PrimitiveType)3); ((Object)obj).name = "EmpressSlotMachineFallbackBeacon"; obj.transform.SetParent(((Component)this).transform, false); obj.transform.localPosition = new Vector3(0f, 0.85f, 0f); obj.transform.localRotation = Quaternion.identity; obj.transform.localScale = new Vector3(0.55f, 1.1f, 0.35f); Collider component = obj.GetComponent(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } Renderer component2 = obj.GetComponent(); if ((Object)(object)component2 != (Object)null) { component2.sharedMaterial = new Material(Shader.Find("Standard")) { color = new Color(1f, 0.12f, 0.8f, 1f) }; } } } private static EmpressSlotMachineController? ResolveController(PhysGrabObject physGrabObject) { if ((Object)(object)physGrabObject == (Object)null) { return null; } EmpressSlotMachineController empressSlotMachineController = ((Component)physGrabObject).GetComponent(); if ((Object)(object)empressSlotMachineController == (Object)null) { empressSlotMachineController = ((Component)physGrabObject).GetComponentInChildren(true); } return empressSlotMachineController; } private void RememberInteractor(string? steamId) { if (!string.IsNullOrWhiteSpace(steamId)) { _lastInteractorSteamId = steamId; } } private string? ResolveInteractorSteamId() { if (!string.IsNullOrWhiteSpace(_lastInteractorSteamId)) { return _lastInteractorSteamId; } string primaryGrabberSteamId = EmpressSlotsAccess.GetPrimaryGrabberSteamId(_physGrabObject); if (!string.IsNullOrWhiteSpace(primaryGrabberSteamId)) { _lastInteractorSteamId = primaryGrabberSteamId; return primaryGrabberSteamId; } string playerSteamId = EmpressSlotsAccess.GetPlayerSteamId(EmpressSlotsAccess.GetLocalPlayerAvatar()); if (!string.IsNullOrWhiteSpace(playerSteamId)) { _lastInteractorSteamId = playerSteamId; } return _lastInteractorSteamId; } private static bool TryChargeLevelHealth(string? steamId) { PlayerAvatar val = EmpressSlotsAccess.GetPlayerAvatarFromSteamId(steamId) ?? EmpressSlotsAccess.GetLocalPlayerAvatar(); if ((Object)(object)val == (Object)null || !EmpressSlotsAccess.CanAffectPlayer(val)) { return false; } EmpressSlotsAccess.HurtPlayer(val, EmpressSlotsConfig.LevelSpinHealthCost); return true; } private void GrantPendingShopReward() { if (IsHost() && _pendingShopWinAmount > 0 && IsShopScene()) { SemiFunc.StatSetRunCurrency(SemiFunc.StatGetRunCurrency() + _pendingShopWinAmount); _pendingShopWinAmount = 0; } } private void GrantPendingLevelReward() { if (IsHost() && !string.IsNullOrWhiteSpace(_pendingLevelRewardSteamId) && !string.IsNullOrWhiteSpace(_pendingLevelRewardUpgrade)) { EmpressSlotsAccess.GrantPlayerUpgrade(_pendingLevelRewardSteamId, _pendingLevelRewardUpgrade, 1); _pendingLevelRewardSteamId = null; _pendingLevelRewardUpgrade = null; } } private static string PickRandomUpgradeName() { return LevelUpgradeNames[Random.Range(0, LevelUpgradeNames.Length)]; } private static Transform? FindByName(Transform[] transforms, string name) { foreach (Transform val in transforms) { if (((Object)val).name == name) { return val; } } return null; } private void SetReelAngle(int index, float angle) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) if (index >= 0 && index < _rollers.Length && !((Object)(object)_rollers[index] == (Object)null)) { Vector3 localEulerAngles = _rollerBaseEuler[index]; localEulerAngles.x = Mathf.Repeat(angle, 360f); _rollers[index].localEulerAngles = localEulerAngles; } } private void PlayClip(string clipName, float volume) { if (!((Object)(object)_audioSource == (Object)null)) { AudioClip val = EmpressSlotBundleVisuals.LoadAudioClip(clipName); if (!((Object)(object)val == (Object)null)) { _audioSource.PlayOneShot(val, volume); } } } private static Symbol[] GenerateSymbols() { return new Symbol[3] { (Symbol)Random.Range(0, 6), (Symbol)Random.Range(0, 6), (Symbol)Random.Range(0, 6) }; } private static Outcome EvaluateOutcome(Symbol[] symbols) { if (IsUniform(symbols)) { if (symbols[0] != Symbol.Seven) { return Outcome.BigWin; } return Outcome.Jackpot; } return Outcome.NoWin; } private static int GetWinAmount(Outcome outcome, int betAmount) { return outcome switch { Outcome.Jackpot => betAmount * 25, Outcome.BigWin => betAmount * 10, Outcome.SmallWin => betAmount * 4, Outcome.MiniWin => betAmount * 2, _ => 0, }; } private static bool IsUniform(Symbol[] symbols) { if (symbols[0] == symbols[1]) { return symbols[1] == symbols[2]; } return false; } private static float GetSpinTarget(float startAngle, Symbol symbol, int reelIndex) { float num = SymbolToRotation(symbol); float num2 = Mathf.DeltaAngle(Mathf.Repeat(startAngle, 360f), num); if (num2 < 0f) { num2 += 360f; } return startAngle + num2 + 360f * (float)(4 + reelIndex); } private static float SymbolToRotation(Symbol symbol) { return symbol switch { Symbol.Cherry => 120f, Symbol.Lemon => 240f, Symbol.Grape => 300f, Symbol.Watermelon => 60f, Symbol.Bell => 180f, Symbol.Seven => 0f, _ => 0f, }; } private static Symbol ClampSymbol(int value) { return (Symbol)Mathf.Clamp(value, 0, 5); } private static bool IsHost() { try { return SemiFunc.IsMasterClientOrSingleplayer(); } catch { return false; } } private static bool IsShopScene() { try { return (Object)(object)EmpressSlotsAccess.GetRunManagerInstance() != (Object)null && SemiFunc.RunIsShop(); } catch { return false; } } private static bool IsLevelScene() { try { return (Object)(object)EmpressSlotsAccess.GetRunManagerInstance() != (Object)null && SemiFunc.RunIsLevel(); } catch { return false; } } } internal sealed class EmpressSlotMachinePrefabFactory { public const string PrefabId = "Empress.EmpressSlots.SlotMachine"; public const string PrefabName = "EmpressSlotMachine"; private readonly ManualLogSource _log; private readonly Dictionary _templates = new Dictionary(); private GameObject? _prefabBank; public EmpressSlotMachinePrefabFactory(ManualLogSource log) { _log = log; } public PrefabRef? TryRegister() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) EmpressSlotDefinition empressSlotDefinition = EmpressSlotDefinitions.FindByPrefabName("EmpressSlotMachineVisual"); if (empressSlotDefinition == null) { _log.LogWarning((object)"Slot machine definition is missing."); return null; } ResolveTemplates(); GameObject template = GetTemplate(empressSlotDefinition.VolumeType); if ((Object)(object)template == (Object)null) { return null; } GameObject val = CreatePrefab(empressSlotDefinition, template); return NetworkPrefabs.RegisterNetworkPrefab("Empress.EmpressSlots.SlotMachine", val); } private void ResolveTemplates() { //IL_0031: 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_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) _templates.Clear(); foreach (LevelValuables value in ValuablePresets.AllValuablePresets.Values) { Type[] volumeTypes = EmpressSlotFallbackVisuals.VolumeTypes; foreach (Type val in volumeTypes) { if (!_templates.ContainsKey(val)) { GameObject val2 = FindTemplateInList(EmpressSlotsAccess.GetList(value, val)); if ((Object)(object)val2 != (Object)null) { _templates.Add(val, val2); } } } } } private static GameObject? FindTemplateInList(List? prefabRefs) { if (prefabRefs == null) { return null; } foreach (PrefabRef prefabRef in prefabRefs) { if (prefabRef != null && prefabRef.IsValid()) { GameObject prefab = prefabRef.Prefab; if ((Object)(object)prefab != (Object)null && (Object)(object)prefab.GetComponent() != (Object)null && (Object)(object)prefab.GetComponent() != (Object)null) { return prefab; } } } return null; } private GameObject? GetTemplate(Type type) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) if (_templates.TryGetValue(type, out GameObject value) && (Object)(object)value != (Object)null) { return value; } if (_templates.TryGetValue((Type)3, out value) && (Object)(object)value != (Object)null) { return value; } if (_templates.TryGetValue((Type)2, out value) && (Object)(object)value != (Object)null) { return value; } foreach (GameObject value2 in _templates.Values) { if ((Object)(object)value2 != (Object)null) { return value2; } } return null; } private GameObject CreatePrefab(EmpressSlotDefinition definition, GameObject template) { GameObject val = EnsurePrefabBank(); GameObject val2 = Object.Instantiate(template, val.transform, false); ((Object)val2).name = "EmpressSlotMachine"; ((Object)val2).hideFlags = (HideFlags)61; val2.SetActive(true); RemoveTemplateVisuals(val2); RemoveValuableIdentity(val2); if (!EmpressSlotBundleVisuals.TryAttach(val2.transform, definition)) { EmpressSlotFallbackVisuals.Build(val2.transform, definition); } EmpressSlotGrabBounds.Add(val2.transform, definition); ConfigureStationaryPhysics(val2); (val2.GetComponent() ?? val2.AddComponent()).ConfigurePrefab(definition); return val2; } private GameObject EnsurePrefabBank() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown if ((Object)(object)_prefabBank != (Object)null) { return _prefabBank; } _prefabBank = new GameObject("Empress Slots Prefab Bank") { hideFlags = (HideFlags)61 }; _prefabBank.SetActive(false); Object.DontDestroyOnLoad((Object)(object)_prefabBank); return _prefabBank; } private static void RemoveTemplateVisuals(GameObject prefab) { Renderer[] componentsInChildren = prefab.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren[i]); } MeshFilter[] componentsInChildren2 = prefab.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren2.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren2[i]); } } private static void RemoveValuableIdentity(GameObject prefab) { ValuableObject[] componentsInChildren = prefab.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren[i]); } ValuableDiscoverCustom[] componentsInChildren2 = prefab.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren2.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren2[i]); } WorldSpaceUIValue[] componentsInChildren3 = prefab.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren3.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren3[i]); } } private static void ConfigureStationaryPhysics(GameObject prefab) { Rigidbody component = prefab.GetComponent(); if ((Object)(object)component != (Object)null) { component.mass = 100f; component.drag = 20f; component.angularDrag = 20f; component.useGravity = false; component.constraints = (RigidbodyConstraints)126; } PhysGrabObject component2 = prefab.GetComponent(); if ((Object)(object)component2 != (Object)null) { EmpressSlotsAccess.MarkPhysGrabObjectSpawned(component2); } PhysGrabObjectImpactDetector component3 = prefab.GetComponent(); if ((Object)(object)component3 != (Object)null) { EmpressSlotsAccess.ConfigureStationaryImpactDetector(component3); } } } internal sealed class EmpressSlotMachineSpawner : MonoBehaviour { private static readonly Vector3 ShopWorldPosition = new Vector3(-1.815f, 0.657f, -8.235f); private static readonly Vector3 ShopWorldEuler = new Vector3(0f, 90.556f, 0f); private const float LevelStationSideClearance = 0.9f; private const float LevelSlotPivotHeightFromStationFloor = 0.58f; private PrefabRef? _slotMachinePrefab; private ManualLogSource? _log; private GameObject? _spawned; private float _shopCheckTimer; public void Configure(PrefabRef slotMachinePrefab, ManualLogSource log) { _slotMachinePrefab = slotMachinePrefab; _log = log; } private void Update() { if (_slotMachinePrefab != null) { _shopCheckTimer -= Time.deltaTime; if (!(_shopCheckTimer > 0f)) { _shopCheckTimer = 0.5f; TickPresence(); } } } private void TickPresence() { //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) PrefabRef slotMachinePrefab = _slotMachinePrefab; if (slotMachinePrefab == null) { return; } if (!IsAllowedScene()) { DestroySpawnedIfHost(); return; } if (!IsHost()) { EmpressSlotMachineController? empressSlotMachineController = FindExistingMachine(); _spawned = ((empressSlotMachineController != null) ? ((Component)empressSlotMachineController).gameObject : null); return; } if ((Object)(object)_spawned != (Object)null) { MoveSelectedToHome(_spawned); return; } EmpressSlotMachineController empressSlotMachineController2 = FindExistingMachine(); Vector3 position; Quaternion rotation; if ((Object)(object)empressSlotMachineController2 != (Object)null) { _spawned = ((Component)empressSlotMachineController2).gameObject; DestroyExtraMachinesExcept(_spawned); MoveSelectedToHome(_spawned); } else if (ResolveHomePose(out position, out rotation)) { _spawned = NetworkPrefabs.SpawnNetworkPrefab(slotMachinePrefab, position, rotation, (byte)0, (object[])null); if (!((Object)(object)_spawned == (Object)null)) { ApplyHomePose(_spawned, ref position, rotation); } } } private void DestroySpawnedIfHost() { if (!IsHost()) { _spawned = null; return; } DestroyExtraMachinesExcept(null); _spawned = null; } private void MoveSelectedToHome(GameObject selected) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)selected == (Object)null) && ResolveHomePose(out var position, out var rotation) && !((Object)(object)selected.GetComponent() == (Object)null)) { ApplyHomePose(selected, ref position, rotation); } } private static EmpressSlotMachineController? ApplyHomePose(GameObject selected, ref Vector3 position, Quaternion rotation) { //IL_001b: 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_0029: Unknown result type (might be due to invalid IL or missing references) EmpressSlotMachineController component = selected.GetComponent(); if ((Object)(object)component == (Object)null) { return null; } component.ForceVisibleRenderers(); TryGroundLevelPose(selected, ref position, rotation); component.SetHomePose(position, rotation); component.TeleportHomeImmediate(); component.BroadcastHomePose(); return component; } private void DestroyExtraMachinesExcept(GameObject? keep) { if (!IsHost()) { return; } EmpressSlotMachineController[] array = Object.FindObjectsOfType(); foreach (EmpressSlotMachineController empressSlotMachineController in array) { if (!((Object)(object)empressSlotMachineController == (Object)null) && !((Object)(object)((Component)empressSlotMachineController).gameObject == (Object)(object)keep)) { DestroyMachine(((Component)empressSlotMachineController).gameObject); } } } private static void DestroyMachine(GameObject target) { if ((Object)(object)target == (Object)null) { return; } try { if (SemiFunc.IsMultiplayer()) { PhotonNetwork.Destroy(target); } else { Object.Destroy((Object)(object)target); } } catch { Object.Destroy((Object)(object)target); } } private static bool ResolveHomePose(out Vector3 position, out Quaternion rotation) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0063: 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) if (IsShopScene()) { position = ShopWorldPosition; rotation = Quaternion.Euler(ShopWorldEuler); return true; } if (!IsLevelScene()) { position = ShopWorldPosition; rotation = Quaternion.Euler(ShopWorldEuler); return true; } Transform chargingStationTransform = EmpressSlotsAccess.GetChargingStationTransform(); if ((Object)(object)chargingStationTransform == (Object)null) { position = Vector3.zero; rotation = Quaternion.identity; return false; } ResolveChargingStationPose(chargingStationTransform, out position, out rotation); return true; } private static void ResolveChargingStationPose(Transform chargingStation, out Vector3 position, out Quaternion rotation) { //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_000b: 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_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_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_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: 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_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: 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) Vector3 val = Vector3.ProjectOnPlane(chargingStation.right, Vector3.up); Vector3 val2 = ((Vector3)(ref val)).normalized; if (((Vector3)(ref val2)).sqrMagnitude < 0.01f) { val2 = Vector3.right; } val = Vector3.ProjectOnPlane(chargingStation.forward, Vector3.up); Vector3 val3 = ((Vector3)(ref val)).normalized; if (((Vector3)(ref val3)).sqrMagnitude < 0.01f) { val3 = Vector3.forward; } if (TryGetUsefulBounds(chargingStation, out var bounds)) { float num = ProjectBoundsExtent(bounds, val2); position = ((Bounds)(ref bounds)).center + val2 * (num + 0.9f); position -= val3 * 0.1f; position.y = ((Bounds)(ref bounds)).min.y + 0.58f; } else { position = chargingStation.position + val2 * 1.6f - val3 * 0.1f; position.y = chargingStation.position.y + 0.58f; } rotation = Quaternion.LookRotation(val3, Vector3.up); } private static bool TryGroundLevelPose(GameObject selected, ref Vector3 position, Quaternion rotation) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002f: 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_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) if (!IsLevelScene() || IsShopScene() || !TryGetChargingStationFloor(out var floorY)) { return false; } Transform transform = selected.transform; Vector3 position2 = transform.position; Quaternion rotation2 = transform.rotation; transform.SetPositionAndRotation(position, rotation); Bounds bounds; bool flag = TryGetUsefulBounds(transform, out bounds); transform.SetPositionAndRotation(position2, rotation2); if (!flag) { return false; } float num = floorY - ((Bounds)(ref bounds)).min.y + 0.01f; if (Mathf.Abs(num) < 0.002f) { return false; } position.y += num; return true; } private static bool TryGetChargingStationFloor(out float floorY) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) floorY = 0f; Transform chargingStationTransform = EmpressSlotsAccess.GetChargingStationTransform(); if ((Object)(object)chargingStationTransform == (Object)null || !TryGetUsefulBounds(chargingStationTransform, out var bounds)) { return false; } floorY = ((Bounds)(ref bounds)).min.y; return true; } private static bool TryGetUsefulBounds(Transform root, out Bounds bounds) { //IL_0004: 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_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: 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_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_011c: 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) bool flag = false; bounds = new Bounds(root.position, Vector3.zero); Renderer[] componentsInChildren = ((Component)root).GetComponentsInChildren(false); Bounds bounds2; Vector3 size; foreach (Renderer val in componentsInChildren) { if ((Object)(object)val == (Object)null || val is ParticleSystemRenderer || val is LineRenderer) { continue; } bounds2 = val.bounds; size = ((Bounds)(ref bounds2)).size; if (((Vector3)(ref size)).sqrMagnitude <= 0.001f) { continue; } bounds2 = val.bounds; size = ((Bounds)(ref bounds2)).size; if (!(((Vector3)(ref size)).sqrMagnitude > 100f)) { if (!flag) { bounds = val.bounds; flag = true; } else { ((Bounds)(ref bounds)).Encapsulate(val.bounds); } } } if (flag) { return true; } Collider[] componentsInChildren2 = ((Component)root).GetComponentsInChildren(false); foreach (Collider val2 in componentsInChildren2) { if ((Object)(object)val2 == (Object)null || val2.isTrigger) { continue; } bounds2 = val2.bounds; size = ((Bounds)(ref bounds2)).size; if (((Vector3)(ref size)).sqrMagnitude <= 0.001f) { continue; } bounds2 = val2.bounds; size = ((Bounds)(ref bounds2)).size; if (!(((Vector3)(ref size)).sqrMagnitude > 100f)) { if (!flag) { bounds = val2.bounds; flag = true; } else { ((Bounds)(ref bounds)).Encapsulate(val2.bounds); } } } return flag; } private static float ProjectBoundsExtent(Bounds bounds, Vector3 direction) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: 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_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) Vector3 normalized = ((Vector3)(ref direction)).normalized; return Mathf.Abs(normalized.x) * ((Bounds)(ref bounds)).extents.x + Mathf.Abs(normalized.y) * ((Bounds)(ref bounds)).extents.y + Mathf.Abs(normalized.z) * ((Bounds)(ref bounds)).extents.z; } private static bool IsAllowedScene() { try { return (Object)(object)EmpressSlotsAccess.GetRunManagerInstance() != (Object)null && (SemiFunc.RunIsShop() || EmpressSlotsAccess.CurrentLevelLooksLikeShop() || SemiFunc.RunIsLevel()); } catch { return false; } } private static bool IsShopScene() { try { return (Object)(object)EmpressSlotsAccess.GetRunManagerInstance() != (Object)null && (SemiFunc.RunIsShop() || EmpressSlotsAccess.CurrentLevelLooksLikeShop()); } catch { return false; } } private static bool IsLevelScene() { try { return (Object)(object)EmpressSlotsAccess.GetRunManagerInstance() != (Object)null && SemiFunc.RunIsLevel(); } catch { return false; } } private static bool IsHost() { try { return SemiFunc.IsMasterClientOrSingleplayer(); } catch { return false; } } private static EmpressSlotMachineController? FindExistingMachine() { return Object.FindObjectOfType(); } } internal static class EmpressSlotsAccess { internal readonly struct TruckAnchorCandidate { public string Kind { get; } public Transform Transform { get; } public TruckAnchorCandidate(string kind, Transform transform) { Kind = kind; Transform = transform; } } private delegate void PlayerHealthHurtOtherDelegate(PlayerHealth instance, int damage, Vector3 hurtPosition, bool savingGrace, int enemyIndex, bool hurtByHeal); private delegate void PlayerTumbleRequestDelegate(PlayerTumble instance, bool isTumbling, bool playerInput); private delegate void PlayerTumbleOverrideTimeDelegate(PlayerTumble instance, float time); private delegate void EnemyHealthHurtDelegate(EnemyHealth instance, int damage, Vector3 hurtDirection); private delegate void ImpactDestroyObjectDelegate(PhysGrabObjectImpactDetector instance, bool effects); private delegate PlayerAvatar? PlayerAvatarFromSteamIdDelegate(string steamID); private delegate void PunTesterUpgradeCommandDelegate(PunManager instance, string steamID, string upgradeName, int upgradeNum, PhotonMessageInfo info); private static readonly FieldRef RunManagerInstanceRef = AccessTools.StaticFieldRefAccess(RequiredField(typeof(RunManager), "instance")); private static readonly FieldRef PlayerAvatarInstanceRef = AccessTools.StaticFieldRefAccess(RequiredField(typeof(PlayerAvatar), "instance")); private static readonly FieldRef PunManagerInstanceRef = AccessTools.StaticFieldRefAccess(RequiredField(typeof(PunManager), "instance")); private static readonly FieldRef LevelGeneratorInstanceRef = AccessTools.StaticFieldRefAccess(RequiredField(typeof(LevelGenerator), "Instance")); private static readonly FieldRef TruckSafetySpawnPointInstanceRef = AccessTools.StaticFieldRefAccess(RequiredField(typeof(TruckSafetySpawnPoint), "instance")); private static readonly FieldRef TruckHealerInstanceRef = AccessTools.StaticFieldRefAccess(RequiredField(typeof(TruckHealer), "instance")); private static readonly FieldRef TruckScreenTextInstanceRef = AccessTools.StaticFieldRefAccess(RequiredField(typeof(TruckScreenText), "instance")); private static readonly FieldRef ChargingStationInstanceRef = AccessTools.StaticFieldRefAccess(RequiredField(typeof(ChargingStation), "instance")); private static readonly FieldRef> TinyRef = AccessTools.FieldRefAccess>("tiny"); private static readonly FieldRef> SmallRef = AccessTools.FieldRefAccess>("small"); private static readonly FieldRef> MediumRef = AccessTools.FieldRefAccess>("medium"); private static readonly FieldRef> BigRef = AccessTools.FieldRefAccess>("big"); private static readonly FieldRef> WideRef = AccessTools.FieldRefAccess>("wide"); private static readonly FieldRef> TallRef = AccessTools.FieldRefAccess>("tall"); private static readonly FieldRef> VeryTallRef = AccessTools.FieldRefAccess>("veryTall"); private static readonly FieldRef ValuePresetRef = AccessTools.FieldRefAccess("valuePreset"); private static readonly FieldRef DurabilityPresetRef = AccessTools.FieldRefAccess("durabilityPreset"); private static readonly FieldRef PhysAttributePresetRef = AccessTools.FieldRefAccess("physAttributePreset"); private static readonly FieldRef VolumeTypeRef = AccessTools.FieldRefAccess("volumeType"); private static readonly FieldRef DollarValueOverrideRef = AccessTools.FieldRefAccess("dollarValueOverride"); private static readonly FieldRef DebugVolumeRef = AccessTools.FieldRefAccess("debugVolume"); private static readonly FieldRef ParticleColorsRef = AccessTools.FieldRefAccess("particleColors"); private static readonly FieldRef ValueMinRef = AccessTools.FieldRefAccess("valueMin"); private static readonly FieldRef ValueMaxRef = AccessTools.FieldRefAccess("valueMax"); private static readonly FieldRef FragilityRef = AccessTools.FieldRefAccess("fragility"); private static readonly FieldRef DurabilityRef = AccessTools.FieldRefAccess("durability"); private static readonly FieldRef MassRef = AccessTools.FieldRefAccess("mass"); private static readonly FieldRef GrabbedRef = AccessTools.FieldRefAccess("grabbed"); private static readonly FieldRef GrabbedLocalRef = AccessTools.FieldRefAccess("grabbedLocal"); private static readonly FieldRef HeldByLocalPlayerRef = AccessTools.FieldRefAccess("heldByLocalPlayer"); private static readonly FieldRef> PlayerGrabbingRef = AccessTools.FieldRefAccess>("playerGrabbing"); private static readonly FieldRef SpawnedRef = AccessTools.FieldRefAccess("spawned"); private static readonly FieldRef BreakLevelHeavyRef = AccessTools.FieldRefAccess("breakLevelHeavy"); private static readonly FieldRef BreakLevelMediumRef = AccessTools.FieldRefAccess("breakLevelMedium"); private static readonly FieldRef BreakLevelLightRef = AccessTools.FieldRefAccess("breakLevelLight"); private static readonly FieldRef DestroyDisableRef = AccessTools.FieldRefAccess("destroyDisable"); private static readonly FieldRef DestroyInvestigateRef = AccessTools.FieldRefAccess("destroyInvestigate"); private static readonly FieldRef ImpactDisableRef = AccessTools.FieldRefAccess("impactDisable"); private static readonly FieldRef PlayerHurtDisableRef = AccessTools.FieldRefAccess("playerHurtDisable"); private static readonly FieldRef ParticleDisableRef = AccessTools.FieldRefAccess("particleDisable"); private static readonly FieldRef ParticleBreakSmokeDisableRef = AccessTools.FieldRefAccess("particleBreakSmokeDisable"); private static readonly FieldRef IsIndestructibleRef = AccessTools.FieldRefAccess("isIndestructible"); private static readonly FieldRef IndestructibleBreakEffectsRef = AccessTools.FieldRefAccess("indestructibleBreakEffects"); private static readonly FieldRef RunManagerLevelCurrentRef = AccessTools.FieldRefAccess("levelCurrent"); private static readonly FieldRef LevelNarrativeNameRef = AccessTools.FieldRefAccess("NarrativeName"); private static readonly FieldRef PlayerIsDisabledRef = AccessTools.FieldRefAccess("isDisabled"); private static readonly FieldRef PlayerDeadSetRef = AccessTools.FieldRefAccess("deadSet"); private static readonly FieldRef PlayerSteamIdRef = AccessTools.FieldRefAccess("steamID"); private static readonly FieldRef PlayerHealthRef = AccessTools.FieldRefAccess("playerHealth"); private static readonly FieldRef PlayerTumbleRef = AccessTools.FieldRefAccess("tumble"); private static readonly FieldRef GrabberPlayerAvatarRef = AccessTools.FieldRefAccess("playerAvatar"); private static readonly FieldRef PunManagerPhotonViewRef = AccessTools.FieldRefAccess("photonView"); private static readonly FieldRef LevelPathTruckRef = AccessTools.FieldRefAccess("LevelPathTruck"); private static readonly FieldRef LevelPointRoomRef = AccessTools.FieldRefAccess("Room"); private static readonly FieldRef RoomVolumeTruckRef = AccessTools.FieldRefAccess("Truck"); private static readonly FieldRef RoomVolumeModuleRef = AccessTools.FieldRefAccess("Module"); private static readonly FieldRef BoxColliderDrawGizmosRef = AccessTools.FieldRefAccess("drawGizmos"); private static readonly FieldRef MeshColliderShowGizmoRef = AccessTools.FieldRefAccess("showGizmo"); private static readonly PlayerHealthHurtOtherDelegate PlayerHealthHurtOtherRef = AccessTools.MethodDelegate(RequiredMethod(typeof(PlayerHealth), "HurtOther", typeof(int), typeof(Vector3), typeof(bool), typeof(int), typeof(bool)), (object)null, true); private static readonly PlayerTumbleRequestDelegate PlayerTumbleRequestRef = AccessTools.MethodDelegate(RequiredMethod(typeof(PlayerTumble), "TumbleRequest", typeof(bool), typeof(bool)), (object)null, true); private static readonly PlayerTumbleOverrideTimeDelegate PlayerTumbleOverrideTimeRef = AccessTools.MethodDelegate(RequiredMethod(typeof(PlayerTumble), "TumbleOverrideTime", typeof(float)), (object)null, true); private static readonly EnemyHealthHurtDelegate EnemyHealthHurtRef = AccessTools.MethodDelegate(RequiredMethod(typeof(EnemyHealth), "Hurt", typeof(int), typeof(Vector3)), (object)null, true); private static readonly ImpactDestroyObjectDelegate ImpactDestroyObjectRef = AccessTools.MethodDelegate(RequiredMethod(typeof(PhysGrabObjectImpactDetector), "DestroyObject", typeof(bool)), (object)null, true); private static readonly PlayerAvatarFromSteamIdDelegate PlayerAvatarFromSteamIdRef = AccessTools.MethodDelegate(RequiredMethod(typeof(SemiFunc), "PlayerAvatarGetFromSteamID", typeof(string)), (object)null, true); private static readonly PunTesterUpgradeCommandDelegate PunTesterUpgradeCommandRef = AccessTools.MethodDelegate(RequiredMethod(typeof(PunManager), "TesterUpgradeCommandRPC", typeof(string), typeof(string), typeof(int), typeof(PhotonMessageInfo)), (object)null, true); public static RunManager? GetRunManagerInstance() { return RunManagerInstanceRef.Invoke(); } public static PlayerAvatar? GetLocalPlayerAvatar() { return PlayerAvatarInstanceRef.Invoke(); } public static Transform? GetTruckAnchorTransform() { string anchorKind; return GetTruckAnchorTransform(out anchorKind); } public static Transform? GetChargingStationTransform() { ChargingStation val = ChargingStationInstanceRef.Invoke(); if ((Object)(object)val != (Object)null) { return ((Component)val).transform; } val = Object.FindObjectOfType(); if (!((Object)(object)val != (Object)null)) { return null; } return ((Component)val).transform; } public static Transform? GetTruckAnchorTransform(out string anchorKind) { using (List.Enumerator enumerator = GetTruckAnchorCandidates().GetEnumerator()) { if (enumerator.MoveNext()) { TruckAnchorCandidate current = enumerator.Current; anchorKind = current.Kind; return current.Transform; } } anchorKind = ""; return null; } public static List GetTruckAnchorCandidates() { List list = new List(); TruckHealer val = TruckHealerInstanceRef.Invoke(); if ((Object)(object)val != (Object)null) { AddTruckAnchorCandidate(list, "TruckHealer", ((Component)val).transform); } LevelGenerator val2 = LevelGeneratorInstanceRef.Invoke(); if ((Object)(object)val2 != (Object)null) { LevelPoint val3 = LevelPathTruckRef.Invoke(val2); if ((Object)(object)val3 != (Object)null) { RoomVolume val4 = LevelPointRoomRef.Invoke(val3); if ((Object)(object)val4 != (Object)null) { AddTruckRoomAnchor(list, val4, "LevelPathTruckRoom"); } AddTruckAnchorCandidate(list, "LevelPathTruck", ((Component)val3).transform); } } RoomVolume[] array = Object.FindObjectsOfType(); foreach (RoomVolume val5 in array) { if (!((Object)(object)val5 == (Object)null) && RoomVolumeTruckRef.Invoke(val5)) { AddTruckRoomAnchor(list, val5, "TruckRoom"); } } TruckScreenText val6 = TruckScreenTextInstanceRef.Invoke(); if ((Object)(object)val6 != (Object)null) { AddTruckAnchorCandidate(list, "TruckScreenText", ((Component)val6).transform); } TruckSafetySpawnPoint val7 = TruckSafetySpawnPointInstanceRef.Invoke(); if ((Object)(object)val7 != (Object)null) { AddTruckAnchorCandidate(list, "TruckSafetySpawnPoint", ((Component)val7).transform); } return list; } private static void AddTruckRoomAnchor(List candidates, RoomVolume roomVolume, string roomKind) { Module val = RoomVolumeModuleRef.Invoke(roomVolume); if ((Object)(object)val != (Object)null) { AddTruckAnchorCandidate(candidates, roomKind + "Module", ((Component)val).transform); } else { AddTruckAnchorCandidate(candidates, roomKind, ((Component)roomVolume).transform); } } private static void AddTruckAnchorCandidate(List candidates, string kind, Transform? transform) { if ((Object)(object)transform == (Object)null) { return; } foreach (TruckAnchorCandidate candidate in candidates) { if ((Object)(object)candidate.Transform == (Object)(object)transform || candidate.Kind == kind) { return; } } candidates.Add(new TruckAnchorCandidate(kind, transform)); } public static bool CurrentLevelLooksLikeShop() { RunManager val = RunManagerInstanceRef.Invoke(); if ((Object)(object)val == (Object)null) { return false; } Level val2 = RunManagerLevelCurrentRef.Invoke(val); if ((Object)(object)val2 == (Object)null) { return false; } if (!ContainsShop(((Object)val2).name)) { return ContainsShop(LevelNarrativeNameRef.Invoke(val2)); } return true; } public static PlayerAvatar? GetPlayerAvatarFromSteamId(string? steamId) { if (string.IsNullOrWhiteSpace(steamId)) { return null; } return PlayerAvatarFromSteamIdRef(steamId); } public static string? GetPlayerSteamId(PlayerAvatar? player) { if ((Object)(object)player == (Object)null) { return null; } string text = PlayerSteamIdRef.Invoke(player); if (!string.IsNullOrWhiteSpace(text)) { return text; } return null; } public static string? GetGrabberSteamId(PhysGrabber? grabber) { if ((Object)(object)grabber == (Object)null) { return null; } return GetPlayerSteamId(GrabberPlayerAvatarRef.Invoke(grabber)); } public static string? GetGrabberSteamId(int photonViewId) { PhotonView val = PhotonView.Find(photonViewId); if ((Object)(object)val == (Object)null) { return null; } return GetGrabberSteamId(((Component)val).GetComponent()); } public static string? GetPrimaryGrabberSteamId(PhysGrabObject? physGrabObject) { if ((Object)(object)physGrabObject == (Object)null) { return null; } List list = PlayerGrabbingRef.Invoke(physGrabObject); if (list == null) { return null; } for (int num = list.Count - 1; num >= 0; num--) { string grabberSteamId = GetGrabberSteamId(list[num]); if (!string.IsNullOrWhiteSpace(grabberSteamId)) { return grabberSteamId; } } return null; } public static List GetList(LevelValuables preset, Type type) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected I4, but got Unknown return (int)type switch { 0 => TinyRef.Invoke(preset), 1 => SmallRef.Invoke(preset), 2 => MediumRef.Invoke(preset), 3 => BigRef.Invoke(preset), 4 => WideRef.Invoke(preset), 5 => TallRef.Invoke(preset), 6 => VeryTallRef.Invoke(preset), _ => MediumRef.Invoke(preset), }; } public static void ConfigureValuable(ValuableObject valuable, EmpressSlotDefinition definition) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected I4, but got Unknown ValuePresetRef.Invoke(valuable) = CreateValuePreset(definition); DurabilityPresetRef.Invoke(valuable) = CreateDurabilityPreset(definition); PhysAttributePresetRef.Invoke(valuable) = CreatePhysAttributePreset(definition); VolumeTypeRef.Invoke(valuable) = (Type)(int)definition.VolumeType; DollarValueOverrideRef.Invoke(valuable) = 0; DebugVolumeRef.Invoke(valuable) = false; ParticleColorsRef.Invoke(valuable) = CreateParticleGradient(definition); } public static bool IsGrabbed(PhysGrabObject physGrabObject) { return GrabbedRef.Invoke(physGrabObject); } public static bool IsGrabbedForVoice(PhysGrabObject physGrabObject) { List list = PlayerGrabbingRef.Invoke(physGrabObject); if (!GrabbedRef.Invoke(physGrabObject) && !GrabbedLocalRef.Invoke(physGrabObject) && !HeldByLocalPlayerRef.Invoke(physGrabObject)) { if (list != null) { return list.Count > 0; } return false; } return true; } public static void MarkPhysGrabObjectSpawned(PhysGrabObject physGrabObject) { if ((Object)(object)physGrabObject != (Object)null) { SpawnedRef.Invoke(physGrabObject) = true; } } public static void ConfigureStationaryImpactDetector(PhysGrabObjectImpactDetector detector) { if (!((Object)(object)detector == (Object)null)) { DestroyDisableRef.Invoke(detector) = true; DestroyInvestigateRef.Invoke(detector) = false; ImpactDisableRef.Invoke(detector) = true; PlayerHurtDisableRef.Invoke(detector) = true; ParticleDisableRef.Invoke(detector) = true; ParticleBreakSmokeDisableRef.Invoke(detector) = true; IsIndestructibleRef.Invoke(detector) = true; IndestructibleBreakEffectsRef.Invoke(detector) = false; } } public static ImpactState GetBreakState(PhysGrabObjectImpactDetector detector, int breakLevel) { if (breakLevel != BreakLevelHeavyRef.Invoke(detector)) { if (breakLevel != BreakLevelMediumRef.Invoke(detector)) { if (breakLevel != BreakLevelLightRef.Invoke(detector)) { return (ImpactState)0; } return (ImpactState)1; } return (ImpactState)2; } return (ImpactState)3; } public static bool CanAffectPlayer(PlayerAvatar player) { if ((Object)(object)player != (Object)null && !PlayerIsDisabledRef.Invoke(player) && !PlayerDeadSetRef.Invoke(player)) { return (Object)(object)PlayerHealthRef.Invoke(player) != (Object)null; } return false; } public static void HurtPlayer(PlayerAvatar player, int damage) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) PlayerHealth val = PlayerHealthRef.Invoke(player); if ((Object)(object)val != (Object)null) { PlayerHealthHurtOtherRef(val, damage, Vector3.zero, savingGrace: false, -1, hurtByHeal: false); } } public static bool GrantPlayerUpgrade(string? steamId, string upgradeName, int amount) { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrWhiteSpace(steamId) || string.IsNullOrWhiteSpace(upgradeName) || amount == 0) { return false; } PunManager val = PunManagerInstanceRef.Invoke(); if ((Object)(object)val == (Object)null) { return false; } if (SemiFunc.IsMultiplayer()) { PhotonView val2 = PunManagerPhotonViewRef.Invoke(val); if ((Object)(object)val2 == (Object)null) { return false; } val2.RPC("TesterUpgradeCommandRPC", (RpcTarget)0, new object[3] { steamId, upgradeName, amount }); return true; } PunTesterUpgradeCommandRef(val, steamId, upgradeName, amount, default(PhotonMessageInfo)); return true; } public static void TumblePlayer(PlayerAvatar player, float time) { PlayerTumble val = PlayerTumbleRef.Invoke(player); if (!((Object)(object)val == (Object)null)) { PlayerTumbleRequestRef(val, isTumbling: true, playerInput: false); PlayerTumbleOverrideTimeRef(val, time); } } public static void HurtEnemy(EnemyHealth enemyHealth, int damage, Vector3 hurtDirection) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)enemyHealth != (Object)null) { EnemyHealthHurtRef(enemyHealth, damage, hurtDirection); } } public static void DestroyImpactObject(PhysGrabObjectImpactDetector detector, bool effects) { if ((Object)(object)detector != (Object)null) { ImpactDestroyObjectRef(detector, effects); } } public static void HideGrabMeshColliderGizmo(PhysGrabObjectMeshCollider meshHelper) { if ((Object)(object)meshHelper != (Object)null) { MeshColliderShowGizmoRef.Invoke(meshHelper) = false; } } public static void HideGrabBoxColliderGizmo(PhysGrabObjectBoxCollider boxHelper) { if ((Object)(object)boxHelper != (Object)null) { BoxColliderDrawGizmosRef.Invoke(boxHelper) = false; } } private static Value CreateValuePreset(EmpressSlotDefinition definition) { Value val = ScriptableObject.CreateInstance(); ((Object)val).hideFlags = (HideFlags)61; ((Object)val).name = "Value - " + definition.DisplayName; ValueMinRef.Invoke(val) = definition.ValueMin; ValueMaxRef.Invoke(val) = definition.ValueMax; return val; } private static Durability CreateDurabilityPreset(EmpressSlotDefinition definition) { Durability val = ScriptableObject.CreateInstance(); ((Object)val).hideFlags = (HideFlags)61; ((Object)val).name = "Durability - " + definition.DisplayName; FragilityRef.Invoke(val) = Mathf.Clamp(definition.Fragility + StableJitter(definition.PrefabName, "fragility", 5.5f), 5f, 95f); DurabilityRef.Invoke(val) = Mathf.Clamp(definition.Durability + StableJitter(definition.PrefabName, "durability", 5.5f), 5f, 100f); return val; } private static PhysAttribute CreatePhysAttributePreset(EmpressSlotDefinition definition) { PhysAttribute val = ScriptableObject.CreateInstance(); ((Object)val).hideFlags = (HideFlags)61; ((Object)val).name = "PhysAttribute - " + definition.DisplayName; MassRef.Invoke(val) = definition.Mass; return val; } private static float StableJitter(string name, string salt, float radius) { uint num = 2166136261u; string text = name + ":" + salt; for (int i = 0; i < text.Length; i++) { num ^= text[i]; num *= 16777619; } return ((float)(num & 0xFFFFu) / 65535f * 2f - 1f) * radius; } private static Gradient CreateParticleGradient(EmpressSlotDefinition definition) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_0010: 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_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_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_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) Gradient val = new Gradient(); val.SetKeys((GradientColorKey[])(object)new GradientColorKey[3] { new GradientColorKey(definition.Accent, 0f), new GradientColorKey(Color.Lerp(definition.Primary, definition.Secondary, 0.6f), 0.55f), new GradientColorKey(definition.Secondary, 1f) }, (GradientAlphaKey[])(object)new GradientAlphaKey[3] { new GradientAlphaKey(1f, 0f), new GradientAlphaKey(0.8f, 0.75f), new GradientAlphaKey(0f, 1f) }); return val; } private static bool ContainsShop(string? value) { if (!string.IsNullOrWhiteSpace(value)) { return value.IndexOf("shop", StringComparison.OrdinalIgnoreCase) >= 0; } return false; } private static FieldInfo RequiredField(Type type, string fieldName) { FieldInfo fieldInfo = AccessTools.Field(type, fieldName); if (fieldInfo == null) { throw new MissingFieldException(type.FullName, fieldName); } return fieldInfo; } private static MethodInfo RequiredMethod(Type type, string methodName, params Type[] parameters) { MethodInfo methodInfo = AccessTools.Method(type, methodName, parameters, (Type[])null); if (methodInfo == null) { throw new MissingMethodException(type.FullName, methodName); } return methodInfo; } } internal static class EmpressSlotsConfig { private static ConfigEntry? _shopSpinCost; private static ConfigEntry? _levelSpinHealthCost; public static int ShopSpinCostK => ParseShopCost(_shopSpinCost?.Value); public static int LevelSpinHealthCost => ParseHealthCost(_levelSpinHealthCost?.Value); public static void Bind(ConfigFile config) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Expected O, but got Unknown _shopSpinCost = config.Bind("Gambling", "Shop Spin Cost", "1K", new ConfigDescription("Host-controlled shop spin cost.", (AcceptableValueBase)(object)new AcceptableValueList(new string[3] { "1K", "10K", "100K" }), Array.Empty())); _levelSpinHealthCost = config.Bind("Gambling", "Level Spin Health Cost", "5", new ConfigDescription("Host-controlled health cost for spinning the slot machine during real levels.", (AcceptableValueBase)(object)new AcceptableValueList(new string[4] { "5", "10", "50", "999" }), Array.Empty())); } private static int ParseShopCost(string? value) { if (!(value == "10K")) { if (value == "100K") { return 100; } return 1; } return 10; } private static int ParseHealthCost(string? value) { return value switch { "10" => 10, "50" => 50, "999" => 999, _ => 5, }; } } [HarmonyPatch(typeof(PhysGrabObject), "GrabStarted")] internal static class EmpressSlotsPhysGrabObjectGrabStartedPatch { private static void Postfix(PhysGrabObject __instance, PhysGrabber player) { EmpressSlotMachineController.TriggerFrom(__instance, "GrabStarted", player); } } [HarmonyPatch(typeof(PhysGrabObject), "GrabStartedRPC")] internal static class EmpressSlotsPhysGrabObjectGrabStartedRpcPatch { private static void Postfix(PhysGrabObject __instance, int playerPhotonID) { EmpressSlotMachineController.TriggerFrom(__instance, "GrabStartedRPC", playerPhotonID); } } [HarmonyPatch(typeof(PhysGrabObject), "GrabPlayerAddRPC")] internal static class EmpressSlotsPhysGrabObjectGrabPlayerAddRpcPatch { private static void Postfix(PhysGrabObject __instance, int photonViewID) { EmpressSlotMachineController.TriggerFrom(__instance, "GrabPlayerAddRPC", photonViewID); } } [HarmonyPatch(typeof(PhysGrabObject), "GrabLinkRPC")] internal static class EmpressSlotsPhysGrabObjectGrabLinkRpcPatch { private static void Postfix(PhysGrabObject __instance, int playerPhotonID) { EmpressSlotMachineController.TriggerFrom(__instance, "GrabLinkRPC", playerPhotonID); } } [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("Empress.REPO.EmpressSlots", "Empress Slots", "1.0.0")] public sealed class EmpressSlotsPlugin : BaseUnityPlugin { internal const string PluginGuid = "Empress.REPO.EmpressSlots"; internal const string PluginName = "Empress Slots"; internal const string PluginVersion = "1.0.0"; private static readonly Harmony Harmony = new Harmony("Empress.REPO.EmpressSlots"); private bool _registrationStarted; private EmpressSlotMachineSpawner? _shopSpawner; internal static ManualLogSource Log { get; private set; } = null; private void Awake() { Log = ((BaseUnityPlugin)this).Logger; ((Component)this).gameObject.transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); EmpressSlotsConfig.Bind(((BaseUnityPlugin)this).Config); Harmony.PatchAll(typeof(EmpressSlotsPlugin).Assembly); ((MonoBehaviour)this).StartCoroutine(RegisterWhenREPOLibIsReady()); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Empress Slots v1.0.0 loaded."); } private IEnumerator RegisterWhenREPOLibIsReady() { if (!_registrationStarted) { _registrationStarted = true; while ((Object)(object)EmpressSlotsAccess.GetRunManagerInstance() == (Object)null || ValuablePresets.AllValuablePresets.Count == 0) { yield return null; } yield return null; EmpressSlotBundleVisuals.Initialize(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location) ?? string.Empty, ((BaseUnityPlugin)this).Logger); PrefabRef val = new EmpressSlotMachinePrefabFactory(((BaseUnityPlugin)this).Logger).TryRegister(); if (val == null) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"Empress slot machine could not be registered because no vanilla physics template was available."); yield break; } _shopSpawner = ((Component)this).gameObject.GetComponent() ?? ((Component)this).gameObject.AddComponent(); _shopSpawner.Configure(val, ((BaseUnityPlugin)this).Logger); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Registered the Empress slot machine network prefab. It will spawn in shop and real level truck scenes."); } } } }