Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of BoozeVasya v0.3.12
plugins/BoozeVasya/Reddeq.BoozeVasya.dll
Decompiled a day ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Serialization.Json; using System.Runtime.Versioning; using System.Security.Cryptography; using System.Text; using BepInEx; using BepInEx.Configuration; using BoozeVasya.Core; using BoozeVasya.Integration; using HarmonyLib; using Jotunn; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Events; using UnityEngine.InputSystem; using UnityEngine.Networking; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Reddeq.BoozeVasya")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.3.12.0")] [assembly: AssemblyInformationalVersion("0.3.12")] [assembly: AssemblyProduct("Reddeq.BoozeVasya")] [assembly: AssemblyTitle("Reddeq.BoozeVasya")] [assembly: AssemblyVersion("0.3.12.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace BoozeVasya { [NetworkCompatibility(/*Could not decode attribute arguments.*/)] [BepInPlugin("reddeq.boozevasya", "BoozeVasya", "0.3.12")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class BoozeVasyaPlugin : BaseUnityPlugin { public const string Guid = "reddeq.boozevasya"; private ConfigEntry<KeyboardShortcut> openKey; private ConfigEntry<float> volume; private ScoreManager scores; private Harmony harmony; private string assets; public static BoozeVasyaPlugin Instance { get; private set; } public static MinigameManager Manager { get; private set; } private void Awake() { //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Expected O, but got Unknown //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Expected O, but got Unknown Instance = this; string directoryName = Path.GetDirectoryName(Path.GetFullPath(((BaseUnityPlugin)this).Info.Location)); assets = Path.Combine(directoryName, "assets"); ModText.Initialize(directoryName); PrefabManager.OnVanillaPrefabsAvailable += RegisterTable; ((Component)this).gameObject.AddComponent<WorldLeaderboard>().Initialize(); if (!GUIManager.IsHeadless()) { openKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("General", "OpenKey", new KeyboardShortcut((KeyCode)289, Array.Empty<KeyCode>()), ModText.Get("bv_config_open_key")); volume = ((BaseUnityPlugin)this).Config.Bind<float>("Audio", "Volume", 0.65f, new ConfigDescription(ModText.Get("bv_config_volume"), (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); scores = new ScoreManager(new LocalScoreStorage(Path.Combine(Paths.ConfigPath, "BoozeVasya", "best-score.txt")), delegate(Exception e) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Score storage: " + e.Message)); }); Manager = new MinigameManager(delegate(Exception e) { ((BaseUnityPlugin)this).Logger.LogError((object)e); }); harmony = new Harmony("reddeq.boozevasya"); harmony.PatchAll(typeof(BoozeVasyaPlugin).Assembly); ((BaseUnityPlugin)this).Logger.LogInfo((object)"BoozeVasya ready. Open the minigame with the configured hotkey or build its arcade table with the hammer."); } } private void RegisterTable() { try { ArcadeTable.Register(); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Arcade table registration failed: " + ex)); } finally { PrefabManager.OnVanillaPrefabsAvailable -= RegisterTable; } } public bool OpenGame() { if (Manager != null) { return Manager.Open(() => new BoozeVasyaSession(assets, scores, volume.Value, delegate(string s) { ((BaseUnityPlugin)this).Logger.LogWarning((object)s); })); } return false; } private void Update() { //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) ModText.Refresh(); if (Manager == null) { return; } KeyboardShortcut value = openKey.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { if (Manager.IsOpen) { Manager.Close(); } else { OpenGame(); } } Manager.Update(); } private void OnDisable() { Manager?.Close(); } private void OnDestroy() { PrefabManager.OnVanillaPrefabsAvailable -= RegisterTable; Manager?.Dispose(); Manager = null; Harmony obj = harmony; if (obj != null) { obj.UnpatchSelf(); } ModText.Dispose(); ArcadeBackboard.ReleaseAssets(); ArcadeTableDecor.ReleaseAssets(); ArcadeTableIcon.Release(); if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } } } } namespace BoozeVasya.Integration { public sealed class ArcadeBackboard : MonoBehaviour { private static Material woodMaterial; private static Mesh plankMesh; private static Material[] woodTones; private static Font rankingFont; private Text[] labels; private int revision = -1; private string language; private float nextRefresh; public static void Build(GameObject prefab) { //IL_0042: 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_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Expected O, but got Unknown //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Expected O, but got Unknown //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Expected O, but got Unknown //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0355: Unknown result type (might be due to invalid IL or missing references) //IL_037d: Unknown result type (might be due to invalid IL or missing references) //IL_03bb: Unknown result type (might be due to invalid IL or missing references) //IL_0419: Unknown result type (might be due to invalid IL or missing references) //IL_042d: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_04a0: Unknown result type (might be due to invalid IL or missing references) //IL_04b7: Unknown result type (might be due to invalid IL or missing references) //IL_04f0: 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_00f5: 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) MeshRenderer[] array = (from r in prefab.GetComponentsInChildren<MeshRenderer>(true) where ((Renderer)r).sharedMaterials.Any((Material m) => Object.op_Implicit((Object)(object)m) && Object.op_Implicit((Object)(object)m.mainTexture) && ((Object)m.shader).name == "Custom/Piece" && ((Object)m).name.IndexOf("worn", StringComparison.OrdinalIgnoreCase) < 0) select r).ToArray(); if (array.Length == 0) { throw new InvalidOperationException("Table mesh not found"); } Bounds tabletop = default(Bounds); bool flag = true; MeshRenderer[] array2 = array; foreach (MeshRenderer val in array2) { MeshFilter component = ((Component)val).GetComponent<MeshFilter>(); if (!Object.op_Implicit((Object)(object)component) || !Object.op_Implicit((Object)(object)component.sharedMesh)) { continue; } Bounds bounds = component.sharedMesh.bounds; for (int num2 = 0; num2 < 8; num2++) { Vector3 val2 = ((Bounds)(ref bounds)).center + Vector3.Scale(((Bounds)(ref bounds)).extents, new Vector3((float)(((num2 & 1) != 0) ? 1 : (-1)), (float)(((num2 & 2) != 0) ? 1 : (-1)), (float)(((num2 & 4) != 0) ? 1 : (-1)))); val2 = prefab.transform.InverseTransformPoint(((Component)val).transform.TransformPoint(val2)); if (flag) { ((Bounds)(ref tabletop))..ctor(val2, Vector3.zero); flag = false; } else { ((Bounds)(ref tabletop)).Encapsulate(val2); } } } Material val3 = array.SelectMany((MeshRenderer r) => ((Renderer)r).sharedMaterials).First((Material m) => Object.op_Implicit((Object)(object)m) && Object.op_Implicit((Object)(object)m.mainTexture)); woodMaterial = new Material(val3) { name = "BV_BackboardWood" }; woodTones = (Material[])(object)new Material[4]; float[] array3 = new float[4] { 0.94f, 1f, 1.025f, 0.8f }; for (int num3 = 0; num3 < woodTones.Length; num3++) { woodTones[num3] = new Material(val3) { name = "BV_RusticWood_" + num3 }; if (val3.HasProperty("_Color")) { Color color = val3.GetColor("_Color"); float a = color.a; color *= array3[num3]; color.a = a; woodTones[num3].SetColor("_Color", color); } } RusticWoodMesh.Surface[] array4 = RusticWoodMesh.TableSurfaces(prefab.transform, array, val3, ((Bounds)(ref tabletop)).max.y); Material wood = woodMaterial; float num4 = Mathf.Max(1.5f, ((Bounds)(ref tabletop)).size.x * 0.93f); float y = ((Bounds)(ref tabletop)).max.y; float num5 = ((Bounds)(ref tabletop)).max.z - 0.06f; GameObject val4 = new GameObject("BV_Backboard"); val4.layer = prefab.layer; val4.transform.SetParent(prefab.transform, false); val4.transform.localPosition = new Vector3(((Bounds)(ref tabletop)).center.x, y, num5); float[] array5 = new float[5] { -0.008f, 0.006f, -0.004f, 0.01f, -0.003f }; float[] array6 = new float[5] { -0.35f, 0.28f, -0.22f, 0.32f, -0.16f }; for (int num6 = 0; num6 < 5; num6++) { RoughWood("BackPlank", val4.transform, new Vector3(array5[num6], 0.16f + (float)num6 * 0.25f + array5[(num6 + 2) % 5] * 0.3f, 0.04f + array5[num6] * 0.3f), new Vector3(num4 - Mathf.Abs(array5[num6]), 0.235f + array5[num6] * 0.3f, 0.08f), woodTones[num6 % 3], prefab.layer, array4[num6 % array4.Length], num6).transform.localRotation = Quaternion.Euler(0f, 0f, array6[num6]); } int num7 = 0; float[] array7 = new float[2] { (0f - num4) / 2f, num4 / 2f }; foreach (float num8 in array7) { RoughWood("Post", val4.transform, new Vector3(num8, 0.53f, 0.055f), new Vector3(0.09f, 1.46f, 0.13f), woodTones[0], prefab.layer, array4[num7++ % array4.Length], 5 + num7); } for (int num9 = 0; num9 < 3; num9++) { RoughWood("RankPlate_" + num9, val4.transform, new Vector3(0f, 0.88f - (float)num9 * 0.31f, -0.08f), new Vector3(num4 * 0.88f, 0.255f, 0.075f), woodTones[3], prefab.layer, array4[(num9 + 1) % array4.Length], 10 + num9); } ArcadeTableDecor.Build(prefab, tabletop, wood); ((Behaviour)prefab.AddComponent<ArcadeBackboard>()).enabled = true; } public static void ReleaseAssets() { RusticWoodMesh.Release(); if (woodTones != null) { Material[] array = woodTones; foreach (Material val in array) { if (Object.op_Implicit((Object)(object)val)) { Object.Destroy((Object)(object)val); } } } woodTones = null; if (Object.op_Implicit((Object)(object)woodMaterial)) { Object.Destroy((Object)(object)woodMaterial); } woodMaterial = null; if (Object.op_Implicit((Object)(object)plankMesh)) { Object.Destroy((Object)(object)plankMesh); } plankMesh = null; if (Object.op_Implicit((Object)(object)rankingFont)) { Object.Destroy((Object)(object)rankingFont); } rankingFont = null; } private static GameObject RoughWood(string name, Transform parent, Vector3 position, Vector3 scale, Material material, int layer, RusticWoodMesh.Surface surface, int variant) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: 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) GameObject obj = Wood(name, parent, position, scale, material, layer); obj.GetComponent<MeshFilter>().sharedMesh = RusticWoodMesh.Create(scale, surface, variant); return obj; } internal static GameObject Wood(string name, Transform parent, Vector3 position, Vector3 scale, Material material, int layer) { //IL_0028: 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_0085: Unknown result type (might be due to invalid IL or missing references) GameObject obj = GameObject.CreatePrimitive((PrimitiveType)3); ((Object)obj).name = name; obj.layer = layer; obj.transform.SetParent(parent, false); obj.transform.localPosition = position; obj.transform.localScale = scale; MeshFilter component = obj.GetComponent<MeshFilter>(); if (!Object.op_Implicit((Object)(object)plankMesh)) { plankMesh = Object.Instantiate<Mesh>(component.sharedMesh); ((Object)plankMesh).name = "BV_PlankMesh"; plankMesh.colors = Enumerable.Repeat<Color>(new Color(0f, 0f, 0f, 1f), plankMesh.vertexCount).ToArray(); } component.sharedMesh = plankMesh; obj.GetComponent<Renderer>().sharedMaterial = material; return obj; } private void Start() { //IL_00cd: 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_0114: 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_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) if (GUIManager.IsHeadless()) { return; } Transform val = ((Component)this).transform.Find("BV_Backboard"); if (!Object.op_Implicit((Object)(object)val)) { return; } if (!Object.op_Implicit((Object)(object)rankingFont)) { rankingFont = Object.Instantiate<Font>(GUIManager.Instance.AveriaSerifBold); ((Object)rankingFont).name = "BV_RankingFont"; } labels = (Text[])(object)new Text[3]; Vector2 val8 = default(Vector2); for (int i = 0; i < 3; i++) { Transform val2 = val.Find("RankPlate_" + i); Transform val3 = val.Find("RankText_" + i); GameObject val4 = (GameObject)(Object.op_Implicit((Object)(object)val3) ? ((object)((Component)val3).gameObject) : ((object)new GameObject("RankText_" + i, new Type[2] { typeof(RectTransform), typeof(Canvas) }))); val4.layer = ((Component)this).gameObject.layer; val4.transform.SetParent(val, false); val4.transform.localPosition = new Vector3(0f, val2.localPosition.y, val2.localPosition.z - val2.localScale.z * 0.5f - 0.05f); val4.transform.localScale = Vector3.one * 0.003f; ((RectTransform)val4.transform).sizeDelta = new Vector2(val2.localScale.x / 0.003f - 24f, 72f); Canvas component = val4.GetComponent<Canvas>(); component.renderMode = (RenderMode)2; CanvasScaler val5 = val4.GetComponent<CanvasScaler>(); if (!Object.op_Implicit((Object)(object)val5)) { val5 = val4.AddComponent<CanvasScaler>(); } val5.dynamicPixelsPerUnit = 2f; component.scaleFactor = 2f; Transform val6 = val4.transform.Find("Text"); object obj = (Object.op_Implicit((Object)(object)val6) ? ((object)((Component)val6).gameObject) : ((object)new GameObject("Text", new Type[2] { typeof(RectTransform), typeof(Text) }))); ((GameObject)obj).transform.SetParent(val4.transform, false); RectTransform val7 = (RectTransform)((GameObject)obj).transform; ((Vector2)(ref val8))..ctor(0.5f, 0.5f); val7.anchorMax = val8; val7.anchorMin = val8; val7.anchoredPosition = Vector2.zero; Text component2 = ((GameObject)obj).GetComponent<Text>(); component2.font = rankingFont; component2.fontSize = 40; component2.resizeTextForBestFit = false; component2.alignment = (TextAnchor)4; ((Graphic)component2).color = new Color(0.95f, 0.84f, 0.56f); component2.supportRichText = false; ((Graphic)component2).raycastTarget = false; component2.horizontalOverflow = (HorizontalWrapMode)1; labels[i] = component2; } Refresh(); } private static void SetLabel(Text text, string value) { //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_004a: 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_0064: Unknown result type (might be due to invalid IL or missing references) text.text = value; RectTransform rectTransform = ((Graphic)text).rectTransform; Rect rect = ((RectTransform)((Transform)rectTransform).parent).rect; float width = ((Rect)(ref rect)).width; float num = Mathf.Min(1f, (width - 8f) / Mathf.Max(1f, text.preferredWidth)); ((Transform)rectTransform).localScale = Vector3.one * num; rectTransform.sizeDelta = new Vector2(width / num, 72f / num); } private void Update() { if (labels != null && !(Time.unscaledTime < nextRefresh)) { nextRefresh = Time.unscaledTime + 0.25f; if (language != ModText.Language || (Object.op_Implicit((Object)(object)WorldLeaderboard.Instance) && revision != WorldLeaderboard.Instance.Revision)) { Refresh(); } } } private void Refresh() { language = ModText.Language; WorldLeaderboard instance = WorldLeaderboard.Instance; revision = (Object.op_Implicit((Object)(object)instance) ? instance.Revision : (-1)); for (int i = 0; i < 3; i++) { IReadOnlyList<RankedScore> readOnlyList = (Object.op_Implicit((Object)(object)instance) ? instance.Ranking.Entries : null); SetLabel(labels[i], (readOnlyList != null && i < readOnlyList.Count) ? ModText.Format("bv_rank_entry", i + 1, readOnlyList[i].Name, readOnlyList[i].Score) : ModText.Format("bv_rank_empty", i + 1)); } } } public sealed class ArcadeTable : MonoBehaviour, Hoverable, Interactable { public const string PrefabName = "BV_ArcadeTable"; public static void Register() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Expected O, but got Unknown PieceConfig val = new PieceConfig(); val.Name = "$bv_table_name"; val.Description = "$bv_table_description"; val.PieceTable = "Hammer"; val.Category = "Furniture"; val.Icon = (GUIManager.IsHeadless() ? null : ArcadeTableIcon.Get()); val.Requirements = (RequirementConfig[])(object)new RequirementConfig[1] { new RequirementConfig("Wood", 10, 0, true) }; CustomPiece val2 = new CustomPiece("BV_ArcadeTable", "piece_table", val); ArcadeBackboard.Build(val2.PiecePrefab); val2.PiecePrefab.AddComponent<ArcadeTable>(); PieceManager.Instance.AddPiece(val2); } public float GetHoverOffset() { return 0f; } public string GetHoverName() { return ModText.Get("bv_table_name"); } public string GetHoverText() { return Localization.instance.Localize(ModText.Format("bv_table_hover", GetHoverName(), ModText.Get("bv_table_play"))); } public bool Interact(Humanoid user, bool hold, bool alt) { if (hold || (Object)(object)user != (Object)(object)Player.m_localPlayer) { return false; } if (Object.op_Implicit((Object)(object)BoozeVasyaPlugin.Instance)) { return BoozeVasyaPlugin.Instance.OpenGame(); } return false; } public bool UseItem(Humanoid user, ItemData item) { return false; } } public sealed class ArcadeTableDecor : MonoBehaviour { private static Texture2D portrait; public static void Build(GameObject prefab, Bounds tabletop, Material wood) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_002b: 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_0045: 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_0066: 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_00d0: 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_0142: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Expected O, but got Unknown //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Unknown result type (might be due to invalid IL or missing references) //IL_02fe: Unknown result type (might be due to invalid IL or missing references) //IL_0323: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("BV_TableDecor"); val.layer = prefab.layer; val.transform.SetParent(prefab.transform, false); float x = ((Bounds)(ref tabletop)).center.x; float z = ((Bounds)(ref tabletop)).center.z; float num = ((Bounds)(ref tabletop)).max.y + 0.008f; float x2 = ((Bounds)(ref tabletop)).size.x; float z2 = ((Bounds)(ref tabletop)).size.z; Item("Cup_Left", "Tankard", val.transform, new Vector3(x - x2 * 0.24f, num, z - z2 * 0.24f), -32f, 0.2f); Item("Cup_Right", "Tankard", val.transform, new Vector3(x + x2 * 0.22f, num, z + z2 * 0.12f), 47f, 0.2f); Item("Mead_Amber", "MeadTasty", val.transform, new Vector3(x + x2 * 0.35f, num, z - z2 * 0.07f), -17f, 0.26f); Item("Mead_Health", "MeadHealthMinor", val.transform, new Vector3(x + x2 * 0.32f, num, z + z2 * 0.23f), 21f, 0.24f); GameObject val2 = new GameObject("VasyaPhotoFrame"); val2.layer = prefab.layer; val2.transform.SetParent(val.transform, false); val2.transform.localPosition = new Vector3(x - x2 * 0.34f, num + 0.24f, z + z2 * 0.2f); val2.transform.localRotation = Quaternion.Euler(9f, -12f, -3f); FrameWood("PhotoBack", val2.transform, new Vector3(0f, 0f, 0.012f), new Vector3(0.38f, 0.46f, 0.022f), wood, prefab.layer); float[] array = new float[2] { -1f, 1f }; foreach (float num2 in array) { FrameWood("FrameSide", val2.transform, new Vector3(num2 * 0.1725f, 0f, 0f), new Vector3(0.035f, 0.46f, 0.035f), wood, prefab.layer); FrameWood("FrameEdge", val2.transform, new Vector3(0f, num2 * 0.2125f, 0f), new Vector3(0.38f, 0.035f, 0.035f), wood, prefab.layer); } FrameWood("PhotoStand", val2.transform, new Vector3(0f, -0.12f, 0.105f), new Vector3(0.035f, 0.25f, 0.035f), wood, prefab.layer).transform.localRotation = Quaternion.Euler(-25f, 0f, 0f); prefab.AddComponent<ArcadeTableDecor>(); } private static GameObject FrameWood(string name, Transform parent, Vector3 p, Vector3 size, Material material, int layer) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) GameObject obj = ArcadeBackboard.Wood(name, parent, p, size, material, layer); obj.GetComponent<Collider>().enabled = false; return obj; } private static void Item(string name, string prefabName, Transform parent, Vector3 position, float yaw, float height) { //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Expected O, but got Unknown //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Expected O, but got Unknown //IL_01e0: 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_020e: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Unknown result type (might be due to invalid IL or missing references) //IL_038b: Unknown result type (might be due to invalid IL or missing references) //IL_03a4: Unknown result type (might be due to invalid IL or missing references) //IL_03ab: Unknown result type (might be due to invalid IL or missing references) //IL_03be: Unknown result type (might be due to invalid IL or missing references) //IL_03cb: Unknown result type (might be due to invalid IL or missing references) //IL_03d8: Unknown result type (might be due to invalid IL or missing references) //IL_03e3: Unknown result type (might be due to invalid IL or missing references) //IL_03ea: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_02f3: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_02fe: Unknown result type (might be due to invalid IL or missing references) //IL_0303: Unknown result type (might be due to invalid IL or missing references) //IL_0307: Unknown result type (might be due to invalid IL or missing references) //IL_032d: Unknown result type (might be due to invalid IL or missing references) //IL_0332: Unknown result type (might be due to invalid IL or missing references) //IL_0337: Unknown result type (might be due to invalid IL or missing references) //IL_033c: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Unknown result type (might be due to invalid IL or missing references) //IL_035c: Unknown result type (might be due to invalid IL or missing references) //IL_0349: Unknown result type (might be due to invalid IL or missing references) //IL_034b: Unknown result type (might be due to invalid IL or missing references) GameObject prefab = PrefabManager.Instance.GetPrefab(prefabName); if (!Object.op_Implicit((Object)(object)prefab)) { throw new InvalidOperationException("Missing tabletop decoration: " + prefabName); } Transform val = prefab.transform.Find("model"); if (!Object.op_Implicit((Object)(object)val)) { val = prefab.transform.Find("attach"); } if (!Object.op_Implicit((Object)(object)val)) { val = prefab.transform; } HashSet<Renderer> lodRenderers = new HashSet<Renderer>(); HashSet<Renderer> highest = new HashSet<Renderer>(); LODGroup[] componentsInChildren = prefab.GetComponentsInChildren<LODGroup>(true); for (int i = 0; i < componentsInChildren.Length; i++) { LOD[] lODs = componentsInChildren[i].GetLODs(); LOD[] array = lODs; for (int j = 0; j < array.Length; j++) { Renderer[] renderers = array[j].renderers; foreach (Renderer item in renderers) { lodRenderers.Add(item); } } if (lODs.Length != 0) { Renderer[] renderers = lODs[0].renderers; foreach (Renderer item2 in renderers) { highest.Add(item2); } } } MeshRenderer[] array2 = (from r in ((Component)val).GetComponentsInChildren<MeshRenderer>(true) where (!lodRenderers.Contains((Renderer)(object)r) || highest.Contains((Renderer)(object)r)) && Object.op_Implicit((Object)(object)((Component)r).GetComponent<MeshFilter>()) && Object.op_Implicit((Object)(object)((Component)r).GetComponent<MeshFilter>().sharedMesh) select r).ToArray(); if (array2.Length == 0) { throw new InvalidOperationException("No static decoration mesh: " + prefabName); } GameObject val2 = new GameObject(name); val2.layer = ((Component)parent).gameObject.layer; val2.transform.SetParent(parent, false); val2.transform.localPosition = position; val2.transform.localRotation = Quaternion.Euler(0f, yaw, 0f); GameObject val3 = new GameObject("Visual"); val3.layer = val2.layer; val3.transform.SetParent(val2.transform, false); Bounds val4 = default(Bounds); bool flag = true; MeshRenderer[] array3 = array2; foreach (MeshRenderer val5 in array3) { Mesh sharedMesh = ((Component)val5).GetComponent<MeshFilter>().sharedMesh; Matrix4x4 val6 = prefab.transform.worldToLocalMatrix * ((Component)val5).transform.localToWorldMatrix; GameObject val7 = new GameObject(((Object)val5).name, new Type[2] { typeof(MeshFilter), typeof(MeshRenderer) }) { layer = val2.layer }; val7.transform.SetParent(val3.transform, false); val7.transform.localPosition = Vector4.op_Implicit(((Matrix4x4)(ref val6)).GetColumn(3)); val7.transform.localRotation = ((Matrix4x4)(ref val6)).rotation; val7.transform.localScale = ((Matrix4x4)(ref val6)).lossyScale; val7.GetComponent<MeshFilter>().sharedMesh = sharedMesh; MeshRenderer component = val7.GetComponent<MeshRenderer>(); ((Renderer)component).sharedMaterials = ((Renderer)val5).sharedMaterials; ((Renderer)component).shadowCastingMode = ((Renderer)val5).shadowCastingMode; ((Renderer)component).receiveShadows = ((Renderer)val5).receiveShadows; for (int num = 0; num < 8; num++) { Bounds bounds = sharedMesh.bounds; Vector3 center = ((Bounds)(ref bounds)).center; bounds = sharedMesh.bounds; Vector3 val8 = ((Matrix4x4)(ref val6)).MultiplyPoint3x4(center + Vector3.Scale(((Bounds)(ref bounds)).extents, new Vector3((float)(((num & 1) != 0) ? 1 : (-1)), (float)(((num & 2) != 0) ? 1 : (-1)), (float)(((num & 4) != 0) ? 1 : (-1))))); if (flag) { ((Bounds)(ref val4))..ctor(val8, Vector3.zero); flag = false; } else { ((Bounds)(ref val4)).Encapsulate(val8); } } } float num2 = height / Mathf.Max(0.001f, ((Bounds)(ref val4)).size.y); val3.transform.localScale = Vector3.one * num2; val3.transform.localPosition = new Vector3(0f - ((Bounds)(ref val4)).center.x, 0f - ((Bounds)(ref val4)).min.y, 0f - ((Bounds)(ref val4)).center.z) * num2; } private void Start() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_010b: 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_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: Unknown result type (might be due to invalid IL or missing references) if (GUIManager.IsHeadless()) { return; } Transform val = ((Component)this).transform.Find("BV_TableDecor/VasyaPhotoFrame"); if (!Object.op_Implicit((Object)(object)val)) { return; } if (!Object.op_Implicit((Object)(object)portrait)) { portrait = new Texture2D(2, 2, (TextureFormat)4, true) { name = "BV_VasyaPhotograph", wrapMode = (TextureWrapMode)1, filterMode = (FilterMode)2 }; if (!ImageConversion.LoadImage(portrait, AssetPaths.ReadBytes("vasya-fan-photo.png"), true)) { throw new IOException("Vasya photograph could not be loaded"); } } Transform val2 = val.Find("VasyaPhotograph"); GameObject val3 = (GameObject)(Object.op_Implicit((Object)(object)val2) ? ((object)((Component)val2).gameObject) : ((object)new GameObject("VasyaPhotograph", new Type[2] { typeof(RectTransform), typeof(Canvas) }))); val3.layer = ((Component)this).gameObject.layer; val3.transform.SetParent(val, false); val3.transform.localPosition = new Vector3(-0.008f, 0f, -0.035f); val3.transform.localScale = Vector3.one * 0.001f; val3.transform.localRotation = Quaternion.identity; RectTransform component = val3.GetComponent<RectTransform>(); Vector2 val4 = default(Vector2); ((Vector2)(ref val4))..ctor(0.5f, 0.5f); component.pivot = val4; Vector2 anchorMin = (component.anchorMax = val4); component.anchorMin = anchorMin; component.sizeDelta = new Vector2(310f, 390f); val3.GetComponent<Canvas>().renderMode = (RenderMode)2; Image component2 = val3.GetComponent<Image>(); if (Object.op_Implicit((Object)(object)component2)) { ((Behaviour)component2).enabled = false; Object.Destroy((Object)(object)component2); } Transform val6 = val3.transform.Find("VasyaPortrait"); object obj = (Object.op_Implicit((Object)(object)val6) ? ((object)((Component)val6).gameObject) : ((object)new GameObject("VasyaPortrait", new Type[2] { typeof(RectTransform), typeof(RawImage) }))); ((GameObject)obj).transform.SetParent(val3.transform, false); RectTransform component3 = ((GameObject)obj).GetComponent<RectTransform>(); ((Vector2)(ref val4))..ctor(0.5f, 0.5f); component3.pivot = val4; anchorMin = (component3.anchorMax = val4); component3.anchorMin = anchorMin; component3.anchoredPosition3D = Vector3.zero; ((Transform)component3).localRotation = Quaternion.identity; ((Transform)component3).localScale = Vector3.one; float num = Mathf.Min(310f / (float)((Texture)portrait).width, 390f / (float)((Texture)portrait).height); component3.sizeDelta = new Vector2((float)((Texture)portrait).width * num, (float)((Texture)portrait).height * num); RawImage component4 = ((GameObject)obj).GetComponent<RawImage>(); component4.texture = (Texture)(object)portrait; ((Graphic)component4).raycastTarget = false; ((Graphic)component4).color = new Color(0.62f, 0.59f, 0.54f, 1f); } public static void ReleaseAssets() { if (Object.op_Implicit((Object)(object)portrait)) { Object.Destroy((Object)(object)portrait); } portrait = null; } } internal static class ArcadeTableIcon { private static Sprite icon; private static Texture2D texture; internal static Sprite Get() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0026: 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_0035: Expected O, but got Unknown //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)icon)) { return icon; } Texture2D val = new Texture2D(2, 2, (TextureFormat)4, true) { name = "BV_ArcadeTableIconTexture", filterMode = (FilterMode)2, wrapMode = (TextureWrapMode)1 }; try { if (!ImageConversion.LoadImage(val, AssetPaths.ReadBytes("arcade-table-icon.png"), true)) { throw new InvalidDataException("Invalid arcade table icon."); } icon = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0); ((Object)icon).name = "BV_ArcadeTableIcon"; texture = val; return icon; } catch { Object.Destroy((Object)(object)val); throw; } } internal static void Release() { if (Object.op_Implicit((Object)(object)icon)) { Object.Destroy((Object)(object)icon); } icon = null; if (Object.op_Implicit((Object)(object)texture)) { Object.Destroy((Object)(object)texture); } texture = null; } } public static class AssetPaths { public static byte[] ReadBytes(string name) { using Stream stream = typeof(AssetPaths).Assembly.GetManifestResourceStream("BoozeVasya.Assets." + name); if (stream == null) { throw new FileNotFoundException("Missing embedded BoozeVasya resource: " + name, name); } using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); return memoryStream.ToArray(); } public static string CacheAudio(string name, string directory) { byte[] array = ReadBytes(name); string text; using (SHA256 sHA = SHA256.Create()) { text = BitConverter.ToString(sHA.ComputeHash(array)).Replace("-", "").ToLowerInvariant(); } Directory.CreateDirectory(directory); string text2 = Path.Combine(directory, Path.GetFileNameWithoutExtension(name) + "-" + text + Path.GetExtension(name)); if (ValidCache(text2, array.Length, text)) { return text2; } string text3 = text2 + "." + Guid.NewGuid().ToString("N") + ".tmp"; try { File.WriteAllBytes(text3, array); try { if (File.Exists(text2)) { File.Replace(text3, text2, null); } else { File.Move(text3, text2); } } catch (IOException) { if (!ValidCache(text2, array.Length, text)) { throw; } } } finally { if (File.Exists(text3)) { File.Delete(text3); } } return text2; } private static bool ValidCache(string path, int size, string hash) { if (!File.Exists(path) || new FileInfo(path).Length != size) { return false; } using FileStream inputStream = File.OpenRead(path); using SHA256 sHA = SHA256.Create(); return BitConverter.ToString(sHA.ComputeHash(inputStream)).Replace("-", "").ToLowerInvariant() == hash; } public static string Resolve(string assets, string name) { string text = Path.Combine(assets, name); if (File.Exists(text)) { return text; } string text2 = Path.Combine(Path.GetDirectoryName(Path.GetFullPath(assets)), name); if (File.Exists(text2)) { return text2; } throw new FileNotFoundException("Missing BoozeVasya resource. Searched: " + text + "; " + text2, name); } public static IEnumerable<string> LocalizationFiles(string pluginDirectory) { string fullPath = Path.GetFullPath(pluginDirectory); string[] array = new string[4] { fullPath, Path.Combine(fullPath, "assets"), Path.Combine(fullPath, "assets", "localization"), Path.Combine(fullPath, "localization") }; string[] array2 = array; foreach (string path in array2) { if (!Directory.Exists(path)) { continue; } string[] files = Directory.GetFiles(path, "*.json"); foreach (string text in files) { string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(text); if (!fileNameWithoutExtension.Equals("manifest", StringComparison.OrdinalIgnoreCase) && !fileNameWithoutExtension.Equals("provenance", StringComparison.OrdinalIgnoreCase)) { yield return text; } } } } } public sealed class AudioController : MonoBehaviour { private AudioSource music; private AudioSource death; private AudioSource gulp; private AudioSource bite; private readonly List<UnityWebRequest> pending = new List<UnityWebRequest>(); private readonly List<AudioClip> clips = new List<AudioClip>(); private bool wantsMusic; private Action<string> report; public void Initialize(string assets, float volume, Action<string> report) { this.report = report; music = Source(volume); death = Source(volume); gulp = Source(volume); bite = Source(volume); music.loop = true; string directory = Path.Combine(Paths.ConfigPath, "BoozeVasya", "cache", "audio"); ((MonoBehaviour)this).StartCoroutine(Load(AssetPaths.CacheAudio("music.ogg", directory), (AudioType)14, music)); ((MonoBehaviour)this).StartCoroutine(Load(AssetPaths.CacheAudio("gameover.wav", directory), (AudioType)20, death)); ((MonoBehaviour)this).StartCoroutine(Load(AssetPaths.CacheAudio("gulp.wav", directory), (AudioType)20, gulp)); ((MonoBehaviour)this).StartCoroutine(Load(AssetPaths.CacheAudio("bite.wav", directory), (AudioType)20, bite)); } private AudioSource Source(float volume) { AudioSource obj = ((Component)this).gameObject.AddComponent<AudioSource>(); obj.playOnAwake = false; obj.spatialBlend = 0f; obj.ignoreListenerPause = true; obj.volume = Mathf.Clamp01(volume); return obj; } private IEnumerator Load(string path, AudioType type, AudioSource source) { //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) UnityWebRequest request = UnityWebRequestMultimedia.GetAudioClip(new Uri(path).AbsoluteUri, type); pending.Add(request); yield return request.SendWebRequest(); try { if ((int)request.result != 1) { report?.Invoke("Audio: " + path + ": " + request.error); yield break; } AudioClip content = DownloadHandlerAudioClip.GetContent(request); clips.Add(content); source.clip = content; if ((Object)(object)source == (Object)(object)music && wantsMusic) { music.Play(); } } finally { pending.Remove(request); request.Dispose(); } } public void Consume(bool pancake) { AudioSource val = (pancake ? bite : gulp); if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.clip)) { val.Play(); } } public void StartMusic() { wantsMusic = true; death.Stop(); gulp.Stop(); bite.Stop(); if (Object.op_Implicit((Object)(object)music.clip)) { music.Play(); } } public void GameOver() { wantsMusic = false; music.Stop(); if (Object.op_Implicit((Object)(object)death.clip)) { death.Play(); } } private void OnDestroy() { ((MonoBehaviour)this).StopAllCoroutines(); foreach (UnityWebRequest item in pending) { item.Abort(); item.Dispose(); } pending.Clear(); foreach (AudioClip clip in clips) { if (Object.op_Implicit((Object)(object)clip)) { Object.Destroy((Object)(object)clip); } } clips.Clear(); } } public interface IMinigameSession : IDisposable { bool IsAlive { get; } void Update(double seconds); } public sealed class BoozeVasyaSession : IMinigameSession, IDisposable { private readonly BoozeVasyaGame game = new BoozeVasyaGame(); private readonly MinigameUI ui; private readonly AudioController audio; private readonly InputController input = new InputController(); private readonly ScoreManager scores; private readonly string characterName; public bool IsAlive => ui.IsAlive; public BoozeVasyaSession(string assets, ScoreManager scores, float volume, Action<string> report) { this.scores = scores; characterName = (Object.op_Implicit((Object)(object)Player.m_localPlayer) ? Player.m_localPlayer.GetPlayerName() : ""); ui = new MinigameUI(assets); try { audio = ui.Root.AddComponent<AudioController>(); audio.Initialize(assets, volume, report); ui.StartRequested += Start; game.Ended += Ended; game.Consumed += Consumed; ui.Render(game, scores.Best); } catch { ui.Dispose(); game.Dispose(); throw; } } private void Start() { if (ui.CanStart(game)) { ui.ClearEffects(); game.Start(); audio.StartMusic(); } } private void Consumed(bool pancake) { audio.Consume(pancake); ui.Consume(pancake, game.Player.Position); } private void Ended(int score) { scores.Record(score); WorldLeaderboard.Instance?.SubmitResult(characterName, score); audio.GameOver(); } public void Update(double seconds) { if (input.StartPressed) { Start(); } game.Advance(seconds, input.Direction()); ui.Render(game, scores.Best); } public void Dispose() { game.Ended -= Ended; game.Consumed -= Consumed; game.Dispose(); ui.Dispose(); } } public sealed class InputController { public bool ClosePressed { get { if (!Input.GetKeyDown((KeyCode)27)) { Gamepad current = Gamepad.current; if (current == null) { return false; } return current.buttonEast.wasPressedThisFrame; } return true; } } public bool StartPressed { get { if (!Input.GetKeyDown((KeyCode)13) && !Input.GetKeyDown((KeyCode)32)) { Gamepad current = Gamepad.current; if (current == null) { return false; } return current.buttonSouth.wasPressedThisFrame; } return true; } } public Vec2 Direction() { //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: 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) float num = 0f; float num2 = 0f; if (Input.GetKey((KeyCode)100) || Input.GetKey((KeyCode)275)) { num += 1f; } if (Input.GetKey((KeyCode)97) || Input.GetKey((KeyCode)276)) { num -= 1f; } if (Input.GetKey((KeyCode)115) || Input.GetKey((KeyCode)274)) { num2 += 1f; } if (Input.GetKey((KeyCode)119) || Input.GetKey((KeyCode)273)) { num2 -= 1f; } if (num != 0f || num2 != 0f) { return new Vec2(num, num2).Normalized; } Gamepad current = Gamepad.current; if (current == null) { return default(Vec2); } Vector2 val = ((InputControl<Vector2>)(object)current.dpad).ReadValue(); if (((Vector2)(ref val)).sqrMagnitude > 0f) { return new Vec2(val.x, 0f - val.y).Normalized; } Vector2 val2 = ((InputControl<Vector2>)(object)current.leftStick).ReadValue(); return new Vec2(val2.x, 0f - val2.y); } } [HarmonyPatch(typeof(Player), "OnDeath")] internal static class PlayerDeathPatch { private static void Prefix(Player __instance) { if ((Object)(object)__instance == (Object)(object)Player.m_localPlayer) { BoozeVasyaPlugin.Manager?.Close(); } } } [HarmonyPatch(typeof(ZNet), "OnDestroy")] internal static class NetworkDestroyedPatch { private static void Prefix() { BoozeVasyaPlugin.Manager?.Close(); } } public sealed class MinigameManager : IDisposable { private IMinigameSession session; private Player owner; private bool blocked; private ValheimMusicMute musicMute; private int closedFrame = -1; private static readonly Func<Player, bool> PlayerCanTakeInput = (Func<Player, bool>)Delegate.CreateDelegate(typeof(Func<Player, bool>), AccessTools.Method(typeof(Player), "TakeInput", (Type[])null, (Type[])null)); private static readonly FieldInfo JotunnBlocked = AccessTools.Field(typeof(GUIManager), "InputBlocked"); private readonly InputController input = new InputController(); private readonly Action<Exception> report; public bool IsOpen => session != null; public bool SuppressMenu { get { if (!IsOpen) { return closedFrame == Time.frameCount; } return true; } } public MinigameManager(Action<Exception> report) { this.report = report; SceneManager.activeSceneChanged += OnSceneChanged; } public bool Open(Func<IMinigameSession> factory) { //IL_007f: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if (IsOpen || !Object.op_Implicit((Object)(object)localPlayer) || ((Character)localPlayer).IsDead() || ((Character)localPlayer).IsTeleporting() || !Object.op_Implicit((Object)(object)GUIManager.CustomGUIFront) || (bool)JotunnBlocked.GetValue(null) || !PlayerCanTakeInput(localPlayer)) { return false; } owner = localPlayer; try { GUIManager.BlockInput(true); blocked = true; musicMute = new ValheimMusicMute(); session = factory(); localPlayer.SetControls(Vector3.zero, false, false, false, false, false, false, false, false, false, false, false); return true; } catch (Exception obj) { Close(); report(obj); return false; } } public void Update() { if (!IsOpen) { return; } if (!Object.op_Implicit((Object)(object)owner) || (Object)(object)owner != (Object)(object)Player.m_localPlayer || ((Character)owner).IsDead() || ((Character)owner).IsTeleporting() || !Object.op_Implicit((Object)(object)ZNet.instance) || !session.IsAlive || input.ClosePressed) { Close(); return; } try { RefreshMusicMute(); session.Update(Time.unscaledDeltaTime); } catch (Exception obj) { Close(); report(obj); } } internal void RefreshMusicMute() { musicMute?.Refresh(); } public void Close() { if (session != null || blocked) { closedFrame = Time.frameCount; } IMinigameSession minigameSession = session; session = null; owner = null; try { minigameSession?.Dispose(); } catch (Exception obj) { report(obj); } finally { try { musicMute?.Dispose(); } finally { musicMute = null; if (blocked) { blocked = false; GUIManager.BlockInput(false); } } } } private void OnSceneChanged(Scene previous, Scene next) { Close(); } public void Dispose() { Close(); SceneManager.activeSceneChanged -= OnSceneChanged; } } [HarmonyPatch(typeof(Player), "TakeInput")] internal static class PlayerInputPatch { private static bool Prefix(Player __instance, ref bool __result) { MinigameManager manager = BoozeVasyaPlugin.Manager; if (manager == null || !manager.IsOpen || (Object)(object)__instance != (Object)(object)Player.m_localPlayer) { return true; } __result = false; return false; } } [HarmonyPatch(typeof(PlayerController), "TakeInput")] internal static class ControllerInputPatch { private static bool Prefix(PlayerController __instance, ref bool __result) { MinigameManager manager = BoozeVasyaPlugin.Manager; if (manager == null || !manager.IsOpen || (Object)(object)((Component)__instance).GetComponent<Player>() != (Object)(object)Player.m_localPlayer) { return true; } __result = false; return false; } } [HarmonyPatch(typeof(GameCamera), "UpdateCamera")] internal static class CameraInputPatch { private static bool Prefix() { MinigameManager manager = BoozeVasyaPlugin.Manager; if (manager == null) { return true; } return !manager.IsOpen; } } [HarmonyPatch(typeof(Menu), "Update")] internal static class EscapeMenuPatch { private static bool Prefix() { MinigameManager manager = BoozeVasyaPlugin.Manager; if (manager == null) { return true; } return !manager.SuppressMenu; } } [HarmonyPatch(typeof(Player), "OnDestroy")] internal static class PlayerDestroyedPatch { private static void Prefix(Player __instance) { if ((Object)(object)__instance == (Object)(object)Player.m_localPlayer) { BoozeVasyaPlugin.Manager?.Close(); } } } public sealed class MinigameUI : IDisposable { private RectTransform board; private RectTransform frame; private static readonly Vector2 FrameSize = new Vector2(552f, 792f); private Image vasya; private Image blue; private PickupEffects effects; private Text score; private Text message; private Text best; private Text startText; private Text help; private Button start; private readonly Dictionary<int, Image> objects = new Dictionary<int, Image>(); private readonly List<int> stale = new List<int>(); private readonly Dictionary<string, Sprite> sprites = new Dictionary<string, Sprite>(); private readonly List<Texture2D> textures = new List<Texture2D>(); private readonly Font font; private AssetBundle fontBundle; public GameObject Root { get; private set; } public bool IsAlive { get { if (Object.op_Implicit((Object)(object)Root)) { return Object.op_Implicit((Object)(object)board); } return false; } } public event Action StartRequested; public MinigameUI(string assets, Transform parent = null) { //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Expected O, but got Unknown //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_00f4: 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_00ff: 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_010a: 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_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Expected O, but got Unknown //IL_0352: Unknown result type (might be due to invalid IL or missing references) //IL_0385: Unknown result type (might be due to invalid IL or missing references) //IL_03d3: Unknown result type (might be due to invalid IL or missing references) //IL_03da: Expected O, but got Unknown //IL_04f6: Unknown result type (might be due to invalid IL or missing references) //IL_0505: Unknown result type (might be due to invalid IL or missing references) //IL_0527: Unknown result type (might be due to invalid IL or missing references) //IL_0536: Unknown result type (might be due to invalid IL or missing references) //IL_055d: Unknown result type (might be due to invalid IL or missing references) //IL_0581: Unknown result type (might be due to invalid IL or missing references) //IL_059d: Expected O, but got Unknown //IL_05c5: Unknown result type (might be due to invalid IL or missing references) //IL_05ed: Unknown result type (might be due to invalid IL or missing references) //IL_05fc: Unknown result type (might be due to invalid IL or missing references) //IL_0645: Unknown result type (might be due to invalid IL or missing references) //IL_064f: Expected O, but got Unknown //IL_0660: Unknown result type (might be due to invalid IL or missing references) //IL_066f: Unknown result type (might be due to invalid IL or missing references) //IL_0691: Unknown result type (might be due to invalid IL or missing references) //IL_06a0: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_0311: Unknown result type (might be due to invalid IL or missing references) //IL_043f: Unknown result type (might be due to invalid IL or missing references) //IL_044e: Unknown result type (might be due to invalid IL or missing references) try { fontBundle = AssetBundle.LoadFromMemory(AssetPaths.ReadBytes("boozevasya-font")); if (!Object.op_Implicit((Object)(object)fontBundle)) { throw new IOException("Could not load original font bundle."); } font = fontBundle.LoadAsset<Font>("Assets/Fonts/Xolonium-Regular.ttf"); if (!Object.op_Implicit((Object)(object)font)) { throw new IOException("Original Xolonium font is missing."); } Root = new GameObject("BoozeVasya.Overlay", new Type[2] { typeof(RectTransform), typeof(Image) }); Root.transform.SetParent(Object.op_Implicit((Object)(object)parent) ? parent : GUIManager.CustomGUIFront.transform, false); RectTransform val = (RectTransform)Root.transform; val.anchorMin = Vector2.zero; val.anchorMax = Vector2.one; Vector2 offsetMin = (val.offsetMax = Vector2.zero); val.offsetMin = offsetMin; ((Graphic)Root.GetComponent<Image>()).color = new Color(0f, 0f, 0f, 0.88f); frame = Rect("WoodenFrame", Root.transform, FrameSize); Texture2D val2 = new Texture2D(2, 2, (TextureFormat)4, false); textures.Add(val2); if (!ImageConversion.LoadImage(val2, AssetPaths.ReadBytes("ui-wood-frame.png"))) { throw new IOException("Invalid wooden frame texture."); } ((Object)val2).name = "BV_WoodenFrame"; ((Texture)val2).filterMode = (FilterMode)1; ((Texture)val2).wrapMode = (TextureWrapMode)1; float[] array = new float[4] { 0f, 144f, ((Texture)val2).width - 144, ((Texture)val2).width }; float[] array2 = new float[4] { 0f, 144f, ((Texture)val2).height - 144, ((Texture)val2).height }; float[] array3 = new float[4] { -276f, -240f, 240f, 276f }; float[] array4 = new float[4] { -396f, -360f, 360f, 396f }; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { if (j != 1 || i != 1) { RectTransform obj = Rect("Carving_" + j + "_" + i, (Transform)(object)frame, new Vector2(array3[j + 1] - array3[j], array4[i + 1] - array4[i])); obj.anchoredPosition = new Vector2((array3[j] + array3[j + 1]) * 0.5f, (array4[i] + array4[i + 1]) * 0.5f); RawImage obj2 = ((Component)obj).gameObject.AddComponent<RawImage>(); obj2.texture = (Texture)(object)val2; ((Graphic)obj2).raycastTarget = false; obj2.uvRect = new Rect(array[j] / (float)((Texture)val2).width, array2[i] / (float)((Texture)val2).height, (array[j + 1] - array[j]) / (float)((Texture)val2).width, (array2[i + 1] - array2[i]) / (float)((Texture)val2).height); } } } board = Rect("Field", Root.transform, new Vector2(480f, 720f)); ((Graphic)((Component)board).gameObject.AddComponent<Image>()).color = new Color(0f, 0.690196f, 0.290196f, 1f); ((Component)board).gameObject.AddComponent<RectMask2D>(); string[] array5 = new string[3] { "vasya", "beer", "pancake" }; foreach (string text in array5) { Texture2D val3 = new Texture2D(2, 2, (TextureFormat)4, false); textures.Add(val3); if (!ImageConversion.LoadImage(val3, AssetPaths.ReadBytes(text + ".png"))) { throw new IOException("Invalid texture: " + text); } ((Texture)val3).filterMode = (FilterMode)1; sprites[text] = Sprite.Create(val3, new Rect(0f, 0f, (float)((Texture)val3).width, (float)((Texture)val3).height), new Vector2(0.5f, 0.5f), 1f); } vasya = SpriteImage("Vasya", "vasya", 0.6f); blue = SpriteImage("Intoxication", "vasya", 0.6f); effects = PickupEffects.Create(board, (Texture)(object)sprites["pancake"].texture, ((Graphic)vasya).rectTransform, ((Graphic)blue).rectTransform); score = Label("Score", new Vector2(240f, 39f), new Vector2(470f, 78f), 64); message = Label("Message", new Vector2(240f, 360f), new Vector2(480f, 180f), 64); start = ((Component)Rect("Start", (Transform)(object)board, new Vector2(200f, 100f))).gameObject.AddComponent<Button>(); At((RectTransform)((Component)start).transform, 240.0, 178.0); Image val4 = ((Component)start).gameObject.AddComponent<Image>(); ((Graphic)val4).color = new Color(0.06f, 0.18f, 0.12f, 0.95f); ((Selectable)start).targetGraphic = (Graphic)(object)val4; startText = Label("StartText", new Vector2(240f, 178f), new Vector2(200f, 100f), 60); startText.resizeTextForBestFit = true; startText.resizeTextMinSize = 22; startText.resizeTextMaxSize = 60; ((UnityEvent)start.onClick).AddListener((UnityAction)delegate { this.StartRequested?.Invoke(); }); best = Label("Best", new Vector2(240f, 667f), new Vector2(470f, 30f), 20); help = Label("Help", new Vector2(240f, 702f), new Vector2(475f, 28f), 14); help.resizeTextForBestFit = true; help.resizeTextMinSize = 10; help.resizeTextMaxSize = 14; } catch { Dispose(); throw; } } private static RectTransform Rect(string name, Transform parent, Vector2 size) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) RectTransform component = new GameObject(name, new Type[1] { typeof(RectTransform) }).GetComponent<RectTransform>(); ((Transform)component).SetParent(parent, false); Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(0.5f, 0.5f); component.anchorMax = val; component.anchorMin = val; component.sizeDelta = size; return component; } private static void At(RectTransform rt, double x, double y) { //IL_0013: 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_0025: Unknown result type (might be due to invalid IL or missing references) Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(0f, 1f); rt.anchorMax = val; rt.anchorMin = val; rt.anchoredPosition = new Vector2((float)x, (float)(0.0 - y)); } private Text Label(string name, Vector2 pos, Vector2 size, int fontSize) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) RectTransform obj = Rect(name, (Transform)(object)board, size); At(obj, pos.x, pos.y); Text obj2 = ((Component)obj).gameObject.AddComponent<Text>(); obj2.font = font; obj2.fontSize = fontSize; obj2.alignment = (TextAnchor)4; ((Graphic)obj2).color = Colors(); ((Graphic)obj2).raycastTarget = false; obj2.horizontalOverflow = (HorizontalWrapMode)0; obj2.verticalOverflow = (VerticalWrapMode)1; return obj2; } private static Color Colors() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return Color.white; } private Image SpriteImage(string name, string sprite, float scale) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) Sprite val = sprites[sprite]; RectTransform parent = board; Rect rect = val.rect; Image obj = ((Component)Rect(name, (Transform)(object)parent, ((Rect)(ref rect)).size * scale)).gameObject.AddComponent<Image>(); obj.sprite = val; ((Graphic)obj).raycastTarget = false; return obj; } public void Consume(bool pancake, Vec2 position) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) effects.Emit(pancake, new Vector2((float)position.X, (float)position.Y)); } public void ClearEffects() { effects.Clear(); } public bool CanStart(BoozeVasyaGame game) { if (game.Phase != GamePhase.Ready) { if (game.Phase == GamePhase.GameOver) { return game.PhaseTime >= 2.0; } return false; } return true; } public void Render(BoozeVasyaGame game, int record) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0030: 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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_03ca: Unknown result type (might be due to invalid IL or missing references) RectTransform val = (RectTransform)Root.transform; Rect rect = val.rect; float num = ((Rect)(ref rect)).width / FrameSize.x; rect = val.rect; float num2 = Mathf.Max(0.01f, Mathf.Min(num, ((Rect)(ref rect)).height / FrameSize.y) * 0.96f); RectTransform obj = board; Vector3 localScale = (((Transform)frame).localScale = Vector3.one * num2); ((Transform)obj).localScale = localScale; At(((Graphic)vasya).rectTransform, game.Player.Position.X, game.Player.Position.Y); At(((Graphic)blue).rectTransform, game.Player.Position.X, game.Player.Position.Y); ((Graphic)blue).color = new Color(0f, 0f, 1f, (float)game.Player.BlueAlpha); bool flag = game.Phase == GamePhase.GetReady || game.Phase == GamePhase.Playing; Image obj2 = vasya; bool enabled = (((Behaviour)blue).enabled = flag); ((Behaviour)obj2).enabled = enabled; score.text = game.Score.ToString(); best.text = ModText.Format("bv_status", record, game.Player.Sobriety); startText.text = ModText.Get("bv_start"); help.text = ModText.Get("bv_controls"); message.text = ((game.Phase == GamePhase.Ready) ? ModText.Get("bv_title") : ((game.Phase == GamePhase.GetReady && game.PhaseTime < 1.0) ? ModText.Get("bv_ready") : ((game.Phase != GamePhase.GameOver) ? "" : ((game.PhaseTime < 1.0) ? ModText.Get("bv_game_over") : ModText.Get("bv_title"))))); ((Component)start).gameObject.SetActive(CanStart(game)); ((Component)((Transform)board).Find("StartText")).gameObject.SetActive(((Component)start).gameObject.activeSelf); stale.Clear(); foreach (int key in objects.Keys) { stale.Add(key); } foreach (Projectile projectile in game.Projectiles) { if (!objects.TryGetValue(projectile.Id, out var value)) { value = SpriteImage("Projectile_" + projectile.Id, projectile.IsPancake ? "pancake" : "beer", projectile.IsPancake ? 0.3f : 0.25f); ((Component)value).transform.SetAsFirstSibling(); objects.Add(projectile.Id, value); } stale.Remove(projectile.Id); At(((Graphic)value).rectTransform, projectile.Position.X, projectile.Position.Y); ((Transform)((Graphic)value).rectTransform).localRotation = Quaternion.Euler(0f, 0f, (float)((0.0 - projectile.Angle) * 57.295780181884766 - (double)((!projectile.IsPancake) ? 90 : 0))); } foreach (int item in stale) { Object.Destroy((Object)(object)((Component)objects[item]).gameObject); objects.Remove(item); } } public void Dispose() { this.StartRequested = null; if (Object.op_Implicit((Object)(object)Root)) { Root.SetActive(false); Object.Destroy((Object)(object)Root); } Root = null; foreach (Sprite value in sprites.Values) { Object.Destroy((Object)(object)value); } foreach (Texture2D texture in textures) { Object.Destroy((Object)(object)texture); } sprites.Clear(); textures.Clear(); objects.Clear(); if (Object.op_Implicit((Object)(object)fontBundle)) { fontBundle.Unload(true); } fontBundle = null; } } public static class ModText { private static readonly Dictionary<string, Dictionary<string, string>> languages = new Dictionary<string, Dictionary<string, string>>(StringComparer.OrdinalIgnoreCase); private static readonly HashSet<string> invalidFormats = new HashSet<string>(); private static Dictionary<string, string> english; private static string appliedLanguage; private static bool applying; private static readonly Action<Localization, string, string> AddWord = (Action<Localization, string, string>)Delegate.CreateDelegate(typeof(Action<Localization, string, string>), AccessTools.Method(typeof(Localization), "AddWord", (Type[])null, (Type[])null)); public static string Language => PlatformPrefs.GetString("language", "English"); public static void Initialize(string pluginDirectory) { languages.Clear(); foreach (string item in AssetPaths.LocalizationFiles(pluginDirectory)) { try { using FileStream stream = File.OpenRead(item); Dictionary<string, string> dictionary = Read(stream); string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(item); if (!languages.TryGetValue(fileNameWithoutExtension, out var value)) { value = (languages[fileNameWithoutExtension] = new Dictionary<string, string>()); } foreach (KeyValuePair<string, string> item2 in dictionary) { if (!string.IsNullOrWhiteSpace(item2.Value)) { value[item2.Key] = item2.Value; } } } catch (Exception ex) { Logger.LogWarning((object)("Localization file " + item + ": " + ex.Message)); } } if (!languages.TryGetValue("English", out var value2)) { throw new FileNotFoundException("BoozeVasya requires external English.json in localization/ beside the DLL."); } english = new Dictionary<string, string>(value2); LocalizationManager.OnLocalizationAdded += Apply; Localization.OnLanguageChange = (Action)Delegate.Combine(Localization.OnLanguageChange, new Action(Apply)); } private static Dictionary<string, string> Read(Stream stream) { return (Dictionary<string, string>)new DataContractJsonSerializer(typeof(Dictionary<string, string>), new DataContractJsonSerializerSettings { UseSimpleDictionaryFormat = true }).ReadObject(stream); } public static void Refresh() { if (appliedLanguage != Language) { Apply(); } } private static void Apply() { if (applying) { return; } applying = true; try { appliedLanguage = Language; Localization instance = Localization.instance; foreach (string key in english.Keys) { AddWord(instance, key, Get(key)); } } finally { applying = false; } } public static string Get(string key) { if (languages.TryGetValue(Language, out var value) && value.TryGetValue(key, out var value2)) { return value2; } if (!english.TryGetValue(key, out value2)) { return "$" + key; } return value2; } public static string Format(string key, params object[] values) { try { return string.Format(CultureInfo.CurrentCulture, Get(key), values); } catch (FormatException) { if (invalidFormats.Add(key)) { Logger.LogWarning((object)("Invalid localization format: " + key)); } string value; string text = (english.TryGetValue(key, out value) ? value : ("$" + key)); try { return string.Format(CultureInfo.InvariantCulture, text, values); } catch (FormatException) { return text; } } } public static void Dispose() { LocalizationManager.OnLocalizationAdded -= Apply; Localization.OnLanguageChange = (Action)Delegate.Remove(Localization.OnLanguageChange, new Action(Apply)); languages.Clear(); invalidFormats.Clear(); appliedLanguage = null; } } public sealed class PickupEffects : MonoBehaviour { private PickupParticleGraphic beer; private PickupParticleGraphic crumbs; private RectTransform player; private RectTransform overlay; private float reactionAge = 0.42f; private float reactionStrength; private readonly Random random = new Random(); public static PickupEffects Create(RectTransform board, Texture pancake, RectTransform player, RectTransform overlay) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0037: 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_0049: 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_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("PickupEffects", new Type[2] { typeof(RectTransform), typeof(PickupEffects) }); val.transform.SetParent((Transform)(object)board, false); RectTransform component = val.GetComponent<RectTransform>(); component.anchorMin = Vector2.zero; component.anchorMax = Vector2.one; Vector2 offsetMin = (component.offsetMax = Vector2.zero); component.offsetMin = offsetMin; PickupEffects component2 = val.GetComponent<PickupEffects>(); component2.player = player; component2.overlay = overlay; component2.beer = component2.Layer("BeerDrops", null); component2.crumbs = component2.Layer("PancakeCrumbs", pancake); return component2; } private PickupParticleGraphic Layer(string name, Texture texture) { //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_0045: 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_0065: 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_0067: 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_007e: 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) GameObject val = new GameObject(name, new Type[3] { typeof(RectTransform), typeof(CanvasRenderer), typeof(PickupParticleGraphic) }); val.transform.SetParent(((Component)this).transform, false); RectTransform component = val.GetComponent<RectTransform>(); Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(0f, 1f); component.pivot = val2; Vector2 anchorMin = (component.anchorMax = val2); component.anchorMin = anchorMin; component.sizeDelta = new Vector2(480f, 720f); component.anchoredPosition = Vector2.zero; PickupParticleGraphic component2 = val.GetComponent<PickupParticleGraphic>(); component2.Texture = texture; ((Graphic)component2).raycastTarget = false; return component2; } public void Emit(bool pancake, Vector2 position) { //IL_005a: 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_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_009b: 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_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) reactionAge = 0f; reactionStrength = (pancake ? 0.15f : 0.12f); PickupParticleGraphic pickupParticleGraphic = (pancake ? crumbs : beer); int num = (pancake ? 7 : 9); for (int i = 0; i < num; i++) { float num2 = (float)random.NextDouble(); pickupParticleGraphic.Emit(new PickupParticleGraphic.Particle { Position = position + new Vector2(-8f, 10f), Velocity = new Vector2((num2 - 0.5f) * 150f, -45f - (float)random.NextDouble() * 95f), Life = (pancake ? 0.42f : 0.32f) + (float)random.NextDouble() * 0.18f, Size = (float)(pancake ? 7 : 4) + (float)random.NextDouble() * 4f, Angle = (float)random.NextDouble() * 360f, Spin = ((float)random.NextDouble() - 0.5f) * 400f, Tint = (pancake ? Color.white : Color.Lerp(new Color(1f, 0.72f, 0.12f, 0.8f), new Color(1f, 0.94f, 0.45f, 0.85f), num2)), UV = new Vector2(0.4f + (float)random.NextDouble() * 0.2f, 0.4f + (float)random.NextDouble() * 0.2f) }); } } public void Clear() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0033: 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) beer.Clear(); crumbs.Clear(); reactionAge = 0.42f; RectTransform obj = player; Vector3 localScale = (((Transform)overlay).localScale = Vector3.one); ((Transform)obj).localScale = localScale; } private void Update() { Advance(Time.unscaledDeltaTime); } public void Advance(float dt) { //IL_009b: 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) beer.Advance(dt); crumbs.Advance(dt); reactionAge = Mathf.Min(0.42f, reactionAge + dt); float num = ((reactionAge >= 0.42f) ? 0f : (reactionStrength * Mathf.Exp(-7f * reactionAge) * Mathf.Sin(reactionAge * 24f))); RectTransform obj = player; RectTransform obj2 = overlay; Vector3 localScale = default(Vector3); ((Vector3)(ref localScale))..ctor(1f + num, 1f - num * 0.8f, 1f); ((Transform)obj2).localScale = localScale; ((Transform)obj).localScale = localScale; } } public sealed class PickupParticleGraphic : MaskableGraphic { public struct Particle { public Vector2 Position; public Vector2 Velocity; public Vector2 UV; public Color Tint; public float Age; public float Life; public float Size; public float Angle; public float Spin; } public Texture Texture; private readonly Particle[] particles = new Particle[64]; private int next; private static readonly Vector2[] Drop = (Vector2[])(object)new Vector2[6] { new Vector2(0f, 1f), new Vector2(-0.5f, 0.1f), new Vector2(-0.45f, -0.5f), new Vector2(0f, -0.7f), new Vector2(0.45f, -0.5f), new Vector2(0.5f, 0.1f) }; private static readonly Vector2[] Crumb = (Vector2[])(object)new Vector2[3] { new Vector2(-0.6f, -0.4f), new Vector2(0.65f, -0.25f), new Vector2(-0.15f, 0.7f) }; public override Texture mainTexture { get { if (!Object.op_Implicit((Object)(object)Texture)) { return (Texture)(object)Texture2D.whiteTexture; } return Texture; } } public void Emit(Particle particle) { particles[next] = particle; next = (next + 1) % particles.Length; ((Graphic)this).SetVerticesDirty(); } public void Clear() { Array.Clear(particles, 0, particles.Length); next = 0; ((Graphic)this).SetVerticesDirty(); } public void Advance(float dt) { //IL_0053: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) bool flag = false; for (int i = 0; i < particles.Length; i++) { Particle particle = particles[i]; if (!(particle.Life <= 0f) && !(particle.Age >= particle.Life)) { float num = Mathf.Min(dt, particle.Life - particle.Age); ref Vector2 position = ref particle.Position; position += particle.Velocity * num + new Vector2(0f, 130f * num * num); particle.Velocity.y += 260f * num; particle.Age += num; particle.Angle += particle.Spin * num; particles[i] = particle; flag = true; } } if (flag) { ((Graphic)this).SetVerticesDirty(); } } protected override void OnPopulateMesh(VertexHelper mesh) { //IL_0062: 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_00dc: 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_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0105: 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_0121: 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_0134: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0153: 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_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) mesh.Clear(); Particle[] array = particles; Vector2 val3 = default(Vector2); for (int i = 0; i < array.Length; i++) { Particle particle = array[i]; if (!(particle.Life <= 0f) && !(particle.Age >= particle.Life)) { float num = particle.Age / particle.Life; float num2 = particle.Size * (1f - 0.35f * num); Color tint = particle.Tint; tint.a *= (1f - num) * (1f - num); float num3 = Mathf.Sin(particle.Angle * (MathF.PI / 180f)); float num4 = Mathf.Cos(particle.Angle * (MathF.PI / 180f)); Vector2[] array2 = (Object.op_Implicit((Object)(object)Texture) ? Crumb : Drop); int currentVertCount = mesh.currentVertCount; Vector2[] array3 = array2; foreach (Vector2 val in array3) { Vector2 val2 = val * num2; ((Vector2)(ref val3))..ctor(val2.x * num4 - val2.y * num3, val2.x * num3 + val2.y * num4); mesh.AddVert(new Vector3(particle.Position.x + val3.x, 0f - particle.Position.y + val3.y, 0f), Color32.op_Implicit(tint), Vector4.op_Implicit(Object.op_Implicit((Object)(object)Texture) ? (particle.UV + val * 0.14f) : Vector2.zero)); } for (int k = 1; k < array2.Length - 1; k++) { mesh.AddTriangle(currentVertCount, currentVertCount + k, currentVertCount + k + 1); } } } } } internal static class RusticWoodMesh { internal struct Surface { public Rect UV; public Color Mask; public bool LongAxisV; public float Area; } private static readonly List<Mesh> meshes = new List<Mesh>(); internal static Surface[] TableSurfaces(Transform table, MeshRenderer[] renderers, Material material, float top) { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0086: 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_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_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_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) //IL_011a: 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_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_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_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02aa: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_02f9: Unknown result type (might be due to invalid IL or missing references) //IL_0305: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_02de: Unknown result type (might be due to invalid IL or missing references) //IL_0343: Unknown result type (might be due to invalid IL or missing references) //IL_034c: Unknown result type (might be due to invalid IL or missing references) //IL_0351: Unknown result type (might be due to invalid IL or missing references) //IL_035a: Unknown result type (might be due to invalid IL or missing references) //IL_035f: Unknown result type (might be due to invalid IL or missing references) //IL_0369: Unknown result type (might be due to invalid IL or missing references) //IL_0338: Unknown result type (might be due to invalid IL or missing references) //IL_036e: Unknown result type (might be due to invalid IL or missing references) List<Surface> list = new List<Surface>(); foreach (MeshRenderer val in renderers) { MeshFilter component = ((Component)val).GetComponent<MeshFilter>(); if (!Object.op_Implicit((Object)(object)component) || !Object.op_Implicit((Object)(object)component.sharedMesh) || !component.sharedMesh.isReadable) { continue; } Mesh sharedMesh = component.sharedMesh; Vector3[] vertices = sharedMesh.vertices; Vector2[] uv = sharedMesh.uv; Color[] colors = sharedMesh.colors; if (uv.Length != vertices.Length) { continue; } Matrix4x4 val2 = table.worldToLocalMatrix * ((Component)val).transform.localToWorldMatrix; for (int j = 0; j < sharedMesh.subMeshCount; j++) { if (j >= ((Renderer)val).sharedMateri