Decompiled source of Polaroid Bestiary v0.5.7
BepInEx/plugins/WhiteKnucklePhotoCamera/WhiteKnucklePhotoCamera.dll
Decompiled 3 days 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.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using Rewired; using Steamworks; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.Rendering; using UnityEngine.UI; using WKModUI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyFileVersion("0.5.7.0")] [assembly: AssemblyVersion("0.5.7.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 WKModUI { internal static class SharedLanguage { internal const string Protocol = "ilya.whiteknuckle.shared-language.v1"; private static Dictionary<string, object> State => AppDomain.CurrentDomain.GetData("ilya.whiteknuckle.shared-language.v1") as Dictionary<string, object>; internal static string Current { get { Dictionary<string, object> state = State; if (state != null) { return (string)state["resolved"]; } return "en"; } } internal static string Label { get { if (!(Current == "ru")) { return "ENG"; } return "RU"; } } private static SortedDictionary<string, object[]> Clients(Dictionary<string, object> state) { return (SortedDictionary<string, object[]>)state["clients"]; } internal static string Normalize(string language) { language = (language ?? "").Trim().ToLowerInvariant().Replace('_', '-'); switch (language) { default: if (!language.StartsWith("ru-", StringComparison.Ordinal)) { return "en"; } break; case "ru": case "russian": case "русский": break; } return "ru"; } private static string Choice(string value) { if (!(value == "ru") && !(value == "en")) { return "auto"; } return value; } internal static void Connect(string id, Action<string> apply, Func<bool> visible, string automatic, string legacy, Func<object[]> settings, Action<Exception> error) { Dictionary<string, object> dictionary = State; if (dictionary == null) { object[] array = settings(); dictionary = new Dictionary<string, object>(StringComparer.Ordinal) { { "clients", new SortedDictionary<string, object[]>(StringComparer.Ordinal) }, { "read", array[1] }, { "write", array[2] }, { "choice", Choice(((Func<string>)array[1])()) }, { "allowLegacy", !(bool)array[0] }, { "resolved", "en" } }; AppDomain.CurrentDomain.SetData("ilya.whiteknuckle.shared-language.v1", dictionary); } Clients(dictionary)[id] = new object[4] { apply, visible, Normalize(automatic), error }; if ((bool)dictionary["allowLegacy"] && (legacy == "ru" || legacy == "en")) { SetChoice(legacy); } Refresh(dictionary); Apply(Clients(dictionary)[id], (string)dictionary["resolved"]); } internal static void Disconnect(string id) { Dictionary<string, object> state = State; if (state != null) { Clients(state).Remove(id); Refresh(state); } } internal static void Automatic(string id, string language) { Dictionary<string, object> state = State; if (state != null && Clients(state).TryGetValue(id, out var value)) { value[2] = Normalize(language); state["choice"] = Choice(((Func<string>)state["read"])()); Refresh(state); } } internal static void Toggle() { SetChoice((Current == "ru") ? "en" : "ru"); } internal static void SetChoice(string choice) { if (choice != "auto" && choice != "ru" && choice != "en") { throw new ArgumentException("Expected auto, ru or en.", "choice"); } Dictionary<string, object> state = State; if (state == null) { return; } state["allowLegacy"] = false; state["choice"] = choice; try { ((Action<string>)state["write"])(choice); } catch (Exception exception) { foreach (object[] value in Clients(state).Values) { Report(value, exception); } } Refresh(state); } internal static bool OwnsButton(string id) { Dictionary<string, object> state = State; if (state == null) { return false; } foreach (KeyValuePair<string, object[]> item in Clients(state)) { bool flag = false; try { flag = ((Func<bool>)item.Value[1])(); } catch (Exception exception) { Report(item.Value, exception); } if (flag) { return item.Key == id; } } return false; } private static void Refresh(Dictionary<string, object> state) { string text = (string)state["choice"]; if (text == "auto") { text = "en"; using SortedDictionary<string, object[]>.ValueCollection.Enumerator enumerator = Clients(state).Values.GetEnumerator(); if (enumerator.MoveNext()) { text = (string)enumerator.Current[2]; } } if ((string)state["resolved"] == text) { return; } state["resolved"] = text; foreach (object[] item in new List<object[]>(Clients(state).Values)) { Apply(item, text); } } private static void Apply(object[] client, string language) { try { ((Action<string>)client[0])(language); } catch (Exception exception) { Report(client, exception); } } private static void Report(object[] client, Exception exception) { if (client[3] is Action<Exception> action) { try { action(exception); } catch (Exception) { } } } } internal static class SharedLanguageConfig { internal const string Filename = "ilya.whiteknuckle.shared-language.cfg"; internal static object[] Open(string directory) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Expected O, but got Unknown string text = Path.Combine(directory, "ilya.whiteknuckle.shared-language.cfg"); bool flag = File.Exists(text); ConfigFile file = new ConfigFile(text, false) { SaveOnConfigSet = false }; ConfigEntry<string> choice = file.Bind<string>("General", "Language", "auto", new ConfigDescription("Language for all compatible Ilyushkins WK mods. RU/ENG switches every connected mod. auto follows the game; ru = Russian; en = English. / Язык всех совместимых WK-модов Илюшкинса. RU/ENG переключает все подключённые моды. auto = язык игры; ru = русский; en = английский.", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[3] { "auto", "ru", "en" }), Array.Empty<object>())); if (!flag) { file.Save(); } return new object[3] { flag, (Func<string>)(() => choice.Value), (Action<string>)delegate(string value) { choice.Value = value; file.Save(); } }; } } } namespace WhiteKnucklePhotoCamera { internal sealed class AlbumPixelFont { private sealed class Glyph { internal int Advance; internal int X; internal int Y; internal int Width; internal int Height; internal byte[] Mask; } private readonly Dictionary<char, Glyph> _glyphs = new Dictionary<char, Glyph>(); private int _size; internal static AlbumPixelFont Read(Stream stream) { if (stream == null) { throw new InvalidDataException("Album font is missing."); } using BinaryReader binaryReader = new BinaryReader(stream); if (new string(binaryReader.ReadChars(4)) != "WKFT" || binaryReader.ReadInt32() != 1) { throw new InvalidDataException("Invalid album font."); } AlbumPixelFont albumPixelFont = new AlbumPixelFont { _size = binaryReader.ReadInt32() }; int num = binaryReader.ReadInt32(); if (albumPixelFont._size < 8 || albumPixelFont._size > 64 || num < 1 || num > 4096) { throw new InvalidDataException("Invalid album font dimensions."); } for (int i = 0; i < num; i++) { char key = (char)binaryReader.ReadInt32(); Glyph glyph = new Glyph { Advance = binaryReader.ReadInt32(), X = binaryReader.ReadInt32(), Y = binaryReader.ReadInt32(), Width = binaryReader.ReadInt32(), Height = binaryReader.ReadInt32() }; if (glyph.Advance < 0 || glyph.Advance > 128 || glyph.Width < 0 || glyph.Width > 128 || glyph.Height < 0 || glyph.Height > 128) { throw new InvalidDataException("Invalid album glyph."); } glyph.Mask = binaryReader.ReadBytes(glyph.Width * glyph.Height); if (glyph.Mask.Length != glyph.Width * glyph.Height) { throw new EndOfStreamException(); } albumPixelFont._glyphs.Add(key, glyph); } return albumPixelFont; } internal bool Contains(char c) { return _glyphs.ContainsKey(c); } private Glyph Get(char c) { if (!_glyphs.TryGetValue(c, out var value)) { return _glyphs['?']; } return value; } internal float Measure(string text, int size) { float num = 0f; foreach (char c in text) { num += (float)Get(c).Advance * (float)size / (float)_size; } return num; } internal List<string> Lines(string text, int size, int width, bool wrap) { List<string> list = new List<string>(); string[] array = (text ?? "").Replace("\r", "").Split('\n'); foreach (string text2 in array) { if (!wrap || text2.Length == 0) { list.Add(text2); continue; } StringBuilder stringBuilder = new StringBuilder(); string[] array2 = text2.Split(' '); foreach (string text3 in array2) { if (stringBuilder.Length > 0 && Measure(stringBuilder?.ToString() + " " + text3, size) > (float)width) { list.Add(stringBuilder.ToString()); stringBuilder.Clear(); } if (stringBuilder.Length > 0) { stringBuilder.Append(' '); } string text4 = text3; for (int k = 0; k < text4.Length; k++) { char value = text4[k]; if (stringBuilder.Length > 0 && Measure(stringBuilder.ToString() + value, size) > (float)width) { list.Add(stringBuilder.ToString()); stringBuilder.Clear(); } stringBuilder.Append(value); } } list.Add(stringBuilder.ToString()); } return list; } internal int Height(string text, int size, int width) { return Lines(text, size, Math.Max(1, width), wrap: true).Count * (int)Math.Ceiling((double)size * 1.4); } internal byte[] Rasterize(string text, int width, int height, int size, bool wrap, bool center, bool middle, int minimumSize = 10) { if (width < 1 || height < 1 || width > 4096 || height > 8192) { throw new ArgumentOutOfRangeException(); } List<string> list = Lines(text, size, width, wrap); if (!wrap) { float num = 0f; foreach (string item in list) { num = Math.Max(num, Measure(item, size)); } if (num > (float)width) { size = Math.Max(minimumSize, (int)((float)(size * width) / num)); } } float num2 = (float)size / (float)_size; int num3 = (int)Math.Ceiling((double)size * 1.4); float num4 = (middle ? Math.Max(0f, (float)(height - list.Count * num3) * 0.5f) : 0f); byte[] array = new byte[checked(width * height * 4)]; for (int i = 0; i < array.Length; i += 4) { int num5 = i; int num6 = i + 1; byte b; array[i + 2] = (b = byte.MaxValue); array[num5] = (array[num6] = b); } foreach (string item2 in list) { float num7 = (center ? Math.Max(0f, ((float)width - Measure(item2, size)) * 0.5f) : 0f); float num8 = num4 + (float)size; string text2 = item2; foreach (char c in text2) { Glyph glyph = Get(c); int num9 = (int)Math.Ceiling((float)glyph.Width * num2); int num10 = (int)Math.Ceiling((float)glyph.Height * num2); int num11 = (int)Math.Round(num7 + (float)glyph.X * num2); int num12 = (int)Math.Round(num8 + (float)glyph.Y * num2); for (int k = 0; k < num10; k++) { int num13 = num12 + k; if (num13 < 0 || num13 >= height) { continue; } int num14 = Math.Min(glyph.Height - 1, (int)(((float)k + 0.5f) / num2)); for (int l = 0; l < num9; l++) { int num15 = num11 + l; if (num15 >= 0 && num15 < width) { int num16 = Math.Min(glyph.Width - 1, (int)(((float)l + 0.5f) / num2)); int num17 = ((height - 1 - num13) * width + num15) * 4; byte b2 = glyph.Mask[num14 * glyph.Width + num16]; if (b2 != 0) { array[num17 + 3] = Math.Max(array[num17 + 3], b2); } } } } num7 += (float)glyph.Advance * num2; } num4 += (float)num3; } return array; } } internal sealed class AlbumTheme : IDisposable { internal readonly Texture2D Book; internal readonly GUIStyle Search; internal readonly GUISkin Skin; private readonly GUIStyle _button; private readonly GUIStyle _selectedButton; private readonly GUIStyle _dangerButton; private readonly GUIStyle _disabledButton; private readonly AlbumPixelFont _body; private readonly AlbumPixelFont _ui; private readonly AlbumPixelFont _display; private readonly List<Texture2D> _assets = new List<Texture2D>(); private readonly Dictionary<string, Texture2D> _text = new Dictionary<string, Texture2D>(); private readonly Queue<string> _order = new Queue<string>(); private const int Density = 2; private const long TextCacheLimit = 29360128L; private long _textBytes; internal static readonly Color Ink = Rgb(3287587); internal static readonly Color Muted = Rgb(6576204); internal static readonly Color Completed = Rgb(5658706); internal static readonly Color Red = Rgb(8535862); internal static readonly Color Rule = Rgb(13812135); internal static readonly Color Panel = Rgb(16446180); internal static readonly Color AccentWash = Rgb(15654353); internal AlbumTheme() { //IL_015f: 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_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0173: 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_0182: Expected O, but got Unknown //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Expected O, but got Unknown //IL_0198: Expected O, but got Unknown //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_0267: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Expected O, but got Unknown //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_029d: Expected O, but got Unknown //IL_02d5: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Expected O, but got Unknown //IL_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_02fa: Unknown result type (might be due to invalid IL or missing references) //IL_030a: Expected O, but got Unknown Book = LoadTexture("album-book.png"); _body = AlbumPixelFont.Read(Resource("album-body.wkfont")); _ui = AlbumPixelFont.Read(Resource("album-ui.wkfont")); _display = AlbumPixelFont.Read(Resource("album-display.wkfont")); Texture2D normal = Control(15853267, 13220514); Texture2D val = Control(15194562, 11114107); Texture2D val2 = Control(14535085, 10455150); Texture2D normal2 = Control(15654353, 10115662); Texture2D hover = Control(15389382, 9259071); Texture2D normal3 = Control(8535862, 8535862); Texture2D hover2 = Control(10177857, 10177857); Texture2D active = Control(7419182, 7419182); Texture2D val3 = Control(15327183, 14207926); _button = MakeButton(normal, val, val2); _selectedButton = MakeButton(normal2, hover, val2); _dangerButton = MakeButton(normal3, hover2, active); _disabledButton = MakeButton(val3, val3, val3); Search = new GUIStyle(GUI.skin.textField) { fontSize = 18, alignment = (TextAnchor)3, border = new RectOffset(6, 6, 6, 6), padding = new RectOffset(12, 12, 4, 4) }; SetState(Search.normal, Control(16446439, 13220514)); SetState(Search.hover, val); SetState(Search.focused, Control(16775405, 10115662)); SetState(Search.active, Search.focused.background); Skin = Object.Instantiate<GUISkin>(GUI.skin); Skin.settings.cursorColor = Ink; Skin.settings.selectionColor = new Color(0.54f, 0.29f, 0.23f, 0.28f); Skin.verticalScrollbar = new GUIStyle(GUI.skin.verticalScrollbar) { fixedWidth = 11f }; Skin.verticalScrollbarThumb = new GUIStyle(_button) { fixedWidth = 10f }; SetState(Skin.verticalScrollbar.normal, val3); SetState(Skin.verticalScrollbarThumb.normal, val2); Skin.verticalScrollbarUpButton = new GUIStyle(GUIStyle.none) { fixedHeight = 0f }; Skin.verticalScrollbarDownButton = new GUIStyle(GUIStyle.none) { fixedHeight = 0f }; } internal static Color Rgb(int rgb) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) return new Color((float)((rgb >> 16) & 0xFF) / 255f, (float)((rgb >> 8) & 0xFF) / 255f, (float)(rgb & 0xFF) / 255f); } private static Color32 Pixel(int rgb) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) return new Color32((byte)(rgb >> 16), (byte)(rgb >> 8), (byte)rgb, byte.MaxValue); } private static Stream Resource(string name) { return typeof(AlbumTheme).Assembly.GetManifestResourceStream("WhiteKnucklePhotoCamera." + name); } private Texture2D LoadTexture(string name) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown using Stream stream = Resource(name); using MemoryStream memoryStream = new MemoryStream(); if (stream == null) { throw new InvalidDataException("Album artwork is missing."); } stream.CopyTo(memoryStream); Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); if (!ImageConversion.LoadImage(val, memoryStream.ToArray(), true)) { throw new InvalidDataException("Invalid album artwork."); } ((Object)val).name = "WK_" + name; ((Texture)val).filterMode = (FilterMode)1; ((Texture)val).wrapMode = (TextureWrapMode)1; _assets.Add(val); return val; } private static void SetState(GUIStyleState state, Texture2D texture) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) state.background = texture; state.textColor = Ink; } private static GUIStyle MakeButton(Texture2D normal, Texture2D hover, Texture2D active) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_003e: 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_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0094: 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_00ad: Expected O, but got Unknown GUIStyle val = new GUIStyle(GUI.skin.button) { border = new RectOffset(6, 6, 6, 6), padding = new RectOffset(9, 9, 2, 2), margin = new RectOffset(0, 0, 0, 0), alignment = (TextAnchor)4, richText = false }; SetState(val.normal, normal); SetState(val.hover, hover); SetState(val.active, active); SetState(val.focused, hover); SetState(val.onNormal, active); SetState(val.onHover, hover); SetState(val.onActive, active); SetState(val.onFocused, hover); return val; } private Texture2D Control(int surface, int edge) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Expected O, but got Unknown //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) Color32[] array = (Color32[])(object)new Color32[196]; Color32 val = Pixel(surface); Color32 val2 = Pixel(edge); for (int i = 0; i < 14; i++) { for (int j = 0; j < 14; j++) { int num = Math.Min(j, 14 - j - 1); int num2 = Math.Min(i, 14 - i - 1); if (num + num2 >= 3) { array[i * 14 + j] = ((num == 0 || num2 == 0 || num + num2 == 3) ? val2 : val); } } } Texture2D val3 = new Texture2D(14, 14, (TextureFormat)4, false) { name = "WK_Album_Control", filterMode = (FilterMode)1, wrapMode = (TextureWrapMode)1 }; val3.SetPixels32(array); val3.Apply(false, true); _assets.Add(val3); return val3; } internal float TextHeight(string text, int size, int width) { return _body.Height(text, size, width); } internal void Text(Rect rect, string text, int size, Color color, bool wrap = false, bool center = false, bool middle = false, bool display = false, bool strong = false) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Invalid comparison between Unknown and I4 //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_022d: 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_01ce: 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_01de: 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_01ed: Expected O, but got Unknown if (string.IsNullOrEmpty(text) || (int)Event.current.type != 7) { return; } int num = Math.Max(1, Mathf.RoundToInt(((Rect)(ref rect)).width * 2f)); int num2 = Math.Max(1, Mathf.RoundToInt(((Rect)(ref rect)).height * 2f)); string text2 = num + ":" + num2 + ":" + size + ":" + wrap + ":" + center + ":" + middle + ":" + display + ":" + strong + ":" + text; if (!_text.TryGetValue(text2, out var value)) { byte[] array = (display ? _display : (strong ? _ui : _body)).Rasterize(text, num, num2, size * 2, wrap, center, middle, Math.Min(size, 13) * 2); while (_order.Count > 0 && (_order.Count >= 128 || _textBytes + array.Length > 29360128)) { string key = _order.Dequeue(); Texture2D val = _text[key]; _textBytes -= (long)((Texture)val).width * (long)((Texture)val).height * 4; Object.Destroy((Object)(object)val); _text.Remove(key); } value = new Texture2D(num, num2, (TextureFormat)4, false) { name = "WK_Album_Text", filterMode = (FilterMode)1, wrapMode = (TextureWrapMode)1 }; value.LoadRawTextureData(array); value.Apply(false, true); _text.Add(text2, value); _order.Enqueue(text2); _textBytes += array.Length; } Color color2 = GUI.color; GUI.color = color; GUI.DrawTexture(rect, (Texture)(object)value); GUI.color = color2; } internal bool DrawButton(Rect rect, string text, bool selected = false, bool danger = false, int size = 17) { //IL_0000: 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_0066: 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_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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_0051: Unknown result type (might be due to invalid IL or missing references) GUI.color = Color.white; GUIStyle val = ((!GUI.enabled) ? _disabledButton : (danger ? _dangerButton : (selected ? _selectedButton : _button))); bool result = GUI.Button(rect, GUIContent.none, val); Text(color: (!GUI.enabled) ? Muted : (danger ? Panel : (selected ? Red : Ink)), rect: new Rect(((Rect)(ref rect)).x + 7f, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width - 14f, ((Rect)(ref rect)).height), text: text, size: size, wrap: false, center: true, middle: true, display: false, strong: true); return result; } public void Dispose() { foreach (Texture2D asset in _assets) { Object.Destroy((Object)(object)asset); } foreach (Texture2D value in _text.Values) { Object.Destroy((Object)(object)value); } _assets.Clear(); _text.Clear(); _order.Clear(); _textBytes = 0L; Object.Destroy((Object)(object)Skin); } } [HarmonyPatch(typeof(Item_Object_Flashlight), "Execute")] internal static class CameraFlashlightPatch { [HarmonyPrefix] internal static bool Prefix(Item_Object_Flashlight __instance) { if (__instance != null && ((Item_Object)__instance).itemData != null) { return !string.Equals(((Item_Object)__instance).itemData.prefabName, "WK_PhotoCamera", StringComparison.Ordinal); } return true; } } internal sealed class CameraShotMotion { private enum Phase { Idle, Raising, AtEye, Lowering } internal const float RaiseDuration = 0.32f; internal const float SettleDuration = 0.07f; internal const float LowerDuration = 0.34f; private Phase _phase; private float _age; private float _lowerFrom; internal bool IsBusy => _phase != Phase.Idle; internal bool Ready => _phase == Phase.AtEye; internal float Weight { get { if (_phase == Phase.Raising) { return Smooth(_age / 0.32f); } if (_phase == Phase.AtEye) { return 1f; } if (_phase == Phase.Lowering) { return _lowerFrom * (1f - Smooth(_age / 0.34f)); } return 0f; } } internal bool Begin() { if (IsBusy) { return false; } _phase = Phase.Raising; _age = 0f; return true; } internal void Advance(float delta) { if (!(delta <= 0f) && !float.IsNaN(delta) && !float.IsInfinity(delta)) { _age += delta; if (_phase == Phase.Raising && _age >= 0.39f) { _phase = Phase.AtEye; } else if (_phase == Phase.Lowering && _age >= 0.34f) { Reset(); } } } internal void Finish() { if (_phase != Phase.Idle && _phase != Phase.Lowering) { _lowerFrom = Weight; _age = 0f; _phase = Phase.Lowering; } } internal void Reset() { _phase = Phase.Idle; _age = 0f; } private static float Smooth(float t) { t = Math.Max(0f, Math.Min(1f, t)); return t * t * (3f - 2f * t); } } internal sealed class CreatureTarget { internal CreatureDefinition Definition; internal GameObject Root; internal GameObject VisualRoot; internal GameEntity Entity; internal Item Item; internal Behaviour Actor; } internal static class CreatureCatalog { internal static void Refresh(PhotoAlbumStore album) { if (album == null) { return; } foreach (CreatureGuideEntry item in CreatureGuide.All) { album.Register(item.Definition); } album.Save(); } internal static IEnumerable<CreatureTarget> SceneTargets() { HashSet<int> seen = new HashSet<int>(); MonoBehaviour[] array = Object.FindObjectsByType<MonoBehaviour>((FindObjectsSortMode)1); foreach (MonoBehaviour val in array) { if (!((Object)(object)val == (Object)null) && ((Behaviour)val).isActiveAndEnabled) { CreatureTarget creatureTarget = Resolve(val, scene: true); if (creatureTarget != null && creatureTarget.Root.activeInHierarchy && seen.Add(((Object)creatureTarget.VisualRoot).GetInstanceID())) { yield return creatureTarget; } } } Renderer[] array2 = Object.FindObjectsByType<Renderer>((FindObjectsSortMode)1); foreach (Renderer val2 in array2) { if ((Object)(object)val2 == (Object)null || !val2.enabled || !((Component)val2).gameObject.activeInHierarchy) { continue; } Transform val3 = ((Component)val2).transform; int num = 0; while ((Object)(object)val3 != (Object)null && num < 5) { CreatureGuideEntry creatureGuideEntry = CreatureGuide.Find(((Object)val3).name); if (creatureGuideEntry != null && creatureGuideEntry.IsPhotoTarget) { Item_Object componentInParent = ((Component)val3).GetComponentInParent<Item_Object>(); if (!((Object)(object)((Component)val3).GetComponentInParent<ENT_Player>() != (Object)null) && (!((Object)(object)componentInParent != (Object)null) || componentInParent.itemData == null || (!((Object)(object)componentInParent.itemData.inventory != (Object)null) && !componentInParent.itemData.used))) { GameEntity componentInParent2 = ((Component)val3).GetComponentInParent<GameEntity>(); if ((!((Object)(object)componentInParent2 != (Object)null) || (!componentInParent2.dead && !(creatureGuideEntry.Id != "creature:adenocells"))) && seen.Add(((Object)((Component)val3).gameObject).GetInstanceID())) { yield return new CreatureTarget { Root = (((Object)(object)componentInParent2 != (Object)null) ? ((Component)componentInParent2).gameObject : ((Component)val3).gameObject), VisualRoot = ((Component)val3).gameObject, Entity = componentInParent2, Item = (((Object)(object)componentInParent != (Object)null) ? componentInParent.itemData : null), Definition = creatureGuideEntry.Definition }; } } break; } num++; val3 = val3.parent; } } } private static CreatureTarget Resolve(MonoBehaviour behaviour, bool scene) { if ((Object)(object)behaviour == (Object)null || behaviour is DEN_HadalDiver_Segment) { return null; } ENT_Hitbox val = (ENT_Hitbox)(object)((behaviour is ENT_Hitbox) ? behaviour : null); if ((Object)(object)val != (Object)null) { if ((Object)(object)val.entity == (Object)null) { return null; } CreatureTarget creatureTarget = Resolve((MonoBehaviour)(object)val.entity, scene); if (creatureTarget != null) { creatureTarget.VisualRoot = ((Component)val).gameObject; } return creatureTarget; } Item_Object val2 = (Item_Object)(object)((behaviour is Item_Object) ? behaviour : null); if ((Object)(object)val2 != (Object)null) { Item itemData = val2.itemData; if (itemData == null) { return null; } CreatureGuideEntry creatureGuideEntry = CreatureGuide.Find(itemData.prefabName); if ((creatureGuideEntry == null || !creatureGuideEntry.IsPhotoTarget) && ((Object)(object)itemData.handItemAsset == (Object)null || (Object)(object)((Component)itemData.handItemAsset).GetComponentInChildren<Hand_Roach_Base>(true) == (Object)null)) { return null; } if (scene && ((Object)(object)itemData.inventory != (Object)null || itemData.used)) { return null; } return new CreatureTarget { Root = ((Component)val2).gameObject, VisualRoot = ((Component)val2).gameObject, Item = itemData, Actor = (Behaviour)(object)val2, Definition = CreatureIdentity.Create(itemData.prefabName, ((Object)val2).name, "Roach", itemData.itemName) }; } string type = ((object)behaviour).GetType().Name; bool flag = behaviour is Denizen || CreatureIdentity.IsCreatureType(type); if (!flag && !(behaviour is GameEntity)) { return null; } GameEntity val3 = ((behaviour is DEN_HadalDiver) ? null : ((Component)behaviour).GetComponentInParent<GameEntity>()); CreatureGuideEntry creatureGuideEntry2 = (((Object)(object)val3 != (Object)null) ? (CreatureGuide.Find(val3.entityPrefabID) ?? CreatureGuide.Find(((Object)val3).name)) : null); if (!flag && (creatureGuideEntry2 == null || !creatureGuideEntry2.IsPhotoTarget)) { return null; } if (scene && (Object)(object)val3 != (Object)null && val3.dead) { return null; } GameObject val4 = (((Object)(object)val3 != (Object)null) ? ((Component)val3).gameObject : ((Component)behaviour).gameObject); Item_Object componentInParent = val4.GetComponentInParent<Item_Object>(); Item val5 = (((Object)(object)componentInParent != (Object)null) ? componentInParent.itemData : null); if (scene && val5 != null && ((Object)(object)val5.inventory != (Object)null || val5.used)) { return null; } if ((Object)(object)val4.GetComponent<DEN_Buddy>() != (Object)null) { type = "DEN_Buddy"; } if ((Object)(object)val4.GetComponent<ENV_RoachTrader>() != (Object)null) { type = "ENV_RoachTrader"; } return new CreatureTarget { Root = val4, VisualRoot = val4, Entity = val3, Actor = (Behaviour)(object)behaviour, Item = val5, Definition = CreatureIdentity.Create(((Object)(object)val3 != (Object)null) ? val3.entityPrefabID : null, ((Object)val4).name, type) }; } } internal static class CreatureDetector { private sealed class CachedTarget { internal CreatureTarget Target; internal Renderer[] Renderers; } private static readonly List<CachedTarget> Targets = new List<CachedTarget>(); private static float _refreshAt; private static bool _hasSnapshot; internal static void ClearCache() { Targets.Clear(); _hasSnapshot = false; _refreshAt = 0f; } private static void RefreshTargets(bool force) { if (!force && _hasSnapshot && Time.realtimeSinceStartup < _refreshAt) { return; } Targets.Clear(); foreach (CreatureTarget item in CreatureCatalog.SceneTargets()) { if ((Object)(object)item.VisualRoot != (Object)null) { Targets.Add(new CachedTarget { Target = item, Renderers = item.VisualRoot.GetComponentsInChildren<Renderer>(true) }); } } _hasSnapshot = true; _refreshAt = Time.realtimeSinceStartup + 1f; } internal static CreatureDefinition FindBestCreatureInFrame(Camera camera, bool refresh = true) { //IL_0167: 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_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_0251: 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_0258: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_029f: 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_02af: Unknown result type (might be due to invalid IL or missing references) //IL_02ba: Unknown result type (might be due to invalid IL or missing references) //IL_02c9: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_02e9: 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_02f7: 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_02fe: 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_030c: Unknown result type (might be due to invalid IL or missing references) //IL_030e: Unknown result type (might be due to invalid IL or missing references) //IL_0313: Unknown result type (might be due to invalid IL or missing references) //IL_031c: Unknown result type (might be due to invalid IL or missing references) //IL_0321: 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) //IL_0328: Unknown result type (might be due to invalid IL or missing references) //IL_0331: Unknown result type (might be due to invalid IL or missing references) //IL_0336: 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_033d: Unknown result type (might be due to invalid IL or missing references) //IL_0344: Unknown result type (might be due to invalid IL or missing references) //IL_0346: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_0359: Unknown result type (might be due to invalid IL or missing references) //IL_035e: Unknown result type (might be due to invalid IL or missing references) //IL_0361: Unknown result type (might be due to invalid IL or missing references) //IL_0363: Unknown result type (might be due to invalid IL or missing references) //IL_0368: Unknown result type (might be due to invalid IL or missing references) //IL_036a: Unknown result type (might be due to invalid IL or missing references) //IL_037c: Unknown result type (might be due to invalid IL or missing references) //IL_0383: Unknown result type (might be due to invalid IL or missing references) //IL_039f: Unknown result type (might be due to invalid IL or missing references) //IL_03aa: Unknown result type (might be due to invalid IL or missing references) //IL_03b1: Unknown result type (might be due to invalid IL or missing references) //IL_03b8: Unknown result type (might be due to invalid IL or missing references) //IL_03c7: Unknown result type (might be due to invalid IL or missing references) //IL_03d7: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)camera == (Object)null) { return null; } RefreshTargets(refresh); Plane[] array = GeometryUtility.CalculateFrustumPlanes(camera); CreatureDefinition creatureDefinition = null; float num = float.PositiveInfinity; foreach (CachedTarget target2 in Targets) { CreatureTarget target = target2.Target; if ((Object)(object)target.Root == (Object)null || (Object)(object)target.VisualRoot == (Object)null || !target.Root.activeInHierarchy || !target.VisualRoot.activeInHierarchy || ((Object)(object)target.Entity != (Object)null && target.Entity.dead) || ((Object)(object)target.Actor != (Object)null && !target.Actor.isActiveAndEnabled) || (target.Item != null && ((Object)(object)target.Item.inventory != (Object)null || target.Item.used))) { continue; } Renderer[] renderers = target2.Renderers; foreach (Renderer val in renderers) { if ((Object)(object)val == (Object)null || !val.enabled || val.forceRenderingOff || !((Component)val).gameObject.activeInHierarchy || (camera.cullingMask & (1 << ((Component)val).gameObject.layer)) == 0 || !GeometryUtility.TestPlanesAABB(array, val.bounds)) { continue; } Item_Object componentInParent = ((Component)val).GetComponentInParent<Item_Object>(); if ((Object)(object)componentInParent != (Object)null && (Object)(object)((Component)componentInParent).gameObject != (Object)(object)target.Root) { continue; } switch (((object)val).GetType().Name) { case "ParticleSystemRenderer": case "TrailRenderer": case "LineRenderer": continue; } SpriteRenderer val2 = (SpriteRenderer)(object)((val is SpriteRenderer) ? val : null); if ((Object)(object)val2 != (Object)null && ((Object)(object)val2.sprite == (Object)null || val2.color.a <= 0.01f)) { continue; } Bounds bounds = val.bounds; Vector3 right = ((Component)camera).transform.right; Vector3 extents = ((Bounds)(ref bounds)).extents; Vector3 val3 = right * Mathf.Min(((Vector3)(ref extents)).magnitude * 0.6f, 2f); Vector3 val4 = Vector3.up * Mathf.Min(((Bounds)(ref bounds)).extents.y * 0.6f, 2f); Vector3 val5 = ((Bounds)(ref bounds)).ClosestPoint(((Component)camera).transform.position + ((Component)camera).transform.forward * Mathf.Max(0.1f, Vector3.Dot(((Bounds)(ref bounds)).center - ((Component)camera).transform.position, ((Component)camera).transform.forward))); Vector3[] array2 = (Vector3[])(object)new Vector3[6] { ((Bounds)(ref bounds)).center, ((Bounds)(ref bounds)).center + val3, ((Bounds)(ref bounds)).center - val3, ((Bounds)(ref bounds)).center + val4, ((Bounds)(ref bounds)).center - val4, val5 }; foreach (Vector3 val6 in array2) { Vector3 val7 = camera.WorldToViewportPoint(val6); if (!(val7.z < camera.nearClipPlane) && PhotoGeometry.ContainsViewportPoint(val7.x, val7.y, Screen.width, Screen.height) && HasLineOfSight(camera, val6, target)) { float num2 = Vector2.Distance(new Vector2(val7.x, val7.y), new Vector2(0.5f, 0.5f)) * 5f + val7.z * 0.0025f; if (!(num2 > num) && (num2 != num || (creatureDefinition != null && CreatureGuide.Find(target.Definition.Id) != null && CreatureGuide.Find(creatureDefinition.Id) == null))) { creatureDefinition = target.Definition; num = num2; } } } } } return creatureDefinition; } private static bool HasLineOfSight(Camera camera, Vector3 point, CreatureTarget target) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: 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_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) Transform transform = target.Root.transform; Vector3 position = ((Component)camera).transform.position; Vector3 val = point - position; float magnitude = ((Vector3)(ref val)).magnitude; if (magnitude < 0.01f) { return true; } ENT_Player player = ENT_Player.GetPlayer(); RaycastHit[] array = Physics.RaycastAll(position, val / magnitude, magnitude, -5, (QueryTriggerInteraction)1); for (int i = 0; i < array.Length; i++) { RaycastHit val2 = array[i]; if ((Object)(object)((RaycastHit)(ref val2)).collider == (Object)null || ((RaycastHit)(ref val2)).distance >= magnitude - 0.04f) { continue; } Transform transform2 = ((Component)((RaycastHit)(ref val2)).collider).transform; if (!((Object)(object)transform2 == (Object)(object)transform) && !transform2.IsChildOf(transform)) { ENT_Hitbox componentInParent = ((Component)((RaycastHit)(ref val2)).collider).GetComponentInParent<ENT_Hitbox>(); if ((!((Object)(object)target.Entity != (Object)null) || !((Object)(object)componentInParent != (Object)null) || !((Object)(object)componentInParent.entity == (Object)(object)target.Entity)) && (!((Object)(object)player != (Object)null) || (!((Object)(object)transform2 == (Object)(object)((Component)player).transform) && !transform2.IsChildOf(((Component)player).transform)))) { return false; } } } return true; } } internal sealed class CreatureGuideEntry { public string Id; public string Name; public string Section; public string Hint; public string Note; public string HintEn; public string NoteEn; public string[] Locations; public string[] Tags; public string[] Aliases; public string[] Types; public int Order; public string NameRu { get; set; } internal CreatureDefinition Definition => new CreatureDefinition { Id = Id, Name = Name }; internal bool IsPhotoTarget => Section != "Reference"; internal string NameFor(bool russian) { if (!russian || string.IsNullOrEmpty(NameRu)) { return Name; } return NameRu; } internal string HintFor(bool russian) { if (!russian) { return HintEn; } return Hint; } internal string NoteFor(bool russian) { if (!russian) { return NoteEn; } return Note; } } internal static class CreatureGuide { private static readonly List<CreatureGuideEntry> Entries = Load(); private static readonly Dictionary<string, CreatureGuideEntry> Aliases = BuildAliases(); private static readonly Dictionary<string, CreatureGuideEntry> LookupCache = new Dictionary<string, CreatureGuideEntry>(StringComparer.Ordinal); internal static IEnumerable<CreatureGuideEntry> All => Entries; internal static int MainCount => Entries.Count((CreatureGuideEntry c) => c.Section == "Main"); internal static int BonusCount => Entries.Count((CreatureGuideEntry c) => c.Section == "Bonus"); internal static int ReferenceCount => Entries.Count((CreatureGuideEntry c) => c.Section == "Reference"); private static List<CreatureGuideEntry> Load() { using Stream stream = typeof(CreatureGuide).Assembly.GetManifestResourceStream("WhiteKnucklePhotoCamera.creature-guide.json"); if (stream == null) { throw new InvalidDataException("Creature guide resource is missing."); } using StreamReader streamReader = new StreamReader(stream); List<CreatureGuideEntry> list = JsonConvert.DeserializeObject<List<CreatureGuideEntry>>(streamReader.ReadToEnd()); if (list == null || !list.Any((CreatureGuideEntry c) => c.Section == "Main") || list.Select((CreatureGuideEntry c) => c.Id).Distinct().Count() != list.Count) { throw new InvalidDataException("Invalid creature guide."); } return list; } private static Dictionary<string, CreatureGuideEntry> BuildAliases() { Dictionary<string, CreatureGuideEntry> dictionary = new Dictionary<string, CreatureGuideEntry>(StringComparer.Ordinal); foreach (CreatureGuideEntry entry in Entries) { foreach (string item in new string[2] { entry.Id, entry.Name }.Concat(entry.Aliases)) { string key = Token(item); if (dictionary.TryGetValue(key, out var value) && value.Id != entry.Id) { throw new InvalidDataException("Conflicting creature alias: " + item); } dictionary[key] = entry; } } return dictionary; } internal static string Token(string value) { value = value ?? ""; if (value.StartsWith("creature:", StringComparison.Ordinal)) { value = value.Substring(9); } else if (value.StartsWith("special:", StringComparison.Ordinal)) { value = value.Substring(8); } else if (value.Contains(":")) { return value; } value = CreatureIdentity.Clean(value).ToLowerInvariant(); value = Regex.Replace(value, "[^a-z0-9]", ""); return Regex.Replace(value, "^(denizen|den|ent|env|item)", ""); } internal static CreatureGuideEntry Find(string value) { if (string.IsNullOrEmpty(value)) { return null; } if (LookupCache.TryGetValue(value, out var value2)) { return value2; } string text = Token(value); if (!Aliases.TryGetValue(text, out value2) && text.EndsWith("navmesh", StringComparison.Ordinal)) { Aliases.TryGetValue(text.Substring(0, text.Length - 7), out value2); if (value2 != null && !value2.IsPhotoTarget) { value2 = null; } } if (LookupCache.Count >= 8192) { LookupCache.Clear(); } LookupCache[value] = value2; return value2; } internal static CreatureGuideEntry ByType(string type) { return Entries.FirstOrDefault((CreatureGuideEntry c) => c.Types.Contains(type)); } internal static string DisplayName(CreatureDefinition creature, bool russian) { if (creature == null) { return null; } CreatureGuideEntry creatureGuideEntry = Find(creature.Id); if (creatureGuideEntry == null) { return creature.Name; } return creatureGuideEntry.NameFor(russian); } internal static CreatureGuideEntry Info(CreatureDefinition creature) { CreatureGuideEntry creatureGuideEntry = Find(creature.Id); if (creatureGuideEntry == null) { CreatureGuideEntry creatureGuideEntry2 = new CreatureGuideEntry(); creatureGuideEntry2.Id = creature.Id; creatureGuideEntry2.Name = creature.Name; creatureGuideEntry2.Section = "Uncatalogued"; creatureGuideEntry2.Order = 999; creatureGuideEntry2.Locations = new string[1] { "Unverified" }; creatureGuideEntry2.Tags = new string[0]; creatureGuideEntry2.Aliases = new string[0]; creatureGuideEntry2.Types = new string[0]; creatureGuideEntry2.Hint = "Снимок сохранён в дополнительных записях. Этот объект пока не включён в основной перечень существ."; creatureGuideEntry2.HintEn = "This photograph is saved in Extras. The subject has yet to be added to the field guide."; creatureGuideEntry2.Note = "Вид и место появления пока не подтверждены."; creatureGuideEntry2.NoteEn = "Its species and spawn location are unconfirmed."; creatureGuideEntry = creatureGuideEntry2; } return creatureGuideEntry; } } internal static class AlbumQuery { internal static List<CreatureDefinition> Apply(PhotoAlbumStore store, bool extras, string search, int status, string location, string tag, int sort, bool russian = false) { IEnumerable<CreatureDefinition> source = from c in store.Creatures where CreatureGuide.Info(c).Section != "Main" == extras where Matches(CreatureGuide.Info(c), search, location, tag) where status == 0 || (CreatureGuide.Info(c).IsPhotoTarget && store.Latest(c.Id) != null == (status == 1)) select c; StringComparer comparer = (russian ? StringComparer.Create(CultureInfo.GetCultureInfo("ru-RU"), ignoreCase: true) : StringComparer.OrdinalIgnoreCase); return (sort switch { 1 => source.OrderBy<CreatureDefinition, string>((CreatureDefinition c) => CreatureGuide.DisplayName(c, russian), comparer), 2 => source.OrderBy<CreatureDefinition, string>((CreatureDefinition c) => GuideTerms.Place(CreatureGuide.Info(c).Locations.FirstOrDefault(), russian), comparer), 3 => source.OrderBy((CreatureDefinition c) => store.Latest(c.Id) != null), _ => source.OrderBy((CreatureDefinition c) => CreatureGuide.Info(c).Order), }).ThenBy<CreatureDefinition, string>((CreatureDefinition c) => CreatureGuide.DisplayName(c, russian), comparer).ToList(); } internal static bool Matches(CreatureGuideEntry entry, string search, string location, string tag) { if ((!string.IsNullOrEmpty(location) && !entry.Locations.Contains(location)) || (!string.IsNullOrEmpty(tag) && !entry.Tags.Contains(tag))) { return false; } if (string.IsNullOrWhiteSpace(search)) { return true; } return (entry.Name + " " + entry.NameRu + " " + string.Join(" ", entry.Aliases) + " " + string.Join(" ", entry.Locations) + " " + string.Join(" ", entry.Locations.Select((string p) => GuideTerms.Place(p, russian: true))) + " " + string.Join(" ", entry.Tags) + " " + string.Join(" ", entry.Tags.Select((string t) => GuideTerms.Tag(t, russian: true)))).IndexOf(search.Trim(), StringComparison.OrdinalIgnoreCase) >= 0; } internal static string[] Options(PhotoAlbumStore store, bool extras, bool locations) { return (from c in store.Creatures.Select(CreatureGuide.Info) where c.Section != "Main" == extras select c).SelectMany((CreatureGuideEntry c) => (!locations) ? c.Tags : c.Locations).Distinct().OrderBy<string, string>((string s) => s, StringComparer.OrdinalIgnoreCase) .ToArray(); } } internal sealed class CreatureDefinition { public string Id; public string Name; } internal static class CreatureIdentity { internal const string AdenocellsId = "creature:adenocells"; internal static bool IsCreatureType(string type) { switch (type) { default: if (type.StartsWith("DEN_", StringComparison.Ordinal) && type != "DEN_HadalDiver_Segment" && type != "DEN_DeathwallManager" && !type.EndsWith("_Animator", StringComparison.Ordinal)) { return !type.EndsWith("_Arm", StringComparison.Ordinal); } goto case null; case null: return false; case "ENV_RoachTrader": case "ENV_BearTrap": return true; } } internal static CreatureDefinition Create(string prefabId, string objectName, string type, string itemName = null) { switch (type) { case "DEN_Buddy": case "ENV_RoachTrader": case "DEN_DeathFloor": case "DEN_LadderNightmare": case "DEN_Apparition": case "DEN_Mask": case "DEN_RatKing": case "DEN_Remains_Active": case "DEN_Remains_Inactive": case "DEN_HadalDiver": case "ENV_BearTrap": return CreatureGuide.ByType(type).Definition; default: { bool flag = !string.IsNullOrWhiteSpace(prefabId) && prefabId != "entity"; CreatureGuideEntry creatureGuideEntry = CreatureGuide.Find(flag ? prefabId : objectName); if (creatureGuideEntry != null) { return creatureGuideEntry.Definition; } if (flag && (creatureGuideEntry = CreatureGuide.Find(objectName)) != null && creatureGuideEntry.Id == "creature:adenocells") { return creatureGuideEntry.Definition; } if (!flag && (creatureGuideEntry = CreatureGuide.ByType(type)) != null) { return creatureGuideEntry.Definition; } string text = Clean(flag ? prefabId : objectName); if (text.Length == 0) { text = Clean(type); } string text2 = Regex.Replace(text.ToLowerInvariant(), "[^\\p{L}\\p{Nd}]+", "-").Trim('-'); if (text2.Length == 0) { text2 = "unknown"; } return new CreatureDefinition { Id = "creature:" + text2, Name = Display(text) }; } } } internal static CreatureDefinition Canonicalize(CreatureDefinition creature) { if (creature == null || creature.Id == null) { return creature; } CreatureGuideEntry creatureGuideEntry = CreatureGuide.Find(creature.Id); if (creatureGuideEntry != null) { return creatureGuideEntry.Definition; } string text = (creature.Id.StartsWith("creature:", StringComparison.Ordinal) ? creature.Id.Substring(9) : creature.Name); if (!string.IsNullOrEmpty(creature.Name) && CreatureGuide.Token(creature.Name) == CreatureGuide.Token(text)) { text = creature.Name; } return new CreatureDefinition { Id = creature.Id, Name = Display(text ?? creature.Id) }; } internal static string CanonicalId(string id) { if (id != null) { return Canonicalize(new CreatureDefinition { Id = id }).Id; } return null; } internal static string Clean(string value) { value = Regex.Replace(value ?? "", "<[^>]*>", "").Replace("(Clone)", "").Trim(); value = Regex.Replace(value, "\\s+\\(\\d+\\)$", ""); value = Regex.Replace(value, "^(Denizen|DEN|ENT|ENV|Item)[_\\- ]+", "", RegexOptions.IgnoreCase); return value.Trim(); } private static string Display(string value) { string text = Regex.Replace(Clean(value), "([a-z0-9])([A-Z])", "$1 $2"); text = Regex.Replace(text.Replace('_', ' ').Replace('-', ' '), "\\s+", " ").Trim(); return CultureInfo.InvariantCulture.TextInfo.ToTitleCase(text.ToLowerInvariant()); } } internal static class GuardedCoroutine { internal static IEnumerator Run(IEnumerator routine, Action<Exception> onError, Action onFinished) { try { while (true) { object current; try { if (!routine.MoveNext()) { break; } current = routine.Current; } catch (Exception obj) { onError(obj); break; } yield return current; } } finally { try { if (routine is IDisposable disposable) { disposable.Dispose(); } } finally { onFinished(); } } } } internal static class GuideTerms { private static readonly Dictionary<string, string> Locations = new Dictionary<string, string> { ["Abyss"] = "Бездна", ["Across Campaign"] = "По всей кампании", ["Air Exchange"] = "Воздухообмен", ["Arterial Bypass"] = "Артериальный обход", ["Bazaar"] = "Базар", ["Body Cavity"] = "Полость тела", ["Breath Extractor"] = "Экстрактор дыхания", ["Cheatrooms"] = "Чит-комнаты", ["Confinement"] = "Изолятор", ["Deep Storage"] = "Глубокое хранилище", ["Delta Labs"] = "Лаборатории Дельта", ["Developer Playground"] = "Полигон разработчиков", ["Drainage System"] = "Дренажная система", ["Gastric Bypass"] = "Желудочный обход", ["Gastric Outpost"] = "Желудочный форпост", ["Habitation"] = "Жилой сектор", ["Hanging Gardens"] = "Висячие сады", ["Hanging Gardens (Legacy)"] = "Висячие сады (старая версия)", ["Haunted Pier"] = "Призрачный пирс", ["Hot Zone"] = "Горячая зона", ["Hot Zone Outro"] = "Выход из Горячей зоны", ["Infested Labs"] = "Заражённые лаборатории", ["Interlude: Ascent"] = "Интерлюдия Подъём", ["Interlude: Lockdown"] = "Интерлюдия Блокировка", ["Interlude: Symbiosis"] = "Интерлюдия Симбиоз", ["Ladder"] = "Лестница", ["Nest"] = "Гнездо", ["Organism Zeta"] = "Организм Зета", ["Parasite"] = "Паразит", ["Pipe Organ"] = "Трубный орган", ["Pipeworks"] = "Трубопроводы", ["Roach Run"] = "Тараканий забег", ["Rotten Duct"] = "Гнилой канал", ["Service Shaft"] = "Техническая шахта", ["Silos"] = "Силосы", ["Substructure 10"] = "Подструктура 10", ["Tangled Sink"] = "Спутанный сток", ["The Chimney"] = "Дымоход", ["Training Sector"] = "Учебный сектор", ["Transit Scaffolds"] = "Переходные леса", ["Underworks"] = "Нижние цеха", ["Unknown"] = "Неизвестно", ["Unverified"] = "Не подтверждено", ["Void"] = "Пустота", ["Waste Heap"] = "Свалка" }; private static readonly Dictionary<string, string> Tags = new Dictionary<string, string> { ["Aquatic"] = "Водные", ["Dangerous"] = "Опасные", ["Flying"] = "Летающие", ["Mechanical"] = "Механические", ["Peaceful"] = "Мирные", ["Roach"] = "Тараканы", ["Stationary"] = "Неподвижные" }; internal static string Place(string place, bool russian) { return Translate(Locations, place, russian); } internal static string Tag(string tag, bool russian) { return Translate(Tags, tag, russian); } private static string Translate(Dictionary<string, string> terms, string key, bool russian) { if (!russian || key == null || !terms.TryGetValue(key, out var value)) { return key; } return value; } } internal sealed class PcmWave { internal int Channels { get; private set; } internal int SampleRate { get; private set; } internal float[] Samples { get; private set; } internal int FrameCount => Samples.Length / Channels; internal static PcmWave Read(Stream stream) { if (stream == null) { throw new InvalidDataException("Embedded shutter sound is missing."); } using BinaryReader binaryReader = new BinaryReader(stream, Encoding.ASCII, leaveOpen: true); if (stream.Length < 12 || ReadTag(binaryReader) != "RIFF") { throw new InvalidDataException("Invalid WAV header."); } long num = 8L + (long)binaryReader.ReadUInt32(); if (ReadTag(binaryReader) != "WAVE" || num > stream.Length || num < 12) { throw new InvalidDataException("Truncated WAV file."); } int num2 = 0; int num3 = 0; int num4 = 0; byte[] array = null; while (stream.Position + 8 <= num) { string text = ReadTag(binaryReader); uint num5 = binaryReader.ReadUInt32(); long num6 = stream.Position + num5; if (num6 > num || num5 > int.MaxValue) { throw new InvalidDataException("Truncated WAV chunk."); } if (text == "fmt ") { if (num5 < 16 || binaryReader.ReadUInt16() != 1) { throw new InvalidDataException("Shutter WAV must be PCM16."); } num2 = binaryReader.ReadUInt16(); num3 = binaryReader.ReadInt32(); binaryReader.ReadUInt32(); num4 = binaryReader.ReadUInt16(); int num7 = binaryReader.ReadUInt16(); if (num2 < 1 || num2 > 2 || num3 <= 0 || num7 != 16 || num4 != num2 * 2) { throw new InvalidDataException("Unsupported shutter WAV format."); } } else if (text == "data") { array = binaryReader.ReadBytes((int)num5); } stream.Position = num6 + (num5 & 1); } if (num2 == 0 || array == null || array.Length == 0 || array.Length % num4 != 0) { throw new InvalidDataException("Shutter WAV has no complete audio frames."); } float[] array2 = new float[array.Length / 2]; for (int i = 0; i < array2.Length; i++) { array2[i] = (float)(short)(array[i * 2] | (array[i * 2 + 1] << 8)) / 32768f; } return new PcmWave { Channels = num2, SampleRate = num3, Samples = array2 }; } private static string ReadTag(BinaryReader reader) { return Encoding.ASCII.GetString(reader.ReadBytes(4)); } } internal sealed class PhotoAimState { internal CreatureDefinition Target { get; private set; } internal void SetTarget(CreatureDefinition target) { Target = CreatureIdentity.Canonicalize(target); } internal void Clear() { Target = null; } internal bool CanDraw(bool holdingCamera, bool gameplay, bool capturing, bool showingCard) { if (Target != null && holdingCamera && gameplay && !capturing) { return !showingCard; } return false; } internal bool IsPhotographed(PhotoAlbumStore album) { if (Target != null && album != null) { return album.PhotoCount(Target.Id) > 0; } return false; } } internal sealed class PhotoAlbumView : IDisposable { private readonly HashSet<string> _gallerySelection = new HashSet<string>(StringComparer.OrdinalIgnoreCase); private List<PhotoRecord> _galleryPhotos = new List<PhotoRecord>(); private Dictionary<string, List<PhotoRecord>> _photosBySubject = new Dictionary<string, List<PhotoRecord>>(StringComparer.Ordinal); private List<PhotoRecord> _galleryVisible = new List<PhotoRecord>(); private CreatureDefinition _gallerySubject; private string[] _deleteConfirmation; private int _galleryPage; private PhotoMessage _galleryStatus; private readonly PhotoAlbumStore _store; private readonly Action<string> _warning; private readonly Dictionary<string, Texture2D> _textures = new Dictionary<string, Texture2D>(); private readonly Queue<string> _textureOrder = new Queue<string>(); private CL_GameManager _manager; private float _previousTimescale; private bool _previousAudioPause; private bool _previousShowCursor; private CursorLockMode _previousCursorLock; private bool _returnToPauseMenu; private CanvasGroup _titleGroup; private bool _previousTitleRaycasts; private GameObject _previousSelection; private bool _closePending; private int _page; private int _filter; private int _tab; private int _sort; private int _popup; private const int PageSize = 8; private const int ExtrasTab = 1; private const int GalleryTab = 2; private const int SettingsTab = 3; private const int KeysPopup = 4; internal const KeyCode DefaultKey = (KeyCode)287; private const string SearchControl = "WKPolaroidSearch"; private AlbumTheme _theme; private string _location = ""; private string _tag = ""; private PhotoMessage _status; private PhotoMessage _keyStatus; private bool _russian; private bool _confirmReset; private bool _waitingForKey; private bool _searchFocused; private Vector2 _popupScroll; private Vector2 _detailScroll; private readonly Func<PhotoMessage> _giveCamera; private readonly Func<PhotoMessage> _openFolder; private readonly Action _resetProgress; private readonly Action<KeyCode> _setKey; private readonly Func<KeyCode, bool> _nativeConflict; private readonly Func<bool> _giveAtStart; private readonly Action<bool> _setGiveAtStart; private static readonly string[] SortEnglish = new string[4] { "Field guide order", "By name", "By location", "Missing first" }; private static readonly string[] SortRussian = new string[4] { "По порядку", "По имени", "По локации", "Сначала неснятые" }; private static readonly string[] TabsEnglish = new string[4] { "Bestiary", "Extras", "Gallery", "Settings" }; private static readonly string[] TabsRussian = new string[4] { "Бестиарий", "Дополнительно", "Галерея", "Настройки" }; private static readonly string[] FilterEnglish = new string[3] { "All", "Taken", "Missing" }; private static readonly string[] FilterRussian = new string[3] { "Все", "Снято", "Осталось" }; private static readonly float[] TabX = new float[4] { 74f, 190f, 336f, 444f }; private static readonly float[] TabWidth = new float[4] { 108f, 138f, 100f, 104f }; private static readonly float[] ColumnX = new float[4] { 74f, 318f, 634f, 878f }; private string _search = ""; private string _selectedId; private List<CreatureDefinition> _visible = new List<CreatureDefinition>(); private GUIStyle _title; private GUIStyle _heading; private GUIStyle _body; private GUIStyle _small; private GUIStyle _paragraph; private static readonly Color Ink = AlbumTheme.Ink; private static readonly Color Muted = AlbumTheme.Muted; private static readonly PhotoMessage KeyConflict = new PhotoMessage("White Knuckle already uses this binding. Choose another key.", "Эта клавиша уже используется в White Knuckle. Выбери другую."); private int GalleryPages => Math.Max(1, (_galleryVisible.Count + 8 - 1) / 8); internal bool IsOpen { get; private set; } internal int BlockInputThroughFrame { get; private set; } internal AlbumTheme Theme => _theme ?? (_theme = new AlbumTheme()); private bool OpenedFromTitle => _titleGroup != null; private string[] SortNames { get { if (!_russian) { return SortEnglish; } return SortRussian; } } private void ReloadGallery() { try { _galleryPhotos = _store.GalleryPhotos(); } catch (Exception ex) { _galleryPhotos.Clear(); _galleryStatus = new PhotoMessage("Could not read the photo folder.", "Не удалось прочитать папку со снимками."); _warning("Could not read the gallery: " + ex.Message); } _photosBySubject = (from photo in _galleryPhotos where !string.IsNullOrEmpty(photo.CreatureId) group photo by photo.CreatureId).ToDictionary<IGrouping<string, PhotoRecord>, string, List<PhotoRecord>>((IGrouping<string, PhotoRecord> group) => group.Key, (IGrouping<string, PhotoRecord> group) => group.ToList(), StringComparer.Ordinal); UpdateGalleryScope(); } private void SetGallerySubject(CreatureDefinition subject) { _gallerySubject = subject; _galleryPage = 0; _gallerySelection.Clear(); _deleteConfirmation = null; _galleryStatus = default(PhotoMessage); UpdateGalleryScope(); } private int SubjectPhotoCount(string subjectId) { if (!_photosBySubject.TryGetValue(subjectId, out var value)) { return 0; } return value.Count; } private void UpdateGalleryScope() { if (_gallerySubject == null) { _galleryVisible = _galleryPhotos; } else if (!_photosBySubject.TryGetValue(_gallerySubject.Id, out _galleryVisible)) { _galleryVisible = new List<PhotoRecord>(); } _gallerySelection.IntersectWith(_galleryVisible.Select((PhotoRecord photo) => photo.FileName)); _galleryPage = Math.Min(_galleryPage, GalleryPages - 1); } private void DrawGallery() { //IL_005a: 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_0038: 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_00b3: 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_0106: 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_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: 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_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0270: 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_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_0316: Unknown result type (might be due to invalid IL or missing references) if (_gallerySubject == null) { Label(new Rect(74f, 211f, 474f, 35f), T("Photo gallery", "Галерея снимков"), _heading, Ink); } else { if (Button(new Rect(74f, 210f, 134f, 36f), T("← To card", "← К карточке"), selected: false, danger: false, 15)) { SetGallerySubject(null); return; } Label(new Rect(220f, 212f, 328f, 34f), CreatureGuide.DisplayName(_gallerySubject, _russian), _heading, Ink); } Label(new Rect(74f, 248f, 474f, 22f), T("Newest first · Photos ", "Сначала новые · Снимков ") + _galleryVisible.Count, _small, Muted); Label(new Rect(634f, 222f, 143f, 22f), T("Selected ", "Выбрано ") + _gallerySelection.Count, _body, Ink); bool enabled = GUI.enabled; GUI.enabled = enabled && _gallerySelection.Count > 0; if (Button(new Rect(779f, 210f, 124f, 36f), T("Clear", "Снять выбор"), selected: false, danger: false, 15)) { _gallerySelection.Clear(); } if (Button(new Rect(911f, 210f, 193f, 36f), T("Delete selected", "Удалить выбранные"), selected: false, danger: true, 15)) { RequestDelete(_gallerySelection); } GUI.enabled = enabled; Fill(new Rect(74f, 273f, 474f, 1f), AlbumTheme.Rule); Fill(new Rect(634f, 273f, 470f, 1f), AlbumTheme.Rule); if (_galleryVisible.Count == 0) { Label(new Rect(74f, 341f, 474f, 36f), T("No photos here yet", "Здесь пока нет снимков"), _heading, Ink); Label(new Rect(74f, 389f, 474f, 75f), T("Photos appear here as you take them. Landscape shots are included.", "Снимки появляются здесь после съёмки. Кадры без существ тоже попадут в галерею."), _paragraph, Muted); } int num = _galleryPage * 8; int num2 = Math.Min(8, _galleryVisible.Count - num); for (int i = 0; i < num2; i++) { DrawGalleryPhoto(new Rect(ColumnX[i % 4], (float)(283 + i / 4 * 202), 226f, 195f), _galleryVisible[num + i]); } DrawSpreadNavigation(ref _galleryPage, GalleryPages, _galleryStatus.In(_russian), T("Use the boxes to select. Hover a photo for actions.", "Отметь кадры галочками. Наведи на снимок для действий.")); } private void DrawGalleryPhoto(Rect cell, PhotoRecord photo) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0077: 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_0173: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: 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) string text = "wk-photo-" + photo.FileName; string nameOfFocusedControl = GUI.GetNameOfFocusedControl(); bool flag = _gallerySelection.Contains(photo.FileName); bool flag2 = GUI.enabled && (((Rect)(ref cell)).Contains(Event.current.mousePosition) || (!string.IsNullOrEmpty(nameOfFocusedControl) && nameOfFocusedControl.StartsWith(text + "/", StringComparison.Ordinal))); if (flag || flag2) { Fill(cell, flag ? AlbumTheme.AccentWash : AlbumTheme.Panel); } DrawCard(new Rect(((Rect)(ref cell)).x + 43f, ((Rect)(ref cell)).y + 2f, 140f, 158f), photo, target: true); GUI.SetNextControlName(text + "/select"); if (Button(new Rect(((Rect)(ref cell)).x + 190f, ((Rect)(ref cell)).y + 5f, 30f, 30f), flag ? "✓" : "", flag)) { if (flag) { _gallerySelection.Remove(photo.FileName); } else { _gallerySelection.Add(photo.FileName); } } bool visible = GUI.enabled && (flag2 || flag); GUI.SetNextControlName(text + "/open"); if (GalleryAction(new Rect(((Rect)(ref cell)).x + 12f, ((Rect)(ref cell)).y + 132f, 99f, 31f), T("Open", "Открыть"), visible, danger: false)) { OpenPhoto(photo); } GUI.SetNextControlName(text + "/remove"); if (GalleryAction(new Rect(((Rect)(ref cell)).x + 116f, ((Rect)(ref cell)).y + 132f, 98f, 31f), T("Delete", "Удалить"), visible, danger: true)) { RequestDelete(new string[1] { photo.FileName }); } string text2 = ((!string.IsNullOrEmpty(photo.CreatureId)) ? CreatureGuide.DisplayName(new CreatureDefinition { Id = photo.CreatureId, Name = photo.CreatureName }, _russian) : (photo.FileOnly ? T("Unlabelled", "Без метки") : T("Landscape", "Пейзаж"))); Label(new Rect(((Rect)(ref cell)).x + 5f, ((Rect)(ref cell)).y + 165f, 216f, 20f), text2, _body, Ink, centered: true); Label(new Rect(((Rect)(ref cell)).x + 5f, ((Rect)(ref cell)).y + 184f, 216f, 18f), FormatPhotoTime(photo), _small, Muted, centered: true); } private bool GalleryAction(Rect rect, string text, bool visible, bool danger) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) if (visible) { return Button(rect, text, selected: false, danger, 15); } bool enabled = GUI.enabled; GUI.enabled = false; GUI.Button(rect, GUIContent.none, GUIStyle.none); GUI.enabled = enabled; return false; } private string FormatPhotoTime(PhotoRecord photo) { return photo.TakenAtUtc.ToLocalTime().ToString(T("yyyy-MM-dd HH:mm", "dd.MM.yyyy HH:mm")); } private void OpenPhoto(PhotoRecord photo) { try { if (!_store.HasFile(photo)) { throw new FileNotFoundException("Photo file is missing."); } Process.Start(new ProcessStartInfo { FileName = _store.PhotoPath(photo), UseShellExecute = true }); _galleryStatus = default(PhotoMessage); } catch (Exception ex) { _galleryStatus = new PhotoMessage("Could not open the image.", "Не удалось открыть снимок."); _warning("Could not open gallery photo " + photo.FileName + ": " + ex.Message); } } private void RequestDelete(IEnumerable<string> filenames) { string[] array = filenames.ToArray(); if (array.Length != 0) { _deleteConfirmation = array; } } private void DrawDeleteConfirmation() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_008d: 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_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) DrawDialogSurface(new Rect(322f, 261f, 536f, 279f)); int num = _deleteConfirmation.Length; Label(new Rect(354f, 291f, 472f, 41f), (num == 1) ? T("Delete this photo?", "Удалить этот снимок?") : T("Delete the selected photos?", "Удалить выбранные снимки?"), _heading, Ink); Label(new Rect(354f, 348f, 472f, 82f), T("Photos to delete: ", "Снимков к удалению: ") + num + T(". This deletes the files from disk. Removing the last photo clears the creature's mark.", ". Файлы удалятся с диска. Если у существа больше нет снимков, отметка о съёмке снимется."), _paragraph, Muted); if (Button(new Rect(354f, 461f, 224f, 42f), T("Cancel", "Отмена"))) { _deleteConfirmation = null; } if (Button(new Rect(602f, 461f, 224f, 42f), T("Delete", "Удалить"), selected: false, danger: true)) { ConfirmDelete(); } } private void ConfirmDelete() { string[] deleteConfirmation = _deleteConfirmation; _deleteConfirmation = null; if (deleteConfirmation == null) { return; } try { int num = _store.DeletePhotos(deleteConfirmation); ClearTextures(); ReloadGallery(); Refilter(); _galleryStatus = ((num == deleteConfirmation.Length) ? new PhotoMessage("Deleted " + num + ".", "Удалено снимков: " + num + ".") : new PhotoMessage("Deleted " + num + " of " + deleteConfirmation.Length + ".", "Удалено " + num + " из " + deleteConfirmation.Length + " снимков.")); } catch (Exception ex) { _galleryStatus = new PhotoMessage("Could not delete the selected photos.", "Не удалось удалить выбранные снимки."); _warning("Could not delete gallery selection: " + ex.Message); } } internal PhotoAlbumView(PhotoAlbumStore store, Action<string> warning, Func<PhotoMessage> giveCamera, Func<PhotoMessage> openFolder, Action resetProgress, Action<KeyCode> setKey, Func<KeyCode, bool> nativeConflict, Func<bool> giveAtStart, Action<bool> setGiveAtStart) { _store = store; _warning = warning; _giveCamera = giveCamera; _openFolder = openFolder; _resetProgress = resetProgress; _setKey = setKey; _nativeConflict = nativeConflict; _giveAtStart = giveAtStart; _setGiveAtStart = setGiveAtStart; } private string T(string english, string russian) { if (!_russian) { return english; } return russian; } internal void SetLanguage(bool russian) { if (_russian != russian) { _russian = russian; if (IsOpen) { Refilter(); } } } internal bool Open(bool fromPauseMenu = false) { //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) CL_GameManager gMan = CL_GameManager.gMan; ENT_Player player = ENT_Player.GetPlayer(); if (!IsOpen && !((Object)(object)gMan == (Object)null) && !((Object)(object)player == (Object)null) && !((GameEntity)player).dead && gMan.isPaused == fromPauseMenu && !((Object)(object)gMan.pauseMenu == (Object)null) && !CL_GameManager.IsLoading() && CL_GameManager.IsInGame()) { bool num; if (!fromPauseMenu) { if (!gMan.canPause || OS_Manager.inUse) { goto IL_007f; } num = Inventory.IsShowingInventory(); } else { num = !gMan.pauseMenu.activeInHierarchy; } if (!num) { try { CreatureCatalog.Refresh(_store); } catch (Exception ex) { _warning("Could not refresh album catalog: " + ex.Message); } _manager = gMan; _previousTimescale = CL_GameManager.GetBaseTimescale(); _previousAudioPause = AudioListener.pause; _previousShowCursor = CL_GameManager.showCursor; _previousCursorLock = Cursor.lockState; _returnToPauseMenu = fromPauseMenu; EventSystem current = EventSystem.current; _previousSelection = ((fromPauseMenu && (Object)(object)current != (Object)null) ? current.currentSelectedGameObject : null); if (!fromPauseMenu) { gMan.Pause(); } gMan.pauseMenu.SetActive(false); if ((Object)(object)current != (Object)null) { current.SetSelectedGameObject((GameObject)null); } BeginOpen(fromPauseMenu ? new int?(0) : ((int?)null)); return true; } } goto IL_007f; IL_007f: return false; } internal bool OpenFromTitle(CanvasGroup group) { if (IsOpen || (Object)(object)group == (Object)null || !((Behaviour)group).isActiveAndEnabled || !group.interactable || CL_GameManager.IsInGame() || ((Object)(object)CL_GameManager.gMan != (Object)null && CL_GameManager.IsLoading())) { return false; } _titleGroup = group; _previousTitleRaycasts = group.blocksRaycasts; group.interactable = false; group.blocksRaycasts = false; EventSystem current = EventSystem.current; if ((Object)(object)current != (Object)null) { _previousSelection = current.currentSelectedGameObject; current.SetSelectedGameObject((GameObject)null); } BeginOpen(0); return true; } private void BeginOpen(int? startTab) { IsOpen = true; _closePending = false; _selectedId = null; _popup = 0; _confirmReset = false; _waitingForKey = false; _searchFocused = false; if (startTab.HasValue) { _tab = startTab.Value; } try { SetGallerySubject(null); ReloadGallery(); ClearTextures(); Refilter(); } catch { Close(resume: true); throw; } } internal void Update(KeyCode key) { //IL_00ed: 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_0106: Invalid comparison between Unknown and I4 //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Invalid comparison between Unknown and I4 if (!IsOpen) { return; } if (OpenedFromTitle) { if ((Object)(object)_titleGroup == (Object)null || !((Behaviour)_titleGroup).isActiveAndEnabled || CL_GameManager.IsInGame() || ((Object)(object)CL_GameManager.gMan != (Object)null && CL_GameManager.IsLoading())) { Close(resume: false); return; } } else { ENT_Player player = ENT_Player.GetPlayer(); if ((Object)(object)_manager == (Object)null || _manager != CL_GameManager.gMan || !CL_GameManager.IsInGame() || CL_GameManager.IsLoading() || (Object)(object)player == (Object)null || ((GameEntity)player).dead || !_manager.isPaused || ((Object)(object)_manager.pauseMenu != (Object)null && _manager.pauseMenu.activeSelf)) { Close(resume: false); return; } } bool keyDown = Input.GetKeyDown((KeyCode)27); if (_waitingForKey) { if (keyDown) { _waitingForKey = false; } } else if (keyDown || (Input.GetKeyDown(key) && (!_searchFocused || ((int)key >= 282 && (int)key <= 296)))) { if (_deleteConfirmation != null && keyDown) { _deleteConfirmation = null; } else if (_popup != 0 && keyDown) { _popup = 0; } else if (_confirmReset && keyDown) { _confirmReset = false; } else if (_gallerySubject != null && keyDown) { SetGallerySubject(null); } else if (_selectedId != null && keyDown) { _selectedId = null; } else { _closePending = true; } } } internal void LateUpdate() { if (_closePending) { Close(resume: true); } } internal void Close(bool resume) { //IL_0140: Unknown result type (might be due to invalid IL or missing references) bool isOpen = IsOpen; IsOpen = false; _closePending = false; _selectedId = null; _waitingForKey = false; _searchFocused = false; SetGallerySubject(null); BlockInputThroughFrame = Time.frameCount + 1; try { if (OpenedFromTitle) { if ((Object)(object)_titleGroup != (Object)null) { _titleGroup.interactable = true; _titleGroup.blocksRaycasts = _previousTitleRaycasts; if (resume) { RestoreSelection(); } } } else { if (!(isOpen && resume) || !((Object)(object)_manager != (Object)null) || _manager != CL_GameManager.gMan || !_manager.isPaused || CL_GameManager.IsLoading()) { return; } ENT_Player player = ENT_Player.GetPlayer(); if ((Object)(object)player != (Object)null && !((GameEntity)player).dead) { if (_returnToPauseMenu && (Object)(object)_manager.pauseMenu != (Object)null) { _manager.pauseMenu.SetActive(true); RestoreSelection(); return; } _manager.UnPause(); CL_GameManager.SetTimescale(_previousTimescale); AudioListener.pause = _previousAudioPause; CL_GameManager.showCursor = _previousShowCursor; Cursor.lockState = _previousCursorLock; } } } finally { _manager = null; _titleGroup = null; _returnToPauseMenu = false; _previousSelection = null; ClearTextures(); } } private void RestoreSelection() { EventSystem current = EventSystem.current; if ((Object)(object)current != (Object)null && (Object)(object)_previousSelection != (Object)null && _previousSelection.activeInHierarchy) { current.SetSelectedGameObject(_previousSelection); } } private void Refilter() { _visible = AlbumQuery.Apply(_store, _tab == 1, _search, _filter, _location, _tag, _sort, _russian); _page = Mathf.Clamp(_page, 0, Math.Max(0, (_visible.Count - 1) / 8)); } internal void Draw(KeyCode key) { //IL_047e: Unknown result type (might be due to invalid IL or missing references) //IL_0484: Unknown result type (might be due to invalid IL or missing references) //IL_048a: Unknown result type (might be due to invalid IL or missing references) //IL_0490: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_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_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: 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_0076: 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_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_012f: 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_0142: 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_016f: 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_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_024b: 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_02b7: 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_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_0389: Unknown result type (might be due to invalid IL or missing references) //IL_038e: Unknown result type (might be due to invalid IL or missing references) //IL_03af: Unknown result type (might be due to invalid IL or missing references) //IL_03b4: Unknown result type (might be due to invalid IL or missing references) //IL_03d2: Unknown result type (might be due to invalid IL or missing references) //IL_03d7: Unknown result type (might be due to invalid IL or missing references) //IL_0400: Unknown result type (might be due to invalid IL or missing references) //IL_0405: Unknown result type (might be due to invalid IL or missing references) //IL_0346: Unknown result type (might be due to invalid IL or missing references) //IL_041f: Unknown result type (might be due to invalid IL or missing references) //IL_0476: Unknown result type (might be due to invalid IL or missing references) if (!IsOpen) { return; } if (_waitingForKey) { CaptureKey(Event.current); } if (_title == null) { CreateStyles(); } Color color = GUI.color; Color backgroundColor = GUI.backgroundColor; Color contentColor = GUI.contentColor; Matrix4x4 matrix = GUI.matrix; int depth = GUI.depth; bool enabled = GUI.enabled; GUISkin skin = GUI.skin; try { GUI.skin = Theme.Skin; GUI.depth = -1200; GUI.backgroundColor = (GUI.contentColor = Color.white); GUI.enabled = enabled && _popup == 0 && _deleteConfirmation == null; GUI.matrix = Matrix4x4.identity; Fill(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), new Color(0.018f, 0.016f, 0.013f, 0.96f)); float num = Mathf.Min((float)Screen.width / 1180f, (float)Screen.height / 800f); GUI.matrix = Matrix4x4.TRS(new Vector3(((float)Screen.width - 1180f * num) / 2f, ((float)Screen.height - 800f * num) / 2f, 0f), Quaternion.identity, new Vector3(num, num, 1f)); GUI.color = Color.white; GUI.DrawTexture(new Rect(18f, 18f, 1144f, 764f), (Texture)(object)_theme.Book); Label(new Rect(74f, 49f, 476f, 48f), "Polaroid Bestiary", _title, Ink); Label(new Rect(76f, 108f, 473f, 26f), T("Campaign ", "Кампания ") + _store.CompletedCount + " / " + CreatureGuide.MainCount, _body, Muted); Label(new Rect(634f, 57f, 244f, 24f), T("Field journal", "Полевой журнал"), _small, Muted); int num2 = _store.CompletedIn("Bonus"); Label(new Rect(634f, 108f, 410f, 26f), T("Extra encounters ", "Дополнительные встречи ") + num2 + " / " + CreatureGuide.BonusCount, _body, Muted); string text = ((OpenedFromTitle || _returnToPauseMenu) ? "Esc" : KeyName(key)); if (Button(new Rect(881f, 55f, 147f, 38f), T("Close · ", "Закрыть · ") + text, selected: false, danger: false, 16)) { _closePending = true; } if (SharedLanguage.OwnsButton("ilya.whiteknuckle.photocamera") && Button(new Rect(1036f, 55f, 68f, 38f), SharedLanguage.Label, selected: false, danger: false, 16)) { SharedLanguage.Toggle(); } float num3 = (float)_store.CompletedCount / (float)CreatureGuide.MainCount; Fill(new Rect(76f, 137f, 472f, 3f), AlbumTheme.Rule); Fill(new Rect(76f, 137f, 472f * num3, 3f), AlbumTheme.Red); Fill(new Rect(634f, 137f, 470f, 3f), AlbumTheme.Rule); Fill(new Rect(634f, 137f, (float)(470 * num2) / (float)CreatureGuide.BonusCount, 3f), AlbumTheme.Red); DrawNavigation(); if (_tab == 3) { DrawSettings(key); } else if (_tab == 2 || _gallerySubject != null) { DrawGallery(); } else if (_selectedId != null) { DrawSelected(); } else { DrawGrid(); } GUI.enabled = enabled; if (_deleteConfirmation != null) { DrawDeleteConfirmation(); } else if (_popup != 0) { DrawPopup(key); } } finally { GUI.color = color; GUI.backgroundColor = backgroundColor; GUI.contentColor = contentColor; GUI.matrix = matrix; GUI.depth = depth; GUI.enabled = enabled; GUI.skin = skin; } } private bool Button(Rect rect, string text, bool selected = false, bool danger = false, int size = 17) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return _theme.DrawButton(rect, text, selected, danger, size); } private void DrawNavigation() { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: 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) string[] array = (_russian ? TabsRussian : TabsEnglish); for (int i = 0; i < array.Length; i++) { if (Button(new Rect(TabX[i], 157f, TabWidth[i], 40f), array[i], i == _tab, danger: false, 16) && (i != _tab || _selectedId != null)) { _tab = i; _selectedId = null; _confirmReset = false; _page = 0; _location = ""; _tag = ""; SetGallerySubject(null); Refilter(); } } if (_tab >= 2 || _selectedId != null) { _searchFocused = false; return; } Label(new Rect(634f, 168f, 88f, 26f), T("Search", "Поиск"), _body, Muted); GUI.SetNextControlName("WKPolaroidSearch"); string text = GUI.TextField(new Rect(714f, 157f, 390f, 40f), _search, 80, _theme.Search); _searchFocused = GUI.GetNameOfFocusedControl() == "WKPolaroidSearch"; if (text != _search) { _search = text; _page = 0; Refilter(); } } private void DrawGrid() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0219: 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_02f1: Unknown result type (might be due to invalid IL or missing references) //IL_0329: 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_02c2: Unknown result type (might be due to invalid IL or missing references) //IL_036c: Unknown result type (might be due to invalid IL or missing references) //IL_0365: Unknown result type (might be due to invalid IL or missing references) //IL_035e: Unknown result type (might be due to invalid IL or missing references) //IL_03ae: Unknown result type (might be due t