using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.IO.Compression; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.Json; using BattingCage; using HarmonyLib; using HoldTheFort; using Il2CppFishNet; using Il2CppInterop.Runtime; using Il2CppInterop.Runtime.InteropTypes; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppScheduleOne; using Il2CppScheduleOne.AvatarFramework; using Il2CppScheduleOne.AvatarFramework.Animation; using Il2CppScheduleOne.Building; using Il2CppScheduleOne.Core.Items.Framework; using Il2CppScheduleOne.DevUtilities; using Il2CppScheduleOne.Economy; using Il2CppScheduleOne.Equipping; using Il2CppScheduleOne.Instancing; using Il2CppScheduleOne.ItemFramework; using Il2CppScheduleOne.Map; using Il2CppScheduleOne.NPCs; using Il2CppScheduleOne.NPCs.Relation; using Il2CppScheduleOne.Networking; using Il2CppScheduleOne.Persistence; using Il2CppScheduleOne.PlayerScripts; using Il2CppScheduleOne.Property; using Il2CppScheduleOne.Storage; using Il2CppScheduleOne.Tiles; using Il2CppScheduleOne.UI; using Il2CppScheduleOne.UI.Shop; using Il2CppScheduleOne.Vehicles; using Il2CppScheduleOne.Weather; using Il2CppSteamworks; using Il2CppSystem; using Il2CppSystem.Collections.Generic; using Il2CppSystem.Reflection; using Il2CppTMPro; using MelonLoader; using MelonLoader.Preferences; using MelonLoader.Utils; using Microsoft.CodeAnalysis; using S1API.Entities; using S1API.GameTime; using S1API.Items; using S1API.Items.Storable; using S1API.Lifecycle; using S1API.Rendering; using S1API.Shops; using Schedule2; using Schedule2.Game; using UnityEngine; using UnityEngine.AI; using UnityEngine.EventSystems; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.Rendering; using UnityEngine.Rendering.Universal; using UnityEngine.UI; using WS_BC.FybCommon; using WS_BC.WoodKit; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: MelonInfo(typeof(CageCore), "Floodlight Batting Cage", "1.1.0", "Wood Studios", null)] [assembly: MelonGame("TVGS", "Schedule I")] [assembly: MelonOptionalDependencies(new string[] { "HoldTheFort" })] [assembly: AssemblyTitle("WoodStudios.BattingCage")] [assembly: AssemblyProduct("WoodStudios.BattingCage")] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.1.0.0")] [module: UnverifiableCode] [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 Schedule2 { internal static class Res { private static readonly Assembly Asm = typeof(Res).Assembly; public static Stream Open(string name) { Stream manifestResourceStream = Asm.GetManifestResourceStream(name); if (manifestResourceStream == null) { return null; } int num = manifestResourceStream.ReadByte(); int num2 = manifestResourceStream.ReadByte(); manifestResourceStream.Position = 0L; if (num != 31 || num2 != 139) { return manifestResourceStream; } MemoryStream memoryStream = new MemoryStream(); using (GZipStream gZipStream = new GZipStream(manifestResourceStream, CompressionMode.Decompress)) { gZipStream.CopyTo(memoryStream); } memoryStream.Position = 0L; return memoryStream; } } } namespace Schedule2.Game { internal static class Sfx { public static AudioClip Create(string name, int lengthSamples, int channels, int frequency, bool stream) { return AudioClip.Create(name, lengthSamples, channels, frequency, stream); } public static bool SetData(AudioClip clip, Il2CppStructArray data, int offset) { if ((Object)(object)clip != (Object)null) { return clip.SetData(data, offset); } return false; } } } namespace WS_BC.WoodKit { internal static class Catalog { public static readonly List Items = new List(); private static readonly Dictionary ById = new Dictionary(StringComparer.OrdinalIgnoreCase); public static void Add(ItemSpec s) { Items.Add(s); ById[s.Id] = s; } public static ItemSpec Get(string id) { if (string.IsNullOrEmpty(id) || !ById.TryGetValue(id, out var value)) { return null; } return value; } public static void BuildTemplates() { foreach (ItemSpec item in Items) { if ((Object)(object)item.Template != (Object)null || item.BuildModel == null) { continue; } try { item.Template = item.BuildModel(); if ((Object)(object)item.Template != (Object)null && (Object)(object)item.Template.transform.parent == (Object)null) { item.Template.transform.SetParent(Models.Root, false); } } catch (Exception ex) { Instance log = Kit.Log; if (log != null) { log.Error("Couldn't build the " + item.Name + " model: " + ex.Message); } } } } } internal static class CoopMirror { private sealed class Shown { public string Payload; public readonly List Gos = new List(); } private const int Chunk = 3500; private const int MaxChunks = 24; private static readonly Dictionary Views = new Dictionary(); private static string _published; private static int _publishedChunks; private static float _nextBuild; private static float _nextView; private static string Key => "wk_" + (Kit.Prefix ?? "x"); private static bool InLobby(out CSteamID lobby, out int members) { //IL_0001: 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_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) lobby = default(CSteamID); members = 0; try { Lobby instance = Singleton.Instance; if ((Object)(object)instance == (Object)null || !instance.IsInLobby || instance.LobbyID == 0L) { return false; } lobby = new CSteamID { m_SteamID = instance.LobbyID }; members = SteamMatchmaking.GetNumLobbyMembers(lobby); return members > 1; } catch { return false; } } public static void Update() { //IL_006c: 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) if (!InLobby(out var lobby, out var members)) { if (Views.Count > 0) { Clear(); } _published = null; return; } float unscaledTime = Time.unscaledTime; if (unscaledTime >= _nextBuild) { _nextBuild = unscaledTime + 1.5f; string text = Build(); if (text != _published) { Publish(lobby, text); } } if (unscaledTime >= _nextView) { _nextView = unscaledTime + 1f; Refresh(lobby, members); } } public static void Reset() { Clear(); _published = null; _publishedChunks = 0; _nextBuild = (_nextView = 0f); } private static string Build() { //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) StringBuilder stringBuilder = new StringBuilder(); foreach (Placement.Placed item in Placement.All) { try { if (item != null && !((Object)(object)item.Go == (Object)null) && item.Spec != null && !item.OnShip && !((Object)(object)item.Spec.Template == (Object)null) && item.Go.activeInHierarchy) { Transform transform = item.Go.transform; Vector3 position = transform.position; Quaternion rotation = transform.rotation; Vector3 lossyScale = transform.lossyScale; if (stringBuilder.Length > 0) { stringBuilder.Append('~'); } stringBuilder.Append(item.Spec.Id).Append(';'); Num(stringBuilder, position.x); stringBuilder.Append(','); Num(stringBuilder, position.y); stringBuilder.Append(','); Num(stringBuilder, position.z); stringBuilder.Append(';'); Num(stringBuilder, rotation.x, 4); stringBuilder.Append(','); Num(stringBuilder, rotation.y, 4); stringBuilder.Append(','); Num(stringBuilder, rotation.z, 4); stringBuilder.Append(','); Num(stringBuilder, rotation.w, 4); stringBuilder.Append(';'); Num(stringBuilder, lossyScale.x, 3); stringBuilder.Append(','); Num(stringBuilder, lossyScale.y, 3); stringBuilder.Append(','); Num(stringBuilder, lossyScale.z, 3); } } catch { } } return stringBuilder.ToString(); } private static void Publish(CSteamID lobby, string payload) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) try { int num = ((payload.Length != 0) ? Math.Min(24, (payload.Length + 3500 - 1) / 3500) : 0); for (int i = 0; i < num; i++) { SteamMatchmaking.SetLobbyMemberData(lobby, Key + "_" + i, payload.Substring(i * 3500, Math.Min(3500, payload.Length - i * 3500))); } for (int j = num; j < _publishedChunks; j++) { SteamMatchmaking.SetLobbyMemberData(lobby, Key + "_" + j, ""); } SteamMatchmaking.SetLobbyMemberData(lobby, Key + "_n", num.ToString(CultureInfo.InvariantCulture) + "|" + payload.Length.ToString(CultureInfo.InvariantCulture)); _publishedChunks = num; _published = payload; } catch { } } private static void Refresh(CSteamID lobby, int members) { //IL_0003: 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_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003f: 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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) ulong num = 0uL; try { num = SteamUser.GetSteamID().m_SteamID; } catch { } HashSet hashSet = new HashSet(); for (int i = 0; i < members; i++) { CSteamID lobbyMemberByIndex; try { lobbyMemberByIndex = SteamMatchmaking.GetLobbyMemberByIndex(lobby, i); } catch { continue; } if (lobbyMemberByIndex.m_SteamID == num || lobbyMemberByIndex.m_SteamID == 0L) { continue; } hashSet.Add(lobbyMemberByIndex.m_SteamID); string lobbyMemberData = SteamMatchmaking.GetLobbyMemberData(lobby, lobbyMemberByIndex, Key + "_n"); if (string.IsNullOrEmpty(lobbyMemberData)) { continue; } string[] array = lobbyMemberData.Split('|'); if (array.Length < 2 || !int.TryParse(array[0], NumberStyles.Integer, CultureInfo.InvariantCulture, out var result) || !int.TryParse(array[1], NumberStyles.Integer, CultureInfo.InvariantCulture, out var result2) || result < 0 || result > 24) { continue; } StringBuilder stringBuilder = new StringBuilder(); for (int j = 0; j < result; j++) { stringBuilder.Append(SteamMatchmaking.GetLobbyMemberData(lobby, lobbyMemberByIndex, Key + "_" + j) ?? ""); } string text = stringBuilder.ToString(); if (text.Length == result2 && (!Views.TryGetValue(lobbyMemberByIndex.m_SteamID, out var value) || !(value.Payload == text))) { if (value != null) { Destroy(value); } value = new Shown { Payload = text }; Views[lobbyMemberByIndex.m_SteamID] = value; Spawn(value, text); } } List list = new List(); foreach (KeyValuePair view in Views) { if (!hashSet.Contains(view.Key)) { list.Add(view.Key); } } foreach (ulong item in list) { Destroy(Views[item]); Views.Remove(item); } } private static void Spawn(Shown shown, string payload) { //IL_0098: 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: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrEmpty(payload)) { return; } string[] array = payload.Split('~'); foreach (string text in array) { try { string[] array2 = text.Split(';'); if (array2.Length < 4) { continue; } ItemSpec itemSpec = Catalog.Get(array2[0]); if (itemSpec != null && !((Object)(object)itemSpec.Template == (Object)null)) { GameObject val = Object.Instantiate(itemSpec.Template); ((Object)val).name = Kit.Prefix + "Mirror_" + itemSpec.Id; val.transform.SetParent((Transform)null, false); val.transform.SetPositionAndRotation(Vec(array2[1]), Rot(array2[2])); Vector3 val2 = Vec(array2[3]); if (val2.x > 0.001f && val2.y > 0.001f && val2.z > 0.001f) { val.transform.localScale = val2; } val.SetActive(true); shown.Gos.Add(val); } } catch { } } } internal static bool IsMirror(GameObject go) { Transform val = (((Object)(object)go != (Object)null) ? go.transform : null); while ((Object)(object)val != (Object)null) { if ((((Object)val).name ?? "").Contains("Mirror_")) { return true; } val = val.parent; } return false; } private static void Num(StringBuilder sb, float v, int dp = 2) { sb.Append(Math.Round(v, dp).ToString(CultureInfo.InvariantCulture)); } private static Vector3 Vec(string s) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) string[] a = s.Split(','); return new Vector3(P(a, 0), P(a, 1), P(a, 2)); } private static Quaternion Rot(string s) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0088: 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_0098: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) string[] a = s.Split(','); Quaternion val = default(Quaternion); ((Quaternion)(ref val))..ctor(P(a, 0), P(a, 1), P(a, 2), P(a, 3)); float num = Mathf.Sqrt(val.x * val.x + val.y * val.y + val.z * val.z + val.w * val.w); if (!(num > 0.0001f)) { return Quaternion.identity; } return new Quaternion(val.x / num, val.y / num, val.z / num, val.w / num); } private static float P(string[] a, int i) { if (i >= a.Length || !float.TryParse(a[i], NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) { return 0f; } return result; } private static void Destroy(Shown s) { foreach (GameObject go in s.Gos) { try { if ((Object)(object)go != (Object)null) { Object.Destroy((Object)(object)go); } } catch { } } s.Gos.Clear(); } private static void Clear() { foreach (KeyValuePair view in Views) { Destroy(view.Value); } Views.Clear(); } } internal static class Core { internal const string PickupLabel = "Hold Right Click"; public static Instance Log => Kit.Log; public static KeyCode ViewKey => FortifyApi.UseKey; public static KeyCode RotateKey => Kit.RotateKey; } internal static class GltfLoader { private static readonly Dictionary TexCache = new Dictionary(); public static GameObject LoadEmbedded(string fileName, Transform parent) { using Stream stream = Res.Open(Kit.ModelResourcePrefix + fileName); if (stream == null) { throw new FileNotFoundException("Embedded model missing: " + fileName); } using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); return Load(memoryStream.ToArray(), Path.GetFileNameWithoutExtension(fileName), parent); } public static GameObject Load(byte[] glb, string name, Transform parent) { //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Expected O, but got Unknown if (glb.Length < 20 || BitConverter.ToUInt32(glb, 0) != 1179937895) { throw new InvalidDataException("Not a GLB file"); } int num = (int)BitConverter.ToUInt32(glb, 12); string json = Encoding.UTF8.GetString(glb, 20, num); int bin = 20 + num + 8; using JsonDocument jsonDocument = JsonDocument.Parse(json); JsonElement rootElement = jsonDocument.RootElement; Material[] materials = BuildMaterials(rootElement, glb, 20 + num + 8); Dictionary meshCache = new Dictionary(); GameObject val = new GameObject(name); val.transform.SetParent(parent, false); JsonElement property = rootElement.GetProperty("nodes"); HashSet hashSet = new HashSet(); for (int i = 0; i < property.GetArrayLength(); i++) { if (!property[i].TryGetProperty("children", out var value)) { continue; } foreach (JsonElement item in value.EnumerateArray()) { hashSet.Add(item.GetInt32()); } } for (int j = 0; j < property.GetArrayLength(); j++) { if (!hashSet.Contains(j)) { BuildNode(rootElement, property, j, val.transform, glb, bin, materials, meshCache); } } return val; } private static void BuildNode(JsonElement root, JsonElement nodes, int index, Transform parent, byte[] glb, int bin, Material[] materials, Dictionary meshCache) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) JsonElement jsonElement = nodes[index]; JsonElement value; GameObject val = new GameObject(jsonElement.TryGetProperty("name", out value) ? value.GetString() : ("node" + index)); Transform transform = val.transform; transform.SetParent(parent, false); if (jsonElement.TryGetProperty("translation", out var value2)) { transform.localPosition = new Vector3(value2[0].GetSingle(), value2[1].GetSingle(), 0f - value2[2].GetSingle()); } if (jsonElement.TryGetProperty("rotation", out var value3)) { transform.localRotation = new Quaternion(0f - value3[0].GetSingle(), 0f - value3[1].GetSingle(), value3[2].GetSingle(), value3[3].GetSingle()); } if (jsonElement.TryGetProperty("scale", out var value4)) { transform.localScale = new Vector3(value4[0].GetSingle(), value4[1].GetSingle(), value4[2].GetSingle()); } if (jsonElement.TryGetProperty("mesh", out var value5)) { int @int = value5.GetInt32(); if (!meshCache.TryGetValue(@int, out var value6)) { (Mesh, Material[]) tuple = (meshCache[@int] = BuildMesh(root, @int, glb, bin, materials)); value6 = tuple; } val.AddComponent().sharedMesh = value6.Item1; MeshRenderer val2 = val.AddComponent(); Il2CppReferenceArray val3 = new Il2CppReferenceArray((long)value6.Item2.Length); for (int i = 0; i < value6.Item2.Length; i++) { ((Il2CppArrayBase)(object)val3)[i] = value6.Item2[i]; } ((Renderer)val2).sharedMaterials = val3; } if (!jsonElement.TryGetProperty("children", out var value7)) { return; } foreach (JsonElement item in value7.EnumerateArray()) { BuildNode(root, nodes, item.GetInt32(), transform, glb, bin, materials, meshCache); } } private static (Mesh, Material[]) BuildMesh(JsonElement root, int meshIndex, byte[] glb, int bin, Material[] materials) { //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_02de: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Expected O, but got Unknown //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_0192: 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) JsonElement property = root.GetProperty("meshes")[meshIndex].GetProperty("primitives"); List list = new List(); List list2 = new List(); List list3 = new List(); List list4 = new List(); List list5 = new List(); foreach (JsonElement item in property.EnumerateArray()) { JsonElement property2 = item.GetProperty("attributes"); int count = list.Count; int count2; float[] array = ReadFloats(root, property2.GetProperty("POSITION").GetInt32(), glb, bin, out count2); for (int i = 0; i < count2; i++) { list.Add(new Vector3(array[i * 3], array[i * 3 + 1], 0f - array[i * 3 + 2])); } int count3; if (property2.TryGetProperty("NORMAL", out var value)) { float[] array2 = ReadFloats(root, value.GetInt32(), glb, bin, out count3); for (int j = 0; j < count2; j++) { list2.Add(new Vector3(array2[j * 3], array2[j * 3 + 1], 0f - array2[j * 3 + 2])); } } else { for (int k = 0; k < count2; k++) { list2.Add(Vector3.up); } } if (property2.TryGetProperty("TEXCOORD_0", out var value2)) { float[] array3 = ReadFloats(root, value2.GetInt32(), glb, bin, out count3); for (int l = 0; l < count2; l++) { list3.Add(new Vector2(array3[l * 2], 1f - array3[l * 2 + 1])); } } else { for (int m = 0; m < count2; m++) { list3.Add(Vector2.zero); } } int[] array4; if (item.TryGetProperty("indices", out var value3)) { array4 = ReadIndices(root, value3.GetInt32(), glb, bin); } else { array4 = new int[count2]; for (int n = 0; n < count2; n++) { array4[n] = n; } } for (int num = 0; num + 2 < array4.Length; num += 3) { int num2 = array4[num] + count; int num3 = array4[num + 1] + count; int num4 = array4[num + 2] + count; array4[num] = num2; array4[num + 1] = num4; array4[num + 2] = num3; } list4.Add(array4); JsonElement value4; int num5 = (item.TryGetProperty("material", out value4) ? value4.GetInt32() : (-1)); list5.Add((num5 >= 0 && num5 < materials.Length) ? materials[num5] : Models.Mat("gltf_default", Color.gray)); } Mesh val = new Mesh { name = "HTF_" + meshIndex }; if (list.Count > 65000) { val.indexFormat = (IndexFormat)1; } val.vertices = new Il2CppStructArray(list.ToArray()); val.normals = new Il2CppStructArray(list2.ToArray()); val.uv = new Il2CppStructArray(list3.ToArray()); val.subMeshCount = list4.Count; for (int num6 = 0; num6 < list4.Count; num6++) { val.SetTriangles(new Il2CppStructArray(list4[num6]), num6); } val.RecalculateBounds(); ((Object)val).hideFlags = (HideFlags)32; return (val, list5.ToArray()); } private static Material[] BuildMaterials(JsonElement root, byte[] glb, int bin) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_033c: Unknown result type (might be due to invalid IL or missing references) //IL_0343: Unknown result type (might be due to invalid IL or missing references) if (!root.TryGetProperty("materials", out var value)) { return Array.Empty(); } Material[] array = (Material[])(object)new Material[value.GetArrayLength()]; for (int i = 0; i < array.Length; i++) { JsonElement jsonElement = value[i]; JsonElement value2; string text = (jsonElement.TryGetProperty("name", out value2) ? value2.GetString() : ("mat" + i)); Color white = Color.white; float metallic = 1f; float num = 1f; JsonElement value5; if (jsonElement.TryGetProperty("pbrMetallicRoughness", out var value3)) { if (value3.TryGetProperty("baseColorFactor", out var value4)) { float single = value4[0].GetSingle(); float single2 = value4[1].GetSingle(); float single3 = value4[2].GetSingle(); value5 = value4[3]; ((Color)(ref white))..ctor(single, single2, single3, value5.GetSingle()); } if (value3.TryGetProperty("metallicFactor", out var value6)) { metallic = value6.GetSingle(); } if (value3.TryGetProperty("roughnessFactor", out var value7)) { num = value7.GetSingle(); } } Color? emission = null; if (jsonElement.TryGetProperty("emissiveFactor", out var value8)) { float num2 = 1f; if (jsonElement.TryGetProperty("extensions", out var value9) && value9.TryGetProperty("KHR_materials_emissive_strength", out var value10) && value10.TryGetProperty("emissiveStrength", out var value11)) { num2 = value11.GetSingle(); } float single4 = value8[0].GetSingle(); float single5 = value8[1].GetSingle(); value5 = value8[2]; Color value12 = new Color(single4, single5, value5.GetSingle()) * Mathf.Min(num2, 8f) * 0.5f; if (((Color)(ref value12)).maxColorComponent > 0.001f) { emission = value12; } } Texture2D val = null; if (value3.ValueKind == JsonValueKind.Object && value3.TryGetProperty("baseColorTexture", out var value13)) { JsonElement root2 = root; value5 = value13.GetProperty("index"); val = LoadTexture(root2, value5.GetInt32(), glb, bin); } if ((Object)(object)val != (Object)null && !emission.HasValue && jsonElement.TryGetProperty("emissiveTexture", out value5)) { emission = Color.white; } Material val2 = Models.Mat("glb_" + text, ((Object)(object)val != (Object)null) ? Color.white : white, metallic, 1f - num, emission); if ((Object)(object)val != (Object)null) { val2.mainTexture = (Texture)(object)val; if (val2.HasProperty("_BaseMap")) { val2.SetTexture("_BaseMap", (Texture)(object)val); } if (emission.HasValue && jsonElement.TryGetProperty("emissiveTexture", out value5)) { if (val2.HasProperty("_EmissionMap")) { val2.SetTexture("_EmissionMap", (Texture)(object)val); } float num3 = 1f; if (jsonElement.TryGetProperty("extensions", out var value14) && value14.TryGetProperty("KHR_materials_emissive_strength", out var value15) && value15.TryGetProperty("emissiveStrength", out var value16)) { num3 = Mathf.Min(value16.GetSingle(), 8f) * 0.5f; } val2.SetColor("_EmissionColor", Color.white * num3); } } array[i] = val2; } return array; } private static Texture2D LoadTexture(JsonElement root, int texIndex, byte[] glb, int bin) { //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Expected O, but got Unknown try { int @int = root.GetProperty("textures")[texIndex].GetProperty("source").GetInt32(); JsonElement jsonElement = root.GetProperty("images")[@int]; JsonElement value; string key = (jsonElement.TryGetProperty("name", out value) ? value.GetString() : "img") + "#" + @int + "#" + glb.Length; if (TexCache.TryGetValue(key, out var value2) && (Object)(object)value2 != (Object)null) { return value2; } JsonElement jsonElement2 = root.GetProperty("bufferViews")[jsonElement.GetProperty("bufferView").GetInt32()]; JsonElement value3; int srcOffset = bin + (jsonElement2.TryGetProperty("byteOffset", out value3) ? value3.GetInt32() : 0); int int2 = jsonElement2.GetProperty("byteLength").GetInt32(); byte[] array = new byte[int2]; Buffer.BlockCopy(glb, srcOffset, array, 0, int2); Texture2D val = new Texture2D(2, 2, (TextureFormat)4, true); if (!ImageConversion.LoadImage(val, new Il2CppStructArray(array), false)) { return null; } ((Texture)val).wrapMode = (TextureWrapMode)0; ((Texture)val).filterMode = (FilterMode)2; ((Texture)val).anisoLevel = 8; ((Object)val).hideFlags = (HideFlags)32; TexCache[key] = val; return val; } catch { return null; } } private static float[] ReadFloats(JsonElement root, int accessor, byte[] glb, int bin, out int count) { JsonElement jsonElement = root.GetProperty("accessors")[accessor]; count = jsonElement.GetProperty("count").GetInt32(); int num = Components(jsonElement.GetProperty("type").GetString()); JsonElement jsonElement2 = root.GetProperty("bufferViews")[jsonElement.GetProperty("bufferView").GetInt32()]; JsonElement value; JsonElement value2; int num2 = bin + (jsonElement2.TryGetProperty("byteOffset", out value) ? value.GetInt32() : 0) + (jsonElement.TryGetProperty("byteOffset", out value2) ? value2.GetInt32() : 0); JsonElement value3; int num3 = (jsonElement2.TryGetProperty("byteStride", out value3) ? value3.GetInt32() : (num * 4)); float[] array = new float[count * num]; for (int i = 0; i < count; i++) { for (int j = 0; j < num; j++) { array[i * num + j] = BitConverter.ToSingle(glb, num2 + i * num3 + j * 4); } } return array; } private static int[] ReadIndices(JsonElement root, int accessor, byte[] glb, int bin) { JsonElement jsonElement = root.GetProperty("accessors")[accessor]; int @int = jsonElement.GetProperty("count").GetInt32(); int int2 = jsonElement.GetProperty("componentType").GetInt32(); JsonElement value; JsonElement value2; int num = bin + (root.GetProperty("bufferViews")[jsonElement.GetProperty("bufferView").GetInt32()].TryGetProperty("byteOffset", out value) ? value.GetInt32() : 0) + (jsonElement.TryGetProperty("byteOffset", out value2) ? value2.GetInt32() : 0); int[] array = new int[@int]; for (int i = 0; i < @int; i++) { int[] array2 = array; int num2 = i; int[] array3 = array2; int num3 = num2; array3[num3] = int2 switch { 5121 => glb[num + i], 5123 => BitConverter.ToUInt16(glb, num + i * 2), _ => (int)BitConverter.ToUInt32(glb, num + i * 4), }; } return array; } private static int Components(string type) { return type switch { "SCALAR" => 1, "VEC2" => 2, "VEC3" => 3, "VEC4" => 4, _ => 1, }; } } internal static class Host { public static bool Ok; public static string LinkedInGameNote = "Fortify Your Base already sells these at the hardware stores."; private static bool _linkedTold; private static bool _whereTold; public static string WhereToBuyNote; private static string _linkedNote; private static Action _onLoaded; private static Action _onUnloaded; private static string _folder; public static void Init(MelonMod mod, string folder, string title, string prefix, string linkedNote = null, Action onLoaded = null, Action onUnloaded = null) { _folder = folder; Kit.Log = ((MelonBase)mod).LoggerInstance; Kit.Prefix = prefix; Kit.Title = title; Kit.ModelResourcePrefix = ((object)mod).GetType().Namespace + ".models."; FortifyApi.Init(mod, folder, title); _linkedNote = linkedNote; _onLoaded = onLoaded; _onUnloaded = onUnloaded; FortifyApi.AfterLoad += Loaded; FortifyApi.BeforeSave += Placement.Save; FortifyApi.Unloaded += Unloaded; } private static void Loaded() { Registration.ResetForNewScene(); Placement.Load(); try { _onLoaded?.Invoke(); } catch (Exception ex) { Instance log = Kit.Log; if (log != null) { log.Warning("Loading: " + ex.Message); } } MelonCoroutines.Start(Registration.RenderIcons()); } private static void Unloaded() { try { _onUnloaded?.Invoke(); } catch { } Placement.Reset(); CoopMirror.Reset(); } public static bool Update() { //IL_00f3: Unknown result type (might be due to invalid IL or missing references) if (!Ok) { return false; } try { Registration.TryRegister(); } catch { } if (!FortifyApi.InGame) { return false; } FortifyApi.Frame(); try { StuckInput.Update(); } catch { } if (FortifyApi.Linked && _linkedNote != null) { if (!_linkedTold) { _linkedTold = true; Instance log = Kit.Log; if (log != null) { log.Msg(_linkedNote); } TellLinkedOnce(); } Registration.TryAddToShops(onlyWithFyb: true); } else { Registration.TryAddToShops(); } if (!_whereTold && WhereToBuyNote != null && FortifyApi.DataReady) { _whereTold = true; if (!FortifyApi.Linked || _linkedNote == null) { TellWhereOnce(); } } try { Placement.Update(); try { CoopMirror.Update(); } catch { } } catch (Exception ex) { if (Time.frameCount % 600 == 0) { Instance log2 = Kit.Log; if (log2 != null) { log2.Warning("Placement: " + ex.Message); } } } if (FortifyApi.DevKeys && FortifyApi.KeyHeld((KeyCode)308) && FortifyApi.KeyDown(Kit.DevGiveKey)) { Placement.DevGive(); } return true; } private static void TellLinkedOnce() { try { MelonPreferences_Category val = MelonPreferences.GetCategory(_folder) ?? MelonPreferences.CreateCategory(_folder, Kit.Title); MelonPreferences_Entry val2 = val.GetEntry("LinkedNoticeShown") ?? val.CreateEntry("LinkedNoticeShown", false, "Linked notice shown", "Set once the in-game note about Fortify Your Base has been shown.", true, false, (ValueValidator)null, (string)null); if (!val2.Value) { val2.Value = true; FortifyApi.Notify(Kit.Title, LinkedInGameNote); MelonPreferences.Save(); } } catch { } } private static void TellWhereOnce() { try { MelonPreferences_Category val = MelonPreferences.GetCategory(_folder) ?? MelonPreferences.CreateCategory(_folder, Kit.Title); MelonPreferences_Entry val2 = val.GetEntry("WhereNoticeShown") ?? val.CreateEntry("WhereNoticeShown", false, "Where-to-buy notice shown", "Set once the in-game note about where the items are sold has been shown.", true, false, (ValueValidator)null, (string)null); if (!val2.Value) { val2.Value = true; FortifyApi.Notify(Kit.Title, WhereToBuyNote); MelonPreferences.Save(); } } catch { } } public static void DrawHint() { if (!Ok || !FortifyApi.InGame) { return; } try { FortifyApi.Hint(Placement.Hint); PickupHold.Draw(); } catch { } } } internal static class InputUtil { private static bool _legacyBroken; public static bool Suppressed; public static KeyCode Parse(string name, KeyCode fallback) { //IL_001a: 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) if (!string.IsNullOrWhiteSpace(name) && Enum.TryParse(name.Trim(), ignoreCase: true, out KeyCode result)) { return result; } return fallback; } public static bool Down(KeyCode key) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) if (!Suppressed && !TextBoxElsewhere()) { return RawDown(key); } return false; } public static bool Held(KeyCode key) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) if (!Suppressed && !TextBoxElsewhere()) { return RawHeld(key); } return false; } private static bool TextBoxElsewhere() { try { return AppDomain.CurrentDomain.GetData("WoodStudios.TextBoxFrame") is int num && Time.frameCount - num <= 2; } catch { return false; } } public static bool RawDown(KeyCode key) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) if (!_legacyBroken) { try { return Input.GetKeyDown(key); } catch { _legacyBroken = true; } } KeyControl obj2 = Control(key); if (obj2 == null) { return false; } return ((ButtonControl)obj2).wasPressedThisFrame; } public static bool RawHeld(KeyCode key) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) if (!_legacyBroken) { try { return Input.GetKey(key); } catch { _legacyBroken = true; } } KeyControl obj2 = Control(key); if (obj2 == null) { return false; } return ((ButtonControl)obj2).isPressed; } public static bool MouseDown(int button) { if (!_legacyBroken) { try { return Input.GetMouseButtonDown(button); } catch { _legacyBroken = true; } } try { Mouse current = Mouse.current; if (current == null) { return false; } return (button == 0) ? current.leftButton.wasPressedThisFrame : current.rightButton.wasPressedThisFrame; } catch { return false; } } public static bool MouseHeld(int button) { if (!_legacyBroken) { try { return Input.GetMouseButton(button); } catch { _legacyBroken = true; } } try { Mouse current = Mouse.current; if (current == null) { return false; } return (button == 0) ? current.leftButton.isPressed : current.rightButton.isPressed; } catch { return false; } } private unsafe static KeyControl Control(KeyCode key) { //IL_0098: Unknown result type (might be due to invalid IL or missing references) try { Keyboard current = Keyboard.current; if (current == null) { return null; } string text = ((object)(*(KeyCode*)(&key))/*cast due to .constrained prefix*/).ToString(); if (text.StartsWith("Alpha")) { text = "Digit" + text.Substring(5); } else if (text == "Return") { text = "Enter"; } else if (text == "KeypadEnter") { text = "NumpadEnter"; } else if (text.StartsWith("Keypad")) { text = "Numpad" + text.Substring(6); } if (!Enum.TryParse(text, ignoreCase: true, out Key result)) { return null; } return current[result]; } catch { return null; } } } internal sealed class ItemSpec { public string Id; public string Name; public string Description; public float Price; public PlaceKind Kind; public int StackLimit = 10; public float RotateStep = 90f; public Color IconColor = Color.gray; public Func BuildModel; public Func IconModel; public string[] Stores; public bool NotSold; public bool SoldWithFyb; public float FitLift; public Bounds? FitBounds; public GameObject Template; } internal static class Kit { public delegate bool UseHandler(Placement.Placed p, RaycastHit hit, out string hint); public delegate bool Placer(ItemSpec spec, Camera cam, Player player, out string hint); public static string Prefix = "wk_"; public static string ModelResourcePrefix = "WoodKit.models."; public static string Title = "Wood Studios"; public static string SaveKey = "Items"; public static Instance Log; public static string[] Stores = new string[2] { "Dan's Hardware", "Handy Hank's Hardware" }; public static Func PriceMultiplier = () => 1f; public static KeyCode RotateKey = (KeyCode)114; public static KeyCode DevGiveKey = (KeyCode)117; public static readonly Dictionary Use = new Dictionary(StringComparer.OrdinalIgnoreCase); public static readonly Dictionary CustomPlace = new Dictionary(StringComparer.OrdinalIgnoreCase); public static Func Busy = () => false; public static Func CanPickUp; public static event Action Created; public static event Action Removed; internal static void RaiseCreated(Placement.Placed p) { try { Kit.Created?.Invoke(p); } catch (Exception ex) { Instance log = Log; if (log != null) { log.Warning(p?.Spec?.Name + ": " + ex.Message); } } } internal static void RaiseRemoved(Placement.Placed p) { try { Kit.Removed?.Invoke(p); } catch (Exception ex) { Instance log = Log; if (log != null) { log.Warning(p?.Spec?.Name + ": " + ex.Message); } } } } internal static class Locals { private const int Nearest = 2; private static float _next; private static float _localsAt = -100f; private static readonly List _locals = new List(); private static readonly HashSet _localSet = new HashSet(); private static readonly HashSet _reported = new HashSet(); private static bool _warned; public static void Reset() { _locals.Clear(); _localSet.Clear(); _reported.Clear(); _localsAt = -100f; _next = 0f; } public static void Keep(IList ours, string title) { if (ours == null || ours.Count == 0 || Time.unscaledTime < _next) { return; } _next = Time.unscaledTime + 5f; try { if (_locals.Count == 0 || (Object)(object)_locals[0] == (Object)null || Time.unscaledTime - _localsAt > 60f) { FindLocals(); } if (_locals.Count == 0) { return; } foreach (NPC our in ours) { if ((Object)(object)our != (Object)null) { Link(our, title); } } } catch (Exception ex) { if (!_warned) { _warned = true; Instance log = Kit.Log; if (log != null) { log.Warning(title + ": linking customers to the locals (" + ex.Message + ")."); } } } } private static void FindLocals() { _localsAt = Time.unscaledTime; _locals.Clear(); _localSet.Clear(); HashSet hashSet = new HashSet(); Assembly assembly = typeof(NPC).Assembly; foreach (NPC item in NPC.All) { try { if (item != null && ((object)item).GetType().Assembly != assembly && (Object)(object)item.gameObject != (Object)null) { hashSet.Add(((Il2CppObjectBase)item.gameObject).Pointer); } } catch { } } List nPCRegistry = NPCManager.NPCRegistry; int num = 0; while (nPCRegistry != null && num < nPCRegistry.Count) { NPC val = nPCRegistry[num]; if (!((Object)(object)val == (Object)null) && !((Object)(object)((Component)val).gameObject == (Object)null) && !hashSet.Contains(((Il2CppObjectBase)((Component)val).gameObject).Pointer) && val.RelationData != null && !((Object)(object)((Component)val).GetComponent() == (Object)null)) { _locals.Add(val); _localSet.Add(((Il2CppObjectBase)val).Pointer); } num++; } } private static bool Has(List list, NPC n) { for (int i = 0; i < list.Count; i++) { NPC val = list[i]; if ((Object)(object)val != (Object)null && ((Il2CppObjectBase)val).Pointer == ((Il2CppObjectBase)n).Pointer) { return true; } } return false; } private static void Join(NPC me, NPC local) { List connections = me.RelationData.Connections; if (!Has(connections, local)) { connections.Add(local); } NPCRelationData relationData = local.RelationData; List val = ((relationData != null) ? relationData.Connections : null); if (val != null && !Has(val, me)) { val.Add(me); } } private static void Link(NPC me, string title) { //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) NPCRelationData relationData = me.RelationData; List val = ((relationData != null) ? relationData.Connections : null); if (val == null) { return; } int num = 0; bool flag = false; for (int i = 0; i < val.Count; i++) { NPC val2 = val[i]; if (!((Object)(object)val2 == (Object)null) && _localSet.Contains(((Il2CppObjectBase)val2).Pointer)) { num++; if (val2.RelationData != null && val2.RelationData.Unlocked) { flag = true; } } } if (num >= 2 && (flag || relationData.Unlocked)) { return; } Vector3 at = ((Component)me).transform.position; EMapRegion region = me.Region; List list = new List(); foreach (NPC local in _locals) { if ((Object)(object)local != (Object)null && local.Region == region) { list.Add(local); } } if (list.Count == 0) { list.AddRange(_locals); } list.Sort(delegate(NPC a, NPC b) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) Vector3 val3 = ((Component)a).transform.position - at; float sqrMagnitude = ((Vector3)(ref val3)).sqrMagnitude; val3 = ((Component)b).transform.position - at; return sqrMagnitude.CompareTo(((Vector3)(ref val3)).sqrMagnitude); }); List list2 = new List(); foreach (NPC item in list) { if (num >= 2) { break; } if (!Has(val, item)) { Join(me, item); num++; if (item.RelationData.Unlocked) { flag = true; } list2.Add(item.FirstName); } } if (!flag && !relationData.Unlocked) { foreach (NPC item2 in list) { if (item2.RelationData.Unlocked && !Has(val, item2)) { Join(me, item2); list2.Add(item2.FirstName + " (you know them)"); break; } } } if (list2.Count <= 0 || !FortifyApi.DevKeys) { return; } string value = ""; if (!_reported.Contains(((Il2CppObjectBase)me).Pointer)) { _reported.Add(((Il2CppObjectBase)me).Pointer); try { Customer component = ((Component)me).GetComponent(); string text = null; bool flag2 = (Object)(object)component != (Object)null && component.SampleOptionValid(ref text); value = (relationData.Unlocked ? " Already a customer." : (flag2 ? " A sample can be offered now." : (" No sample yet: " + text + "."))); } catch (Exception ex) { value = " (sample check: " + ex.Message + ")"; } } Instance log = Kit.Log; if (log != null) { log.Msg($"{title}: {me.FirstName} knows {string.Join(", ", list2)}.{value}"); } } } internal static class Models { private static GameObject _root; private static readonly Dictionary Mats = new Dictionary(); private static Shader _litShader; public const float WallHeight = 2.4f; public const float WallThick = 0.25f; public static Transform Root { get { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown if ((Object)(object)_root == (Object)null) { _root = new GameObject(Kit.Prefix + "Templates"); _root.SetActive(false); Object.DontDestroyOnLoad((Object)(object)_root); } return _root.transform; } } internal static Material Concrete => Mat("concrete", new Color(0.58f, 0.58f, 0.56f), 0f, 0.12f); internal static Material Mortar => Mat("mortar", new Color(0.42f, 0.42f, 0.41f), 0f, 0.05f); internal static Material SteelDark => Mat("steel_dark", new Color(0.2f, 0.21f, 0.23f), 0.8f, 0.45f); internal static Material SteelLight => Mat("steel_light", new Color(0.55f, 0.57f, 0.6f), 0.85f, 0.55f); internal static Material Housing => Mat("housing", new Color(0.86f, 0.86f, 0.84f), 0.1f, 0.5f); internal static Material BlackPlastic => Mat("black", new Color(0.05f, 0.05f, 0.06f), 0.2f, 0.6f); internal static Material LedRed => Mat("led_red", new Color(1f, 0.1f, 0.1f), 0f, 0.8f, (Color?)new Color(4f, 0.2f, 0.2f)); internal static Material LensWarm => Mat("lens_warm", new Color(1f, 0.96f, 0.85f), 0f, 0.9f, (Color?)new Color(3f, 2.8f, 2.3f)); internal static Material Chain => Mat("chain", new Color(0.52f, 0.54f, 0.57f), 0.7f, 0.4f); internal static Material Burlap => Mat("burlap", new Color(0.62f, 0.55f, 0.4f), 0f, 0.05f); internal static Material Hazard => Mat("hazard", new Color(0.95f, 0.75f, 0.1f)); internal static Shader Lit() { return LitShader(); } public static Sprite FallbackIcon(Color color) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(64, 64, (TextureFormat)4, false); Color val2 = default(Color); ((Color)(ref val2))..ctor(0f, 0f, 0f, 0f); for (int i = 0; i < 64; i++) { for (int j = 0; j < 64; j++) { bool flag = i > 6 && i < 57 && j > 6 && j < 57; bool flag2 = flag && (i < 11 || i > 52 || j < 11 || j > 52); val.SetPixel(i, j, (!flag) ? val2 : (flag2 ? (color * 0.55f) : color)); } } val.Apply(); ((Object)val).hideFlags = (HideFlags)32; Sprite obj = Sprite.Create(val, new Rect(0f, 0f, 64f, 64f), new Vector2(0.5f, 0.5f)); ((Object)obj).hideFlags = (HideFlags)32; return obj; } private static Shader LitShader() { if ((Object)(object)_litShader != (Object)null) { return _litShader; } _litShader = Shader.Find("Universal Render Pipeline/Lit"); if ((Object)(object)_litShader == (Object)null) { _litShader = Shader.Find("Universal Render Pipeline/Simple Lit"); } if ((Object)(object)_litShader == (Object)null) { foreach (Material item in Resources.FindObjectsOfTypeAll()) { if ((Object)(object)item != (Object)null && (Object)(object)item.shader != (Object)null && ((Object)item.shader).name.Contains("Lit")) { _litShader = item.shader; break; } } } if ((Object)(object)_litShader == (Object)null) { _litShader = Shader.Find("Standard"); } return _litShader; } public static Material Mat(string key, Color color, float metallic = 0f, float smoothness = 0.3f, Color? emission = null) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) if (Mats.TryGetValue(key, out var value) && (Object)(object)value != (Object)null) { return value; } Material val = new Material(LitShader()); ((Object)val).name = Kit.Prefix + key; val.color = color; if (val.HasProperty("_BaseColor")) { val.SetColor("_BaseColor", color); } if (val.HasProperty("_Metallic")) { val.SetFloat("_Metallic", metallic); } if (val.HasProperty("_Smoothness")) { val.SetFloat("_Smoothness", smoothness); } if (val.HasProperty("_Glossiness")) { val.SetFloat("_Glossiness", smoothness); } if (emission.HasValue) { val.EnableKeyword("_EMISSION"); if (val.HasProperty("_EmissionColor")) { val.SetColor("_EmissionColor", emission.Value); } val.globalIlluminationFlags = (MaterialGlobalIlluminationFlags)1; } ((Object)val).hideFlags = (HideFlags)32; Mats[key] = val; return val; } internal static GameObject NewRoot(string name) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown GameObject val = new GameObject(name); val.transform.SetParent(Root, false); return val; } internal static GameObject Prim(PrimitiveType type, Transform parent, Vector3 pos, Vector3 scale, Material mat, Vector3? euler = null, bool keepCollider = false) { //IL_0000: 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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) GameObject val = GameObject.CreatePrimitive(type); val.transform.SetParent(parent, false); val.transform.localPosition = pos; val.transform.localRotation = (euler.HasValue ? Quaternion.Euler(euler.Value) : Quaternion.identity); val.transform.localScale = scale; MeshRenderer component = val.GetComponent(); if ((Object)(object)component != (Object)null) { ((Renderer)component).sharedMaterial = mat; } if (!keepCollider) { Collider component2 = val.GetComponent(); if ((Object)(object)component2 != (Object)null) { Object.DestroyImmediate((Object)(object)component2); } } return val; } internal static GameObject Box(Transform p, Vector3 pos, Vector3 size, Material m, Vector3? euler = null) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) return Prim((PrimitiveType)3, p, pos, size, m, euler); } internal static GameObject Rod(Transform p, Vector3 pos, float radius, float height, Material m, Vector3? euler = null) { //IL_0002: 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) return Prim((PrimitiveType)2, p, pos, new Vector3(radius * 2f, height * 0.5f, radius * 2f), m, euler); } internal static void AddBoxCollider(GameObject go, Vector3 center, Vector3 size) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) BoxCollider obj = go.AddComponent(); obj.center = center; obj.size = size; } internal static void NavBlock(GameObject go, Vector3 center, Vector3 size) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) AddNavObstacle(go, center, size); } private static void AddNavObstacle(GameObject go, Vector3 center, Vector3 size) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) try { NavMeshObstacle obj = go.AddComponent(); obj.shape = (NavMeshObstacleShape)1; obj.center = center; obj.size = size; obj.carving = true; } catch { } } public static void Combine(Transform root) { //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_016c: 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_018e: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Expected O, but got Unknown //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) Dictionary> dictionary = new Dictionary>(); Dictionary dictionary2 = new Dictionary(); foreach (MeshFilter componentsInChild in ((Component)root).GetComponentsInChildren(true)) { if ((Object)(object)((Component)componentsInChild).transform == (Object)(object)root || (Object)(object)componentsInChild.sharedMesh == (Object)null) { continue; } if (!componentsInChild.sharedMesh.isReadable) { return; } MeshRenderer component = ((Component)componentsInChild).GetComponent(); if (!((Object)(object)component == (Object)null) && !((Object)(object)((Renderer)component).sharedMaterial == (Object)null)) { int instanceID = ((Object)((Renderer)component).sharedMaterial).GetInstanceID(); if (!dictionary.TryGetValue(instanceID, out var value)) { List list = (dictionary[instanceID] = new List()); value = list; dictionary2[instanceID] = ((Renderer)component).sharedMaterial; } value.Add(componentsInChild); } } Matrix4x4 worldToLocalMatrix = root.worldToLocalMatrix; foreach (KeyValuePair> item in dictionary) { if (item.Value.Count < 2) { continue; } Il2CppStructArray val = new Il2CppStructArray((long)item.Value.Count); for (int i = 0; i < item.Value.Count; i++) { int num = i; CombineInstance val2 = default(CombineInstance); ((CombineInstance)(ref val2)).mesh = item.Value[i].sharedMesh; ((CombineInstance)(ref val2)).transform = worldToLocalMatrix * ((Component)item.Value[i]).transform.localToWorldMatrix; ((Il2CppArrayBase)(object)val)[num] = val2; } Mesh val3 = new Mesh { name = "HTF_Combined" }; val3.indexFormat = (IndexFormat)1; val3.CombineMeshes(val, true, true); val3.RecalculateBounds(); ((Object)val3).hideFlags = (HideFlags)32; GameObject val4 = new GameObject("Combined_" + ((Object)dictionary2[item.Key]).name); val4.transform.SetParent(root, false); val4.AddComponent().sharedMesh = val3; ((Renderer)val4.AddComponent()).sharedMaterial = dictionary2[item.Key]; foreach (MeshFilter item2 in item.Value) { Object.DestroyImmediate((Object)(object)((Component)item2).gameObject); } } } internal static void MeshColliders(GameObject root, params string[] prefixes) { foreach (MeshFilter componentsInChild in root.GetComponentsInChildren(true)) { foreach (string value in prefixes) { if (((Object)componentsInChild).name.StartsWith(value, StringComparison.Ordinal)) { ((Component)componentsInChild).gameObject.AddComponent().sharedMesh = componentsInChild.sharedMesh; break; } } } } internal static Light AddPointLight(Transform parent, string name, Vector3 local, float range, float intensity, Color color) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name); val.transform.SetParent(parent, false); val.transform.localPosition = local; Light obj = val.AddComponent(); obj.type = (LightType)2; obj.range = range; obj.intensity = intensity; obj.color = color; obj.shadows = (LightShadows)0; return obj; } internal static AudioSource AddAudio(Transform parent, string name, Vector3 local, AudioClip clip, bool loop, bool playOnAwake, float volume, float maxDistance) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name); val.transform.SetParent(parent, false); val.transform.localPosition = local; AudioSource obj = val.AddComponent(); obj.clip = clip; obj.loop = loop; obj.playOnAwake = playOnAwake; obj.spatialBlend = 1f; obj.rolloffMode = (AudioRolloffMode)1; obj.minDistance = 1.5f; obj.maxDistance = maxDistance; obj.volume = volume; return obj; } } internal static class PickupHold { private const float Seconds = 0.6f; private static float _start = -1f; private static int _target; private static int _lastFrame = -10; public static float Progress { get; private set; } public static bool Showing { get { if (Progress > 0f) { return Time.frameCount - _lastFrame <= 2; } return false; } } public static bool Held(GameObject target) { int num = (((Object)(object)target != (Object)null) ? ((Object)target).GetInstanceID() : 0); int frameCount = Time.frameCount; bool flag = frameCount - _lastFrame > 2; _lastFrame = frameCount; if (num == 0 || !MouseHeld() || HoldingWeapon()) { _start = -1f; Progress = 0f; _target = num; return false; } if (_start < 0f || num != _target || flag) { _target = num; Progress = 0f; if (!Keys.MouseDown(1)) { _start = -1f; return false; } _start = Time.unscaledTime; } Progress = Mathf.Clamp01((Time.unscaledTime - _start) / 0.6f); if (Progress < 1f) { return false; } _start = -1f; Progress = 0f; return true; } private static bool MouseHeld() { try { return Input.GetMouseButton(1); } catch { try { Mouse current = Mouse.current; return current != null && current.rightButton.isPressed; } catch { return false; } } } private static bool HoldingWeapon() { try { PlayerInventory instance = PlayerSingleton.Instance; Equippable val = ((instance != null) ? instance.Equippable : null); if ((Object)(object)val == (Object)null) { return false; } return (Object)(object)((Il2CppObjectBase)val).TryCast() != (Object)null || (Object)(object)((Il2CppObjectBase)val).TryCast() != (Object)null; } catch { return false; } } public static void Draw() { //IL_003f: 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_006f: 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) if (Showing) { float num = 220f; float num2 = (float)Screen.width * 0.5f - num * 0.5f; float num3 = (float)Screen.height * 0.68f + 40f; FortifyApi.UiFill(new Rect(num2, num3, num, 8f), new Color(0f, 0f, 0f, 0.6f)); FortifyApi.UiFill(new Rect(num2, num3, num * Progress, 8f), new Color(1f, 1f, 1f, 0.9f)); } } } internal sealed class PlacedRecord { public string Id { get; set; } public float[] Pos { get; set; } public float[] Rot { get; set; } public bool Active { get; set; } = true; public int Channel { get; set; } public string Text { get; set; } public float[] Extra { get; set; } } internal enum PlaceKind { Ground, Wall } internal static class Placement { internal sealed class Placed { public GameObject Go; public ItemSpec Spec; public PlacedRecord Rec; public bool Active = true; public int Channel; public string Text; public string Label; public Camera Feed; public bool OnShip; public Vector3[] Extra; public object State; } private const float PlaceReach = 8f; private const float UseReach = 3.5f; private const float Tile = 0.25f; private static readonly List Items = new List(); internal static int Version; private static GameObject _ghost; private static string _ghostId; private static Bounds _ghostLocalBounds; private static float _ghostLift; private static Bounds? _ghostFit; private static float _blockedLogAt = -100f; internal static string LastBlocker; private static bool _ghostShowingValid; private static int _rotIndex; private static float _turn; private const float FineTurn = 15f; private static string _hint; private static readonly HashSet Ignored = new HashSet(); private static float _ignoredRefreshAt; internal static List All => Items; public static string Hint => _hint; internal static int Count(string id) { int num = 0; foreach (Placed item in Items) { if ((Object)(object)item.Go != (Object)null && string.Equals(item.Spec.Id, id, StringComparison.OrdinalIgnoreCase)) { num++; } } return num; } public static void Load() { //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) Reset(); List list = null; try { string data = FortifyApi.GetData(Kit.SaveKey); if (!string.IsNullOrEmpty(data)) { list = JsonSerializer.Deserialize>(data); } } catch (Exception ex) { Instance log = Kit.Log; if (log != null) { log.Warning("Couldn't read the saved items (" + ex.Message + ")."); } } if (list == null) { return; } int num = 0; foreach (PlacedRecord item in list) { ItemSpec itemSpec = Catalog.Get(item?.Id); if (itemSpec != null && !((Object)(object)itemSpec.Template == (Object)null) && item.Pos != null && item.Rot != null) { Placed placed = Create(itemSpec, V(item.Pos), Q(item.Rot), item); Items.Add(placed); num++; Kit.RaiseCreated(placed); } } Version++; if (num > 0) { Instance log2 = Kit.Log; if (log2 != null) { log2.Msg($"Put back {num} placed item(s)."); } } } public static void Save() { try { List list = new List(); foreach (Placed item in Items) { if (!((Object)(object)item.Go == (Object)null)) { UpdateRecord(item); list.Add(item.Rec); } } FortifyApi.SetData(Kit.SaveKey, JsonSerializer.Serialize(list)); } catch (Exception ex) { Instance log = Kit.Log; if (log != null) { log.Warning("Couldn't save the placed items: " + ex.Message); } } } public static void Reset() { foreach (Placed item in Items) { Kit.RaiseRemoved(item); if ((Object)(object)item.Go != (Object)null) { Object.Destroy((Object)(object)item.Go); } } Items.Clear(); Version++; DestroyGhost(); _hint = null; } internal static void UpdateRecord(Placed p) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) Transform transform = p.Go.transform; if (p.Rec == null) { p.Rec = new PlacedRecord { Id = p.Spec.Id }; } p.Rec.Pos = F(transform.position); p.Rec.Rot = F(transform.rotation); p.Rec.Active = p.Active; p.Rec.Channel = p.Channel; p.Rec.Text = p.Text; if (p.Extra != null) { float[] array = new float[p.Extra.Length * 3]; for (int i = 0; i < p.Extra.Length; i++) { array[i * 3] = p.Extra[i].x; array[i * 3 + 1] = p.Extra[i].y; array[i * 3 + 2] = p.Extra[i].z; } p.Rec.Extra = array; } } public static void Update() { _hint = null; Player local = Player.Local; Camera camera = GetCamera(); if ((Object)(object)local == (Object)null || (Object)(object)camera == (Object)null || UiBusy(local)) { HideGhost(); return; } ItemSpec itemSpec = Catalog.Get(EquippedId()); if (itemSpec != null) { if (Kit.CustomPlace.TryGetValue(itemSpec.Id, out var value)) { HideGhost(); value(itemSpec, camera, local, out _hint); } else { UpdatePlacing(itemSpec, camera, local); } } else { HideGhost(); UpdateLooking(camera, local); } } private static void UpdatePlacing(ItemSpec spec, Camera cam, Player player) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_029d: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: 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_02df: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0227: 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_037a: Unknown result type (might be due to invalid IL or missing references) //IL_03b2: Unknown result type (might be due to invalid IL or missing references) //IL_03b7: Unknown result type (might be due to invalid IL or missing references) //IL_03b9: Unknown result type (might be due to invalid IL or missing references) //IL_03bb: Unknown result type (might be due to invalid IL or missing references) //IL_02f0: 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_02fb: Unknown result type (might be due to invalid IL or missing references) //IL_0300: Unknown result type (might be due to invalid IL or missing references) //IL_0305: Unknown result type (might be due to invalid IL or missing references) //IL_0309: 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_0345: Unknown result type (might be due to invalid IL or missing references) //IL_0347: Unknown result type (might be due to invalid IL or missing references) //IL_0349: Unknown result type (might be due to invalid IL or missing references) //IL_034b: Unknown result type (might be due to invalid IL or missing references) //IL_0350: Unknown result type (might be due to invalid IL or missing references) //IL_0355: Unknown result type (might be due to invalid IL or missing references) //IL_0359: Unknown result type (might be due to invalid IL or missing references) //IL_035d: Unknown result type (might be due to invalid IL or missing references) //IL_026e: 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_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_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_03fb: Unknown result type (might be due to invalid IL or missing references) //IL_03fd: Unknown result type (might be due to invalid IL or missing references) //IL_0456: Unknown result type (might be due to invalid IL or missing references) //IL_0458: Unknown result type (might be due to invalid IL or missing references) if (_ghostId != spec.Id) { DestroyGhost(); _rotIndex = 0; _turn = 0f; CreateGhost(spec); } bool flag = spec.RotateStep > 0f; bool flag2 = FortifyApi.KeyHeld((KeyCode)308); if (FortifyApi.KeyDown(Kit.RotateKey)) { if (spec.Kind == PlaceKind.Wall) { if (flag) { _rotIndex++; } } else { _turn = Mathf.Repeat(_turn + (flag2 ? 15f : (flag ? spec.RotateStep : 90f)), 360f); } } string text = ((spec.Kind == PlaceKind.Wall) ? (flag ? $" [{Kit.RotateKey}] Rotate" : "") : (flag2 ? $" [{Kit.RotateKey}] Turn {15f:0}°" : $" [{Kit.RotateKey}] Rotate")); if (!Aim(cam, 8f, player, out var best)) { HideGhost(); _hint = ((spec.Kind == PlaceKind.Wall) ? "Aim at a wall" : "Aim at the ground or a floor"); return; } string text2 = null; Vector3 val2; Quaternion val3; if (spec.Kind == PlaceKind.Wall) { Vector3 normal = ((RaycastHit)(ref best)).normal; if (Mathf.Abs(normal.y) > 0.35f) { HideGhost(); _hint = "Aim at a wall, not the floor or ceiling"; return; } Vector3 val = new Vector3(normal.x, 0f, normal.z); Vector3 normalized = ((Vector3)(ref val)).normalized; val2 = ((RaycastHit)(ref best)).point + normalized * 0.004f; val3 = Quaternion.LookRotation(normalized, Vector3.up); if (flag) { val3 *= Quaternion.Euler(0f, 0f, spec.RotateStep * (float)(_rotIndex % Mathf.Max(1, Mathf.RoundToInt(360f / spec.RotateStep)))); } if (!FitsWall(val2, val3, ((RaycastHit)(ref best)).collider, player, flag2)) { text2 = (flag2 ? "Doesn't fit here" : "Doesn't fit here (hold Left Alt to fit it in closer)"); } } else { if (((RaycastHit)(ref best)).normal.y < 0.75f) { HideGhost(); _hint = "Aim at flat ground or a floor"; return; } GridFrame(((RaycastHit)(ref best)).point, out var origin, out var yaw); Quaternion val4 = Quaternion.Euler(0f, yaw, 0f); val2 = ((RaycastHit)(ref best)).point; if (!flag2) { Vector3 val5 = Quaternion.Inverse(val4) * (val2 - origin); val5.x = Mathf.Round(val5.x / 0.25f) * 0.25f; val5.z = Mathf.Round(val5.z / 0.25f) * 0.25f; val2 = origin + val4 * val5; val2.y = GroundY(val2, ((RaycastHit)(ref best)).point.y, player); } int num = Mathf.RoundToInt(Mathf.DeltaAngle(yaw, ((Component)cam).transform.eulerAngles.y) / 90f); val3 = Quaternion.Euler(0f, yaw + 90f * (float)num + _turn, 0f); if (!Fits(val2, val3, ((RaycastHit)(ref best)).collider, player, flag2)) { text2 = (FortifyApi.DevKeys ? ("Doesn't fit here (" + LastBlocker + ")") : (flag2 ? "Doesn't fit here" : "Doesn't fit here (hold Left Alt to fit it in closer)")); } } ShowGhost(val2, val3, text2 == null); if (text2 != null) { _hint = text2; return; } string text3 = (flag2 ? " Free placement" : ((spec.Kind == PlaceKind.Ground) ? " [Hold Left Alt] Place freely" : "")); _hint = "[Click] Place " + spec.Name + text + text3; if (GameInput.GetButtonDown((ButtonCode)0)) { PlaceNow(spec, val2, val3); } } private static float GroundY(Vector3 snapped, float fallback, Player player) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) Il2CppStructArray val = Physics.RaycastAll(new Ray(snapped + Vector3.up * 1.2f, Vector3.down), 3f, -5, (QueryTriggerInteraction)1); float num = float.MaxValue; float result = fallback; for (int i = 0; i < ((Il2CppArrayBase)(object)val).Length; i++) { RaycastHit val2 = ((Il2CppArrayBase)(object)val)[i]; if (!((Object)(object)((RaycastHit)(ref val2)).collider == (Object)null) && !Ignored.Contains(((Object)((RaycastHit)(ref val2)).collider).GetInstanceID()) && !((Component)((RaycastHit)(ref val2)).collider).transform.IsChildOf(((Component)player).transform) && (!((Object)(object)_ghost != (Object)null) || !((Component)((RaycastHit)(ref val2)).collider).transform.IsChildOf(_ghost.transform)) && !(((RaycastHit)(ref val2)).normal.y < 0.75f) && ((RaycastHit)(ref val2)).distance < num) { num = ((RaycastHit)(ref val2)).distance; result = ((RaycastHit)(ref val2)).point.y; } } return result; } internal static Placed PlaceNow(ItemSpec spec, Vector3 pos, Quaternion rot, Vector3[] extra = null) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) PlayerInventory instance = PlayerSingleton.Instance; HotbarSlot val = (((Object)(object)instance != (Object)null) ? instance.equippedSlot : null); if (val == null || ((ItemSlot)val).ItemInstance == null || !string.Equals(((BaseItemInstance)((ItemSlot)val).ItemInstance).ID, spec.Id, StringComparison.OrdinalIgnoreCase)) { return null; } Placed placed = Create(spec, pos, rot, null, extra); UpdateRecord(placed); Items.Add(placed); Version++; ((ItemSlot)val).ChangeQuantity(-1, false); try { BuildManager instance2 = NetworkSingleton.Instance; if (instance2 != null) { instance2.PlayBuildSound((EBuildSoundType)1, pos); } } catch { } Kit.RaiseCreated(placed); return placed; } internal static Placed PlaceFree(ItemSpec spec, Vector3 pos, Quaternion rot) { //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) if ((Object)(object)spec?.Template == (Object)null) { return null; } Placed placed = Create(spec, pos, rot, null); UpdateRecord(placed); Items.Add(placed); Version++; Kit.RaiseCreated(placed); return placed; } private static Placed Create(ItemSpec spec, Vector3 pos, Quaternion rot, PlacedRecord rec, Vector3[] extra = null) { //IL_003a: 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_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) GameObject val = Object.Instantiate(spec.Template); ((Object)val).name = Kit.Prefix + "Placed_" + spec.Id; val.transform.SetParent((Transform)null, false); val.transform.SetPositionAndRotation(pos, rot); val.SetActive(true); Placed placed = new Placed { Go = val, Spec = spec, Rec = rec, Extra = extra }; if (rec != null) { placed.Active = rec.Active; placed.Channel = rec.Channel; placed.Text = rec.Text; if (rec.Extra != null && rec.Extra.Length >= 3) { placed.Extra = (Vector3[])(object)new Vector3[rec.Extra.Length / 3]; for (int i = 0; i < placed.Extra.Length; i++) { placed.Extra[i] = new Vector3(rec.Extra[i * 3], rec.Extra[i * 3 + 1], rec.Extra[i * 3 + 2]); } } } return placed; } internal static void DevGive() { PlayerInventory instance = PlayerSingleton.Instance; if ((Object)(object)instance == (Object)null) { return; } foreach (ItemSpec item2 in Catalog.Items) { try { ItemDefinition item = Registry.GetItem(item2.Id); ItemInstance val = ((item != null) ? item.GetDefaultInstance(2) : null); if (val != null && instance.CanItemFitInInventory(val, 1)) { instance.AddItemToInventory(val); } } catch { } } Instance log = Kit.Log; if (log != null) { log.Msg("Dev: items given."); } } private static void UpdateLooking(Camera cam, Player player) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) if (!Aim(cam, 3.5f, player, out var best)) { return; } Placed placed = FindPlaced(((RaycastHit)(ref best)).collider); if (placed != null) { string hint = null; if (!Kit.Use.TryGetValue(placed.Spec.Id, out var value) || !value(placed, best, out hint)) { hint = "[Hold Right Click] Pick up " + placed.Spec.Name; } _hint = hint; if ((Kit.CanPickUp == null || Kit.CanPickUp(placed)) && PickupHold.Held(placed.Go)) { PickUp(placed); } } } internal static void PickUp(Placed p) { PlayerInventory instance = PlayerSingleton.Instance; ItemDefinition item = Registry.GetItem(p.Spec.Id); if (!((Object)(object)instance == (Object)null) && !((Object)(object)item == (Object)null)) { ItemInstance defaultInstance = item.GetDefaultInstance(1); if (!instance.CanItemFitInInventory(defaultInstance, 1)) { _hint = "Your inventory is full"; return; } instance.AddItemToInventory(defaultInstance); Remove(p); } } internal static void Remove(Placed p) { Kit.RaiseRemoved(p); if ((Object)(object)p.Go != (Object)null) { Object.Destroy((Object)(object)p.Go); } Items.Remove(p); Version++; } internal static Placed FindPlaced(Collider col) { if ((Object)(object)col == (Object)null) { return null; } string value = Kit.Prefix + "Placed_"; Transform val = ((Component)col).transform; while ((Object)(object)val != (Object)null) { if (((Object)val).name.StartsWith(value, StringComparison.Ordinal)) { foreach (Placed item in Items) { if ((Object)(object)item.Go != (Object)null && (Object)(object)item.Go.transform == (Object)(object)val) { return item; } } break; } val = val.parent; } return null; } private static void CreateGhost(ItemSpec spec) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)spec.Template == (Object)null) { return; } _ghost = Object.Instantiate(spec.Template); ((Object)_ghost).name = Kit.Prefix + "Ghost"; _ghost.transform.SetParent((Transform)null, false); _ghostLocalBounds = LocalBounds(_ghost); _ghostLift = spec.FitLift; _ghostFit = spec.FitBounds; foreach (Collider componentsInChild in _ghost.GetComponentsInChildren(true)) { Object.DestroyImmediate((Object)(object)componentsInChild); } foreach (NavMeshObstacle componentsInChild2 in _ghost.GetComponentsInChildren(true)) { Object.DestroyImmediate((Object)(object)componentsInChild2); } foreach (Light componentsInChild3 in _ghost.GetComponentsInChildren(true)) { ((Behaviour)componentsInChild3).enabled = false; } foreach (AudioSource componentsInChild4 in _ghost.GetComponentsInChildren(true)) { ((Behaviour)componentsInChild4).enabled = false; } foreach (Camera componentsInChild5 in _ghost.GetComponentsInChildren(true)) { ((Behaviour)componentsInChild5).enabled = false; } SetLayer(_ghost.transform, 2); _ghostId = spec.Id; _ghostShowingValid = false; ApplyGhostMaterial(valid: true); _ghost.SetActive(false); } private static void ShowGhost(Vector3 pos, Quaternion rot, bool valid) { //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) if (!((Object)(object)_ghost == (Object)null)) { _ghost.transform.SetPositionAndRotation(pos, rot); if (!_ghost.activeSelf) { _ghost.SetActive(true); } if (valid != _ghostShowingValid) { ApplyGhostMaterial(valid); } } } private static void ApplyGhostMaterial(bool valid) { //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) _ghostShowingValid = valid; Material val = null; try { BuildManager instance = NetworkSingleton.Instance; if ((Object)(object)instance != (Object)null) { val = (valid ? instance.ghostMaterial_White : instance.ghostMaterial_Red); } } catch { } if ((Object)(object)val == (Object)null) { val = (valid ? Models.Mat("ghost_ok", new Color(0.8f, 0.9f, 1f)) : Models.Mat("ghost_bad", new Color(1f, 0.3f, 0.3f))); } foreach (Renderer componentsInChild in _ghost.GetComponentsInChildren(true)) { int num = Mathf.Max(1, ((Il2CppArrayBase)(object)componentsInChild.sharedMaterials).Length); Il2CppReferenceArray val2 = new Il2CppReferenceArray((long)num); for (int i = 0; i < num; i++) { ((Il2CppArrayBase)(object)val2)[i] = val; } componentsInChild.sharedMaterials = val2; } } internal static void HideGhost() { if ((Object)(object)_ghost != (Object)null && _ghost.activeSelf) { _ghost.SetActive(false); } } private static void DestroyGhost() { if ((Object)(object)_ghost != (Object)null) { Object.Destroy((Object)(object)_ghost); } _ghost = null; _ghostId = null; } internal static bool Aim(Camera cam, float reach, Player player, out RaycastHit best) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) best = default(RaycastHit); Il2CppStructArray val = Physics.RaycastAll(new Ray(((Component)cam).transform.position, ((Component)cam).transform.forward), reach, -5, (QueryTriggerInteraction)1); float num = float.MaxValue; bool result = false; RefreshIgnored(); for (int i = 0; i < ((Il2CppArrayBase)(object)val).Length; i++) { RaycastHit val2 = ((Il2CppArrayBase)(object)val)[i]; if (!((Object)(object)((RaycastHit)(ref val2)).collider == (Object)null) && !((RaycastHit)(ref val2)).collider.isTrigger && !Ignored.Contains(((Object)((RaycastHit)(ref val2)).collider).GetInstanceID())) { Transform transform = ((Component)((RaycastHit)(ref val2)).collider).transform; if (!transform.IsChildOf(((Component)player).transform) && (!((Object)(object)_ghost != (Object)null) || !transform.IsChildOf(_ghost.transform)) && ((RaycastHit)(ref val2)).distance < num) { num = ((RaycastHit)(ref val2)).distance; best = val2; result = true; } } } return result; } internal static void GridFrame(Vector3 point, out Vector3 origin, out float yaw) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) origin = Vector3.zero; yaw = 0f; try { if (!Nearest(Property.OwnedProperties, point, 25f, ref origin, ref yaw)) { Nearest(Property.Properties, point, 6f, ref origin, ref yaw); } } catch { } } internal static Property PropertyAt(Vector3 point, float within = 12f) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) try { List ownedProperties = Property.OwnedProperties; Property result = null; float num = within; int num2 = 0; while (ownedProperties != null && num2 < ownedProperties.Count) { Property val = ownedProperties[num2]; if (!((Object)(object)val == (Object)null)) { float num3 = DistanceToProperty(val, point); if (num3 < num) { num = num3; result = val; } } num2++; } return result; } catch { return null; } } private static bool Nearest(List list, Vector3 point, float within, ref Vector3 origin, ref float yaw) { //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) if (list == null) { return false; } float num = within; bool result = false; for (int i = 0; i < list.Count; i++) { Property val = list[i]; if ((Object)(object)val == (Object)null) { continue; } float num2 = DistanceToProperty(val, point); if (num2 >= num) { continue; } num = num2; Transform transform = ((Component)val).transform; try { List grids = val.Grids; if (grids != null && grids.Count > 0 && (Object)(object)grids[0] != (Object)null) { transform = ((Component)grids[0]).transform; } } catch { } origin = transform.position; yaw = transform.eulerAngles.y; result = true; } return result; } private static float DistanceToProperty(Property prop, Vector3 p) { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) float num = float.MaxValue; try { Il2CppReferenceArray propertyBoundsColliders = prop.propertyBoundsColliders; if (propertyBoundsColliders != null) { for (int i = 0; i < ((Il2CppArrayBase)(object)propertyBoundsColliders).Length; i++) { if ((Object)(object)((Il2CppArrayBase)(object)propertyBoundsColliders)[i] != (Object)null) { num = Mathf.Min(num, DistanceToBox(((Il2CppArrayBase)(object)propertyBoundsColliders)[i], p)); } } } } catch { } if (num == float.MaxValue) { num = Mathf.Max(0f, Vector3.Distance(((Component)prop).transform.position, p) - 15f); } return num; } private static float DistanceToBox(BoxCollider box, Vector3 p) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008b: 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_0092: 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) Transform transform = ((Component)box).transform; Vector3 val = transform.InverseTransformPoint(p) - box.center; Vector3 val2 = box.size * 0.5f; Vector3 val3 = default(Vector3); ((Vector3)(ref val3))..ctor(Mathf.Clamp(val.x, 0f - val2.x, val2.x), Mathf.Clamp(val.y, 0f - val2.y, val2.y), Mathf.Clamp(val.z, 0f - val2.z, val2.z)); return Vector3.Distance(p, transform.TransformPoint(val3 + box.center)); } private static bool Fits(Vector3 pos, Quaternion rot, Collider ground, Player player, bool close = false) { //IL_0018: 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_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: 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_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0073: 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_008c: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) Bounds val = (Bounds)(((??)_ghostFit) ?? _ghostLocalBounds); float num = _ghostLift; if (num > 0f) { float num2 = pos.y; for (int i = 0; i < 9; i++) { float num3 = (float)(i % 3 - 1) * Mathf.Max(0f, ((Bounds)(ref val)).extents.x - 0.15f); float num4 = (float)(i / 3 - 1) * Mathf.Max(0f, ((Bounds)(ref val)).extents.z - 0.15f); Vector3 val2 = pos + rot * new Vector3(((Bounds)(ref val)).center.x + num3, 0f, ((Bounds)(ref val)).center.z + num4); num2 = Mathf.Max(num2, GroundY(val2 + Vector3.up * 0.8f, pos.y, player)); } if (num2 - pos.y > 1.2f) { return false; } num = Mathf.Max(num, num2 - pos.y + 0.3f); } num = Mathf.Clamp(num, 0f, Mathf.Max(0f, ((Bounds)(ref val)).size.y - 0.3f)); float num5 = (close ? 0.6f : 1f); Vector3 half = default(Vector3); ((Vector3)(ref half))..ctor(Mathf.Max(0.02f, ((Bounds)(ref val)).extents.x * num5 - 0.06f), Mathf.Max(0.02f, ((Bounds)(ref val)).extents.y - 0.06f - num * 0.5f), Mathf.Max(0.02f, ((Bounds)(ref val)).extents.z * num5 - 0.06f)); return Clear(pos + rot * (((Bounds)(ref val)).center + Vector3.up * (0.06f + num * 0.5f)), half, rot, ground, player); } private static bool FitsWall(Vector3 pos, Quaternion rot, Collider wall, Player player, bool close = false) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: 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) Bounds ghostLocalBounds = _ghostLocalBounds; float num = (close ? 0.6f : 1f); Vector3 half = default(Vector3); ((Vector3)(ref half))..ctor(Mathf.Max(0.02f, ((Bounds)(ref ghostLocalBounds)).extents.x * num - 0.04f), Mathf.Max(0.02f, ((Bounds)(ref ghostLocalBounds)).extents.y * num - 0.04f), Mathf.Max(0.02f, ((Bounds)(ref ghostLocalBounds)).extents.z - 0.04f)); return Clear(pos + rot * (((Bounds)(ref ghostLocalBounds)).center + Vector3.forward * 0.03f), half, rot, wall, player); } private static bool Clear(Vector3 center, Vector3 half, Quaternion rot, Collider surface, Player player) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) Il2CppReferenceArray val = Physics.OverlapBox(center, half, rot, -5, (QueryTriggerInteraction)1); for (int i = 0; i < ((Il2CppArrayBase)(object)val).Length; i++) { Collider val2 = ((Il2CppArrayBase)(object)val)[i]; if ((Object)(object)val2 == (Object)null || (Object)(object)val2 == (Object)(object)surface || val2.isTrigger || Ignored.Contains(((Object)val2).GetInstanceID()) || ((Component)val2).transform.IsChildOf(((Component)player).transform) || ((MemberInfo)((Object)val2).GetIl2CppType()).Name == "TerrainCollider") { continue; } try { if ((Object)(object)((Component)val2).GetComponentInParent() != (Object)null || (Object)(object)((Component)val2).GetComponentInParent() != (Object)null) { continue; } goto IL_00a5; } catch { goto IL_00a5; } IL_00a5: LastBlocker = ((Object)val2).name; if (FortifyApi.DevKeys && Time.unscaledTime - _blockedLogAt > 2f) { _blockedLogAt = Time.unscaledTime; Instance log = Kit.Log; if (log != null) { log.Msg("Dev: no room, " + ((Object)val2).name + " is in the way."); } } return false; } return true; } internal static bool IsPropertyBounds(Collider c) { if ((Object)(object)c != (Object)null) { return Ignored.Contains(((Object)c).GetInstanceID()); } return false; } private static void RefreshIgnored() { if (Time.unscaledTime < _ignoredRefreshAt) { return; } _ignoredRefreshAt = Time.unscaledTime + 5f; Ignored.Clear(); try { List properties = Property.Properties; int num = 0; while (properties != null && num < properties.Count) { Il2CppReferenceArray val = (((Object)(object)properties[num] != (Object)null) ? properties[num].propertyBoundsColliders : null); int num2 = 0; while (val != null && num2 < ((Il2CppArrayBase)(object)val).Length) { if ((Object)(object)((Il2CppArrayBase)(object)val)[num2] != (Object)null) { Ignored.Add(((Object)((Il2CppArrayBase)(object)val)[num2]).GetInstanceID()); } num2++; } num++; } } catch { } } internal static bool UiBusy(Player player) { try { if (Kit.Busy != null && Kit.Busy()) { return true; } if (GameInput.IsTyping) { return true; } if (player.IsInVehicle || player.IsSleeping || player.IsArrested) { return true; } PlayerCamera instance = PlayerSingleton.Instance; if ((Object)(object)instance != (Object)null && instance.ActiveUIElementCount > 0) { return true; } } catch { } return false; } internal static Camera GetCamera() { try { PlayerCamera instance = PlayerSingleton.Instance; if ((Object)(object)instance != (Object)null && (Object)(object)instance.Camera != (Object)null) { return instance.Camera; } } catch { } return Camera.main; } internal static string EquippedId() { try { PlayerInventory instance = PlayerSingleton.Instance; object obj; if (instance == null) { obj = null; } else { HotbarSlot equippedSlot = instance.equippedSlot; obj = ((equippedSlot != null) ? ((ItemSlot)equippedSlot).ItemInstance : null); } return (obj != null) ? ((BaseItemInstance)obj).ID : null; } catch { return null; } } private static Bounds LocalBounds(GameObject go) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) Matrix4x4 worldToLocalMatrix = go.transform.worldToLocalMatrix; bool flag = false; Bounds result = default(Bounds); ((Bounds)(ref result))..ctor(Vector3.zero, Vector3.zero); foreach (MeshRenderer componentsInChild in go.GetComponentsInChildren(true)) { MeshFilter component = ((Component)componentsInChild).GetComponent(); if ((Object)(object)component == (Object)null || (Object)(object)component.sharedMesh == (Object)null) { continue; } Bounds bounds = component.sharedMesh.bounds; Matrix4x4 val = worldToLocalMatrix * ((Component)componentsInChild).transform.localToWorldMatrix; for (int i = 0; i < 8; i++) { Vector3 val2 = ((Bounds)(ref bounds)).center + Vector3.Scale(((Bounds)(ref bounds)).extents, new Vector3((float)(((i & 1) != 0) ? 1 : (-1)), (float)(((i & 2) != 0) ? 1 : (-1)), (float)(((i & 4) != 0) ? 1 : (-1)))); Vector3 val3 = ((Matrix4x4)(ref val)).MultiplyPoint3x4(val2); if (!flag) { result = new Bounds(val3, Vector3.zero); flag = true; } else { ((Bounds)(ref result)).Encapsulate(val3); } } } return result; } internal static void SetLayer(Transform t, int layer) { ((Component)t).gameObject.layer = layer; for (int i = 0; i < t.childCount; i++) { SetLayer(t.GetChild(i), layer); } } private static float[] F(Vector3 v) { //IL_0008: 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_001a: Unknown result type (might be due to invalid IL or missing references) return new float[3] { v.x, v.y, v.z }; } private static float[] F(Quaternion q) { //IL_0008: 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_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) return new float[4] { q.x, q.y, q.z, q.w }; } private static Vector3 V(float[] a) { //IL_0009: 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) if (a == null || a.Length < 3) { return Vector3.zero; } return new Vector3(a[0], a[1], a[2]); } private static Quaternion Q(float[] a) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) if (a == null || a.Length < 4) { return Quaternion.identity; } return new Quaternion(a[0], a[1], a[2], a[3]); } } internal static class Registration { private static readonly Dictionary Definitions = new Dictionary(StringComparer.OrdinalIgnoreCase); private static bool _registered; private static bool _shopsDone; private static bool _iconsRendered; private static int _shopAttempts; private static float _nextAttempt; private static float _nextShopAttempt; private static StoredItem _storedFallback; public static bool Registered => _registered; public static bool TryRegister() { //IL_00e5: Unknown result type (might be due to invalid IL or missing references) if (_registered) { return true; } if (Time.unscaledTime < _nextAttempt) { return false; } _nextAttempt = Time.unscaledTime + 1f; try { if (!Singleton.InstanceExists || !Registry.ItemExists("grandfatherclock")) { return false; } } catch { return false; } Catalog.BuildTemplates(); int num = 0; foreach (ItemSpec item in Catalog.Items) { try { Equippable val = ItemCreator.CreateEquippableBuilder().CreateBasicEquippable(Kit.Prefix + "Equippable_" + item.Id).WithInteraction(true, true) .Build(); StorableItemDefinition val2 = ((StorableItemDefinitionBuilderBase)(object)((StorableItemDefinitionBuilderBase)(object)((StorableItemDefinitionBuilderBase)(object)((StorableItemDefinitionBuilderBase)(object)((StorableItemDefinitionBuilderBase)(object)ItemCreator.CreateBuilder()).WithBasicInfo(item.Id, item.Name, item.Description, (ItemCategory)4)).WithPricing(item.Price * Mathf.Max(0f, Kit.PriceMultiplier()), 0.5f)).WithStackLimit(item.StackLimit)).WithIcon(Models.FallbackIcon(item.IconColor))).WithEquippable(val).Build(); if ((ItemDefinition)(object)val2 != (ItemDefinition)null) { Definitions[item.Id] = (ItemDefinition)(object)val2; num++; } } catch (Exception ex) { Instance log = Kit.Log; if (log != null) { log.Error("Couldn't create '" + item.Name + "': " + ex.Message); } } } FixShopSettings(); _registered = true; Instance log2 = Kit.Log; if (log2 != null) { log2.Msg($"Registered {num} item(s)."); } return true; } private static void FixShopSettings() { List val = null; try { StorableItemDefinition item = Registry.GetItem("largestoragerack"); if ((Object)(object)item != (Object)null && item.ShopCategories != null && item.ShopCategories.Count > 0) { val = item.ShopCategories; } } catch { } foreach (string key in Definitions.Keys) { try { StorableItemDefinition item2 = Registry.GetItem(key); if ((Object)(object)item2 == (Object)null) { continue; } item2.RequiresLevelToPurchase = false; if (val != null) { item2.ShopCategories = val; } if (BadStored(item2.StoredItem)) { StoredItem val2 = StoredFallback(); if ((Object)(object)val2 != (Object)null) { item2.StoredItem = val2; } } } catch { } } } private static bool BadStored(StoredItem s) { if ((Object)(object)s == (Object)null) { return true; } try { List coordinateFootprintTilePairs = s._coordinateFootprintTilePairs; return coordinateFootprintTilePairs == null || coordinateFootprintTilePairs.Count == 0; } catch { return true; } } internal static StoredItem StoredFallback() { if ((Object)(object)_storedFallback != (Object)null) { return _storedFallback; } string[] array = new string[5] { "paracetamol", "flumedicine", "cuke", "energydrink", "baggie" }; foreach (string text in array) { try { StorableItemDefinition item = Registry.GetItem(text); if ((Object)(object)item != (Object)null && !BadStored(item.StoredItem)) { _storedFallback = item.StoredItem; break; } } catch { } } if ((Object)(object)_storedFallback == (Object)null) { Instance log = Kit.Log; if (log != null) { log.Warning("No stored model found for storage racks; our items may not show on racks."); } } return _storedFallback; } public static void ResetForNewScene() { _shopsDone = false; _shopAttempts = 0; } public static void TryAddToShops(bool onlyWithFyb = false) { if (_shopsDone || !_registered || Definitions.Count == 0 || Time.unscaledTime < _nextShopAttempt) { return; } _nextShopAttempt = Time.unscaledTime + 2f; _shopAttempts++; HashSet hashSet = new HashSet(StringComparer.OrdinalIgnoreCase); foreach (ItemSpec item2 in Catalog.Items) { if (!item2.NotSold && (!onlyWithFyb || item2.SoldWithFyb)) { string[] array = item2.Stores ?? Kit.Stores; foreach (string item in array) { hashSet.Add(item); } } } if (hashSet.Count == 0) { _shopsDone = true; return; } int num = 0; foreach (string item3 in hashSet) { Shop val = null; try { val = ShopManager.GetShopByName(item3); } catch { } if (val == null) { continue; } num++; foreach (ItemSpec item4 in Catalog.Items) { if (item4.NotSold || (onlyWithFyb && !item4.SoldWithFyb) || Array.IndexOf(item4.Stores ?? Kit.Stores, item3) < 0 || !Definitions.TryGetValue(item4.Id, out var value)) { continue; } try { if (!val.HasItem(item4.Id)) { val.AddItem(value, (float?)null); } } catch (Exception ex) { Instance log = Kit.Log; if (log != null) { log.Warning($"Couldn't add {item4.Name} to {item3}: {ex.Message}"); } } } } if (num == hashSet.Count || (num > 0 && _shopAttempts > 10)) { _shopsDone = true; Instance log2 = Kit.Log; if (log2 != null) { log2.Msg("For sale at " + string.Join(" and ", hashSet) + "."); } } else if (_shopAttempts > 30) { _shopsDone = true; Instance log3 = Kit.Log; if (log3 != null) { log3.Warning("Couldn't find the shops, so nothing is for sale this session."); } } } public static IEnumerator RenderIcons() { if (_iconsRendered) { yield break; } float wait = Time.unscaledTime + 6f; while (Time.unscaledTime < wait) { yield return null; } int done = 0; List failed = new List(); foreach (ItemSpec item in Catalog.Items) { if (RenderIcon(item)) { done++; } else { failed.Add(item); } yield return null; } for (int attempt = 0; attempt < 2; attempt++) { if (failed.Count <= 0) { break; } wait = Time.unscaledTime + 4f; while (Time.unscaledTime < wait) { yield return null; } for (int i = failed.Count - 1; i >= 0; i--) { if (RenderIcon(failed[i])) { done++; failed.RemoveAt(i); } yield return null; } } _iconsRendered = done > 0; } private static bool RenderIcon(ItemSpec spec) { //IL_0066: Unknown result type (might be due to invalid IL or missing references) GameObject val = null; try { val = ((spec.IconModel != null) ? spec.IconModel() : (((Object)(object)spec.Template != (Object)null) ? Object.Instantiate(spec.Template) : null)); if ((Object)(object)val == (Object)null) { return true; } val.transform.SetParent((Transform)null, false); val.transform.position = new Vector3(0f, -500f, 0f); val.SetActive(true); Sprite val2 = IconFactory.GenerateIconSprite(val.transform, 256, false, true, 0.8f); if ((Object)(object)val2 == (Object)null) { return false; } ((Object)val2).hideFlags = (HideFlags)32; if ((Object)(object)val2.texture != (Object)null) { ((Object)val2.texture).hideFlags = (HideFlags)32; } ItemDefinition item = Registry.GetItem(spec.Id); if ((Object)(object)item != (Object)null) { ((BaseItemDefinition)item).Icon = val2; } try { ShopManager.RefreshItemIcon(spec.Id); } catch { } return true; } catch (Exception ex) { Instance log = Kit.Log; if (log != null) { log.Warning("Icon for " + spec.Name + " couldn't be rendered: " + ex.Message); } return true; } finally { if ((Object)(object)val != (Object)null) { Object.Destroy((Object)(object)val); } } } } internal static class Statics { public static bool Writable(string field) { try { IntPtr nativeClassPtr = Il2CppClassPointerStore.NativeClassPtr; if (nativeClassPtr == IntPtr.Zero) { return false; } IntPtr il2CppField = IL2CPP.GetIl2CppField(nativeClassPtr, field); if (il2CppField == IntPtr.Zero) { return false; } int num = IL2CPP.il2cpp_field_get_flags(il2CppField); return (num & 0x10) != 0 && (num & 0x40) == 0; } catch { return false; } } } internal static class StorageGrid { private static bool _changed; private static bool _btnMoved; private static bool _patched; private static Constraint _was; private static int _countWas; private static Vector2 _btnWas; public static void Patch(Harmony h) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown if (_patched || h == null) { return; } _patched = true; try { HarmonyMethod val = new HarmonyMethod(typeof(StorageGrid), "Before", (Type[])null); int num = 0; foreach (MethodInfo declaredMethod in AccessTools.GetDeclaredMethods(typeof(StorageMenu))) { if (declaredMethod.Name == "Open" || declaredMethod.Name == "Close" || declaredMethod.Name == "CloseMenu") { h.Patch((MethodBase)declaredMethod, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); num++; } } if (num == 0) { Instance log = Kit.Log; if (log != null) { log.Warning("Storage screen: nothing to hook, so its layout is put back when ours closes only."); } } } catch (Exception ex) { Instance log2 = Kit.Log; if (log2 != null) { log2.Warning("Storage screen: " + ex.Message); } } } private static void Before() { Restore(); } public static void Columns(StorageMenu menu, int cols, int slots) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0095: 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_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) GridLayoutGroup val = ((menu != null) ? menu.SlotGridLayout : null); if ((Object)(object)val == (Object)null || cols < 1) { return; } if (!_changed) { _was = val.constraint; _countWas = val.constraintCount; _changed = true; } int num = Mathf.CeilToInt((float)slots / (float)cols); val.constraint = (Constraint)1; val.constraintCount = cols; RectTransform closeButtonContainer = menu.CloseButtonContainer; if (!((Object)(object)closeButtonContainer == (Object)null)) { if (!_btnMoved) { _btnWas = closeButtonContainer.anchoredPosition; _btnMoved = true; } closeButtonContainer.anchoredPosition = _btnWas - new Vector2(0f, (float)Mathf.Max(0, num - 1) * (val.cellSize.y + val.spacing.y)); } } public static void Restore() { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) if (!_changed && !_btnMoved) { return; } try { StorageMenu instance = Singleton.Instance; GridLayoutGroup val = (((Object)(object)instance != (Object)null) ? instance.SlotGridLayout : null); if (_changed && (Object)(object)val != (Object)null) { val.constraint = _was; val.constraintCount = _countWas; } RectTransform val2 = (((Object)(object)instance != (Object)null) ? instance.CloseButtonContainer : null); if (_btnMoved && (Object)(object)val2 != (Object)null) { val2.anchoredPosition = _btnWas; } } catch { } _changed = false; _btnMoved = false; } } internal static class StuckInput { private static float _next; private static float _since = -1f; private static int _fixed; public static void Update() { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Invalid comparison between Unknown and I4 if (Time.unscaledTime < _next) { return; } _next = Time.unscaledTime + 0.5f; try { PlayerCamera instance = PlayerSingleton.Instance; bool flag = GameInput.IsTyping || Keys.Suppressed; if (!flag || !((Object)(object)instance != (Object)null) || instance.ActiveUIElementCount != 0 || (int)Cursor.lockState != 1 || Cursor.visible || TextBoxInUse()) { _since = -1f; } else if (_since < 0f) { _since = Time.unscaledTime; } else { if (Time.unscaledTime - _since < 2f) { return; } _since = -1f; List list = new List(); if (flag) { GameInput.IsTyping = false; Keys.Suppressed = false; try { if (FybLink.Present) { FybLink.Suppress(on: false); } } catch { } list.Add("typing"); } if (list.Count > 0 && ++_fixed <= 5) { Instance log = Kit.Log; if (log != null) { log.Msg("Input: something left the game thinking you were still typing (" + string.Join(", ", list) + "); cleared so you can use things again."); } } } } catch { } } private static bool TextBoxInUse() { try { EventSystem current = EventSystem.current; GameObject val = (((Object)(object)current != (Object)null) ? current.currentSelectedGameObject : null); if ((Object)(object)val == (Object)null) { return false; } TMP_InputField component = val.GetComponent(); if ((Object)(object)component != (Object)null && component.isFocused) { return true; } InputField component2 = val.GetComponent(); if ((Object)(object)component2 != (Object)null && component2.isFocused) { return true; } } catch { } return false; } } internal static class Ui { private static Vector2 _mouse; private static bool _click; private static int _clickFrame; private static readonly Dictionary Styles = new Dictionary(); private static readonly Dictionary Solid = new Dictionary(); private static readonly Dictionary Pictures = new Dictionary(); public static Vector2 MousePos => _mouse; public static void Capture() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) _mouse = MouseGui(); if (InputUtil.MouseDown(0)) { _click = true; _clickFrame = Time.frameCount; } else if (_click && Time.frameCount - _clickFrame > 1) { _click = false; } } private static Vector2 MouseGui() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0039: 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_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) Vector2 val = default(Vector2); bool flag = false; try { val = Vector2.op_Implicit(Input.mousePosition); flag = true; } catch { } if (!flag) { try { Mouse current = Mouse.current; if (current != null) { val = ((InputControl)(object)((Pointer)current).position).ReadValue(); } } catch { } } return new Vector2(val.x, (float)Screen.height - val.y); } public static bool Hover(Rect r) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) return ((Rect)(ref r)).Contains(_mouse); } public static bool Click(Rect r) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) if (!_click || !((Rect)(ref r)).Contains(_mouse)) { return false; } _click = false; return true; } private static GUIStyle SolidStyle(Color c) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Expected O, but got Unknown //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Expected O, but got Unknown //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Expected O, but got Unknown //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Expected O, but got Unknown //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Expected O, but got Unknown int num = (int)(Math.Clamp(c.r, 0f, 1f) * 255f + 0.5f); int num2 = (int)(Math.Clamp(c.g, 0f, 1f) * 255f + 0.5f); int num3 = (int)(Math.Clamp(c.b, 0f, 1f) * 255f + 0.5f); int num4 = (int)(Math.Clamp(c.a, 0f, 1f) * 255f + 0.5f); int key = (num << 24) | (num2 << 16) | (num3 << 8) | num4; if (Solid.TryGetValue(key, out var value) && value != null && (Object)(object)value.normal.background != (Object)null) { return value; } if (Solid.Count > 600) { foreach (GUIStyle value2 in Solid.Values) { if (value2 != null && (Object)(object)value2.normal.background != (Object)null) { Object.Destroy((Object)(object)value2.normal.background); } } Solid.Clear(); } Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); Color32 val2 = default(Color32); ((Color32)(ref val2))..ctor((byte)num, (byte)num2, (byte)num3, (byte)num4); val.SetPixels32(new Il2CppStructArray((Color32[])(object)new Color32[4] { val2, val2, val2, val2 })); val.Apply(); ((Object)val).hideFlags = (HideFlags)32; value = new GUIStyle(); value.normal.background = val; value.border = new RectOffset(0, 0, 0, 0); value.padding = new RectOffset(0, 0, 0, 0); value.margin = new RectOffset(0, 0, 0, 0); Solid[key] = value; return value; } public static void Fill(Rect r, Color c) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (!(c.a <= 0.003f)) { GUI.Label(r, "", SolidStyle(c)); } } public static void Image(Rect r, Texture2D tex) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)tex == (Object)null)) { if (!Pictures.TryGetValue(((Il2CppObjectBase)tex).Pointer, out var value) || value == null) { value = new GUIStyle(); value.normal.background = tex; value.border = new RectOffset(0, 0, 0, 0); value.padding = new RectOffset(0, 0, 0, 0); Pictures[((Il2CppObjectBase)tex).Pointer] = value; } GUI.Label(r, "", value); } } public static void Picture(Rect r, Texture tex) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Invalid comparison between Unknown and I4 //IL_001b: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)tex == (Object)null)) { Event current = Event.current; if (current != null && (int)current.type == 7) { Graphics.DrawTexture(r, tex); } } } public static void Frame(Rect r, Color c, float t = 2f) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) Fill(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, ((Rect)(ref r)).width, t), c); Fill(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).yMax - t, ((Rect)(ref r)).width, t), c); Fill(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, t, ((Rect)(ref r)).height), c); Fill(new Rect(((Rect)(ref r)).xMax - t, ((Rect)(ref r)).y, t, ((Rect)(ref r)).height), c); } public static void Text(Rect r, string s, int size, Color c, TextAnchor a = (TextAnchor)4, bool bold = true, bool wrap = true) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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_0019: Expected I4, but got Unknown //IL_0035: 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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Expected O, but got Unknown int key = size * 64 + a * 4 + (bold ? 2 : 0) + wrap; if (!Styles.TryGetValue(key, out var value) || value == null) { value = new GUIStyle(GUI.skin.label) { fontSize = size, alignment = a, fontStyle = (FontStyle)(bold ? 1 : 0), wordWrap = wrap }; Styles[key] = value; } value.normal.textColor = c; GUI.Label(r, s ?? "", value); } public static bool Button(Rect r, string label, bool enabled = true, bool selected = false, int size = 17) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0082: 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_0060: 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_0045: 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_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) bool flag = enabled && Hover(r); Color c = ((!enabled) ? new Color(0.18f, 0.18f, 0.2f, 0.9f) : (selected ? new Color(0.85f, 0.65f, 0.2f, 0.97f) : (flag ? new Color(0.36f, 0.32f, 0.46f, 0.97f) : new Color(0.24f, 0.22f, 0.3f, 0.95f)))); Fill(r, c); Frame(r, enabled ? new Color(1f, 1f, 1f, flag ? 0.55f : 0.25f) : new Color(1f, 1f, 1f, 0.08f)); Text(r, label, size, (Color)((!enabled) ? new Color(0.5f, 0.5f, 0.55f) : (selected ? Color.black : Color.white)), (TextAnchor)4); if (enabled) { return Click(r); } return false; } } } namespace WS_BC.FybCommon { internal static class FortifyApi { private sealed class SaveDoc { public int Version { get; set; } = 1; public string Created { get; set; } public Dictionary Data { get; set; } = new Dictionary(); } private static Instance _log; private static string _folder; private static MelonPreferences_Entry _devKeys; private static KeyCode _use = (KeyCode)101; private static readonly List DrawnIds = new List(); private static Harmony _harmony; private static bool _loaded; private static int _inGameFrame = -1; private static bool _inGame; private static string _iconItem; private static Sprite _icon; private static Dictionary _data = new Dictionary(); private static string _file; private static bool _readThisSession; private static bool _patched; private static bool _gameKeysOff; private static readonly Dictionary Mats = new Dictionary(); private static Shader _lit; private static int _loadFrame = -1; private static bool _loadUp; private static readonly HashSet Drawn = new HashSet(); private static float _nextDraw; private static readonly List<(string label, AudioClip clip)> NoSongs = new List<(string, AudioClip)>(); public static bool Linked => FybLink.Present; public static string LinkedVersion { get { if (!FybLink.Present) { return null; } return Safe(FybLink.Version, "?"); } } public static bool InGame { get { if (Time.frameCount == _inGameFrame) { return _inGame; } _inGameFrame = Time.frameCount; _inGame = false; if (_loaded) { try { LoadManager instance = Singleton.Instance; _inGame = (Object)(object)instance != (Object)null && instance.IsGameLoaded; } catch { } } return _inGame; } } public static bool IsGuest { get { try { return InstanceFinder.IsClient && !InstanceFinder.IsServer; } catch { return false; } } } public static bool IsHost => !IsGuest; public static bool DevKeys { get { MelonPreferences_Entry devKeys = _devKeys; if (devKeys == null || !devKeys.Value) { if (FybLink.Present) { return Safe(FybLink.DevKeys, fallback: false); } return false; } return true; } } public static bool DataReady { get; private set; } public static KeyCode UseKey { get { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) if (!FybLink.Present) { return _use; } return Safe(FybLink.UseKey, _use); } } public static bool GameKeysOff => _gameKeysOff; public static IReadOnlyList<(string label, AudioClip clip)> YourSongs { get { if (FybLink.Present) { try { return FybLink.Songs() ?? NoSongs; } catch { } } return NoSongs; } } public static event Action BeforeSave; public static event Action AfterLoad; public static event Action Unloaded; public static void Init(MelonMod mod, string folder, string title, params string[] keepDrawnIdPrefixes) { //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) _log = ((MelonBase)mod).LoggerInstance; _folder = folder; DrawnIds.AddRange(keepDrawnIdPrefixes); MelonPreferences_Category obj = MelonPreferences.CreateCategory(folder, title); _devKeys = obj.CreateEntry("DevKeys", false, "Developer keys", "Test keys (for the mod's author).", false, false, (ValueValidator)null, (string)null); _use = Keys.Parse(obj.CreateEntry("UseKey", "E", "Use key", "Key for using things. With Fortify Your Base installed, its own use key is used instead.", false, false, (ValueValidator)null, (string)null).Value, (KeyCode)101); GameLifecycle.OnLoadComplete += OnLoaded; GameLifecycle.OnSaveStart += OnSaving; GameLifecycle.OnPreSceneChange += OnLeaving; _harmony = ((MelonBase)mod).HarmonyInstance; } public static void Log(string msg) { Instance log = _log; if (log != null) { log.Msg(msg); } } public static void Frame() { Ui.Capture(); Shared.Update(); DrawPass(); RainCover.Update(); TreeCut.Update(); } public static void SetNotifyIcon(string itemId) { _iconItem = itemId; _icon = null; } public static void Notify(string title, string text) { try { NotificationsManager instance = Singleton.Instance; if ((Object)(object)instance == (Object)null) { Log(title + ": " + text); return; } if ((Object)(object)_icon == (Object)null && !string.IsNullOrEmpty(_iconItem)) { try { ItemDefinition item = Registry.GetItem(_iconItem); _icon = ((item != null) ? ((BaseItemDefinition)item).Icon : null); } catch { } } instance.SendNotification(title, text, _icon, 6f, true); } catch (Exception ex) { Log($"{title}: {text} ({ex.Message})"); } } public static void LogEvent(string kind, string place, int crew, string outcome) { if (FybLink.Present) { try { FybLink.LogEvent(kind, place, crew, outcome); } catch { } } } public static string GetData(string key) { if (key == null || !_data.TryGetValue(key, out var value)) { return null; } return value; } public static void SetData(string key, string value) { if (key != null) { _data[key] = value ?? ""; } } private static void OnLoaded() { _loaded = true; if (!_patched) { _patched = true; try { Pins.Patch(_harmony); } catch (Exception ex) { Log("Pins: " + ex.Message); } } _data = new Dictionary(); _file = FileFor(SavePath()); try { if (_file != null && File.Exists(_file)) { SaveDoc saveDoc = JsonSerializer.Deserialize(File.ReadAllText(_file)); if (saveDoc != null && SaveStamp.IsStale(_file, saveDoc.Created)) { Log("This is a new game in a save slot that was used before, so this mod starts fresh here (the old game's data was set aside)."); SaveStamp.Retire(_file); saveDoc = null; } if (saveDoc?.Data != null) { _data = saveDoc.Data; } } else if (_file != null) { Migrate(); } } catch (Exception ex2) { Log("Couldn't read the save (" + ex2.Message + "); starting fresh."); } _readThisSession = true; DataReady = true; Log(FybLink.Present ? ("Linked up with Fortify Your Base " + LinkedVersion + ".") : "Running on its own."); try { FortifyApi.AfterLoad?.Invoke(); } catch (Exception ex3) { Log("Load: " + ex3.Message); } } private static void Migrate() { try { string path = Path.Combine(MelonEnvironment.UserDataDirectory, "HoldTheFort", "Saves", Path.GetFileName(_file)); if (!File.Exists(path) || SaveStamp.IsStale(path, null)) { return; } using JsonDocument jsonDocument = JsonDocument.Parse(File.ReadAllText(path)); if (!jsonDocument.RootElement.TryGetProperty("Addons", out var value) || value.ValueKind != JsonValueKind.Object) { return; } int num = 0; foreach (JsonProperty item in value.EnumerateObject()) { if (item.Value.ValueKind == JsonValueKind.String) { _data[item.Name] = item.Value.GetString(); num++; } } if (num > 0) { Log("Picked up this save's progress from Fortify Your Base's save file."); } } catch (Exception ex) { Log("Couldn't read Fortify Your Base's save file (" + ex.Message + ")."); } } private static void OnSaving() { if (!DataReady || !_readThisSession || IsGuest) { return; } try { FortifyApi.BeforeSave?.Invoke(); } catch (Exception ex) { Log("Save: " + ex.Message); } string text = _file ?? FileFor(SavePath()); if (text == null) { return; } try { string text2 = text + ".tmp"; File.WriteAllText(text2, JsonSerializer.Serialize(new SaveDoc { Created = SaveStamp.Current(), Data = _data }, new JsonSerializerOptions { WriteIndented = true })); if (File.Exists(text)) { File.Delete(text); } File.Move(text2, text); } catch (Exception ex2) { Log("Couldn't save: " + ex2.Message); } } private static void OnLeaving() { if (DataReady) { try { FortifyApi.Unloaded?.Invoke(); } catch { } } DataReady = false; _loaded = false; _readThisSession = false; _file = null; _data = new Dictionary(); Shared.Reset(); Pins.Reset(); Drawn.Clear(); RainCover.Reset(); TreeCut.Reset(); } private static string SavePath() { LoadManager instance = Singleton.Instance; string text = null; try { object obj; if (instance == null) { obj = null; } else { SaveInfo activeSaveInfo = instance.ActiveSaveInfo; obj = ((activeSaveInfo != null) ? activeSaveInfo.SavePath : null); } text = (string)obj; } catch { } if (string.IsNullOrEmpty(text)) { try { text = ((instance != null) ? instance.LoadedGameFolderPath : null); } catch { } } return text; } private static string FileFor(string savePath) { if (string.IsNullOrWhiteSpace(savePath)) { return null; } string text = savePath.TrimEnd('/', '\\'); StringBuilder stringBuilder = new StringBuilder(); string fileName = Path.GetFileName(text); foreach (char c in fileName) { stringBuilder.Append((char.IsLetterOrDigit(c) || c == '_' || c == '-') ? c : '_'); } uint num = 2166136261u; fileName = text.ToLowerInvariant().Replace('\\', '/'); foreach (char c2 in fileName) { num ^= c2; num *= 16777619; } string text2 = Path.Combine(MelonEnvironment.UserDataDirectory, _folder ?? "FortifyAddon", "Saves"); Directory.CreateDirectory(text2); return Path.Combine(text2, $"{stringBuilder}_{num:x8}.json"); } public static bool KeyDown(KeyCode k) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return Keys.Down(k); } public static bool KeyHeld(KeyCode k) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return Keys.Held(k); } public static void Typing(bool on) { Keys.Suppressed = on; try { GameInput.IsTyping = on; } catch { } if (FybLink.Present) { try { FybLink.Suppress(on); } catch { } } } public static void GameKeys(bool on) { try { GameInput instance = Singleton.Instance; PlayerInput val = (((Object)(object)instance != (Object)null) ? instance.PlayerInput : null); if ((Object)(object)val == (Object)null) { if (on) { _gameKeysOff = false; } } else if (!on) { if (!_gameKeysOff) { val.DeactivateInput(); _gameKeysOff = true; } } else if (_gameKeysOff) { val.ActivateInput(); _gameKeysOff = false; } } catch { if (on) { _gameKeysOff = false; } } } private static Shader LitShader() { if ((Object)(object)_lit != (Object)null) { return _lit; } _lit = Shader.Find("Universal Render Pipeline/Lit") ?? Shader.Find("Universal Render Pipeline/Simple Lit"); if ((Object)(object)_lit == (Object)null) { foreach (Material item in Resources.FindObjectsOfTypeAll()) { if ((Object)(object)item != (Object)null && (Object)(object)item.shader != (Object)null && ((Object)item.shader).name.Contains("Lit")) { _lit = item.shader; break; } } } if ((Object)(object)_lit == (Object)null) { _lit = Shader.Find("Standard"); } return _lit; } private static Material MakeMat(string key, Color color, float metallic, float smoothness, Color? emission) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) if (Mats.TryGetValue(key, out var value) && (Object)(object)value != (Object)null) { return value; } Material val = new Material(LitShader()) { name = "FYBA_" + key }; val.color = color; if (val.HasProperty("_BaseColor")) { val.SetColor("_BaseColor", color); } if (val.HasProperty("_Metallic")) { val.SetFloat("_Metallic", metallic); } if (val.HasProperty("_Smoothness")) { val.SetFloat("_Smoothness", smoothness); } if (val.HasProperty("_Glossiness")) { val.SetFloat("_Glossiness", smoothness); } if (emission.HasValue) { val.EnableKeyword("_EMISSION"); if (val.HasProperty("_EmissionColor")) { val.SetColor("_EmissionColor", emission.Value); } val.globalIlluminationFlags = (MaterialGlobalIlluminationFlags)1; } ((Object)val).hideFlags = (HideFlags)32; Mats[key] = val; return val; } public static Material Mat(string key, Color c, float metallic = 0f, float smoothness = 0.3f) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return MakeMat(key, c, metallic, smoothness, null); } public static Material Emissive(string key, Color c, Color emission, float smoothness = 0.4f) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) return MakeMat(key, c, 0f, smoothness, emission); } public static Material Glow(string key, Color c) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) return MakeMat(key, c, 0f, 0.5f, c * 2.5f); } public static GameObject Part(Transform parent, PrimitiveType type, Vector3 pos, Vector3 scale, Material m, Vector3? euler = null, bool collider = false, string name = null) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_004a: 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_004f: 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) GameObject val = GameObject.CreatePrimitive(type); if (!collider) { Object.DestroyImmediate((Object)(object)val.GetComponent()); } val.transform.SetParent(parent, false); val.transform.localPosition = pos; val.transform.localRotation = Quaternion.Euler((Vector3)(((??)euler) ?? Vector3.zero)); val.transform.localScale = scale; ((Renderer)val.GetComponent()).sharedMaterial = m; if (name != null) { ((Object)val).name = name; } return val; } public static void UiFill(Rect r, Color c) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) Ui.Fill(r, c); } public static void UiFrame(Rect r, Color c, float t = 2f) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) Ui.Frame(r, c, t); } public static void UiText(Rect r, string s, int size, Color c, TextAnchor a = (TextAnchor)4, bool bold = true) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) Ui.Text(r, s, size, c, a, bold); } public static bool UiButton(Rect r, string label, bool enabled = true, bool selected = false, int size = 17) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return Ui.Button(r, label, enabled, selected, size); } public static void OpenMenu(string name) { try { PlayerCamera instance = PlayerSingleton.Instance; if ((Object)(object)instance != (Object)null) { instance.AddActiveUIElement(name); instance.SetCanLook(false); } } catch { } try { PlayerMovement instance2 = PlayerSingleton.Instance; if ((Object)(object)instance2 != (Object)null) { instance2.CanMove = false; } } catch { } Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; } public static void CloseMenu(string name) { try { PlayerCamera instance = PlayerSingleton.Instance; if ((Object)(object)instance != (Object)null) { instance.RemoveActiveUIElement(name); instance.SetCanLook(true); } } catch { } try { PlayerMovement instance2 = PlayerSingleton.Instance; if ((Object)(object)instance2 != (Object)null) { instance2.CanMove = true; } } catch { } Cursor.lockState = (CursorLockMode)1; Cursor.visible = false; } public static void Hint(string text) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0152: 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) if (string.IsNullOrEmpty(text) || (Cursor.visible && (int)Cursor.lockState != 1) || LoadingScreenUp()) { return; } float num = Screen.width; float num2 = Screen.height; float num3 = Mathf.Clamp(num2 / 1080f, 0.85f, 2f); int num4 = Mathf.RoundToInt(18f * num3); float num5 = Mathf.Min(num - 40f, 920f * num3); float num6 = 14f * num3; int num7 = Mathf.Clamp(Mathf.CeilToInt((float)(text.Length * num4) * 0.56f / (num5 - 2f * num6)), 1, 4); for (int i = 0; i < text.Length; i++) { if (text[i] == '\n') { num7 = Mathf.Min(4, num7 + 1); } } float num8 = (float)(num7 * num4) * 1.4f + 12f * num3; float num9 = HintStack(num8 + 6f * num3); Rect r = default(Rect); ((Rect)(ref r))..ctor((num - num5) * 0.5f, num2 * 0.72f - num9, num5, num8); Ui.Fill(r, new Color(0f, 0f, 0f, 0.66f)); Ui.Text(new Rect(((Rect)(ref r)).x + num6, ((Rect)(ref r)).y, ((Rect)(ref r)).width - 2f * num6, ((Rect)(ref r)).height), text, num4, Color.white, (TextAnchor)4); } public static bool LoadingScreenUp() { if (_loadFrame == Time.frameCount) { return _loadUp; } _loadFrame = Time.frameCount; try { LoadingScreen instance = Singleton.Instance; _loadUp = (Object)(object)instance != (Object)null && instance.IsOpen; } catch { _loadUp = false; } return _loadUp; } private static float HintStack(float take) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) float num = 0f; try { Event current = Event.current; string text = Time.frameCount + ":" + ((current == null) ? (-1) : ((int)current.type)); AppDomain currentDomain = AppDomain.CurrentDomain; if (currentDomain.GetData("WoodStudios.HintPass") as string == text && currentDomain.GetData("WoodStudios.HintUsed") is float num2) { num = num2; } currentDomain.SetData("WoodStudios.HintPass", text); currentDomain.SetData("WoodStudios.HintUsed", num + take); } catch { } return num; } public static void ShareState(string key, string value) { Shared.Set(key, value); } public static string SharedState(string key) { return Shared.Get(key); } public static void SendRequest(string key, string value) { Shared.Request(key, value); } public static List TakeRequests(string key) { Shared.Listen(key); return Shared.Take(key); } public static void Pin(GameObject npc, bool on) { try { NPC val = (((Object)(object)npc != (Object)null) ? npc.GetComponent() : null); if ((Object)(object)val != (Object)null) { Pins.Set(val, on); } } catch { } } public static void KeepDrawn(NPC n) { if ((Object)(object)n == (Object)null) { return; } try { Avatar avatar = n.Avatar; if (!((Object)(object)avatar == (Object)null)) { if (avatar._cullingRange < 130f) { avatar._cullingRange = 130f; } if (avatar._visibilityRangeSqr < 16900f) { avatar._visibilityRangeSqr = 16900f; } } } catch { } } private static void DrawPass() { if (DrawnIds.Count == 0 || Time.unscaledTime < _nextDraw || !_loaded) { return; } _nextDraw = Time.unscaledTime + 2f; try { List nPCRegistry = NPCManager.NPCRegistry; for (int i = 0; nPCRegistry != null && i < nPCRegistry.Count; i++) { NPC val = nPCRegistry[i]; if ((Object)(object)val == (Object)null) { continue; } bool flag = Drawn.Contains(((Il2CppObjectBase)val).Pointer); if (!flag) { string text = val.ID ?? ""; foreach (string drawnId in DrawnIds) { if (text.StartsWith(drawnId, StringComparison.Ordinal)) { flag = true; break; } } if (!flag) { continue; } Drawn.Add(((Il2CppObjectBase)val).Pointer); } KeepDrawn(val); } } catch { } } public static void ReserveArea(string key, Vector3 centre, float radius, float lot = 0f) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (FybLink.Present) { try { FybLink.ReserveArea(key, centre, radius, lot); } catch { } } } public static void AddBuildArea(string key, Func inside, Transform gridFrame = null) { if (FybLink.Present) { try { FybLink.AddBuildArea(key, inside, gridFrame); } catch { } } } public static void RemoveBuildArea(string key) { if (FybLink.Present) { try { FybLink.RemoveBuildArea(key); } catch { } } } public static void AddShelter(string key, Func inside) { if (FybLink.Present) { try { FybLink.AddShelter(key, inside); return; } catch { return; } } RainCover.Add(key, inside); } public static void RemoveShelter(string key) { if (FybLink.Present) { try { FybLink.RemoveShelter(key); return; } catch { return; } } RainCover.Remove(key); } public static void AddTreeClearing(string key, Vector3 centre, float radius) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (FybLink.Present) { try { FybLink.AddTreeClearing(key, centre, radius); return; } catch { return; } } TreeCut.Add(key, centre, radius); } public static void RemoveTreeClearing(string key) { if (FybLink.Present) { try { FybLink.RemoveTreeClearing(key); return; } catch { return; } } TreeCut.Remove(key); } public static bool ParkFoodTruck(string key, Vector3 pos, float yaw) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (FybLink.Present) { try { return FybLink.ParkFoodTruck(key, pos, yaw); } catch { } } return false; } public static void ReleaseFoodTruck(string key) { if (FybLink.Present) { try { FybLink.ReleaseFoodTruck(key); } catch { } } } public static bool FoodTruckParkedBy(string key) { if (FybLink.Present) { try { return FybLink.FoodTruckParkedBy(key); } catch { } } return false; } public static void DevView(Vector3 from, Vector3 at) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (FybLink.Present) { try { FybLink.DevView(from, at); } catch { } } } public static void DevViewEnd() { if (FybLink.Present) { try { FybLink.DevViewEnd(); } catch { } } } private static T Safe(Func f, T fallback) { try { return f(); } catch { return fallback; } } } internal static class FybLink { private static int _present = -1; public static bool Present { get { if (_present >= 0) { return _present == 1; } _present = 0; try { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); for (int i = 0; i < assemblies.Length; i++) { if (assemblies[i].GetName().Name == "WoodStudios.Schedule2") { _present = ((Level() >= 3) ? 1 : 0); break; } } } catch { _present = 0; } return _present == 1; } } [MethodImpl(MethodImplOptions.NoInlining)] private static int Level() { try { return LevelInner(); } catch { return 0; } } [MethodImpl(MethodImplOptions.NoInlining)] private static int LevelInner() { return FortifyApi.Level; } [MethodImpl(MethodImplOptions.NoInlining)] public static string Version() { return FortifyApi.Version; } [MethodImpl(MethodImplOptions.NoInlining)] public static bool DevKeys() { return FortifyApi.DevKeys; } [MethodImpl(MethodImplOptions.NoInlining)] public static KeyCode UseKey() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return FortifyApi.UseKey; } [MethodImpl(MethodImplOptions.NoInlining)] public static void LogEvent(string kind, string place, int crew, string outcome) { FortifyApi.LogEvent(kind, place, crew, outcome); } [MethodImpl(MethodImplOptions.NoInlining)] public static IReadOnlyList<(string label, AudioClip clip)> Songs() { return FortifyApi.YourSongs; } [MethodImpl(MethodImplOptions.NoInlining)] public static void ReserveArea(string key, Vector3 c, float r, float lot) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) FortifyApi.ReserveArea(key, c, r, lot); } [MethodImpl(MethodImplOptions.NoInlining)] public static void AddBuildArea(string key, Func inside, Transform frame) { FortifyApi.AddBuildArea(key, inside, frame); } [MethodImpl(MethodImplOptions.NoInlining)] public static void RemoveBuildArea(string key) { FortifyApi.RemoveBuildArea(key); } [MethodImpl(MethodImplOptions.NoInlining)] public static void AddShelter(string key, Func inside) { FortifyApi.AddShelter(key, inside); } [MethodImpl(MethodImplOptions.NoInlining)] public static void RemoveShelter(string key) { FortifyApi.RemoveShelter(key); } [MethodImpl(MethodImplOptions.NoInlining)] public static void AddTreeClearing(string key, Vector3 c, float r) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) FortifyApi.AddTreeClearing(key, c, r); } [MethodImpl(MethodImplOptions.NoInlining)] public static void RemoveTreeClearing(string key) { FortifyApi.RemoveTreeClearing(key); } [MethodImpl(MethodImplOptions.NoInlining)] public static bool ParkFoodTruck(string key, Vector3 p, float yaw) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return FortifyApi.ParkFoodTruck(key, p, yaw); } [MethodImpl(MethodImplOptions.NoInlining)] public static void ReleaseFoodTruck(string key) { FortifyApi.ReleaseFoodTruck(key); } [MethodImpl(MethodImplOptions.NoInlining)] public static bool FoodTruckParkedBy(string key) { return FortifyApi.FoodTruckParkedBy(key); } [MethodImpl(MethodImplOptions.NoInlining)] public static void DevView(Vector3 from, Vector3 at) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) FortifyApi.DevView(from, at); } [MethodImpl(MethodImplOptions.NoInlining)] public static void DevViewEnd() { FortifyApi.DevViewEnd(); } public static void Suppress(bool on) { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { if (!(assembly.GetName().Name != "WoodStudios.Schedule2")) { (assembly.GetType("HoldTheFort.InputUtil")?.GetField("Suppressed", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic))?.SetValue(null, on); break; } } } } internal static class Keys { private static bool _legacyBroken; public static bool Suppressed; private const string TextBoxKey = "WoodStudios.TextBoxFrame"; public static KeyCode Parse(string name, KeyCode fallback) { //IL_0018: 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) if (string.IsNullOrWhiteSpace(name) || !Enum.TryParse(name.Trim(), ignoreCase: true, out KeyCode result)) { return fallback; } return result; } public static bool Down(KeyCode key) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) if (!Suppressed && !TextBoxElsewhere()) { return RawDown(key); } return false; } public static bool Held(KeyCode key) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) if (!Suppressed && !TextBoxElsewhere()) { return RawHeld(key); } return false; } public static void MarkTextBox() { try { AppDomain.CurrentDomain.SetData("WoodStudios.TextBoxFrame", Time.frameCount); } catch { } } private static bool TextBoxElsewhere() { try { return AppDomain.CurrentDomain.GetData("WoodStudios.TextBoxFrame") is int num && Time.frameCount - num <= 2; } catch { return false; } } public static bool RawDown(KeyCode key) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) if (!_legacyBroken) { try { return Input.GetKeyDown(key); } catch { _legacyBroken = true; } } KeyControl obj2 = Control(key); if (obj2 == null) { return false; } return ((ButtonControl)obj2).wasPressedThisFrame; } public static bool RawHeld(KeyCode key) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) if (!_legacyBroken) { try { return Input.GetKey(key); } catch { _legacyBroken = true; } } KeyControl obj2 = Control(key); if (obj2 == null) { return false; } return ((ButtonControl)obj2).isPressed; } public static bool MouseDown(int button) { if (!_legacyBroken) { try { return Input.GetMouseButtonDown(button); } catch { _legacyBroken = true; } } try { Mouse current = Mouse.current; return current != null && ((button == 0) ? current.leftButton.wasPressedThisFrame : current.rightButton.wasPressedThisFrame); } catch { return false; } } public static string Typed(bool shift) { if (!_legacyBroken) { try { return Input.inputString ?? ""; } catch { _legacyBroken = true; } } StringBuilder stringBuilder = new StringBuilder(); for (char c = 'a'; c <= 'z'; c = (char)(c + 1)) { if (RawDown((KeyCode)(97 + (c - 97)))) { stringBuilder.Append(shift ? char.ToUpperInvariant(c) : c); } } for (int i = 0; i <= 9; i++) { if (RawDown((KeyCode)(48 + i))) { stringBuilder.Append(shift ? ")!@#$%^&*("[i] : ((char)(48 + i))); } } if (RawDown((KeyCode)32)) { stringBuilder.Append(' '); } if (RawDown((KeyCode)45)) { stringBuilder.Append('-'); } if (RawDown((KeyCode)39)) { stringBuilder.Append('\''); } if (RawDown((KeyCode)46)) { stringBuilder.Append('.'); } if (RawDown((KeyCode)8)) { stringBuilder.Append('\b'); } return stringBuilder.ToString(); } private unsafe static KeyControl Control(KeyCode key) { //IL_0097: Unknown result type (might be due to invalid IL or missing references) try { Keyboard current = Keyboard.current; if (current == null) { return null; } string text = ((object)(*(KeyCode*)(&key))/*cast due to .constrained prefix*/).ToString(); if (text.StartsWith("Alpha")) { text = "Digit" + text.Substring(5); } else if (text == "Return") { text = "Enter"; } else if (text == "KeypadEnter") { text = "NumpadEnter"; } else if (text.StartsWith("Keypad")) { text = "Numpad" + text.Substring(6); } Key result; return Enum.TryParse(text, ignoreCase: true, out result) ? current[result] : null; } catch { return null; } } } internal static class Pins { private static readonly HashSet Held = new HashSet(); public static void Set(NPC nat, bool on) { try { NPCMovement val = (((Object)(object)nat != (Object)null) ? nat.Movement : null); if (!((Object)(object)val == (Object)null)) { if (on) { Held.Add(((Il2CppObjectBase)val).Pointer); } else { Held.Remove(((Il2CppObjectBase)val).Pointer); } } } catch { } } public static bool IsHeld(NPC nat) { try { NPCMovement val = (((Object)(object)nat != (Object)null) ? nat.Movement : null); return (Object)(object)val != (Object)null && Held.Contains(((Il2CppObjectBase)val).Pointer); } catch { return false; } } public static void Reset() { Held.Clear(); } public static void Patch(Harmony h) { //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Expected O, but got Unknown //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Expected O, but got Unknown //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Expected O, but got Unknown if (h == null) { return; } Type typeFromHandle = typeof(NPCMovement); foreach (MethodInfo declaredMethod in AccessTools.GetDeclaredMethods(typeFromHandle)) { try { if (declaredMethod.Name == "Warp" || declaredMethod.Name == "Warp_Client") { h.Patch((MethodBase)declaredMethod, new HarmonyMethod(typeof(Pins), "WarpPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } else if (declaredMethod.Name == "IsNPCPositionValid" && declaredMethod.ReturnType == typeof(bool)) { h.Patch((MethodBase)declaredMethod, new HarmonyMethod(typeof(Pins), "ValidPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } catch { } } try { MethodInfo methodInfo = AccessTools.DeclaredPropertyGetter(typeFromHandle, "Velocity"); if (methodInfo != null) { h.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(Pins), "VelocityPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } catch { } try { MethodInfo methodInfo2 = AccessTools.DeclaredMethod(typeof(NPCAnimation), "UpdateMovementAnimation", (Type[])null, (Type[])null); if (methodInfo2 != null) { h.Patch((MethodBase)methodInfo2, new HarmonyMethod(typeof(Pins), "AnimPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } catch { } } private static bool WarpPrefix(NPCMovement __instance) { try { return (Object)(object)__instance == (Object)null || !Held.Contains(((Il2CppObjectBase)__instance).Pointer); } catch { return true; } } private static void VelocityPostfix(NPCMovement __instance, ref Vector3 __result) { //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) try { if ((Object)(object)__instance != (Object)null && Held.Contains(((Il2CppObjectBase)__instance).Pointer)) { __result = Vector3.zero; } } catch { } } private static bool AnimPrefix(NPCAnimation __instance) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) try { NPC val = (((Object)(object)__instance != (Object)null) ? __instance.npc : null); if ((Object)(object)val == (Object)null || !IsHeld(val)) { return true; } AvatarAnimation val2 = (((Object)(object)val.Avatar != (Object)null) ? val.Avatar.Animation : null); if ((Object)(object)val2 != (Object)null) { val2.SetMotion(Vector3.zero, false); val2.SetDirection(0f); val2.SetStrafe(0f); } return false; } catch { return true; } } private static bool ValidPrefix(NPCMovement __instance, ref bool __result) { try { if ((Object)(object)__instance == (Object)null || !Held.Contains(((Il2CppObjectBase)__instance).Pointer)) { return true; } __result = true; return false; } catch { return true; } } } internal static class RainCover { private static readonly Dictionary> Shelters = new Dictionary>(); private static readonly List Rain = new List(); private static readonly List Hidden = new List(); private static readonly List HiddenFeatures = new List(); private static bool _scanned; private static bool _inside; private static float _next; public static void Add(string key, Func inside) { if (key != null && inside != null) { Shelters[key] = inside; } } public static void Remove(string key) { if (key != null) { Shelters.Remove(key); } } public static void Update() { //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) if ((Shelters.Count == 0 && !_inside) || Time.unscaledTime < _next) { return; } _next = Time.unscaledTime + 0.2f; Vector3 position; try { PlayerCamera instance = PlayerSingleton.Instance; Transform val = (((Object)(object)instance != (Object)null && (Object)(object)instance.Camera != (Object)null) ? ((Component)instance.Camera).transform : (((Object)(object)Camera.main != (Object)null) ? ((Component)Camera.main).transform : null)); if ((Object)(object)val == (Object)null) { return; } position = val.position; } catch { return; } bool flag = false; foreach (Func value in Shelters.Values) { try { if (value(position)) { flag = true; break; } } catch { } } if (flag != _inside) { _inside = flag; if (flag) { Hide(); } else { Restore(); } } } private static void Hide() { try { if (!_scanned) { _scanned = true; HashSet hashSet = new HashSet(); foreach (RainController item in Object.FindObjectsOfType()) { foreach (Renderer componentsInChild in ((Component)item).GetComponentsInChildren(true)) { if ((Object)(object)componentsInChild != (Object)null && hashSet.Add(((Object)componentsInChild).GetInstanceID())) { Rain.Add(componentsInChild); } } } } foreach (Renderer item2 in Rain) { if ((Object)(object)item2 != (Object)null && item2.enabled) { item2.enabled = false; Hidden.Add(item2); } } RenderPipelineAsset currentRenderPipeline = GraphicsSettings.currentRenderPipeline; UniversalRenderPipelineAsset val = ((currentRenderPipeline != null) ? ((Il2CppObjectBase)currentRenderPipeline).TryCast() : null); Il2CppReferenceArray val2 = (((Object)(object)val != (Object)null) ? val.m_RendererDataList : null); int num = 0; while (val2 != null && num < ((Il2CppArrayBase)(object)val2).Length) { ScriptableRendererData val3 = ((Il2CppArrayBase)(object)val2)[num]; if (!((Object)(object)val3 == (Object)null) && val3.rendererFeatures != null) { Enumerator enumerator4 = val3.rendererFeatures.GetEnumerator(); while (enumerator4.MoveNext()) { ScriptableRendererFeature current3 = enumerator4.Current; if (!((Object)(object)current3 == (Object)null) && current3.isActive && (((Object)current3).name + " " + ((MemberInfo)((Object)current3).GetIl2CppType()).Name).IndexOf("rain", StringComparison.OrdinalIgnoreCase) >= 0) { current3.SetActive(false); HiddenFeatures.Add(current3); } } } num++; } } catch { } } private static void Restore() { foreach (Renderer item in Hidden) { if ((Object)(object)item != (Object)null) { item.enabled = true; } } Hidden.Clear(); foreach (ScriptableRendererFeature hiddenFeature in HiddenFeatures) { try { if ((Object)(object)hiddenFeature != (Object)null) { hiddenFeature.SetActive(true); } } catch { } } HiddenFeatures.Clear(); } public static void Reset() { Restore(); _inside = false; _scanned = false; Rain.Clear(); Shelters.Clear(); } } internal static class SaveStamp { public static string Current() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) try { LoadManager instance = Singleton.Instance; SaveInfo val = ((instance != null) ? instance.ActiveSaveInfo : null); if (val == null) { return ""; } DateTime dateCreated = val.DateCreated; long ticks = ((DateTime)(ref dateCreated)).Ticks; return (ticks > 0) ? ticks.ToString() : ""; } catch { return ""; } } public static bool IsStale(string path, string stored) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Invalid comparison between Unknown and I4 try { string text = Current(); if (text.Length == 0 || path == null || !File.Exists(path)) { return false; } if (!string.IsNullOrEmpty(stored)) { return stored != text; } SaveInfo activeSaveInfo = Singleton.Instance.ActiveSaveInfo; DateTime dateCreated = activeSaveInfo.DateCreated; DateTime dateTime = new DateTime(((DateTime)(ref dateCreated)).Ticks); bool flag = false; try { dateCreated = activeSaveInfo.DateCreated; flag = (int)((DateTime)(ref dateCreated)).Kind == 1; } catch { } return (flag ? File.GetLastWriteTimeUtc(path) : File.GetLastWriteTime(path)) < dateTime - TimeSpan.FromMinutes(2.0); } catch { return false; } } public static void Retire(string path) { try { string text = path + ".previous-game"; if (File.Exists(text)) { File.Delete(text); } File.Move(path, text); } catch { } } } internal static class Shared { private const string Prefix = "fyb_"; private static readonly Dictionary Local = new Dictionary(); private static readonly Dictionary Sent = new Dictionary(); private static readonly Dictionary Read = new Dictionary(); private static readonly Dictionary MySeq = new Dictionary(); private static readonly Dictionary SeenSeq = new Dictionary(); private static readonly Dictionary> Inbox = new Dictionary>(); private static readonly HashSet Watched = new HashSet(); private static float _nextFlush; private static bool InLobby(out CSteamID lobby) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) lobby = default(CSteamID); try { Lobby instance = Singleton.Instance; if ((Object)(object)instance == (Object)null || !instance.IsInLobby || instance.LobbyID == 0L) { return false; } lobby = new CSteamID { m_SteamID = instance.LobbyID }; return instance.PlayerCount > 1 || FortifyApi.IsGuest; } catch { return false; } } public static void Set(string key, string value) { if (key != null) { Local[key] = value ?? ""; } } public static string Get(string key) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) if (key == null) { return null; } if (!FortifyApi.IsGuest) { if (!Local.TryGetValue(key, out var value)) { return null; } return value; } if (Read.TryGetValue(key, out (string, float) value2) && Time.unscaledTime - value2.Item2 < 0.5f) { return value2.Item1; } string text = null; try { if (InLobby(out var lobby)) { text = SteamMatchmaking.GetLobbyData(lobby, "fyb_" + key); } } catch { } if (string.IsNullOrEmpty(text)) { text = null; } Read[key] = (text, Time.unscaledTime); return text; } public static void Request(string key, string value) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) if (key == null) { return; } if (!FortifyApi.IsGuest) { Queue(key, value); return; } try { if (InLobby(out var lobby)) { int value3; int value2 = (MySeq.TryGetValue(key, out value3) ? value3 : Random.Range(1, 1000)) + 1; MySeq[key] = value2; SteamMatchmaking.SetLobbyMemberData(lobby, "fyb_rq_" + key, value2 + "|" + value); } } catch { } } public static List Take(string key) { List list = new List(); if (key != null && Inbox.TryGetValue(key, out var value)) { list.AddRange(value); value.Clear(); } return list; } private static void Queue(string key, string value) { if (!Inbox.TryGetValue(key, out var value2)) { List list = (Inbox[key] = new List()); value2 = list; } if (value2.Count < 20) { value2.Add(value ?? ""); } } public static void Update() { //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0150: 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_006a: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) if (FortifyApi.IsGuest || Time.unscaledTime < _nextFlush) { return; } _nextFlush = Time.unscaledTime + 0.5f; if (!InLobby(out var lobby)) { return; } try { foreach (KeyValuePair item in Local) { if ((!Sent.TryGetValue(item.Key, out var value) || !(value == item.Value)) && SteamMatchmaking.SetLobbyData(lobby, "fyb_" + item.Key, item.Value)) { Sent[item.Key] = item.Value; } } foreach (string key2 in Inbox.Keys) { Watched.Add(key2); } int numLobbyMembers = SteamMatchmaking.GetNumLobbyMembers(lobby); ulong num = 0uL; try { num = SteamUser.GetSteamID().m_SteamID; } catch { } for (int i = 0; i < numLobbyMembers; i++) { CSteamID lobbyMemberByIndex = SteamMatchmaking.GetLobbyMemberByIndex(lobby, i); if (lobbyMemberByIndex.m_SteamID == num) { continue; } foreach (string item2 in Watched) { string lobbyMemberData = SteamMatchmaking.GetLobbyMemberData(lobby, lobbyMemberByIndex, "fyb_rq_" + item2); if (string.IsNullOrEmpty(lobbyMemberData)) { continue; } int num2 = lobbyMemberData.IndexOf('|'); if (num2 <= 0 || !int.TryParse(lobbyMemberData.Substring(0, num2), out var result)) { continue; } string key = lobbyMemberByIndex.m_SteamID + "/" + item2; if (!SeenSeq.TryGetValue(key, out var value2) || value2 != result) { bool num3 = !SeenSeq.ContainsKey(key); SeenSeq[key] = result; if (!num3) { Queue(item2, lobbyMemberData.Substring(num2 + 1)); } } } } } catch { } } public static void Listen(string key) { if (key != null && !Inbox.ContainsKey(key)) { Inbox[key] = new List(); } } public static void Reset() { Local.Clear(); Sent.Clear(); Read.Clear(); Inbox.Clear(); SeenSeq.Clear(); Watched.Clear(); } } internal static class TreeCut { private static readonly Dictionary Clearings = new Dictionary(); private static readonly Dictionary Textures = new Dictionary(); private static readonly List Trunks = new List(); private static bool _dirty; public static void Add(string key, Vector3 centre, float radius) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) if (key != null) { Clearings[key] = (centre, radius); _dirty = true; } } public static void Remove(string key) { if (key != null && Clearings.Remove(key)) { _dirty = true; } } public static void Update() { if (_dirty) { _dirty = false; Apply(); } } private static bool Cleared(float x, float z, float pad) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) foreach (var value in Clearings.Values) { Vector3 item = value.c; float item2 = value.r; float num = x - item.x; float num2 = z - item.z; float num3 = item2 + pad; if (num * num + num2 * num2 < num3 * num3) { return true; } } return false; } private static void Apply() { //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) int num = 0; int num2 = 0; try { Find(); foreach (KeyValuePair texture in Textures) { var (val, array, num3) = texture.Value; if ((Object)(object)val == (Object)null) { continue; } float[] array2 = new float[array.Length / 4]; Buffer.BlockCopy(array, 0, array2, 0, array.Length); for (int i = 0; i < num3; i++) { int num4 = i * 4; if (!(array2[num4 + 3] <= 0f) && Cleared(array2[num4], array2[num4 + 2], 2.5f)) { array2[num4 + 3] = 0f; num++; } } byte[] array3 = new byte[array.Length]; Buffer.BlockCopy(array2, 0, array3, 0, array3.Length); val.LoadRawTextureData(new Il2CppStructArray(array3)); val.Apply(false, false); } foreach (GameObject trunk in Trunks) { if ((Object)(object)trunk != (Object)null) { trunk.SetActive(true); } } Trunks.Clear(); if (Clearings.Count > 0) { foreach (FoliageRustleSound item in Object.FindObjectsOfType()) { if (!((Object)(object)item == (Object)null) && ((Object)item).name.StartsWith("Tree", StringComparison.OrdinalIgnoreCase)) { Vector3 position = ((Component)item).transform.position; if (Cleared(position.x, position.z, 2.5f)) { ((Component)item).gameObject.SetActive(false); Trunks.Add(((Component)item).gameObject); num2++; } } } } } catch (Exception ex) { FortifyApi.Log("Trees: couldn't clear the lot (" + ex.Message + ")."); return; } if (Clearings.Count > 0) { FortifyApi.Log($"Trees: {num} tree(s) cleared off the lot ({num2} trunk(s))."); } } private static void Find() { //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Invalid comparison between Unknown and I4 List list = new List(); try { InstancingManager val = Object.FindObjectOfType(); List val2 = (((Object)(object)val != (Object)null) ? val.BackedInstanceObjects : null); int num = 0; while (val2 != null && num < val2.Count) { if ((Object)(object)val2[num] != (Object)null) { list.Add(val2[num]); } num++; } } catch { } foreach (InstanceObjectData item in list) { try { if ((item.Id ?? "").IndexOf("tree", StringComparison.OrdinalIgnoreCase) < 0) { continue; } Texture2D positionData = item.PositionData; if ((Object)(object)positionData == (Object)null || !((Texture)positionData).isReadable || (int)positionData.format != 20) { continue; } int instanceID = ((Object)positionData).GetInstanceID(); if (!Textures.ContainsKey(instanceID)) { Il2CppStructArray rawTextureData = positionData.GetRawTextureData(); byte[] array = new byte[((Il2CppArrayBase)(object)rawTextureData).Length]; for (int i = 0; i < array.Length; i++) { array[i] = ((Il2CppArrayBase)(object)rawTextureData)[i]; } Textures[instanceID] = (positionData, array, Math.Min(item.InstanceCount, array.Length / 16)); } } catch { } } } public static void Reset() { try { foreach (KeyValuePair texture in Textures) { var (val, array, _) = texture.Value; if (!((Object)(object)val == (Object)null)) { val.LoadRawTextureData(new Il2CppStructArray(array)); val.Apply(false, false); } } } catch { } foreach (GameObject trunk in Trunks) { if ((Object)(object)trunk != (Object)null) { trunk.SetActive(true); } } Trunks.Clear(); Textures.Clear(); Clearings.Clear(); _dirty = false; } } internal static class Ui { private static Vector2 _mouse; private static bool _click; private static int _clickFrame; private static readonly Dictionary Styles = new Dictionary(); private static readonly Dictionary Solid = new Dictionary(); public static void Capture() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0039: 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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) Vector2 val = default(Vector2); bool flag = false; try { val = Vector2.op_Implicit(Input.mousePosition); flag = true; } catch { } if (!flag) { try { Mouse current = Mouse.current; if (current != null) { val = ((InputControl)(object)((Pointer)current).position).ReadValue(); } } catch { } } _mouse = new Vector2(val.x, (float)Screen.height - val.y); if (Keys.MouseDown(0)) { _click = true; _clickFrame = Time.frameCount; } else if (_click && Time.frameCount - _clickFrame > 1) { _click = false; } } public static bool Hover(Rect r) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) return ((Rect)(ref r)).Contains(_mouse); } public static bool Click(Rect r) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) if (!_click || !((Rect)(ref r)).Contains(_mouse)) { return false; } _click = false; return true; } private static GUIStyle SolidStyle(Color c) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Expected O, but got Unknown //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Expected O, but got Unknown //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Expected O, but got Unknown //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Expected O, but got Unknown //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Expected O, but got Unknown int num = (int)(Math.Clamp(c.r, 0f, 1f) * 255f + 0.5f); int num2 = (int)(Math.Clamp(c.g, 0f, 1f) * 255f + 0.5f); int num3 = (int)(Math.Clamp(c.b, 0f, 1f) * 255f + 0.5f); int num4 = (int)(Math.Clamp(c.a, 0f, 1f) * 255f + 0.5f); int key = (num << 24) | (num2 << 16) | (num3 << 8) | num4; if (Solid.TryGetValue(key, out var value) && value != null && (Object)(object)value.normal.background != (Object)null) { return value; } if (Solid.Count > 600) { foreach (GUIStyle value2 in Solid.Values) { if (value2 != null && (Object)(object)value2.normal.background != (Object)null) { Object.Destroy((Object)(object)value2.normal.background); } } Solid.Clear(); } Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); Color32 val2 = default(Color32); ((Color32)(ref val2))..ctor((byte)num, (byte)num2, (byte)num3, (byte)num4); val.SetPixels32(new Il2CppStructArray((Color32[])(object)new Color32[4] { val2, val2, val2, val2 })); val.Apply(); ((Object)val).hideFlags = (HideFlags)32; value = new GUIStyle(); value.normal.background = val; value.border = new RectOffset(0, 0, 0, 0); value.padding = new RectOffset(0, 0, 0, 0); value.margin = new RectOffset(0, 0, 0, 0); Solid[key] = value; return value; } public static void Fill(Rect r, Color c) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (!(c.a <= 0.003f)) { GUI.Label(r, "", SolidStyle(c)); } } public static void Frame(Rect r, Color c, float t = 2f) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) Fill(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, ((Rect)(ref r)).width, t), c); Fill(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).yMax - t, ((Rect)(ref r)).width, t), c); Fill(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, t, ((Rect)(ref r)).height), c); Fill(new Rect(((Rect)(ref r)).xMax - t, ((Rect)(ref r)).y, t, ((Rect)(ref r)).height), c); } public static void Text(Rect r, string s, int size, Color c, TextAnchor a = (TextAnchor)4, bool bold = true, bool wrap = true) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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_0019: Expected I4, but got Unknown //IL_0035: 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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Expected O, but got Unknown int key = size * 64 + a * 4 + (bold ? 2 : 0) + wrap; if (!Styles.TryGetValue(key, out var value) || value == null) { value = new GUIStyle(GUI.skin.label) { fontSize = size, alignment = a, fontStyle = (FontStyle)(bold ? 1 : 0), wordWrap = wrap }; Styles[key] = value; } value.normal.textColor = c; GUI.Label(r, s ?? "", value); } public static bool Button(Rect r, string label, bool enabled = true, bool selected = false, int size = 17) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0082: 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_0060: 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_0045: 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_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) bool flag = enabled && Hover(r); Color c = ((!enabled) ? new Color(0.18f, 0.18f, 0.2f, 0.9f) : (selected ? new Color(0.85f, 0.65f, 0.2f, 0.97f) : (flag ? new Color(0.36f, 0.32f, 0.46f, 0.97f) : new Color(0.24f, 0.22f, 0.3f, 0.95f)))); Fill(r, c); Frame(r, enabled ? new Color(1f, 1f, 1f, flag ? 0.55f : 0.25f) : new Color(1f, 1f, 1f, 0.08f)); Text(r, label, size, (Color)((!enabled) ? new Color(0.5f, 0.5f, 0.55f) : (selected ? Color.black : Color.white)), (TextAnchor)4); if (enabled) { return Click(r); } return false; } } } namespace BattingCage { internal static class Board { private sealed class Row { public string Name; public bool AtBat; public Vector2 Cage; public int Best; public int Homers; public int Longest; public int Dist = -1; public int Mph = -1; public int Hr; public bool HasBall; public Vector3 Ball; public float Seen; public GameObject Ghost; public string Shown = ""; } private static readonly Dictionary Rows = new Dictionary(); private static Vector3? _atBat; private static int _dist = -1; private static int _mph = -1; private static string _sent = ""; private static string _pub = ""; private static float _next; private static readonly CultureInfo Inv = CultureInfo.InvariantCulture; private static string MyName { get { try { Player local = Player.Local; return Clean(((local != null) ? local.PlayerName : null) ?? "You"); } catch { return "You"; } } } private static string Clean(string s) { return (s ?? "").Replace("|", "").Replace(";", "").Replace("=", "") .Replace(",", ""); } public static void SetAtBat(Vector3? cagePos) { _atBat = cagePos; _dist = (_mph = -1); } public static void Score(int ft, int mph) { _dist = ft; _mph = mph; } public static void Derby(int hr, int longest) { } public static void Hit(Vector3 p, Vector3 v) { } public static string AtBatHere(Vector3 cage) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) string myName = MyName; foreach (Row value in Rows.Values) { if (value.AtBat && value.Name != myName && Time.unscaledTime - value.Seen < 6f) { Vector2 val = new Vector2(cage.x, cage.z) - value.Cage; if (((Vector2)(ref val)).sqrMagnitude < 4f) { return value.Name; } } } return null; } private static string MyLine() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) string myName = MyName; string text = (_atBat.HasValue ? (_atBat.Value.x.ToString("0.0", Inv) + "," + _atBat.Value.z.ToString("0.0", Inv)) : "-"); string text2 = "-"; if (Cage.Batting && Cage.BallPos(out var p)) { text2 = p.x.ToString("0.00", Inv) + "," + p.y.ToString("0.00", Inv) + "," + p.z.ToString("0.00", Inv); } return myName + "=" + text + "|" + CageCore.BestDerby.Value + "|" + CageCore.Homers.Value + "|" + CageCore.LongestFt.Value + "|" + _dist + "|" + _mph + "|" + Cage.BoardHr + "|" + text2; } public static void Update() { if (Time.unscaledTime < _next) { return; } _next = Time.unscaledTime + (Cage.Batting ? 0.1f : 0.25f); try { string text = MyLine(); if (FortifyApi.IsGuest) { if (text != _sent) { _sent = text; FortifyApi.SendRequest("bc_play", text); } string[] array = (FortifyApi.SharedState("bc_board") ?? "").Split(';'); for (int i = 0; i < array.Length; i++) { Read(array[i]); } Read(text); } else { foreach (string item in FortifyApi.TakeRequests("bc_play")) { Read(item); } Read(text); List list = new List(); foreach (Row value in Rows.Values) { if (Time.unscaledTime - value.Seen < 900f) { list.Add(Line(value)); } } string text2 = string.Join(";", list); if (text2 != _pub) { _pub = text2; FortifyApi.ShareState("bc_board", text2); } } } catch { } Mirror(); } private static string Line(Row r) { string text = (r.AtBat ? (r.Cage.x.ToString("0.0", Inv) + "," + r.Cage.y.ToString("0.0", Inv)) : "-"); string text2 = (r.HasBall ? (r.Ball.x.ToString("0.00", Inv) + "," + r.Ball.y.ToString("0.00", Inv) + "," + r.Ball.z.ToString("0.00", Inv)) : "-"); return r.Name + "=" + text + "|" + r.Best + "|" + r.Homers + "|" + r.Longest + "|" + r.Dist + "|" + r.Mph + "|" + r.Hr + "|" + text2; } private static void Read(string s) { //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrEmpty(s)) { return; } int num = s.IndexOf('='); if (num <= 0) { return; } string text = s.Substring(0, num); string[] array = s.Substring(num + 1).Split('|'); if (array.Length < 8) { return; } if (!Rows.TryGetValue(text, out var value)) { value = new Row { Name = text }; Rows[text] = value; } value.Seen = Time.unscaledTime; value.AtBat = array[0] != "-"; if (value.AtBat) { string[] array2 = array[0].Split(','); if (array2.Length == 2 && float.TryParse(array2[0], NumberStyles.Float, Inv, out var result) && float.TryParse(array2[1], NumberStyles.Float, Inv, out var result2)) { value.Cage = new Vector2(result, result2); } } int.TryParse(array[1], out value.Best); int.TryParse(array[2], out value.Homers); int.TryParse(array[3], out value.Longest); int.TryParse(array[4], out value.Dist); int.TryParse(array[5], out value.Mph); int.TryParse(array[6], out value.Hr); value.HasBall = false; if (array[7] != "-") { string[] array3 = array[7].Split(','); if (array3.Length == 3 && float.TryParse(array3[0], NumberStyles.Float, Inv, out var result3) && float.TryParse(array3[1], NumberStyles.Float, Inv, out var result4) && float.TryParse(array3[2], NumberStyles.Float, Inv, out var result5)) { value.HasBall = true; value.Ball = new Vector3(result3, result4, result5); } } } private static void Mirror() { //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: 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_01cd: 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_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) string myName = MyName; foreach (Row value in Rows.Values) { if (value.Name != myName && value.HasBall && Time.unscaledTime - value.Seen < 2f) { if ((Object)(object)value.Ghost == (Object)null) { value.Ghost = CageModels.Ball(); } value.Ghost.transform.position = Vector3.Lerp(value.Ghost.transform.position, value.Ball, 0.6f); } else if ((Object)(object)value.Ghost != (Object)null) { Object.Destroy((Object)(object)value.Ghost); value.Ghost = null; } if (value.Name == myName || !value.AtBat || Time.unscaledTime - value.Seen > 6f) { continue; } string text = value.Dist + "/" + value.Mph + "/" + value.Hr; if (text == value.Shown) { continue; } value.Shown = text; foreach (Placement.Placed item in Placement.All) { if ((Object)(object)item?.Go != (Object)null && item.Spec?.Id == "bc_cage") { Vector2 val = new Vector2(item.Go.transform.position.x, item.Go.transform.position.z) - value.Cage; if (((Vector2)(ref val)).sqrMagnitude < 4f) { Scoreboard.Show(item.Go, "DIST", value.Dist); Scoreboard.Show(item.Go, "MPH", value.Mph); Scoreboard.Show(item.Go, "HR", value.Hr); } } } } } public static void DrawBoard(Rect at, float s) { //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_030d: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Unknown result type (might be due to invalid IL or missing references) //IL_032b: 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_0395: 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_03ad: Unknown result type (might be due to invalid IL or missing references) //IL_03d9: Unknown result type (might be due to invalid IL or missing references) //IL_03fc: Unknown result type (might be due to invalid IL or missing references) //IL_041b: Unknown result type (might be due to invalid IL or missing references) //IL_042e: Unknown result type (might be due to invalid IL or missing references) //IL_044c: Unknown result type (might be due to invalid IL or missing references) //IL_047a: Unknown result type (might be due to invalid IL or missing references) //IL_0498: Unknown result type (might be due to invalid IL or missing references) //IL_04ab: Unknown result type (might be due to invalid IL or missing references) List list = new List(Rows.Values); list.RemoveAll((Row row2) => Time.unscaledTime - row2.Seen > 900f); list.Sort((Row a, Row b) => (a.Best == b.Best) ? b.Longest.CompareTo(a.Longest) : b.Best.CompareTo(a.Best)); if (list.Count == 0) { return; } Color val = default(Color); ((Color)(ref val))..ctor(1f, 0.58f, 0.12f); float num = 26f * s; int num2 = Mathf.Min(list.Count, 6); Rect r = default(Rect); ((Rect)(ref r))..ctor(((Rect)(ref at)).x, ((Rect)(ref at)).y, ((Rect)(ref at)).width, 58f * s + num * (float)num2 + 6f * s); WS_BC.FybCommon.Ui.Fill(r, new Color(0.03f, 0.06f, 0.13f, 0.72f)); WS_BC.FybCommon.Ui.Fill(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, ((Rect)(ref r)).width, 2f * s), val); WS_BC.FybCommon.Ui.Text(new Rect(((Rect)(ref r)).x + 14f * s, ((Rect)(ref r)).y + 6f * s, ((Rect)(ref r)).width, 24f * s), "LEADERBOARD", Mathf.RoundToInt(14f * s), val, (TextAnchor)3, bold: true, wrap: false); int size = Mathf.RoundToInt(14f * s); Color val2 = default(Color); ((Color)(ref val2))..ctor(0.62f, 0.68f, 0.8f); float num3 = ((Rect)(ref r)).y + 32f * s; float num4 = ((Rect)(ref r)).x + ((Rect)(ref r)).width * 0.56f; float num5 = ((Rect)(ref r)).x + ((Rect)(ref r)).width * 0.72f; float num6 = ((Rect)(ref r)).x + ((Rect)(ref r)).width * 0.87f; WS_BC.FybCommon.Ui.Text(new Rect(((Rect)(ref r)).x + 14f * s, num3, 120f * s, 20f * s), "PLAYER", Mathf.RoundToInt(11f * s), val2, (TextAnchor)3, bold: true, wrap: false); WS_BC.FybCommon.Ui.Text(new Rect(num4 - 30f * s, num3, 60f * s, 20f * s), "DERBY", Mathf.RoundToInt(11f * s), val2, (TextAnchor)4, bold: true, wrap: false); WS_BC.FybCommon.Ui.Text(new Rect(num5 - 30f * s, num3, 60f * s, 20f * s), "LONG", Mathf.RoundToInt(11f * s), val2, (TextAnchor)4, bold: true, wrap: false); WS_BC.FybCommon.Ui.Text(new Rect(num6 - 30f * s, num3, 60f * s, 20f * s), "HR", Mathf.RoundToInt(11f * s), val2, (TextAnchor)4, bold: true, wrap: false); num3 += 24f * s; string myName = MyName; for (int num7 = 0; num7 < num2; num7++) { Row row = list[num7]; if (num7 % 2 == 0) { WS_BC.FybCommon.Ui.Fill(new Rect(((Rect)(ref r)).x, num3, ((Rect)(ref r)).width, num), new Color(1f, 1f, 1f, 0.04f)); } bool flag = row.Name == myName; Color c = (Color)(flag ? new Color(1f, 0.86f, 0.5f) : Color.white); string text = ((row.Name.Length > 14) ? (row.Name.Substring(0, 13) + ".") : row.Name); WS_BC.FybCommon.Ui.Text(new Rect(((Rect)(ref r)).x + 14f * s, num3, 24f * s, num), (num7 + 1).ToString(), size, (num7 == 0) ? val : val2, (TextAnchor)3, bold: true, wrap: false); WS_BC.FybCommon.Ui.Text(new Rect(((Rect)(ref r)).x + 36f * s, num3, ((Rect)(ref r)).width * 0.45f, num), text + (row.AtBat ? " ●" : ""), size, c, (TextAnchor)3, flag, wrap: false); WS_BC.FybCommon.Ui.Text(new Rect(num4 - 30f * s, num3, 60f * s, num), row.Best.ToString(), size, c, (TextAnchor)4, bold: true, wrap: false); WS_BC.FybCommon.Ui.Text(new Rect(num5 - 30f * s, num3, 60f * s, num), (row.Longest > 0) ? (row.Longest + "'") : "-", size, c, (TextAnchor)4, bold: false, wrap: false); WS_BC.FybCommon.Ui.Text(new Rect(num6 - 30f * s, num3, 60f * s, num), row.Homers.ToString(), size, c, (TextAnchor)4, bold: false, wrap: false); num3 += num; } } public static void DrawNearby() { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0095: 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_00e1: Unknown result type (might be due to invalid IL or missing references) Player local = Player.Local; if ((Object)(object)local == (Object)null || Cursor.visible) { return; } foreach (Placement.Placed item in Placement.All) { if (!((Object)(object)item?.Go == (Object)null) && !(item.Spec?.Id != "bc_cage")) { Vector3 val = item.Go.transform.InverseTransformPoint(((Component)local).transform.position); if (Mathf.Abs(val.x) < 4.5f && val.z > -5f && val.z < 16f) { float num = (float)Screen.height / 1080f; DrawBoard(new Rect((float)Screen.width - 330f * num, 18f * num, 310f * num, 0f), num); break; } } } } public static void Clear() { foreach (Row value in Rows.Values) { if ((Object)(object)value.Ghost != (Object)null) { Object.Destroy((Object)(object)value.Ghost); } } Rows.Clear(); _atBat = null; } } internal static class Cage { private enum Phase { Wait, Windup, Pitch, InPlay } public sealed class Speed { public string Name; public float Mph; } public enum Venue { Cage, ParkCage, Field } public enum SwingKind { Normal, Power, Contact } public static readonly Speed[] Speeds = new Speed[4] { new Speed { Name = "Little League", Mph = 45f }, new Speed { Name = "High School", Mph = 70f }, new Speed { Name = "Pro", Mph = 90f }, new Speed { Name = "Floodlight Heat", Mph = 102f } }; public static readonly string[] Skins = new string[3] { "Classic", "Neon", "Gold" }; public static readonly int[] SkinNeeds = new int[3] { 0, 3, 6 }; private const float G = 9.81f; private const float Drag = 0.2f; private const float Mps = 0.44704f; private const float Ft = 3.28084f; private const float HomerFt = 330f; public static bool Batting; private static Placement.Placed _at; private static Transform _cage; private static Vector3 _returnPos; private static Quaternion _returnRot; private static Phase _ph; private static float _phAt; private static float _pitchAt; private static float _plateAt; private static float _swingAt = -10f; private static float _resolveAt; private static float _doneAt; private static bool _counted; private static bool _swung; private static bool _contact; private static bool _caught; private static bool _landed; private static bool _isHomer; private static bool _fair; private static bool _hitSomething; private static Vector3 _bp; private static Vector3 _bv; private static Vector3 _p0; private static Vector3 _v0; private static GameObject _ball; private static GameObject _trail; private static GameObject _bat; private static GameObject _pivot; private static LineRenderer _line; private static readonly List Trail = new List(); private static int _speed = 1; private static string _skin = "Classic"; private static float _projFt; private static float _distFt; private static float _exitMph; private static float _launch; private static float _spray; private static string _result = ""; private static string _detail = ""; private static Color _resultColor = Color.white; private static float _resultAt = -10f; private static int _derbyPitch = -1; private static int _derbyHr; private static int _sessionHr; private static float _derbyLong; private static float _lightsAt; private static readonly Dictionary AlarmAt = new Dictionary(); private static readonly Random Rng = new Random(); private static float _nextWarn; public static Venue Where = Venue.Cage; private static Vector3 _release = CageModels.Release; private static Vector3 _batterLocal = CageModels.BatterSpot; private static Vector3 _lookLocal = new Vector3(0.1f, 1.1f, 12.9f); private static SwingKind _kind = SwingKind.Normal; public static Vector2 Pci; public const float ZoneMid = 0.8f; public const float ZoneHalfW = 0.25f; public const float ZoneHalfH = 0.33f; private static string _pitchName = "Fastball"; private static Vector3 _acc; private static Vector3 _crossLocal; private static float _crossAt = -10f; private static string _timingTag = ""; private static string _contactTag = ""; private static bool _perfectPerfect; private static bool _homerCalled; private static int _derbyOuts; public const float WallH = 3f; private static float _landedAt; public static bool PitchMix; private static readonly List _derbyHits = new List(); public static float AutoMs = 9999f; public static bool AutoAim; public static Vector2 AimOff; public static SwingKind AutoKind = SwingKind.Normal; public static string LastHit = ""; private static bool _derbyStartReq; private static readonly Vector3[] HandPos = (Vector3[])(object)new Vector3[3] { new Vector3(0.26f, -0.3f, 0.46f), new Vector3(0.02f, -0.36f, 0.55f), new Vector3(-0.28f, -0.2f, 0.42f) }; private static readonly Vector3[] BarrelDir = (Vector3[])(object)new Vector3[3] { new Vector3(0.3f, 0.92f, -0.12f), new Vector3(1f, 0.02f, 0.42f), new Vector3(-0.7f, 0.45f, -0.55f) }; private static bool _swingPending; private static float _pitchShownAt = -10f; private static float _bonusAt = -10f; private static readonly HashSet Cleared = new HashSet(); private static float _timingE; private static float _timingW; private static float _timingAt = -10f; private static int _chipFt = -1; private static int _chipMph = -1; private static int _chipDeg = -999; private static readonly Color Navy = new Color(0.03f, 0.06f, 0.13f, 0.72f); private static readonly Color Orange = new Color(1f, 0.58f, 0.12f); public static bool InDerby => _derbyPitch >= 0; public static int DerbyOuts => _derbyOuts; public static bool BallCamWanted { get { if (Where == Venue.Field && (Object)(object)_ball != (Object)null && _contact && _fair && _projFt > 280f && !_caught) { if (_landed) { return Time.time < _landedAt + 1.6f; } return true; } return false; } } public static Vector3 BallVelocity => _bv; public static bool FieldDerby { get { if (InDerby) { return Where == Venue.Field; } return false; } } public static int BoardHr { get { if (!InDerby) { return _sessionHr; } return _derbyHr; } } public static string LastLine => _result + " | " + _detail + $" | exit {_exitMph:0} launch {_launch:0} spray {_spray:0} proj {_projFt:0} dist {_distFt:0}"; private static float PitchMps => Speeds[_speed].Mph * 0.44704f; public static bool HitInPlay { get { if (_ph == Phase.InPlay) { return _contact; } return false; } } public static bool BallLanded => _landed; public static float PciHalfW(SwingKind k) { return k switch { SwingKind.Contact => 0.22f, SwingKind.Power => 0.12f, _ => 0.17f, }; } public static float PciHalfH(SwingKind k) { return k switch { SwingKind.Contact => 0.17f, SwingKind.Power => 0.095f, _ => 0.13f, }; } public static bool BallPos(out Vector3 p) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) p = _bp; return (Object)(object)_ball != (Object)null; } public static void Derby() { _derbyStartReq = true; } public static void Throw(Vector3 from, Vector3 vel) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_0043: Unknown result type (might be due to invalid IL or missing references) KillBall(); _contact = true; _caught = (_landed = (_hitSomething = false)); _isHomer = true; _bp = from; _bv = vel; _ball = CageModels.Ball(); _ball.transform.position = from; _doneAt = Time.time + 10f; } public static void SetSkin(string skin) { _skin = skin; MakeBat(); } public static void TestLaunch(float mph, float launch, float spray) { //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: 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_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_cage == (Object)null)) { KillBall(); _swung = (_caught = (_landed = (_hitSomething = (_counted = false)))); _contact = true; _exitMph = mph; _launch = launch; _spray = spray; _fair = Mathf.Abs(spray) <= 45f; _bp = _cage.TransformPoint(new Vector3(0f, 0.9f, 0.1f)); Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(Mathf.Sin(spray * ((float)Math.PI / 180f)) * Mathf.Cos(launch * ((float)Math.PI / 180f)), Mathf.Sin(launch * ((float)Math.PI / 180f)), Mathf.Cos(spray * ((float)Math.PI / 180f)) * Mathf.Cos(launch * ((float)Math.PI / 180f))); _bv = _cage.TransformDirection(val) * (mph * 0.44704f); _projFt = Project(_bp, _bv, _cage.position.y) * 3.28084f; _isHomer = _fair && _projFt >= 330f; _ball = CageModels.Ball(); _ball.transform.position = _bp; _ph = Phase.InPlay; _resolveAt = Time.time + 8f; _doneAt = Time.time + 12f; _chipMph = Mathf.RoundToInt(mph); _chipDeg = Mathf.RoundToInt(launch); Result(_isHomer ? "HOME RUN!" : "Test hit", "", Color.white, -1, -1); } } public static string State() { return $"batting={Batting} phase={_ph} speed={Speeds[_speed].Name} skin={_skin} result='{_result}' {_detail} derby={_derbyPitch}/{_derbyHr} best={CageCore.BestDerby?.Value} hr={CageCore.Homers?.Value} long={CageCore.LongestFt?.Value}"; } public static void Reset() { if (Batting) { Leave(); } KillBall(); _at = null; _cage = null; AlarmAt.Clear(); Board.Clear(); } public static bool Use(Placement.Placed p, RaycastHit hit, out string hint) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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_006c: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) hint = null; if ((Object)(object)p?.Go == (Object)null || Batting) { return false; } Player local = Player.Local; if ((Object)(object)local == (Object)null) { return false; } Vector3 val = p.Go.transform.InverseTransformPoint(((Component)local).transform.position); bool flag = Mathf.Abs(val.x) < 2f && val.z > -1.45f && val.z < 2.2f; string text = Board.AtBatHere(p.Go.transform.position); if (text != null) { hint = text + " is at bat - wait your turn"; return true; } if (!flag) { hint = (Inside(val) ? "Walk up to home plate to bat" : "Floodlight Batting Cage - walk in to home plate to bat"); return true; } KeyCode useKey = FortifyApi.UseKey; hint = $"[{useKey}] Step up to the plate [P] Ferry to Floodlight Park"; if (FortifyApi.KeyDown(useKey)) { Enter(p); } else if (WS_BC.FybCommon.Keys.Down((KeyCode)112)) { Park.Travel(); } return true; } private static bool Inside(Vector3 local) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) if (Mathf.Abs(local.x) < 2.1f && local.z > -1.5f) { return local.z < 14.5f; } return false; } public static void Enter(Placement.Placed p) { EnterAt(p.Go.transform, Venue.Cage, p); } public static void EnterAt(Transform frame, Venue where, Placement.Placed p = null) { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_015e: 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_0148: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) Player local = Player.Local; _at = p; _cage = frame; Where = where; if (where == Venue.Field) { _release = Park.ReleaseLocal; _batterLocal = new Vector3(-0.62f, 0.05f, -0.05f); _lookLocal = new Vector3(0.15f, 1.15f, 17.8f); } else { _release = CageModels.Release; _batterLocal = CageModels.BatterSpot; _lookLocal = new Vector3(0.1f, 1.1f, 12.9f); } Pci = Vector2.zero; _derbyOuts = 0; _returnPos = ((Component)local).transform.position; _returnRot = ((Component)local).transform.rotation; _speed = Mathf.Max(0, Array.FindIndex(Speeds, (Speed s) => string.Equals(s.Name, CageCore.SpeedName.Value, StringComparison.OrdinalIgnoreCase))); _skin = (Unlocked(CageCore.Skin.Value) ? CageCore.Skin.Value : "Classic"); Vector3 val = _cage.TransformPoint(_batterLocal); Quaternion val2 = Quaternion.LookRotation(_cage.forward, Vector3.up); try { PlayerMovement instance = PlayerSingleton.Instance; if ((Object)(object)instance != (Object)null) { instance.Teleport(val, val2, true); instance.CanMove = false; } else { ((Component)local).transform.position = val; } ((Component)local).transform.rotation = val2; PlayerCamera instance2 = PlayerSingleton.Instance; if (instance2 != null) { instance2.LookAt(_cage.TransformPoint(_lookLocal), 0.25f); } try { if (instance2 != null) { instance2.SetCanLook(false); } } catch { } } catch { } try { PlayerInventory instance3 = PlayerSingleton.Instance; if (instance3 != null) { instance3.SetEquippingEnabled(false); } } catch { } Batting = true; _ph = Phase.Wait; _phAt = Time.time + 2.2f; _derbyPitch = -1; _result = ((where == Venue.Field) ? "Floodlight Park" : "Batter up!"); _detail = "Aim the box with the mouse, click to swing when the ball gets to the plate."; _resultColor = new Color(1f, 0.85f, 0.3f); _resultAt = Time.time; MakeBat(); Board.SetAtBat(_cage.position); Scoreboard.Show(((Component)_cage).gameObject, "DIST", -1); Scoreboard.Show(((Component)_cage).gameObject, "MPH", -1); Scoreboard.Show(((Component)_cage).gameObject, "HR", 0); } public static void Leave() { //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: 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) Batting = false; try { PlayerCamera instance = PlayerSingleton.Instance; if (instance != null) { instance.SetCanLook(true); } } catch { } Park.EndBallCam(); try { PlayerInventory instance2 = PlayerSingleton.Instance; if (instance2 != null) { instance2.SetEquippingEnabled(true); } } catch { } if (_derbyPitch >= 0) { _derbyPitch = -1; } try { PlayerMovement instance3 = PlayerSingleton.Instance; if ((Object)(object)instance3 != (Object)null) { instance3.CanMove = true; if ((Object)(object)_cage != (Object)null) { instance3.Teleport(_cage.TransformPoint(new Vector3(-1.3f, 0.05f, 0.6f)), Quaternion.LookRotation(_cage.forward, Vector3.up), true); } } } catch { } if ((Object)(object)_pivot != (Object)null) { Object.Destroy((Object)(object)_pivot); } _pivot = (_bat = null); Board.SetAtBat(null); } private static void MakeBat() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_pivot != (Object)null) { Object.Destroy((Object)(object)_pivot); } Camera main = Camera.main; if ((Object)(object)main == (Object)null) { return; } _pivot = new GameObject("bc_BatPivot"); _pivot.transform.SetParent(((Component)main).transform, false); _bat = CageModels.Bat("Classic"); _bat.transform.SetParent(_pivot.transform, false); _bat.transform.localPosition = new Vector3(0f, -0.06f, 0f); Material val = Models.Mat("bc_bat_wood", new Color(0.72f, 0.55f, 0.36f), 0f, 0.35f); foreach (Renderer componentsInChild in _bat.GetComponentsInChildren(true)) { componentsInChild.shadowCastingMode = (ShadowCastingMode)0; Il2CppReferenceArray val2 = new Il2CppReferenceArray((long)Mathf.Max(1, ((Il2CppArrayBase)(object)componentsInChild.sharedMaterials).Length)); for (int i = 0; i < ((Il2CppArrayBase)(object)val2).Length; i++) { ((Il2CppArrayBase)(object)val2)[i] = val; } componentsInChild.sharedMaterials = val2; } PoseBat(0f); } private static void PoseBat(float since) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: 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_009c: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: 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_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_pivot == (Object)null)) { bool flag = HitInPlay || Park.CamOn; if (_pivot.activeSelf == flag) { _pivot.SetActive(!flag); } Vector3 localPosition; Vector3 val; if (since < 0f || since > 0.95f) { localPosition = HandPos[0]; val = BarrelDir[0]; float num = Mathf.Sin(Time.time * 2.3f) * 0.04f; Vector3 val2 = val + new Vector3(num, 0f, num * 0.5f); val = ((Vector3)(ref val2)).normalized; } else if (since < 0.09f) { float num2 = since / 0.09f; num2 *= num2; localPosition = Vector3.Lerp(HandPos[0], HandPos[1], num2); val = Vector3.Slerp(((Vector3)(ref BarrelDir[0])).normalized, ((Vector3)(ref BarrelDir[1])).normalized, num2); } else if (since < 0.25f) { float num2 = (since - 0.09f) / 0.16f; num2 = 1f - (1f - num2) * (1f - num2); localPosition = Vector3.Lerp(HandPos[1], HandPos[2], num2); val = Vector3.Slerp(((Vector3)(ref BarrelDir[1])).normalized, ((Vector3)(ref BarrelDir[2])).normalized, num2); } else if (since < 0.55f) { localPosition = HandPos[2]; val = BarrelDir[2]; } else { float num2 = (since - 0.55f) / 0.4f; num2 = num2 * num2 * (3f - 2f * num2); localPosition = Vector3.Lerp(HandPos[2], HandPos[0], num2); val = Vector3.Slerp(((Vector3)(ref BarrelDir[2])).normalized, ((Vector3)(ref BarrelDir[0])).normalized, num2); } _pivot.transform.localPosition = localPosition; _pivot.transform.localRotation = Quaternion.FromToRotation(Vector3.up, ((Vector3)(ref val)).normalized); } } public static void Update() { if (Time.unscaledTime >= _lightsAt) { _lightsAt = Time.unscaledTime + 2f; Lights(); } if (!Batting) { if ((Object)(object)_ball != (Object)null && Time.time > _doneAt) { KillBall(); } return; } if ((Object)(object)_cage == (Object)null || (Where == Venue.Cage && (_at == null || !_at.Active || (Object)(object)_at.Go == (Object)null))) { Leave(); return; } try { PlayerMovement instance = PlayerSingleton.Instance; if ((Object)(object)instance != (Object)null && instance.CanMove) { instance.CanMove = false; } } catch { } if ((Object)(object)_pivot == (Object)null) { MakeBat(); } PoseBat(Time.time - _swingAt); SpinWheels(); Keys(); Step(); } private static void Keys() { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) if (Cursor.visible) { return; } if (FortifyApi.KeyDown((KeyCode)120)) { if (InDerby) { Say("Derby over", $"You quit with {_derbyHr} home runs.", Color.white); } Leave(); return; } if (WS_BC.FybCommon.Keys.Down((KeyCode)102) && !InDerby && _ph != Phase.Pitch) { _speed = (_speed + 1) % Speeds.Length; CageCore.SpeedName.Value = Speeds[_speed].Name; Say(Speeds[_speed].Name, $"About {Speeds[_speed].Mph:0} mph pitches.", new Color(0.55f, 0.85f, 1f)); } if ((WS_BC.FybCommon.Keys.Down((KeyCode)121) || _derbyStartReq) && !InDerby && _ph != Phase.Pitch && _ph != Phase.InPlay) { _derbyStartReq = false; _derbyPitch = 0; _derbyHits.Clear(); _derbyHr = 0; _derbyOuts = 0; _derbyLong = 0f; Scoreboard.Show(((Component)_cage).gameObject, "HR", 0); if (Where == Venue.Field) { Say("HOME RUN DERBY", "10 outs. Any swing that isn't a home run is an out. 440+ ft gives one back.", new Color(1f, 0.55f, 0.15f)); Park.Crowd(0.6f); } else { Say("HOME RUN DERBY", "10 pitches. Every home run counts.", new Color(1f, 0.55f, 0.15f)); } _ph = Phase.Wait; _phAt = Time.time + 2.2f; } AimPci(); if (WS_BC.FybCommon.Keys.Down((KeyCode)109) && !InDerby) { PitchMix = !PitchMix; CageCore.Mix.Value = PitchMix; Say(PitchMix ? "Pitch mix" : "Fastballs only", PitchMix ? "Fastballs, changeups, curveballs and sliders." : "Straight batting practice.", new Color(0.55f, 0.85f, 1f)); } if (!_swung && Time.time - _swingAt > 0.95f) { if (InDerby && (WS_BC.FybCommon.Keys.MouseDown(0) || WS_BC.FybCommon.Keys.MouseDown(1))) { _kind = SwingKind.Power; Swing(); } else if (WS_BC.FybCommon.Keys.MouseDown(1)) { _kind = SwingKind.Power; Swing(); } else if (WS_BC.FybCommon.Keys.MouseDown(0)) { _kind = ((WS_BC.FybCommon.Keys.RawHeld((KeyCode)304) || WS_BC.FybCommon.Keys.RawHeld((KeyCode)303)) ? SwingKind.Contact : SwingKind.Normal); Swing(); } } } private static void Step() { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: 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_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) float time = Time.time; switch (_ph) { case Phase.Wait: if (time >= _phAt) { _ph = Phase.Windup; _phAt = time + 0.85f; CageSound.Play(CageSound.Whir, _cage.TransformPoint(CageModels.Release), 0.25f); } break; case Phase.Windup: if (time >= _phAt) { Pitch(); } break; case Phase.Pitch: if (AutoMs < 9000f && !_swung && time >= _plateAt - 0.09f + AutoMs / 1000f) { if (AutoAim) { Vector3 val = _cage.InverseTransformPoint(PlateCross()); Pci = new Vector2(val.x, val.y - 0.8f) + AimOff; } _kind = AutoKind; Swing(); } FlyPitch(time); break; case Phase.InPlay: if (time >= _resolveAt) { NextPitch(); } break; } if (_ph == Phase.InPlay && _swingPending && time >= _swingAt + 0.09f) { _swingPending = false; } } public static void HideBat(bool hide) { if ((Object)(object)_pivot != (Object)null) { _pivot.SetActive(!hide); } } private static float UntilRelease() { if (_ph == Phase.Wait) { return _phAt + 0.85f - Time.time; } if (_ph == Phase.Windup) { return _phAt - Time.time; } return -1f; } private static void AimPci() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0015: 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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0090: 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) Vector2 val = Vector2.zero; try { Mouse current = Mouse.current; if (current != null) { val = ((InputControl)(object)((Pointer)current).delta).ReadValue() * 0.0016f; } } catch { } float num = Time.deltaTime * 0.9f; if (WS_BC.FybCommon.Keys.RawHeld((KeyCode)119)) { val.y += num; } if (WS_BC.FybCommon.Keys.RawHeld((KeyCode)115)) { val.y -= num; } if (WS_BC.FybCommon.Keys.RawHeld((KeyCode)100)) { val.x += num; } if (WS_BC.FybCommon.Keys.RawHeld((KeyCode)97)) { val.x -= num; } Pci += val; Pci.x = Mathf.Clamp(Pci.x, -0.37f, 0.37f); Pci.y = Mathf.Clamp(Pci.y, -0.45000002f, 0.45000002f); } private static void Pitch() { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: 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_0205: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_0278: 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_0296: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) KillBall(); _swung = (_contact = (_caught = (_landed = (_isHomer = (_fair = (_hitSomething = (_counted = false))))))); _swingPending = false; Vector3 val = _cage.TransformPoint(_release); float num = 1f; float num2 = 0f; float num3 = 0f; _pitchName = "Fastball"; if (PitchMix && !InDerby) { double num4 = Rng.NextDouble(); if (num4 < 0.4) { _pitchName = "Fastball"; num3 = 0.08f; } else if (num4 < 0.6) { _pitchName = "Changeup"; num = 0.84f; num3 = -0.22f; num2 = -0.08f; } else if (num4 < 0.8) { _pitchName = "Curveball"; num = 0.79f; num3 = -0.75f; num2 = 0.18f; } else { _pitchName = "Slider"; num = 0.87f; num3 = -0.2f; num2 = 0.36f; } } float num5 = (float)(Rng.NextDouble() * 2.0 - 1.0) * (InDerby ? 0.12f : 0.2f); float num6 = (InDerby ? 0.68f : 0.55f) + (float)Rng.NextDouble() * (InDerby ? 0.32f : 0.55f); Vector3 val2 = _cage.TransformPoint(new Vector3(num5, num6, 0f)); float num7 = PitchMps * num * (0.97f + (float)Rng.NextDouble() * 0.05f); float num8 = Vector3.Distance(val, val2) / num7; _acc = _cage.TransformDirection(new Vector3(num2, num3, 0f)) * (2f / (num8 * num8)); _p0 = val; _v0 = (val2 - val) / num8 - 0.5f * (Vector3.down * 9.81f + _acc) * num8; _crossLocal = new Vector3(num5, num6, 0f); _crossAt = -10f; _pitchAt = Time.time; _plateAt = _pitchAt + num8; _bp = val; _bv = _v0; _ball = CageModels.Ball(); _ball.transform.position = val; _ph = Phase.Pitch; CageSound.Play(CageSound.Thump, val, 0.35f); if (PitchMix && !InDerby) { _pitchShownAt = Time.time; } } private static void FlyPitch(float now) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: 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_010f: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_0196: 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_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_ball == (Object)null) { NextPitch(); return; } float num = now - _pitchAt; _bp = _p0 + _v0 * num + 0.5f * num * num * (Vector3.down * 9.81f + _acc); if (_crossAt < 0f && now >= _plateAt) { _crossAt = now; } _ball.transform.position = _bp; _ball.transform.Rotate(Vector3.right, 1800f * Time.deltaTime, (Space)1); if (_swingPending && now >= _swingAt + 0.09f) { _swingPending = false; Contact(now); return; } Vector3 val = _cage.InverseTransformPoint(_bp); float num2 = ((Where == Venue.Field) ? (-1.1f) : (-1.35f)); if (val.z < num2 || val.y < 0.04f) { CageSound.Play((!(val.z < num2)) ? CageSound.Thud : ((Where == Venue.Field) ? CageSound.Thump : CageSound.Net), _bp, 0.25f); _crossAt = Mathf.Max(_crossAt, now - 0.2f); if (_swung) { Result("Swing and a miss", "Strike.", new Color(1f, 0.45f, 0.4f), -1, -1); } else { Vector3 val2 = _cage.InverseTransformPoint(PlateCross()); bool flag = Mathf.Abs(val2.x) < 0.25f && Mathf.Abs(val2.y - 0.8f) < 0.33f; Result(flag ? "Strike looking" : "Ball", flag ? "That one caught the plate." : "Just off the plate.", new Color(0.8f, 0.8f, 0.8f), -1, -1); } _chipMph = -1; _bv = Vector3.zero; _ph = Phase.InPlay; _resolveAt = now + 1.2f; _doneAt = now + 2f; CountDerbyPitch(homer: false, 0f); } } private static Vector3 PlateCross() { //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_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) float num = _plateAt - _pitchAt; return _p0 + _v0 * num + 0.5f * num * num * (Vector3.down * 9.81f + _acc); } private static void Swing() { //IL_0047: 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) _swingAt = Time.time; _swung = _ph == Phase.Pitch; _swingPending = _ph == Phase.Pitch; CageSound.Play(CageSound.Swish, ((Object)(object)Camera.main != (Object)null) ? ((Component)Camera.main).transform.position : _bp, 0.12f); } public static float Window() { return 0.02f * Mathf.Pow(40f / PitchMps, 0.7f); } private static float R(float a, float b) { return a + (float)Rng.NextDouble() * (b - a); } private static void Contact(float now) { //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_057b: Unknown result type (might be due to invalid IL or missing references) //IL_057d: Unknown result type (might be due to invalid IL or missing references) //IL_058d: Unknown result type (might be due to invalid IL or missing references) //IL_0592: Unknown result type (might be due to invalid IL or missing references) //IL_059c: Unknown result type (might be due to invalid IL or missing references) //IL_05a1: Unknown result type (might be due to invalid IL or missing references) //IL_05a6: Unknown result type (might be due to invalid IL or missing references) //IL_05aa: Unknown result type (might be due to invalid IL or missing references) //IL_05c7: Unknown result type (might be due to invalid IL or missing references) //IL_05e7: Unknown result type (might be due to invalid IL or missing references) //IL_05e9: Unknown result type (might be due to invalid IL or missing references) //IL_05ee: Unknown result type (might be due to invalid IL or missing references) //IL_05f3: Unknown result type (might be due to invalid IL or missing references) //IL_05f8: Unknown result type (might be due to invalid IL or missing references) //IL_0602: Unknown result type (might be due to invalid IL or missing references) //IL_06ba: Unknown result type (might be due to invalid IL or missing references) //IL_075e: Unknown result type (might be due to invalid IL or missing references) //IL_0846: Unknown result type (might be due to invalid IL or missing references) //IL_084b: Unknown result type (might be due to invalid IL or missing references) //IL_07ae: Unknown result type (might be due to invalid IL or missing references) //IL_0831: Unknown result type (might be due to invalid IL or missing references) //IL_081b: Unknown result type (might be due to invalid IL or missing references) float num = now - _plateAt; float num2 = Window() * ((_kind == SwingKind.Contact) ? 1.3f : ((_kind == SwingKind.Power) ? 0.75f : 1f)); _timingE = num; _timingW = num2; _timingAt = Time.time; _chipFt = (_chipMph = -1); float num3 = Mathf.Abs(num); float num4 = ((num >= 0f) ? 1f : (-1f)); float num5 = (Speeds[_speed].Mph - 70f) * 0.12f; Vector3 val = _cage.InverseTransformPoint(PlateCross()); float num6 = PciHalfW(_kind); float num7 = PciHalfH(_kind); float num8 = (val.x - Pci.x) / num6; float num9 = (val.y - (0.8f + Pci.y)) / num7; float num10 = Mathf.Max(Mathf.Abs(num8), Mathf.Abs(num9)); _timingTag = ((num3 <= num2 * 0.35f) ? "PERFECT" : ((num3 <= num2) ? "GOOD" : ((!(num3 <= num2 * 2.2f)) ? ((num < 0f) ? "VERY EARLY" : "VERY LATE") : ((num < 0f) ? "EARLY" : "LATE")))); _contactTag = ((num10 <= 0.3f) ? "PERFECT" : ((num10 <= 0.65f) ? "GOOD" : ((!(num10 <= 1f)) ? "MISSED" : ((!(Mathf.Abs(num9) >= Mathf.Abs(num8))) ? ((num8 > 0f) ? "OFF THE END" : "JAMMED") : ((num9 > 0f) ? "UNDER IT" : "ON TOP"))))); _perfectPerfect = _timingTag == "PERFECT" && _contactTag == "PERFECT"; if (num3 > num2 * 5f || num10 > 1.15f) { _contact = false; _detail = ((num10 > 1.15f) ? ("Timing " + _timingTag + " | Contact MISSED") : ((num < 0f) ? $"Way early ({num3:0.00}s)" : $"Way late ({num3:0.00}s)")); return; } float num11 = Mathf.Pow(Mathf.Clamp01(1f - Mathf.Max(0f, num3 - num2 * 0.35f) / (num2 * 1.8f)), 1.6f); float num12 = Mathf.Pow(Mathf.Clamp01(1f - Mathf.Pow(Mathf.Clamp01(num10), 1.3f)), 1.4f); float num13 = ((_kind == SwingKind.Power) ? 116f : ((_kind == SwingKind.Contact) ? 99f : 109f)); _exitMph = 52f + (num13 - 52f) * (0.32f + 0.68f * num11 * num12) + num5 + R(-3f, 2f); if (_perfectPerfect) { _exitMph = num13 + num5 + R(-5f, 2f); } _launch = Mathf.Clamp(25f + 40f * num9 + R(-4f, 4f), -22f, 78f); if (_perfectPerfect) { _launch = R(15f, 36f); } _spray = num / num2 * 22f + num8 * 10f + R(-17f, 17f); if (_perfectPerfect) { _spray = R(-30f, 30f); } string text; if (num3 > num2 * 2.6f || num10 > 1f) { _spray = num4 * R(48f, 82f); _exitMph = Mathf.Min(_exitMph, R(55f, 82f)); text = "Foul"; } else { text = ((_perfectPerfect || (num11 > 0.75f && num12 > 0.7f && _launch > 18f && _launch < 38f)) ? "Barrel" : ((_launch < 8f) ? "Grounder" : ((_launch < 22f) ? "Line drive" : ((!(_launch < 50f)) ? "Pop up" : "Fly ball")))); } _contact = true; _fair = Mathf.Abs(_spray) <= 45f; _chipMph = Mathf.RoundToInt(_exitMph); _chipDeg = Mathf.RoundToInt(_launch); _chipFt = -1; Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(Mathf.Sin(_spray * ((float)Math.PI / 180f)) * Mathf.Cos(_launch * ((float)Math.PI / 180f)), Mathf.Sin(_launch * ((float)Math.PI / 180f)), Mathf.Cos(_spray * ((float)Math.PI / 180f)) * Mathf.Cos(_launch * ((float)Math.PI / 180f))); _bv = _cage.TransformDirection(val2) * (_exitMph * 0.44704f); Vector3 val3 = _cage.InverseTransformPoint(_bp); val3.z = Mathf.Clamp(val3.z, -0.3f, 0.6f); val3.x = Mathf.Clamp(val3.x, -0.35f, 0.35f); _bp = _cage.TransformPoint(val3); _projFt = Project(_bp, _bv, _cage.position.y) * 3.28084f; _homerCalled = false; _isHomer = Where != Venue.Field && _fair && _projFt >= 330f; bool flag = _fair && _projFt > 300f; _ph = Phase.InPlay; _resolveAt = now + ((_isHomer || (Where == Venue.Field && flag)) ? 7.5f : 4.5f); _doneAt = now + 12f; CageSound.Play((_isHomer || text == "Barrel") ? CageSound.Crack : CageSound.Tick, _bp, (text == "Foul") ? 0.25f : 0.45f); Scoreboard.Show(((Component)_cage).gameObject, "MPH", Mathf.RoundToInt(_exitMph)); Scoreboard.Show(((Component)_cage).gameObject, "DIST", -1); string small = (_detail = (_perfectPerfect ? "PERFECT - PERFECT" : ("Timing " + _timingTag + " | Contact " + _contactTag))); if (_isHomer) { Result("HOME RUN!", small, new Color(1f, 0.8f, 0.2f), -1, Mathf.RoundToInt(_exitMph)); } else if (Where == Venue.Field && flag) { Result((_projFt > 360f) ? "WAY BACK..." : "DEEP FLY BALL...", small, new Color(1f, 0.9f, 0.5f), -1, Mathf.RoundToInt(_exitMph)); Park.Crowd(0.35f); } else { Result(_fair ? ((text == "Barrel") ? "Deep fly ball" : text) : ((num < 0f) ? "Foul ball, pulled" : "Foul ball, pushed"), small, _fair ? new Color(0.55f, 1f, 0.6f) : new Color(1f, 0.6f, 0.4f), -1, Mathf.RoundToInt(_exitMph)); } Board.Hit(_bp, _bv); } private static void HomerCalled() { //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) _homerCalled = true; _isHomer = true; _resolveAt = Mathf.Max(_resolveAt, Time.time + 4.5f); _doneAt = Mathf.Max(_doneAt, Time.time + 8f); Result("HOME RUN!", _perfectPerfect ? "PERFECT - PERFECT" : $"Projected {_projFt:0} ft", new Color(1f, 0.8f, 0.2f), -1, Mathf.RoundToInt(_exitMph)); CageSound.Play(CageSound.Crack, ((Object)(object)Camera.main != (Object)null) ? ((Component)Camera.main).transform.position : _bp, 0.2f); Park.Homer(_bp); } private static float Project(Vector3 p, Vector3 v, float groundY) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003a: 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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_006b: 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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) Vector3 val = p; float num = 0.01f; for (int i = 0; i < 2000; i++) { v += Vector3.down * (9.81f * num); v *= 1f - 0.2f * num; p += v * num; if (p.y <= groundY && v.y < 0f) { break; } } Vector3 val2 = p - val; val2.y = 0f; return ((Vector3)(ref val2)).magnitude; } public static void FixedUpdate() { //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_ball == (Object)null || (!_contact && !_caught)) { return; } float fixedDeltaTime = Time.fixedDeltaTime; int num = Mathf.Clamp(Mathf.CeilToInt(((Vector3)(ref _bv)).magnitude * fixedDeltaTime / 0.5f), 1, 6); float dt = fixedDeltaTime / (float)num; for (int i = 0; i < num; i++) { if (!((Object)(object)_ball != (Object)null)) { break; } BallStep(dt); } if ((Object)(object)_ball != (Object)null) { _ball.transform.position = _bp; _ball.transform.Rotate(Vector3.right, ((Vector3)(ref _bv)).magnitude * 40f * fixedDeltaTime, (Space)1); } } private static void BallStep(float dt) { //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: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0088: 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_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_0433: Unknown result type (might be due to invalid IL or missing references) //IL_0434: Unknown result type (might be due to invalid IL or missing references) //IL_0439: Unknown result type (might be due to invalid IL or missing references) //IL_043e: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0192: 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_019a: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_048f: 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_0495: Unknown result type (might be due to invalid IL or missing references) //IL_0496: Unknown result type (might be due to invalid IL or missing references) //IL_0450: Unknown result type (might be due to invalid IL or missing references) //IL_0455: Unknown result type (might be due to invalid IL or missing references) //IL_0456: Unknown result type (might be due to invalid IL or missing references) //IL_045b: Unknown result type (might be due to invalid IL or missing references) //IL_0461: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: 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_04dd: 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_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_04b9: Unknown result type (might be due to invalid IL or missing references) //IL_04c3: Unknown result type (might be due to invalid IL or missing references) //IL_04c8: Unknown result type (might be due to invalid IL or missing references) //IL_04cd: Unknown result type (might be due to invalid IL or missing references) //IL_0487: Unknown result type (might be due to invalid IL or missing references) //IL_0488: 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_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_02f3: Unknown result type (might be due to invalid IL or missing references) //IL_02fa: Unknown result type (might be due to invalid IL or missing references) //IL_02fb: Unknown result type (might be due to invalid IL or missing references) //IL_0300: Unknown result type (might be due to invalid IL or missing references) //IL_0302: Unknown result type (might be due to invalid IL or missing references) //IL_0309: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_03d4: Unknown result type (might be due to invalid IL or missing references) //IL_03da: Unknown result type (might be due to invalid IL or missing references) //IL_0418: Unknown result type (might be due to invalid IL or missing references) //IL_0419: Unknown result type (might be due to invalid IL or missing references) //IL_041e: Unknown result type (might be due to invalid IL or missing references) //IL_0428: Unknown result type (might be due to invalid IL or missing references) //IL_042d: Unknown result type (might be due to invalid IL or missing references) //IL_0334: Unknown result type (might be due to invalid IL or missing references) //IL_033b: Unknown result type (might be due to invalid IL or missing references) //IL_0342: Unknown result type (might be due to invalid IL or missing references) //IL_0347: Unknown result type (might be due to invalid IL or missing references) //IL_0350: Unknown result type (might be due to invalid IL or missing references) //IL_0357: 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_0363: 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_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0246: 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_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_0284: 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_028f: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_026f: 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_0283: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0378: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) if (((Vector3)(ref _bv)).sqrMagnitude < 0.04f) { _bv = Vector3.zero; return; } Vector3 val = _bv + Vector3.down * (9.81f * dt); val *= 1f - 0.2f * dt; Vector3 val2 = _bp + val * dt; if ((Object)(object)_cage != (Object)null && !_caught && Where != Venue.Field) { Vector3 val3 = _cage.InverseTransformPoint(_bp); Vector3 val4 = _cage.InverseTransformPoint(val2); if (Inside(val3) && val3.y < 3.6f) { bool num = Mathf.Abs(val4.x) >= 2.05f && val4.y < 3.6f; bool flag = val4.z <= -1.45f && val4.y < 3.6f; bool flag2 = val4.z >= 14.45f && val4.y < 3.6f; bool flag3 = !_isHomer && val4.y >= 3.55f && val4.z < 6f; if (num || flag || flag2 || flag3) { Catch(val2); return; } } } Vector2 val7; Vector3 val8; if (Where == Venue.Field && (Object)(object)_cage != (Object)null && _contact) { Vector3 val5 = _cage.InverseTransformPoint(_bp); Vector3 val6 = _cage.InverseTransformPoint(val2); float num2 = Mathf.Atan2(val6.x, val6.z) * 57.29578f; if (Mathf.Abs(num2) <= 48f && val6.y <= 3.05f) { float num3 = Park.FenceR(num2); val7 = new Vector2(val5.x, val5.z); float magnitude = ((Vector2)(ref val7)).magnitude; val7 = new Vector2(val6.x, val6.z); float magnitude2 = ((Vector2)(ref val7)).magnitude; if (magnitude < num3 && magnitude2 >= num3) { Transform cage = _cage; val8 = new Vector3(val6.x, 0f, val6.z); Vector3 val9 = cage.TransformDirection(((Vector3)(ref val8)).normalized); float num4 = Vector3.Dot(val, val9); if (num4 > 0f) { val -= val9 * (num4 * 1.4f); } val *= 0.7f; _bv = val; CageSound.Play(CageSound.Thump, _bp, 0.3f); return; } } } if (Where == Venue.Field && (Object)(object)_cage != (Object)null && _contact && !_homerCalled && _fair) { Vector3 val10 = _cage.InverseTransformPoint(_bp); Vector3 val11 = _cage.InverseTransformPoint(val2); float num5 = Mathf.Atan2(val11.x, val11.z) * 57.29578f; if (Mathf.Abs(num5) <= 46f) { float num6 = Park.FenceR(num5); val7 = new Vector2(val10.x, val10.z); float magnitude3 = ((Vector2)(ref val7)).magnitude; val7 = new Vector2(val11.x, val11.z); float magnitude4 = ((Vector2)(ref val7)).magnitude; if (magnitude3 < num6 && magnitude4 >= num6 && val11.y > 3.05f) { HomerCalled(); } } } if (Where == Venue.Field && _isHomer && !_landed && val2.y <= Park.SeaY && _bp.y > Park.SeaY) { val2.y = Park.SeaY; Land(val2); Park.Splash(val2); Announce("SPLASH HIT!", $"Into the bay - splash hit #{CageCore.Splashes.Value}"); _bp = val2; _bv = Vector3.down * 0.4f; return; } val8 = val2 - _bp; float magnitude5 = ((Vector3)(ref val8)).magnitude; RaycastHit hit = default(RaycastHit); if (magnitude5 > 0.0001f && Physics.Raycast(_bp, (val2 - _bp) / magnitude5, ref hit, magnitude5 + 0.04f, -5, (QueryTriggerInteraction)1) && !Ignore(((RaycastHit)(ref hit)).collider)) { Collide(hit, val); return; } _bp = val2; _bv = val; if (!(_bp.y < -60f)) { if (!((Object)(object)_cage != (Object)null)) { return; } val8 = _bp - _cage.position; if (!(((Vector3)(ref val8)).sqrMagnitude > 67600f)) { return; } } Land(_bp); KillBall(); } private static bool Ignore(Collider c) { if ((Object)(object)c == (Object)null || c.isTrigger) { return true; } try { if (Placement.IsPropertyBounds(c)) { return true; } Player local = Player.Local; if ((Object)(object)local != (Object)null && ((Component)c).transform.IsChildOf(((Component)local).transform)) { return true; } if ((Object)(object)((Component)c).GetComponentInParent() != (Object)null) { return true; } } catch { } return false; } private static void Catch(Vector3 at) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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) _caught = true; _bv *= 0.05f; CageSound.Play(CageSound.Net, at, 0.3f); Land(at); } private static void Collide(RaycastHit hit, Vector3 v) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011e: 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_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0155: 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_015e: 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_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) float magnitude = ((Vector3)(ref v)).magnitude; bool flag = (Object)(object)_cage != (Object)null && ((Component)((RaycastHit)(ref hit)).collider).transform.IsChildOf(_cage); bool flag2 = !flag && (((RaycastHit)(ref hit)).normal.y > 0.65f || (Object)(object)((Il2CppObjectBase)((RaycastHit)(ref hit)).collider).TryCast() != (Object)null); if (flag && ((RaycastHit)(ref hit)).normal.y > 0.65f) { flag2 = true; } if (!flag2 && !flag && magnitude > 8f && !_hitSomething && CageCore.Alarms.Value && Where == Venue.Cage) { Neighbors(hit, magnitude); } else if (flag && !flag2 && magnitude > 6f) { CageSound.Play(CageSound.Clank, ((RaycastHit)(ref hit)).point, 0.25f); } if (flag2 && !_landed) { Land(((RaycastHit)(ref hit)).point); } else if (flag2 && magnitude > 3f) { CageSound.Play(CageSound.Thud, ((RaycastHit)(ref hit)).point, Mathf.Clamp01(magnitude / 25f) * 0.2f); } Vector3 val = Vector3.Reflect(v, ((RaycastHit)(ref hit)).normal); float num = (flag2 ? 0.42f : 0.3f); Vector3 val2 = ((RaycastHit)(ref hit)).normal * Vector3.Dot(val, ((RaycastHit)(ref hit)).normal); Vector3 val3 = val - val2; _bv = val2 * num + val3 * (flag2 ? 0.7f : 0.5f); _bp = ((RaycastHit)(ref hit)).point + ((RaycastHit)(ref hit)).normal * 0.045f; if (flag2 && ((Vector3)(ref _bv)).magnitude < 1.2f) { _bv = Vector3.zero; } } private static void Land(Vector3 at) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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_0198: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) if (_landed) { return; } _landed = true; _landedAt = Time.time; if ((Object)(object)_cage == (Object)null) { return; } Vector3 val = at - _cage.position; val.y = 0f; _distFt = ((_caught || _hitSomething) ? _projFt : (((Vector3)(ref val)).magnitude * 3.28084f)); int num = Mathf.RoundToInt(_distFt); if (_contact) { _chipFt = num; _resultAt = Mathf.Max(_resultAt, Time.time - 0.3f); } Scoreboard.Show(((Component)_cage).gameObject, "DIST", Mathf.Clamp(num, 0, 999)); if (!_contact) { return; } if (_isHomer) { _sessionHr++; MelonPreferences_Entry homers = CageCore.Homers; int value = homers.Value; homers.Value = value + 1; string text = ""; if (num > CageCore.LongestFt.Value) { CageCore.LongestFt.Value = num; text = " Your longest ever!"; } Scoreboard.Show(((Component)_cage).gameObject, "HR", InDerby ? (_derbyHr + 1) : _sessionHr); Result("HOME RUN!", (text.Length > 0) ? "Your longest ever!" : "Gone!", new Color(1f, 0.8f, 0.2f), num, Mathf.RoundToInt(_exitMph)); CageSound.Play(CageSound.Ding, ((Object)(object)Camera.main != (Object)null) ? ((Component)Camera.main).transform.position : at, 0.35f); CageCore.SavePrefs(); Board.Score(num, Mathf.RoundToInt(_exitMph)); } else if (_caught) { _result = (_fair ? _result : "Foul ball"); _detail = (_fair ? "Into the net - projected distance" : "Into the net"); Board.Score(num, Mathf.RoundToInt(_exitMph)); } else { Board.Score(num, Mathf.RoundToInt(_exitMph)); } CountDerbyPitch(_isHomer, _distFt); } private static void Neighbors(RaycastHit hit, float speed) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) _hitSomething = true; string[] obj = new string[5] { ((Object)((RaycastHit)(ref hit)).collider).name, " @", null, null, null }; Vector3 point = ((RaycastHit)(ref hit)).point; obj[2] = ((Vector3)(ref point)).ToString("F1"); obj[3] = " speed "; obj[4] = speed.ToString("0"); LastHit = string.Concat(obj); try { LandVehicle componentInParent = ((Component)((RaycastHit)(ref hit)).collider).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null) { int instanceID = ((Object)((Component)componentInParent).gameObject).GetInstanceID(); CageSound.Play(CageSound.Clank, ((RaycastHit)(ref hit)).point, 0.4f); if (!AlarmAt.TryGetValue(instanceID, out var value) || Time.time - value > 12f) { AlarmAt[instanceID] = Time.time; CageSound.Loop(CageSound.Alarm, ((Component)componentInParent).transform.position + Vector3.up, 0.35f, 6f); Say("Car alarm!", "You dented somebody's car. Run!", new Color(1f, 0.35f, 0.3f)); } LastHit += " CAR"; return; } } catch { } LastHit += (LooksLikeBuilding(((RaycastHit)(ref hit)).collider) ? " HOUSE" : " other"); if (LooksLikeBuilding(((RaycastHit)(ref hit)).collider) && speed > 12f) { if (Rng.NextDouble() < 0.7) { CageSound.Play(CageSound.Glass, ((RaycastHit)(ref hit)).point, 0.45f); Say("CRASH!", "That was a neighbor's window.", new Color(1f, 0.5f, 0.3f)); } else { CageSound.Play(CageSound.Thud, ((RaycastHit)(ref hit)).point, 0.35f); Say("Off the house!", "Right off the siding.", new Color(1f, 0.75f, 0.4f)); } } else { CageSound.Play(CageSound.Thud, ((RaycastHit)(ref hit)).point, 0.3f); } } private static bool LooksLikeBuilding(Collider c) { //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) try { Transform val = ((Component)c).transform; int num = 0; while (num < 4 && (Object)(object)val != (Object)null) { string text = ((Object)val).name.ToLowerInvariant(); if (text.Contains("tree") || text.Contains("bush") || text.Contains("plant") || text.Contains("rock") || text.Contains("lamp") || text.Contains("pole") || text.Contains("npc")) { return false; } num++; val = val.parent; } Bounds bounds = c.bounds; Vector3 size = ((Bounds)(ref bounds)).size; return ((size.x > 2.5f) ? 1 : 0) + ((size.y > 2.5f) ? 1 : 0) + ((size.z > 2.5f) ? 1 : 0) >= 2; } catch { return false; } } private static void NextPitch() { if (Batting) { CountDerbyPitch(_isHomer, _projFt); if (InDerby && ((Where == Venue.Field) ? (_derbyOuts >= 10) : (_derbyPitch >= 10))) { FinishDerby(); } _ph = Phase.Wait; _phAt = Time.time + 1.55f; _swung = false; } } private static void CountDerbyPitch(bool homer, float ft) { if (!InDerby || _counted || (Where == Venue.Field && !_swung)) { return; } _counted = true; _derbyPitch++; _derbyHits.Add(homer); if (homer) { _derbyHr++; _derbyLong = Mathf.Max(_derbyLong, ft); if (Where == Venue.Field && ft >= 440f && _derbyOuts > 0) { _derbyOuts--; _bonusAt = Time.time; } } else if (Where == Venue.Field) { _derbyOuts++; } Scoreboard.Show(((Component)_cage).gameObject, "HR", _derbyHr); } private static void FinishDerby() { //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) int derbyHr = _derbyHr; _derbyPitch = -1; bool flag = derbyHr > CageCore.BestDerby.Value; for (int i = 1; i < Skins.Length; i++) { if (derbyHr >= SkinNeeds[i] && CageCore.BestDerby.Value < SkinNeeds[i]) { _ = Skins[i]; } } if (flag) { CageCore.BestDerby.Value = derbyHr; } CageCore.SavePrefs(); string small = (flag ? "New personal best!" : $"Your best is {CageCore.BestDerby.Value}."); Say($"DERBY: {derbyHr} HOME RUN{((derbyHr == 1) ? "" : "S")}", small, new Color(1f, 0.8f, 0.2f)); Board.Derby(derbyHr, Mathf.RoundToInt(_derbyLong)); if (Where == Venue.Field) { Park.Crowd((derbyHr >= 5) ? 1f : 0.5f); if (derbyHr >= 5) { Park.Fireworks(); } } if (derbyHr >= 5) { CageSound.Play(CageSound.Ding, ((Object)(object)Camera.main != (Object)null) ? ((Component)Camera.main).transform.position : _cage.position, 0.35f); } } public static bool Unlocked(string skin) { int num = Array.IndexOf(Skins, skin); if (num < 0) { return false; } return CageCore.BestDerby.Value >= SkinNeeds[num]; } private static void Result(string big, string small, Color c, int ft, int mph) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) _result = big; _detail = small; _resultColor = c; _resultAt = Time.time; } private static void Say(string big, string small, Color c) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) Result(big, small, c, -1, -1); } public static void Announce(string big, string small) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) Result(big, small, new Color(1f, 0.85f, 0.3f), -1, -1); } private static void SpinWheels() { //IL_004f: Unknown result type (might be due to invalid IL or missing references) float num = Speeds[_speed].Mph * 18f; string[] array = new string[2] { "bc_WheelTop", "bc_WheelBot" }; foreach (string text in array) { Transform val = CageModels.Find(_cage, text); if ((Object)(object)val != (Object)null) { val.Rotate(Vector3.right, (text.EndsWith("Top") ? (-1f) : 1f) * num * 6f * Time.deltaTime, (Space)1); } } } private static void Lights() { bool flag; try { int currentTime = TimeManager.CurrentTime; flag = currentTime >= 1830 || currentTime < 630; } catch { flag = false; } foreach (Placement.Placed item in Placement.All) { if ((Object)(object)item?.Go != (Object)null && item.Active && item.Spec?.Id == "bc_cage") { Scoreboard.Lights(item.Go, flag); Clear(item.Go.transform); } } } private static void Clear(Transform cage) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_003e: 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) Vector3 val = cage.TransformPoint(new Vector3(0f, 0f, 6.5f)); string text = "bc_" + Mathf.RoundToInt(val.x * 2f) + "_" + Mathf.RoundToInt(val.z * 2f); if (Cleared.Add(text)) { FortifyApi.AddTreeClearing(text, val, 10.5f); } } public static void Unclear(Transform cage) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) Vector3 val = cage.TransformPoint(new Vector3(0f, 0f, 6.5f)); string text = "bc_" + Mathf.RoundToInt(val.x * 2f) + "_" + Mathf.RoundToInt(val.z * 2f); if (Cleared.Remove(text)) { FortifyApi.RemoveTreeClearing(text); } } private static void StartTrail() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) Trail.Clear(); if ((Object)(object)_trail == (Object)null) { _trail = new GameObject("bc_Trail"); _line = _trail.AddComponent(); ((Renderer)_line).material = FortifyApi.Emissive("bc_trail", new Color(1f, 1f, 1f, 0.6f), new Color(1.2f, 1.2f, 1.2f)); ((Renderer)_line).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)_line).receiveShadows = false; _line.numCapVertices = 2; _line.widthCurve = AnimationCurve.Linear(0f, 0f, 1f, 0.035f); } _line.positionCount = 0; _trail.SetActive(true); } private static void AddTrail(Vector3 p) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_line == (Object)null) { return; } if (Trail.Count > 0) { Vector3 val = Trail[Trail.Count - 1] - p; if (((Vector3)(ref val)).sqrMagnitude < 0.09f) { return; } } Trail.Add(p); if (Trail.Count > 60) { Trail.RemoveAt(0); } _line.positionCount = Trail.Count; for (int i = 0; i < Trail.Count; i++) { _line.SetPosition(i, Trail[i]); } } private static void KillBall() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_ball != (Object)null) { Object.Destroy((Object)(object)_ball); } _ball = null; _bv = Vector3.zero; if ((Object)(object)_trail != (Object)null) { _trail.SetActive(false); } Board.Hit(Vector3.zero, Vector3.zero); } private static void Shadow(Rect r, string t, int size, Color c, TextAnchor a = (TextAnchor)4, bool bold = true) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) WS_BC.FybCommon.Ui.Text(new Rect(((Rect)(ref r)).x + 2f, ((Rect)(ref r)).y + 3f, ((Rect)(ref r)).width, ((Rect)(ref r)).height), t, size, new Color(0f, 0f, 0f, c.a * 0.55f), a, bold, wrap: false); WS_BC.FybCommon.Ui.Text(r, t, size, c, a, bold, wrap: false); } private static void KeyCap(ref float x, float y, float s, string key, string label) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0082: 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_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) int size = Mathf.RoundToInt(15f * s); float num = Mathf.Max(30f, 11f * (float)key.Length + 16f) * s; Rect r = default(Rect); ((Rect)(ref r))..ctor(x, y, num, 28f * s); WS_BC.FybCommon.Ui.Fill(r, new Color(1f, 1f, 1f, 0.92f)); WS_BC.FybCommon.Ui.Fill(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).yMax - 3f * s, ((Rect)(ref r)).width, 3f * s), new Color(0.7f, 0.72f, 0.78f, 0.95f)); WS_BC.FybCommon.Ui.Text(r, key, size, new Color(0.05f, 0.08f, 0.16f), (TextAnchor)4, bold: true, wrap: false); x += num + 8f * s; float num2 = (9.5f * (float)label.Length + 6f) * s; WS_BC.FybCommon.Ui.Text(new Rect(x, y, num2, 28f * s), label, size, new Color(1f, 1f, 1f, 0.92f), (TextAnchor)3, bold: false, wrap: false); x += num2 + 18f * s; } private static void Chip(Rect r, string label, string value, float s, float a) { //IL_0000: 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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: 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_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) WS_BC.FybCommon.Ui.Fill(r, new Color(0.03f, 0.06f, 0.13f, 0.66f * a)); WS_BC.FybCommon.Ui.Fill(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, 3f * s, ((Rect)(ref r)).height), new Color(Orange.r, Orange.g, Orange.b, a)); WS_BC.FybCommon.Ui.Text(new Rect(((Rect)(ref r)).x + 14f * s, ((Rect)(ref r)).y + 4f * s, ((Rect)(ref r)).width - 18f * s, 18f * s), label, Mathf.RoundToInt(12f * s), new Color(0.7f, 0.76f, 0.86f, a), (TextAnchor)3, bold: true, wrap: false); WS_BC.FybCommon.Ui.Text(new Rect(((Rect)(ref r)).x + 14f * s, ((Rect)(ref r)).y + 20f * s, ((Rect)(ref r)).width - 18f * s, 30f * s), value, Mathf.RoundToInt(24f * s), new Color(1f, 1f, 1f, a), (TextAnchor)3, bold: true, wrap: false); } private static bool ToScreen(Vector3 local, out Vector2 p) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_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_003a: 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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) p = Vector2.zero; Camera main = Camera.main; if ((Object)(object)main == (Object)null || (Object)(object)_cage == (Object)null) { return false; } Vector3 val = main.WorldToScreenPoint(_cage.TransformPoint(local)); if (val.z <= 0.05f) { return false; } p = new Vector2(val.x, (float)Screen.height - val.y); return true; } private static void Outline(Vector2 a, Vector2 b, float t, Color c) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_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_0035: 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_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) WS_BC.FybCommon.Ui.Fill(new Rect(Mathf.Min(a.x, b.x), a.y, Mathf.Abs(b.x - a.x), t), c); WS_BC.FybCommon.Ui.Fill(new Rect(Mathf.Min(a.x, b.x), b.y - t, Mathf.Abs(b.x - a.x), t), c); WS_BC.FybCommon.Ui.Fill(new Rect(a.x, Mathf.Min(a.y, b.y), t, Mathf.Abs(b.y - a.y)), c); WS_BC.FybCommon.Ui.Fill(new Rect(b.x - t, Mathf.Min(a.y, b.y), t, Mathf.Abs(b.y - a.y)), c); } private static void DrawZone(float s) { //IL_001d: 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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0281: 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_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_02fb: Unknown result type (might be due to invalid IL or missing references) //IL_0311: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_cage == (Object)null || !ToScreen(new Vector3(-0.25f, 1.13f, 0f), out var p) || !ToScreen(new Vector3(0.25f, 0.47f, 0f), out var p2)) { return; } Outline(p, p2, Mathf.Max(1f, 1.5f * s), new Color(1f, 1f, 1f, 0.35f)); int k = ((WS_BC.FybCommon.Keys.RawHeld((KeyCode)304) || WS_BC.FybCommon.Keys.RawHeld((KeyCode)303)) ? 2 : 0); float num = PciHalfW((SwingKind)k); float num2 = PciHalfH((SwingKind)k); Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(Pci.x, 0.8f + Pci.y, 0f); if (ToScreen(val + new Vector3(0f - num, num2, 0f), out var p3) && ToScreen(val + new Vector3(num, 0f - num2, 0f), out var p4)) { Outline(p3, p4, Mathf.Max(2f, 2.5f * s), new Color(1f, 0.82f, 0.25f, 0.9f)); if (ToScreen(val + new Vector3((0f - num) * 0.3f, num2 * 0.3f, 0f), out var p5) && ToScreen(val + new Vector3(num * 0.3f, (0f - num2) * 0.3f, 0f), out var p6)) { Outline(p5, p6, Mathf.Max(1f, 1.5f * s), new Color(1f, 1f, 1f, 0.8f)); } if (ToScreen(val, out var p7)) { WS_BC.FybCommon.Ui.Fill(new Rect(p7.x - 2f * s, p7.y - 2f * s, 4f * s, 4f * s), new Color(1f, 1f, 1f, 0.95f)); } } if (_crossAt > 0f && Time.time - _crossAt < 2.2f && ToScreen(_cage.InverseTransformPoint(PlateCross()), out var p8)) { float num3 = Mathf.Clamp01((2.2f - (Time.time - _crossAt)) * 1.5f); float num4 = 7f * s; WS_BC.FybCommon.Ui.Fill(new Rect(p8.x - num4, p8.y - num4, num4 * 2f, num4 * 2f), new Color(1f, 1f, 1f, 0.85f * num3)); WS_BC.FybCommon.Ui.Fill(new Rect(p8.x - num4 * 0.55f, p8.y - num4 * 0.55f, num4 * 1.1f, num4 * 1.1f), new Color(0.85f, 0.15f, 0.15f, num3)); } } private static void DrawControls(float s, float W, float H) { //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_016a: 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_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: 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_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Unknown result type (might be due to invalid IL or missing references) List<(string, string)> list = new List<(string, string)> { ("Mouse", "Aim the box"), (InDerby ? "Click" : "Click", InDerby ? "Power swing" : "Swing") }; if (!InDerby) { list.Add(("R-Click", "Power swing")); list.Add(("Shift+Click", "Contact swing")); list.Add(("F", "Pitch speed")); list.Add(("M", PitchMix ? "Pitch mix: on" : "Pitch mix: off")); list.Add(("Y", "Home Run Derby")); } list.Add(("X", InDerby ? "Quit derby" : "Leave")); float num = 30f * s; float num2 = 270f * s; float num3 = 40f * s + (float)list.Count * num; Rect r = default(Rect); ((Rect)(ref r))..ctor(24f * s, H * 0.5f - num3 / 2f, num2, num3); WS_BC.FybCommon.Ui.Fill(r, new Color(0.03f, 0.06f, 0.13f, 0.62f)); WS_BC.FybCommon.Ui.Fill(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, 3f * s, ((Rect)(ref r)).height), Orange); WS_BC.FybCommon.Ui.Text(new Rect(((Rect)(ref r)).x + 14f * s, ((Rect)(ref r)).y + 6f * s, num2, 24f * s), "CONTROLS", Mathf.RoundToInt(13f * s), Orange, (TextAnchor)3, bold: true, wrap: false); float num4 = ((Rect)(ref r)).y + 34f * s; Rect r2 = default(Rect); foreach (var item3 in list) { string item = item3.Item1; string item2 = item3.Item2; float num5 = Mathf.Max(30f, 9.5f * (float)item.Length + 14f) * s; ((Rect)(ref r2))..ctor(((Rect)(ref r)).x + 14f * s, num4 + 2f * s, num5, 24f * s); WS_BC.FybCommon.Ui.Fill(r2, new Color(1f, 1f, 1f, 0.92f)); WS_BC.FybCommon.Ui.Fill(new Rect(((Rect)(ref r2)).x, ((Rect)(ref r2)).yMax - 3f * s, ((Rect)(ref r2)).width, 3f * s), new Color(0.7f, 0.72f, 0.78f, 0.95f)); WS_BC.FybCommon.Ui.Text(r2, item, Mathf.RoundToInt(13f * s), new Color(0.05f, 0.08f, 0.16f), (TextAnchor)4, bold: true, wrap: false); WS_BC.FybCommon.Ui.Text(new Rect(((Rect)(ref r2)).xMax + 10f * s, num4, num2 - num5 - 30f * s, num), item2, Mathf.RoundToInt(15f * s), new Color(1f, 1f, 1f, 0.92f), (TextAnchor)3, bold: false, wrap: false); num4 += num; } } public static void Draw() { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0088: 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_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_02c9: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_0327: Unknown result type (might be due to invalid IL or missing references) //IL_034c: Unknown result type (might be due to invalid IL or missing references) //IL_03b7: Unknown result type (might be due to invalid IL or missing references) //IL_054c: Unknown result type (might be due to invalid IL or missing references) //IL_0551: Unknown result type (might be due to invalid IL or missing references) //IL_0570: Unknown result type (might be due to invalid IL or missing references) //IL_058e: Unknown result type (might be due to invalid IL or missing references) //IL_05ab: Unknown result type (might be due to invalid IL or missing references) //IL_05d8: Unknown result type (might be due to invalid IL or missing references) //IL_03f4: Unknown result type (might be due to invalid IL or missing references) //IL_03d9: Unknown result type (might be due to invalid IL or missing references) //IL_0463: Unknown result type (might be due to invalid IL or missing references) //IL_0a76: Unknown result type (might be due to invalid IL or missing references) //IL_0a10: Unknown result type (might be due to invalid IL or missing references) //IL_0a3f: Unknown result type (might be due to invalid IL or missing references) //IL_049a: Unknown result type (might be due to invalid IL or missing references) //IL_04a6: Unknown result type (might be due to invalid IL or missing references) //IL_04d3: Unknown result type (might be due to invalid IL or missing references) //IL_04d8: Unknown result type (might be due to invalid IL or missing references) //IL_0778: Unknown result type (might be due to invalid IL or missing references) //IL_0791: Unknown result type (might be due to invalid IL or missing references) //IL_07b6: Unknown result type (might be due to invalid IL or missing references) //IL_07d9: Unknown result type (might be due to invalid IL or missing references) //IL_07f5: Unknown result type (might be due to invalid IL or missing references) //IL_0801: Unknown result type (might be due to invalid IL or missing references) //IL_0824: Unknown result type (might be due to invalid IL or missing references) //IL_0840: Unknown result type (might be due to invalid IL or missing references) //IL_084c: Unknown result type (might be due to invalid IL or missing references) //IL_08a4: Unknown result type (might be due to invalid IL or missing references) //IL_08ba: Unknown result type (might be due to invalid IL or missing references) //IL_08f0: Unknown result type (might be due to invalid IL or missing references) //IL_091d: Unknown result type (might be due to invalid IL or missing references) //IL_0956: Unknown result type (might be due to invalid IL or missing references) //IL_0983: Unknown result type (might be due to invalid IL or missing references) //IL_0644: Unknown result type (might be due to invalid IL or missing references) //IL_067d: Unknown result type (might be due to invalid IL or missing references) //IL_04a1: Unknown result type (might be due to invalid IL or missing references) //IL_06c4: Unknown result type (might be due to invalid IL or missing references) if (Cursor.visible) { return; } if (!Batting) { Board.DrawNearby(); return; } float num = Screen.width; float num2 = Screen.height; float num3 = num2 / 1080f; float num4 = 620f * num3; Rect r = default(Rect); ((Rect)(ref r))..ctor(num / 2f - num4 / 2f, 18f * num3, num4, 58f * num3); WS_BC.FybCommon.Ui.Fill(r, Navy); WS_BC.FybCommon.Ui.Fill(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).yMax - 2f * num3, ((Rect)(ref r)).width, 2f * num3), Orange); WS_BC.FybCommon.Ui.Text(new Rect(((Rect)(ref r)).x + 18f * num3, ((Rect)(ref r)).y, 260f * num3, ((Rect)(ref r)).height), "FLOODLIGHT BASEBALL", Mathf.RoundToInt(20f * num3), Orange, (TextAnchor)3, bold: true, wrap: false); string s = (FieldDerby ? $"DERBY OUTS {_derbyOuts}/10 HR {_derbyHr}" : (InDerby ? $"DERBY {Mathf.Min(_derbyPitch + 1, 10)}/10 HR {_derbyHr}" : $"{Speeds[_speed].Name.ToUpperInvariant()} {Speeds[_speed].Mph:0} MPH{(PitchMix ? " MIX" : "")} HR {_sessionHr}")); WS_BC.FybCommon.Ui.Text(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, ((Rect)(ref r)).width - 18f * num3, ((Rect)(ref r)).height), s, Mathf.RoundToInt(17f * num3), new Color(1f, 1f, 1f, 0.95f), (TextAnchor)5, bold: true, wrap: false); if (!Park.CamOn && !HitInPlay) { DrawZone(num3); } if (Time.time - _pitchShownAt < 1.6f) { float num5 = Mathf.Clamp01((1.6f - (Time.time - _pitchShownAt)) * 2f); Shadow(new Rect(0f, num2 * 0.71f, num, 30f * num3), _pitchName.ToUpperInvariant(), Mathf.RoundToInt(22f * num3), new Color(0.6f, 0.85f, 1f, num5), (TextAnchor)4); } if (Time.time - _bonusAt < 2.5f) { Shadow(new Rect(0f, 330f * num3, num, 34f * num3), "440+ FT - BONUS: ONE OUT BACK", Mathf.RoundToInt(22f * num3), new Color(1f, 0.6f, 0.2f), (TextAnchor)4); } if (FieldDerby) { float num6 = ((Rect)(ref r)).x + ((Rect)(ref r)).width / 2f - 130f * num3 / 2f; for (int i = 0; i < 10; i++) { WS_BC.FybCommon.Ui.Fill(new Rect(num6 + (float)i * 13f * num3, ((Rect)(ref r)).yMax + 6f * num3, 9f * num3, 4f * num3), (i < _derbyOuts) ? new Color(1f, 0.35f, 0.3f, 0.95f) : new Color(1f, 1f, 1f, 0.2f)); } } else if (InDerby) { float num7 = ((Rect)(ref r)).x + ((Rect)(ref r)).width / 2f - 130f * num3 / 2f; for (int j = 0; j < 10; j++) { Color c = (Color)((j < _derbyPitch) ? ((j < _derbyHits.Count && _derbyHits[j]) ? Orange : new Color(1f, 1f, 1f, 0.55f)) : new Color(1f, 1f, 1f, 0.15f)); WS_BC.FybCommon.Ui.Fill(new Rect(num7 + (float)j * 13f * num3, ((Rect)(ref r)).yMax + 6f * num3, 9f * num3, 4f * num3), c); } } float num8 = Time.time - _resultAt; if (num8 < 4.5f && _result.Length > 0) { float num9 = Mathf.Clamp01((4.5f - num8) * 1.5f); float num10 = 1f + Mathf.Max(0f, 0.25f - num8) * 1.2f; Color resultColor = _resultColor; resultColor.a = num9; Shadow(new Rect(0f, 150f * num3, num, 90f * num3), _result.ToUpperInvariant(), Mathf.RoundToInt(64f * num3 * num10), resultColor, (TextAnchor)4); Shadow(new Rect(0f, 232f * num3, num, 34f * num3), _detail, Mathf.RoundToInt(20f * num3), new Color(1f, 1f, 1f, num9 * 0.95f), (TextAnchor)4, bold: false); if (_chipMph > 0) { float num11 = 150f * num3; float num12 = 10f * num3; int num13 = ((_chipFt >= 0) ? 3 : 2); float num14 = num / 2f - (num11 * (float)num13 + num12 * (float)(num13 - 1)) / 2f; float num15 = 278f * num3; Chip(new Rect(num14, num15, num11, 54f * num3), "EXIT VELO", _chipMph + " mph", num3, num9); Chip(new Rect(num14 + num11 + num12, num15, num11, 54f * num3), "LAUNCH", _chipDeg + "°", num3, num9); if (_chipFt >= 0) { Chip(new Rect(num14 + (num11 + num12) * 2f, num15, num11, 54f * num3), "DISTANCE", _chipFt + " ft", num3, num9); } } } float num16 = Time.time - _timingAt; if (num16 < 3f && _timingW > 0f && !HitInPlay && !Park.CamOn) { float num17 = Mathf.Clamp01((3f - num16) * 1.5f); float num18 = 360f * num3; Rect r2 = default(Rect); ((Rect)(ref r2))..ctor(num / 2f - num18 / 2f, num2 * 0.62f, num18, 8f * num3); float num19 = _timingW * 5f; WS_BC.FybCommon.Ui.Fill(r2, new Color(1f, 1f, 1f, 0.18f * num17)); float num20 = num18 * (_timingW * 2f / (num19 * 2f)); WS_BC.FybCommon.Ui.Fill(new Rect(((Rect)(ref r2)).center.x - num20, ((Rect)(ref r2)).y, num20 * 2f, ((Rect)(ref r2)).height), new Color(0.4f, 0.9f, 0.55f, 0.5f * num17)); WS_BC.FybCommon.Ui.Fill(new Rect(((Rect)(ref r2)).center.x - num20 / 2f, ((Rect)(ref r2)).y, num20, ((Rect)(ref r2)).height), new Color(1f, 0.8f, 0.25f, 0.9f * num17)); WS_BC.FybCommon.Ui.Fill(new Rect(((Rect)(ref r2)).center.x + Mathf.Clamp(_timingE / num19, -1f, 1f) * num18 / 2f - 2f * num3, ((Rect)(ref r2)).y - 7f * num3, 4f * num3, ((Rect)(ref r2)).height + 14f * num3), new Color(1f, 1f, 1f, num17)); WS_BC.FybCommon.Ui.Text(new Rect(((Rect)(ref r2)).x - 80f * num3, ((Rect)(ref r2)).y - 10f * num3, 70f * num3, 28f * num3), "EARLY", Mathf.RoundToInt(12f * num3), new Color(1f, 1f, 1f, 0.7f * num17), (TextAnchor)5, bold: true, wrap: false); WS_BC.FybCommon.Ui.Text(new Rect(((Rect)(ref r2)).xMax + 10f * num3, ((Rect)(ref r2)).y - 10f * num3, 70f * num3, 28f * num3), "LATE", Mathf.RoundToInt(12f * num3), new Color(1f, 1f, 1f, 0.7f * num17), (TextAnchor)3, bold: true, wrap: false); } float num21 = UntilRelease(); if (num21 > 0f && num21 < 2.4f) { int num22 = Mathf.Clamp(Mathf.CeilToInt(num21 / 0.8f), 1, 3); float num23 = 1f - (num21 - (float)(num22 - 1) * 0.8f) / 0.8f; float num24 = 1.25f - 0.25f * Mathf.Clamp01(num23 * 3f); Shadow(new Rect(0f, num2 * 0.36f, num, 120f * num3), num22.ToString(), Mathf.RoundToInt(96f * num3 * num24), new Color(1f, 0.85f, 0.3f, 0.95f), (TextAnchor)4); } if (!Park.CamOn) { DrawControls(num3, num, num2); } Board.DrawBoard(new Rect(num - 330f * num3, 18f * num3, 310f * num3, 0f), num3); } } public sealed class CageCore : MelonMod { internal const string CageId = "bc_cage"; internal static MelonPreferences_Entry Price; internal static MelonPreferences_Entry ParkLights; internal static MelonPreferences_Entry Splashes; internal static MelonPreferences_Entry BestDerby; internal static MelonPreferences_Entry Homers; internal static MelonPreferences_Entry LongestFt; internal static MelonPreferences_Entry Skin; internal static MelonPreferences_Entry SpeedName; internal static MelonPreferences_Entry Alarms; internal static MelonPreferences_Entry Mix; internal static MelonPreferences_Entry BallCam; internal static MelonPreferences_Entry ReturnTo; private static float _warnedAt = -100f; private static MelonPreferences_Category _cat; internal static void SavePrefs() { try { MelonPreferences_Category cat = _cat; if (cat != null) { cat.SaveToFile(false); } } catch { } } public override void OnInitializeMelon() { //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) try { Host.Init((MelonMod)(object)this, "BattingCage", "Floodlight Batting Cage", "bc_", null, Loaded, Unloaded); MelonPreferences_Category obj = (_cat = MelonPreferences.GetCategory("BattingCage") ?? MelonPreferences.CreateCategory("BattingCage", "Floodlight Batting Cage")); Price = obj.CreateEntry("PriceMultiplier", 1f, "Price multiplier", "Multiplies the kit price (1 = $2,500, 0 = free). Applies after a game restart.", false, false, (ValueValidator)null, (string)null); Alarms = obj.CreateEntry("CarAlarms", true, "Car alarms and broken windows", "Balls you hit out of the cage can set off car alarms and break house windows.", false, false, (ValueValidator)null, (string)null); SpeedName = obj.CreateEntry("PitchSpeed", "High School", "Pitch speed", "Little League, High School, Pro or Floodlight Heat. You can also change it in the cage with F.", false, false, (ValueValidator)null, (string)null); Mix = obj.CreateEntry("PitchMix", false, "Pitch mix", "Fastballs, changeups, curveballs and sliders in free batting (M in the cage). The derby is always batting practice fastballs.", false, false, (ValueValidator)null, (string)null); ParkLights = obj.CreateEntry("ParkLights", 1f, "Floodlight Park lights", "Brightness of the light towers at Floodlight Park (1 = normal, 2 = twice as bright).", false, false, (ValueValidator)null, (string)null); BallCam = obj.CreateEntry("BallCam", true, "Ball cam", "At Floodlight Park the camera follows long fly balls, like a TV broadcast.", false, false, (ValueValidator)null, (string)null); ReturnTo = obj.CreateEntry("ReturnSpot", "", "", "", true, false, (ValueValidator)null, (string)null); Skin = obj.CreateEntry("BatSkin", "Classic", "Bat", "Classic, Neon or Gold (Neon and Gold unlock in the Home Run Derby).", false, false, (ValueValidator)null, (string)null); Splashes = obj.CreateEntry("SplashHits", 0, "", "", true, false, (ValueValidator)null, (string)null); BestDerby = obj.CreateEntry("BestDerby", 0, "Best derby", "", true, false, (ValueValidator)null, (string)null); Homers = obj.CreateEntry("CareerHomers", 0, "Career home runs", "", true, false, (ValueValidator)null, (string)null); LongestFt = obj.CreateEntry("LongestHomer", 0, "Longest home run (ft)", "", true, false, (ValueValidator)null, (string)null); Kit.PriceMultiplier = () => Mathf.Max(0f, Price?.Value ?? 1f); FortifyApi.SetNotifyIcon("bc_cage"); Catalog.Add(new ItemSpec { Id = "bc_cage", Name = "Floodlight Batting Cage", Price = 2500f, Kind = PlaceKind.Ground, StackLimit = 1, RotateStep = 15f, IconColor = new Color(0.05f, 0.15f, 0.45f), BuildModel = CageModels.Cage, IconModel = CageModels.CageIcon, Description = "A full backyard batting cage kit: netting, a two-wheel pitching machine, home plate, a bat rack, a scoreboard and two floodlights. Needs about 5 x 17 m of flat ground. Walk in and press E at the plate to bat, or P to take the ferry to Floodlight Park for the Home Run Derby on a real field." }); Kit.Use["bc_cage"] = Cage.Use; Kit.Busy = () => Cage.Batting; Kit.Removed += delegate(Placement.Placed p) { if ((Object)(object)p?.Go != (Object)null && p.Spec?.Id == "bc_cage") { Cage.Unclear(p.Go.transform); } }; Host.WhereToBuyNote = "Floodlight Batting Cage: the kit is at Dan's Hardware and Handy Hank's Hardware."; Host.Ok = true; ((MelonBase)this).LoggerInstance.Msg("Floodlight Batting Cage loaded. The kit is at Dan's Hardware and Handy Hank's Hardware."); } catch (Exception ex) { ((MelonBase)this).LoggerInstance.Error("Floodlight Batting Cage couldn't start: " + ex.Message + ". It needs MelonLoader 0.7 and S1API (Bars fork) 3.2.3 or newer."); } } private static void Loaded() { Cage.Reset(); Cage.PitchMix = Mix.Value; Park.OnLoaded(); } private static void Unloaded() { Cage.Reset(); Park.Reset(); } public override void OnUpdate() { if (!Host.Update()) { return; } try { Cage.Update(); Board.Update(); Park.Update(); } catch (Exception ex) { if (Time.unscaledTime - _warnedAt > 30f) { _warnedAt = Time.unscaledTime; ((MelonBase)this).LoggerInstance.Warning("Batting Cage: " + ex.Message + " " + ex.StackTrace); } } } public override void OnFixedUpdate() { if (!Host.Ok || !FortifyApi.InGame) { return; } try { Cage.FixedUpdate(); Park.FixedUpdate(); } catch { } } public override void OnGUI() { Host.DrawHint(); if (!Host.Ok || !FortifyApi.InGame) { return; } try { Cage.Draw(); Park.Draw(); } catch { } } } internal static class CageModels { private static readonly HashSet Fixed = new HashSet(); public const float HalfWidth = 2.1f; public const float Back = -1.5f; public const float Front = 14.5f; public const float Height = 3.6f; public const float RoofEnd = 6f; public static readonly Vector3 Plate = new Vector3(0f, 0f, 0f); public static readonly Vector3 BatterSpot = new Vector3(-0.62f, 0.05f, -0.05f); public static readonly Vector3 Release = new Vector3(0f, 1.05f, 12.95f); public static GameObject Load(string name, string file) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0073: 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) GameObject val = new GameObject(name); ((Object)GltfLoader.LoadEmbedded(file, val.transform)).name = "Model"; foreach (Renderer componentsInChild in val.GetComponentsInChildren(true)) { foreach (Material item in (Il2CppArrayBase)(object)componentsInChild.sharedMaterials) { if (!((Object)(object)item == (Object)null) && Fixed.Add(((Object)item).GetInstanceID())) { Color color = item.color; Color val2 = (item.color = ((Color)(ref color)).gamma); if (item.HasProperty("_BaseColor")) { item.SetColor("_BaseColor", val2); } } } } return val; } public static GameObject Cage() { //IL_0067: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_023d: 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_0086: 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_009c: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) GameObject val = Load("bc_Cage", "BC_Cage.glb"); HashSet hashSet = new HashSet(); Color val2 = default(Color); foreach (Renderer componentsInChild in val.GetComponentsInChildren(true)) { foreach (Material item in (Il2CppArrayBase)(object)componentsInChild.sharedMaterials) { if ((Object)(object)item == (Object)null || !hashSet.Add(((Object)item).GetInstanceID())) { continue; } Color color = item.color; if (color.g > 0.35f && color.g > color.r * 1.4f && color.g > color.b * 1.4f) { ((Color)(ref val2))..ctor(color.r * 0.5f, color.g * 0.45f, color.b * 0.5f, color.a); item.color = val2; if (item.HasProperty("_BaseColor")) { item.SetColor("_BaseColor", val2); } } } } foreach (Renderer componentsInChild2 in val.GetComponentsInChildren(true)) { componentsInChild2.shadowCastingMode = (ShadowCastingMode)((!((Object)componentsInChild2).name.Contains("Netting") && !((Object)componentsInChild2).name.Contains("LNet")) ? 1 : 0); } AddBox(val, new Vector3(0f, 0.02f, 6.5f), new Vector3(4.2f, 0.04f, 16f)); AddBox(val, new Vector3(0f, 0.75f, 13.55f), new Vector3(0.75f, 1.5f, 0.8f)); AddBox(val, new Vector3(-0.28f, 1.05f, 12.5f), new Vector3(1.5f, 2.1f, 0.08f)); AddBox(val, new Vector3(0f, 2.6f, 14.75f), new Vector3(2.9f, 5.2f, 0.2f)); float[] array = new float[2] { -2.75f, 2.75f }; foreach (float num in array) { AddBox(val, new Vector3(num, 3.1f, -2.2f), new Vector3(0.25f, 6.2f, 0.25f)); } val.transform.Find("Model"); string[] array2 = new string[2] { "WheelTop", "WheelBot" }; foreach (string text in array2) { Transform val3 = Find(val.transform, text); if (!((Object)(object)val3 == (Object)null)) { Load("bc_" + text, "BC_Wheel.glb").transform.SetParent(val3, false); } } Scoreboard.Build(val); return val; } public static GameObject CageIcon() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0040: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("bc_CageIcon"); GameObject obj = Load("bc_CageIconModel", "BC_Cage.glb"); obj.transform.SetParent(val.transform, false); obj.transform.localRotation = Quaternion.Euler(0f, 35f, 0f); return val; } public static GameObject Bat(string skin) { string file = ((skin == "Neon") ? "BC_BatNeon.glb" : ((skin == "Gold") ? "BC_BatGold.glb" : "BC_BatClassic.glb")); GameObject val = Load("bc_Bat" + skin, file); foreach (Renderer componentsInChild in val.GetComponentsInChildren(true)) { componentsInChild.shadowCastingMode = (ShadowCastingMode)0; } return val; } public static GameObject Ball() { GameObject val = Load("bc_Ball", "BC_Ball.glb"); foreach (Renderer componentsInChild in val.GetComponentsInChildren(true)) { componentsInChild.shadowCastingMode = (ShadowCastingMode)1; } return val; } public static Transform Find(Transform t, string name) { if (((Object)t).name == name) { return t; } for (int i = 0; i < t.childCount; i++) { Transform val = Find(t.GetChild(i), name); if ((Object)(object)val != (Object)null) { return val; } } return null; } private static void AddBox(GameObject go, Vector3 center, Vector3 size) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("bc_Col"); val.transform.SetParent(go.transform, false); BoxCollider obj = val.AddComponent(); obj.center = center; obj.size = size; } } internal static class Scoreboard { private static Material _on; private static Material _off; private static readonly int[] Digits = new int[10] { 63, 6, 91, 79, 102, 109, 125, 7, 127, 111 }; public static void Build(GameObject cage) { //IL_001b: 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_005e: 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_00e2: Expected O, but got Unknown //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_035f: Unknown result type (might be due to invalid IL or missing references) //IL_0364: Unknown result type (might be due to invalid IL or missing references) //IL_037e: 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_0388: Unknown result type (might be due to invalid IL or missing references) //IL_038a: Unknown result type (might be due to invalid IL or missing references) //IL_0390: Unknown result type (might be due to invalid IL or missing references) //IL_0397: Unknown result type (might be due to invalid IL or missing references) //IL_03ac: 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_03b3: 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_03bd: Unknown result type (might be due to invalid IL or missing references) //IL_0404: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) if (_on == null) { _on = FortifyApi.Emissive("bc_seg_on", new Color(1f, 0.62f, 0.12f), new Color(3.2f, 1.6f, 0.25f)); } if (_off == null) { _off = FortifyApi.Mat("bc_seg_off", new Color(0.06f, 0.04f, 0.03f)); } string[] array = new string[4] { "Score_DIST", "Score_MPH", "Score_HR", "Score_SPLASH" }; Vector3 zero = default(Vector3); Vector3 localScale = default(Vector3); foreach (string name in array) { Transform val = CageModels.Find(cage.transform, name); if ((Object)(object)val == (Object)null) { continue; } for (int j = 0; j < 3; j++) { GameObject val2 = new GameObject("Digit" + j); val2.transform.SetParent(val, false); val2.transform.localPosition = new Vector3((float)(j - 1) * 0.24f, 0f, -0.012f); for (int k = 0; k < 7; k++) { GameObject val3 = GameObject.CreatePrimitive((PrimitiveType)3); Object.Destroy((Object)(object)val3.GetComponent()); ((Object)val3).name = "Seg" + k; val3.transform.SetParent(val2.transform, false); float num = 0.15f; float num2 = 0.15f; float num3 = 0.032f; switch (k) { case 0: ((Vector3)(ref zero))..ctor(0f, num2, 0f); ((Vector3)(ref localScale))..ctor(num, num3, 0.01f); break; case 1: ((Vector3)(ref zero))..ctor(num / 2f, num2 / 2f, 0f); ((Vector3)(ref localScale))..ctor(num3, num2, 0.01f); break; case 2: ((Vector3)(ref zero))..ctor(num / 2f, (0f - num2) / 2f, 0f); ((Vector3)(ref localScale))..ctor(num3, num2, 0.01f); break; case 3: ((Vector3)(ref zero))..ctor(0f, 0f - num2, 0f); ((Vector3)(ref localScale))..ctor(num, num3, 0.01f); break; case 4: ((Vector3)(ref zero))..ctor((0f - num) / 2f, (0f - num2) / 2f, 0f); ((Vector3)(ref localScale))..ctor(num3, num2, 0.01f); break; case 5: ((Vector3)(ref zero))..ctor((0f - num) / 2f, num2 / 2f, 0f); ((Vector3)(ref localScale))..ctor(num3, num2, 0.01f); break; default: zero = Vector3.zero; ((Vector3)(ref localScale))..ctor(num, num3, 0.01f); break; } val3.transform.localPosition = zero; val3.transform.localScale = localScale; Renderer component = val3.GetComponent(); component.sharedMaterial = _off; component.shadowCastingMode = (ShadowCastingMode)0; } } } array = new string[2] { "Lamp_L", "Lamp_R" }; foreach (string name2 in array) { Transform val4 = CageModels.Find(cage.transform, name2); if (!((Object)(object)val4 == (Object)null)) { GameObject val5 = new GameObject("bc_Flood"); val5.transform.SetParent(cage.transform, false); Vector3 val6 = cage.transform.InverseTransformPoint(val4.position); val5.transform.localPosition = val6; val5.transform.localRotation = Quaternion.LookRotation(new Vector3(0f, 0f, 6.5f) - val6, Vector3.up); Light obj = val5.AddComponent(); obj.type = (LightType)0; obj.spotAngle = 80f; obj.range = 30f; obj.intensity = 0f; obj.color = new Color(1f, 0.95f, 0.82f); obj.shadows = (LightShadows)0; ((Behaviour)obj).enabled = false; } } } public static void Show(GameObject cage, string display, int value) { Transform val = CageModels.Find(cage.transform, "Score_" + display); if ((Object)(object)val == (Object)null) { return; } for (int i = 0; i < 3; i++) { Transform val2 = val.Find("Digit" + i); if ((Object)(object)val2 == (Object)null) { continue; } int num = 2 - i; int num2 = ((value < 0) ? (-1) : (value / (int)Mathf.Pow(10f, (float)num) % 10)); int num3 = ((value >= 0 && (num <= 0 || value >= (int)Mathf.Pow(10f, (float)num))) ? Digits[Mathf.Clamp(num2, 0, 9)] : 0); for (int j = 0; j < 7; j++) { Transform val3 = val2.Find("Seg" + j); if ((Object)(object)val3 != (Object)null) { ((Component)val3).GetComponent().sharedMaterial = (((num3 & (1 << j)) != 0) ? _on : _off); } } } } public static void Lights(GameObject cage, bool on) { foreach (Light componentsInChild in cage.GetComponentsInChildren(true)) { if ((!(((Object)componentsInChild).name != "bc_Flood") || !(((Object)((Component)componentsInChild).gameObject).name != "bc_Flood")) && ((Behaviour)componentsInChild).enabled != on) { ((Behaviour)componentsInChild).enabled = on; componentsInChild.intensity = (on ? 14f : 0f); } } } } internal static class CageSound { private sealed class St { public float L; public float Phase; public float Low(float x, float k) { L += (x - L) * k; return L; } } private const float Tau = (float)Math.PI * 2f; private static AudioClip _ding; private static AudioClip _swish; private static AudioClip _crack; private static AudioClip _tick; private static AudioClip _thump; private static AudioClip _whir; private static AudioClip _net; private static AudioClip _clank; private static AudioClip _thud; private static AudioClip _glass; private static AudioClip _alarm; private static AudioClip _cheer; public const float Master = 0.6f; public static AudioClip Crack => _crack ?? (_crack = Make("bc_crack", 0.5f, (float t, Random r, St s) => Noise(r) * Mathf.Exp((0f - t) * 90f) * 0.9f + (Mathf.Sin((float)Math.PI * 2500f * t) * 0.5f + Mathf.Sin((float)Math.PI * 4620f * t) * 0.3f + Mathf.Sin((float)Math.PI * 1280f * t) * 0.35f) * Mathf.Exp((0f - t) * 16f))); public static AudioClip Tick => _tick ?? (_tick = Make("bc_tick", 0.25f, (float t, Random r, St s) => Noise(r) * Mathf.Exp((0f - t) * 120f) * 0.6f + Mathf.Sin((float)Math.PI * 1800f * t) * Mathf.Exp((0f - t) * 30f) * 0.25f)); public static AudioClip Thump => _thump ?? (_thump = Make("bc_thump", 0.35f, (float t, Random r, St s) => Mathf.Sin((float)Math.PI * 2f * (95f - 40f * t) * t) * Mathf.Exp((0f - t) * 14f) * 0.8f + Noise(r) * Mathf.Exp((0f - t) * 60f) * 0.3f)); public static AudioClip Whir => _whir ?? (_whir = Make("bc_whir", 0.8f, (float t, Random r, St s) => (Mathf.Sin((float)Math.PI * 2f * (180f + 220f * t) * t) * 0.25f + Mathf.Sin((float)Math.PI * 2f * (360f + 440f * t) * t) * 0.1f + Noise(r) * 0.06f) * Mathf.Clamp01(t * 6f) * Mathf.Clamp01((0.8f - t) * 8f))); public static AudioClip Net => _net ?? (_net = Make("bc_net", 0.45f, (float t, Random r, St s) => s.Low(Noise(r), 0.25f) * Mathf.Exp((0f - t) * 9f) * 0.9f)); public static AudioClip Clank => _clank ?? (_clank = Make("bc_clank", 0.6f, (float t, Random r, St s) => (Mathf.Sin((float)Math.PI * 1040f * t) * 0.4f + Mathf.Sin((float)Math.PI * 2740f * t) * 0.3f + Mathf.Sin((float)Math.PI * 5780f * t) * 0.15f) * Mathf.Exp((0f - t) * 7f) + Noise(r) * Mathf.Exp((0f - t) * 80f) * 0.4f)); public static AudioClip Thud => _thud ?? (_thud = Make("bc_thud", 0.3f, (float t, Random r, St s) => s.Low(Noise(r), 0.12f) * Mathf.Exp((0f - t) * 20f) * 1.6f + Mathf.Sin((float)Math.PI * 220f * t) * Mathf.Exp((0f - t) * 25f) * 0.4f)); public static AudioClip Glass => _glass ?? (_glass = Make("bc_glass", 1.4f, Shatter)); public static AudioClip Alarm => _alarm ?? (_alarm = Make("bc_alarm", 1.2f, delegate(float t, Random r, St s) { float num = ((t < 0.6f) ? (700f + 900f * (t / 0.6f)) : (1600f - 900f * ((t - 0.6f) / 0.6f))); s.Phase += (float)Math.PI * 2f * num / 22050f; return Mathf.Sign(Mathf.Sin(s.Phase)) * 0.35f + Mathf.Sin(s.Phase * 2f) * 0.15f; })); public static AudioClip Cheer => _cheer ?? (_cheer = Make("bc_cheer", 2.6f, (float t, Random r, St s) => s.Low(Noise(r), 0.35f) * Mathf.Clamp01(t * 2.5f) * Mathf.Clamp01((2.6f - t) * 1.2f) * (0.75f + 0.25f * Mathf.Sin(19.477875f * t + Mathf.Sin(t * 11f))) * 0.9f)); public static AudioClip Ding => _ding ?? (_ding = Make("bc_ding", 1.6f, (float t, Random r, St s) => Bell(t, 1318.5f) * 0.45f + ((t > 0.16f) ? (Bell(t - 0.16f, 1760f) * 0.45f) : 0f))); public static AudioClip Swish => _swish ?? (_swish = Make("bc_swish", 0.25f, (float t, Random r, St s) => s.Low(Noise(r), 0.18f) * Mathf.Sin(t / 0.25f * (float)Math.PI) * 0.8f)); private static float Bell(float t, float f) { return (Mathf.Sin((float)Math.PI * 2f * f * t) + Mathf.Sin((float)Math.PI * 2f * f * 2.01f * t) * 0.35f + Mathf.Sin((float)Math.PI * 2f * f * 3.02f * t) * 0.12f) * Mathf.Exp((0f - t) * 3.2f) * Mathf.Clamp01(t * 400f); } private static float Noise(Random r) { return (float)(r.NextDouble() * 2.0 - 1.0); } private static float Shatter(float t, Random r, St s) { float num = Noise(r) * Mathf.Exp((0f - t) * 30f) * 0.8f; float num2 = 0f; for (int i = 0; i < 9; i++) { float num3 = 0.04f + (float)i * 0.11f + (float)(i * 37 % 7) * 0.013f; float num4 = t - num3; if (num4 > 0f && num4 < 0.25f) { num2 += Mathf.Sin((float)Math.PI * 2f * (2600f + (float)i * 410f) * num4) * Mathf.Exp((0f - num4) * 28f) * (0.35f - (float)i * 0.025f); } } return num + num2 + Noise(r) * Mathf.Exp((0f - t) * 4f) * 0.08f; } private static AudioClip Make(string name, float seconds, Func f) { try { int num = 22050; int num2 = Mathf.CeilToInt(seconds * (float)num); Random arg = new Random(name.GetHashCode()); St arg2 = new St(); Il2CppStructArray val = new Il2CppStructArray((long)num2); for (int i = 0; i < num2; i++) { ((Il2CppArrayBase)(object)val)[i] = Mathf.Clamp(f((float)i / (float)num, arg, arg2), -1f, 1f); } AudioClip obj = Sfx.Create(name, num2, 1, num, stream: false); Sfx.SetData(obj, val, 0); ((Object)obj).hideFlags = (HideFlags)32; return obj; } catch { return null; } } public static void Play(AudioClip c, Vector3 at, float volume) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)c == (Object)null) { return; } try { AudioSource.PlayClipAtPoint(c, at, volume * 0.6f); } catch { } } public static void Loop(AudioClip c, Vector3 at, float volume, float seconds) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: 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_0075: Expected O, but got Unknown if ((Object)(object)c == (Object)null) { return; } try { GameObject val = new GameObject("bc_Loop"); val.transform.position = at; AudioSource obj = val.AddComponent(); obj.clip = c; obj.loop = true; obj.volume = volume * 0.6f; obj.spatialBlend = 1f; obj.minDistance = 4f; obj.maxDistance = 120f; obj.rolloffMode = (AudioRolloffMode)1; obj.Play(); Object.Destroy((Object)val, seconds); } catch { } } } internal static class Park { private sealed class Spark { public GameObject Go; public Vector3 V; public float Born; public float Life; } public static readonly Vector3 Origin = new Vector3(-3000f, 0f, -3000f); public static readonly Vector3 ReleaseLocal = new Vector3(0f, 1.25f, 17.84f); private const float Ft = 0.3048f; public static GameObject Root; private static Transform _home; private static Transform _cageT; private static Transform _depart; private static Vector3 _arrive; private static Quaternion _arriveRot = Quaternion.identity; private static bool _traveling; private static bool _camOn; private static Vector3 _camDir; private static Vector3 _camPos; private static string _hint = ""; private static Sprite _loadSprite; private static readonly List Spots = new List(); private static readonly List Base = new List(); public static float Gain = 1f; private static float _lightsAt; private static bool _choice; private static float _choiceAt; private static Vector3 _choicePos; public static Vector3 StopPos = new Vector3(-78.9f, -2.2f, -84.9f); public static float StopYaw = -28f; private static GameObject _stop; private static Transform _stopUse; private static readonly List<(Transform, Vector3, float)> Bobbers = new List<(Transform, Vector3, float)>(); private static readonly List Sparks = new List(); private static Material[] _sparkMats; private static readonly Random Rng = new Random(); public static bool Built => (Object)(object)Root != (Object)null; public static bool AtPark { get { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) try { Player local = Player.Local; int result; if ((Object)(object)local != (Object)null) { Vector3 val = ((Component)local).transform.position - Origin; result = ((((Vector3)(ref val)).sqrMagnitude < 490000f) ? 1 : 0); } else { result = 0; } return (byte)result != 0; } catch { return false; } } } public static bool CamOn => _camOn; public static float SeaY => Origin.y - 3f; public static string SetGain(float g) { Gain = g; for (int i = 0; i < Spots.Count && i < Base.Count; i++) { if ((Object)(object)Spots[i] != (Object)null) { Spots[i].intensity = Base[i] * CageCore.ParkLights.Value * Gain; } } return $"{Spots.Count} spots, gain {g}"; } public static string SetSpot(float angle, float range) { foreach (Light spot in Spots) { if ((Object)(object)spot != (Object)null) { spot.spotAngle = angle; spot.range = range; } } return "ok"; } public static float FenceR(float thetaDeg) { float num = Mathf.Abs(thetaDeg) / 45f; float num3; float num4; float num2; if (num <= 0.5f) { num2 = num / 0.5f; num3 = 365f; num4 = 350f; } else { num2 = Mathf.Clamp01((num - 0.5f) / 0.5f); num3 = 350f; num4 = 320f; } num2 = (1f - Mathf.Cos((float)Math.PI * num2)) / 2f; return (num3 + (num4 - num3) * num2) * 0.3048f; } public static void Build() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0214: 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_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0390: Unknown result type (might be due to invalid IL or missing references) //IL_0395: Unknown result type (might be due to invalid IL or missing references) //IL_03ab: Unknown result type (might be due to invalid IL or missing references) //IL_03b3: Unknown result type (might be due to invalid IL or missing references) //IL_03bd: Unknown result type (might be due to invalid IL or missing references) //IL_03c5: Unknown result type (might be due to invalid IL or missing references) //IL_03cc: Unknown result type (might be due to invalid IL or missing references) //IL_03d1: Unknown result type (might be due to invalid IL or missing references) //IL_03d6: Unknown result type (might be due to invalid IL or missing references) //IL_03da: Unknown result type (might be due to invalid IL or missing references) //IL_03df: Unknown result type (might be due to invalid IL or missing references) //IL_03e4: Unknown result type (might be due to invalid IL or missing references) //IL_04f7: Unknown result type (might be due to invalid IL or missing references) //IL_051f: Unknown result type (might be due to invalid IL or missing references) //IL_0530: Unknown result type (might be due to invalid IL or missing references) //IL_057d: Unknown result type (might be due to invalid IL or missing references) //IL_046b: Unknown result type (might be due to invalid IL or missing references) //IL_05f1: Unknown result type (might be due to invalid IL or missing references) //IL_0619: Unknown result type (might be due to invalid IL or missing references) //IL_0650: Unknown result type (might be due to invalid IL or missing references) //IL_06c1: Unknown result type (might be due to invalid IL or missing references) //IL_06d2: Unknown result type (might be due to invalid IL or missing references) //IL_072b: Unknown result type (might be due to invalid IL or missing references) //IL_0709: Unknown result type (might be due to invalid IL or missing references) //IL_071d: Unknown result type (might be due to invalid IL or missing references) //IL_0722: Unknown result type (might be due to invalid IL or missing references) //IL_0730: Unknown result type (might be due to invalid IL or missing references) //IL_0735: Unknown result type (might be due to invalid IL or missing references) //IL_073a: Unknown result type (might be due to invalid IL or missing references) //IL_073f: Unknown result type (might be due to invalid IL or missing references) //IL_0744: Unknown result type (might be due to invalid IL or missing references) //IL_07a6: Unknown result type (might be due to invalid IL or missing references) //IL_07e0: Unknown result type (might be due to invalid IL or missing references) //IL_0825: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Root != (Object)null) { return; } float realtimeSinceStartup = Time.realtimeSinceStartup; Root = new GameObject("bc_FloodlightPark"); Root.transform.position = Origin; GameObject val = CageModels.Load("bc_ParkModel", "BC_Park.glb"); val.transform.SetParent(Root.transform, false); Models.MeshColliders(val, "COL_"); foreach (Renderer componentsInChild in val.GetComponentsInChildren(true)) { string name = ((Object)componentsInChild).name; if (name.StartsWith("COL_Ground") || name.StartsWith("COL_Seabed") || name.StartsWith("COL_EdgeWall")) { componentsInChild.enabled = false; continue; } bool flag = name.Contains("Bulb") || name.Contains("Lens") || name.Contains("Rock") || name.Contains("Grass") || name.Contains("Track") || name.Contains("Dirt") || name.Contains("Chalk") || name.Contains("Line") || name.Contains("Isle") || name.Contains("Seawall"); componentsInChild.shadowCastingMode = (ShadowCastingMode)(!flag); } _home = new GameObject("bc_ParkHome").transform; _home.SetParent(Root.transform, false); string[] array = new string[4] { "Score_HR", "Score_MPH", "Score_DIST", "Score_SPLASH" }; foreach (string name2 in array) { Transform val2 = CageModels.Find(val.transform, name2); if (!((Object)(object)val2 == (Object)null)) { Vector3 val3 = val2.position - _home.position; val3.y = 0f; val2.SetParent(_home, true); val2.rotation = Quaternion.LookRotation(((Vector3)(ref val3)).normalized, Vector3.up); val2.localScale = Vector3.one * 7.5f; } } Scoreboard.Build(((Component)_home).gameObject); Scoreboard.Show(((Component)_home).gameObject, "HR", 0); Scoreboard.Show(((Component)_home).gameObject, "MPH", -1); Scoreboard.Show(((Component)_home).gameObject, "DIST", -1); Scoreboard.Show(((Component)_home).gameObject, "SPLASH", CageCore.Splashes.Value); Spots.Clear(); Base.Clear(); foreach (Transform componentsInChild2 in val.GetComponentsInChildren(true)) { if (!((Object)componentsInChild2).name.StartsWith("FL_Spot")) { continue; } string text = ((Object)componentsInChild2).name.Substring(7); int num = ((text.Length > 0) ? (text[text.Length - 1] - 48) : 0); if (num == 1 || num == 2) { Transform val4 = CageModels.Find(val.transform, "FL_Target" + text); if (!((Object)(object)val4 == (Object)null)) { GameObject val5 = new GameObject("bc_ParkSpot" + text); val5.transform.SetParent(Root.transform, false); val5.transform.position = componentsInChild2.position; Transform transform = val5.transform; Vector3 val6 = val4.position - componentsInChild2.position; transform.rotation = Quaternion.LookRotation(((Vector3)(ref val6)).normalized, Vector3.up); Light val7 = val5.AddComponent(); val7.type = (LightType)0; val7.spotAngle = 90f; val7.innerSpotAngle = 55f; val7.range = 300f; float num2 = ((num == 1) ? 1.5f : 2.4f); Base.Add(num2); val7.intensity = num2 * CageCore.ParkLights.Value * Gain; val7.color = new Color(1f, 0.96f, 0.88f); val7.shadows = (LightShadows)0; Spots.Add(val7); } } } Transform val8 = CageModels.Find(val.transform, "FL_EyeTarget"); foreach (Transform componentsInChild3 in val.GetComponentsInChildren(true)) { if (!((Object)(object)val8 == (Object)null) && ((Object)componentsInChild3).name.StartsWith("FL_EyeSpot")) { Light obj = new GameObject("bc_EyeSpot").AddComponent(); ((Component)obj).transform.SetParent(Root.transform, false); ((Component)obj).transform.position = componentsInChild3.position; ((Component)obj).transform.LookAt(val8.position); obj.type = (LightType)0; obj.spotAngle = 60f; obj.innerSpotAngle = 30f; obj.range = 40f; obj.intensity = 3.5f; obj.color = new Color(1f, 0.93f, 0.8f); obj.shadows = (LightShadows)0; } } foreach (Transform componentsInChild4 in val.GetComponentsInChildren(true)) { if (((Object)componentsInChild4).name.StartsWith("FL_Lamp") && ((Object)componentsInChild4).name.EndsWith("_-60")) { Light obj2 = new GameObject("bc_ParkLamp").AddComponent(); ((Component)obj2).transform.SetParent(Root.transform, false); ((Component)obj2).transform.position = componentsInChild4.position; obj2.type = (LightType)2; obj2.range = 16f; obj2.intensity = 6f; obj2.color = new Color(1f, 0.85f, 0.6f); obj2.shadows = (LightShadows)0; } } Transform val9 = CageModels.Find(val.transform, "PK_CageSpot"); if ((Object)(object)val9 != (Object)null) { GameObject obj3 = CageModels.Cage(); ((Object)obj3).name = "bc_ParkCage"; obj3.transform.SetParent(Root.transform, false); obj3.transform.position = val9.position; obj3.transform.rotation = val9.rotation; _cageT = obj3.transform; Scoreboard.Lights(obj3, on: true); } Transform val10 = CageModels.Find(val.transform, "PK_Arrive"); _arrive = (((Object)(object)val10 != (Object)null) ? val10.position : (Origin + new Vector3(0f, 0.2f, -70f))); _arriveRot = Quaternion.LookRotation(Vector3.forward, Vector3.up); _depart = CageModels.Find(val.transform, "PK_DepartSign"); PlantTrees(val); Bobbers.Clear(); foreach (Transform componentsInChild5 in val.GetComponentsInChildren(true)) { if (((Object)componentsInChild5).name.StartsWith("BOB_")) { Bobbers.Add((componentsInChild5, componentsInChild5.localPosition, (float)Rng.NextDouble() * 6.28f)); } else if (((Object)componentsInChild5).name.StartsWith("FL_Point_")) { Light obj4 = new GameObject("bc_ParkPoint").AddComponent(); ((Component)obj4).transform.SetParent(componentsInChild5, false); obj4.type = (LightType)2; obj4.range = 30f; obj4.intensity = 5f; obj4.color = new Color(1f, 0.85f, 0.55f); obj4.shadows = (LightShadows)0; } } WallColliders(); Ocean(); MelonLogger.Msg($"Floodlight Park built in {Time.realtimeSinceStartup - realtimeSinceStartup:0.00} s ({Spots.Count} floodlights)."); } private static void PlantTrees(GameObject model) { //IL_0290: 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_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) List list = new List(); HashSet hashSet = new HashSet(); try { foreach (Terrain item in (Il2CppArrayBase)(object)Terrain.activeTerrains) { if ((Object)(object)item == (Object)null || (Object)(object)item.terrainData == (Object)null) { continue; } foreach (TreePrototype item2 in (Il2CppArrayBase)(object)item.terrainData.treePrototypes) { GameObject val = ((item2 != null) ? item2.prefab : null); if ((Object)(object)val == (Object)null || !hashSet.Add(((Object)val).name)) { continue; } string text = ((Object)val).name.ToLowerInvariant(); if (text.Contains("bush") || text.Contains("shrub") || text.Contains("grass") || text.Contains("rock") || text.Contains("dead") || text.Contains("stump") || text.Contains("log") || text.Contains("palm")) { continue; } Bounds val2 = default(Bounds); bool flag = false; foreach (Renderer componentsInChild in val.GetComponentsInChildren(true)) { if (!((Object)(object)componentsInChild == (Object)null)) { if (!flag) { val2 = componentsInChild.bounds; flag = true; } else { ((Bounds)(ref val2)).Encapsulate(componentsInChild.bounds); } } } if (flag && ((Bounds)(ref val2)).size.y > 3f && ((Bounds)(ref val2)).size.y < 40f) { list.Add(val); } } } } catch (Exception ex) { MelonLogger.Warning("Floodlight Park trees: " + ex.Message); } if (list.Count == 0) { return; } Random random = new Random(1951); int num = 0; foreach (Transform componentsInChild2 in model.GetComponentsInChildren(true)) { if (((Object)componentsInChild2).name.StartsWith("TREE_")) { try { GameObject val3 = list[random.Next(list.Count)]; GameObject obj = Object.Instantiate(val3, Root.transform); ((Object)obj).name = "bc_ParkTree"; obj.transform.position = componentsInChild2.position; obj.transform.rotation = Quaternion.Euler(0f, (float)random.NextDouble() * 360f, 0f); obj.transform.localScale = val3.transform.localScale * (1f + (float)random.NextDouble() * 0.5f); obj.SetActive(true); num++; } catch { } } } if (num >= 10) { foreach (Renderer componentsInChild3 in model.GetComponentsInChildren(true)) { if (((Object)componentsInChild3).name.StartsWith("PK_TreeTrunk") || ((Object)componentsInChild3).name.StartsWith("PK_TreeTop")) { componentsInChild3.enabled = false; } } } MelonLogger.Msg($"Floodlight Park: planted {num} of the game's trees ({list.Count} kinds)."); } private static void WallColliders() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: 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_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) Transform val = Root.transform.Find("bc_ParkHome"); if (!((Object)(object)val == (Object)null)) { GameObject val2 = new GameObject("bc_WallCols"); val2.transform.SetParent(val, false); for (float num = -48f; num < 48f; num += 2f) { float num2 = FenceR(num); float num3 = FenceR(num + 2f); Vector3 val3 = new Vector3(Mathf.Sin(num * ((float)Math.PI / 180f)), 0f, Mathf.Cos(num * ((float)Math.PI / 180f))) * num2; Vector3 val4 = new Vector3(Mathf.Sin((num + 2f) * ((float)Math.PI / 180f)), 0f, Mathf.Cos((num + 2f) * ((float)Math.PI / 180f))) * num3; Vector3 val5 = (val3 + val4) / 2f; Vector3 val6 = val4 - val3; Vector3 val7 = new Vector3(val5.x, 0f, val5.z); Vector3 normalized = ((Vector3)(ref val7)).normalized; GameObject val8 = new GameObject("bc_WallCol"); val8.transform.SetParent(val2.transform, false); val8.transform.localPosition = val5 + normalized * 0.35f + Vector3.up * 1.5f; val8.transform.localRotation = Quaternion.LookRotation(((Vector3)(ref val6)).normalized, Vector3.up); val8.AddComponent().size = new Vector3(0.7f, 3f, ((Vector3)(ref val6)).magnitude + 0.3f); } } } private static void Ocean() { //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) Material val = null; try { foreach (MeshRenderer item in Object.FindObjectsOfType()) { Material val2 = (((Object)(object)item != (Object)null) ? ((Renderer)item).sharedMaterial : null); if (!((Object)(object)val2 == (Object)null) && !((Object)(object)val2.shader == (Object)null) && ((Object)val2.shader).name.ToLowerInvariant().Contains("water")) { Bounds bounds = ((Renderer)item).bounds; if (((Bounds)(ref bounds)).size.x > 100f) { val = val2; break; } } } } catch { } if (val == null) { val = Models.Mat("bc_ParkWater", new Color(0.02f, 0.06f, 0.11f), 0f, 0.92f); } for (int i = -2; i <= 2; i++) { for (int j = -2; j <= 2; j++) { GameObject obj2 = GameObject.CreatePrimitive((PrimitiveType)4); Object.Destroy((Object)(object)obj2.GetComponent()); ((Object)obj2).name = "bc_ParkSea"; obj2.transform.SetParent(Root.transform, false); obj2.transform.localPosition = new Vector3((float)i * 400f, -3f, (float)j * 400f + 40f); obj2.transform.localScale = new Vector3(40f, 1f, 40f); MeshRenderer component = obj2.GetComponent(); ((Renderer)component).sharedMaterial = val; ((Renderer)component).shadowCastingMode = (ShadowCastingMode)0; } } } public static void Travel() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) if (_traveling || Cage.Batting) { return; } try { Player local = Player.Local; if ((Object)(object)local != (Object)null && !AtPark) { Vector3 position = ((Component)local).transform.position; CageCore.ReturnTo.Value = string.Format(CultureInfo.InvariantCulture, "{0:0.00},{1:0.00},{2:0.00},{3:0}", position.x, position.y, position.z, ((Component)local).transform.eulerAngles.y); CageCore.SavePrefs(); } } catch { } MelonCoroutines.Start(Ferry(toPark: true)); } public static void GoHome() { if (!_traveling) { if (Cage.Batting) { Cage.Leave(); } MelonCoroutines.Start(Ferry(toPark: false)); } } private static bool ReturnSpot(out Vector3 p, out Quaternion r) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) p = Vector3.zero; r = Quaternion.identity; string[] array = (CageCore.ReturnTo?.Value ?? "").Split(','); if (array.Length < 3) { return false; } CultureInfo invariantCulture = CultureInfo.InvariantCulture; if (!float.TryParse(array[0], NumberStyles.Float, invariantCulture, out var result) || !float.TryParse(array[1], NumberStyles.Float, invariantCulture, out var result2) || !float.TryParse(array[2], NumberStyles.Float, invariantCulture, out var result3)) { return false; } float result4; float num = ((array.Length > 3 && float.TryParse(array[3], NumberStyles.Float, invariantCulture, out result4)) ? result4 : 0f); p = new Vector3(result, result2 + 0.3f, result3); r = Quaternion.Euler(0f, num, 0f); Vector3 val = p - Origin; return ((Vector3)(ref val)).sqrMagnitude > 810000f; } private static IEnumerator Ferry(bool toPark) { _traveling = true; LoadScreen.Open(toPark ? "Taking the ferry to Floodlight Park..." : "Taking the ferry back to Hyland Point...", Sprite()); float t = 0f; while (!LoadScreen.Covered && t < 2.5f) { t += Time.unscaledDeltaTime; yield return null; } yield return null; try { Vector3 p; Quaternion r; if (toPark) { Build(); Teleport(_arrive, _arriveRot); OpenChoice(); } else if (ReturnSpot(out p, out r)) { Teleport(p, r); } else { Teleport((Vector3)(((Object)(object)_stopUse != (Object)null) ? (_stopUse.position + Vector3.up * 0.3f) : new Vector3(-58f, 0.3f, -66f)), Quaternion.Euler(0f, StopYaw + 180f, 0f)); } } catch (Exception ex) { MelonLogger.Warning("Floodlight Park ferry: " + ex.Message); } t = 0f; while (t < 1.6f) { t += Time.unscaledDeltaTime; yield return null; } LoadScreen.Close(); _traveling = false; if (toPark) { Cage.Announce("FLOODLIGHT PARK", "Walk up to home plate for the Home Run Derby, or try the cage down the right-field line."); } } private static void Teleport(Vector3 p, Quaternion r) { //IL_0010: 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_0030: Unknown result type (might be due to invalid IL or missing references) PlayerMovement instance = PlayerSingleton.Instance; if ((Object)(object)instance != (Object)null) { instance.Teleport(p, r, true); } else if ((Object)(object)Player.Local != (Object)null) { ((Component)Player.Local).transform.position = p; } } private static Sprite Sprite() { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_loadSprite != (Object)null) { return _loadSprite; } try { using Stream stream = Res.Open("BattingCage.img.bc_park_load.jpg"); if (stream == null) { return null; } using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); ImageConversion.LoadImage(val, new Il2CppStructArray(memoryStream.ToArray()), false); ((Object)val).hideFlags = (HideFlags)32; _loadSprite = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f)); ((Object)_loadSprite).hideFlags = (HideFlags)32; } catch (Exception ex) { MelonLogger.Warning("Floodlight Park loading picture: " + ex.Message); } return _loadSprite; } public static void OnLoaded() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) Reset(); BuildStop(); if (AtPark) { try { Build(); Teleport(_arrive, _arriveRot); } catch (Exception ex) { MelonLogger.Warning("Floodlight Park: " + ex.Message); } } } public static void Reset() { Root = null; _choice = false; if ((Object)(object)_stop != (Object)null) { Object.Destroy((Object)(object)_stop); } _stop = null; _stopUse = null; _home = (_cageT = (_depart = null)); _traveling = false; _camOn = false; Spots.Clear(); Sparks.Clear(); LoadScreen.Reset(); } public static void Update() { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0145: 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_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: 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_01e3: 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_0195: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0285: 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_028f: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) LoadScreen.Update(); _hint = ""; UpdateStop(); UpdateChoice(); if ((Object)(object)Root == (Object)null) { return; } UpdateSparks(); BallCam(); float time = Time.time; foreach (var (val, val2, num) in Bobbers) { if (!((Object)(object)val == (Object)null)) { val.localPosition = val2 + Vector3.up * (Mathf.Sin(time * 0.9f + num) * 0.12f); val.localRotation = Quaternion.Euler(Mathf.Sin(time * 0.7f + num) * 3f, val.localEulerAngles.y, Mathf.Cos(time * 0.8f + num) * 3f); } } if (Cage.Batting || _traveling || Cursor.visible) { return; } Player local = Player.Local; if ((Object)(object)local == (Object)null || !AtPark) { return; } Vector3 position = ((Component)local).transform.position; KeyCode useKey = FortifyApi.UseKey; Vector3 val3 = _home.InverseTransformPoint(position); Vector2 val4 = new Vector2(val3.x, val3.z); if (((Vector2)(ref val4)).magnitude < 3.2f && Mathf.Abs(val3.y) < 2f) { _hint = $"[{useKey}] Step up to the plate - press Y at the plate for the Home Run Derby"; if (FortifyApi.KeyDown(useKey)) { Cage.EnterAt(_home, Cage.Venue.Field); } return; } if ((Object)(object)_cageT != (Object)null) { Vector3 val5 = _cageT.InverseTransformPoint(position); if (Mathf.Abs(val5.x) < 2f && val5.z > -1.45f && val5.z < 2.2f && Mathf.Abs(val5.y) < 2f) { _hint = $"[{useKey}] Step up to the plate in the batting cage"; if (FortifyApi.KeyDown(useKey)) { Cage.EnterAt(_cageT, Cage.Venue.ParkCage); } return; } } if (!((Object)(object)_depart != (Object)null)) { return; } Vector3 val6 = position - _depart.position; if (((Vector3)(ref val6)).sqrMagnitude < 10.240001f) { _hint = $"[{useKey}] Take the ferry back to Hyland Point"; if (FortifyApi.KeyDown(useKey)) { GoHome(); } } } public static void FixedUpdate() { } private static void OpenChoice() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) _choice = true; _choiceAt = Time.time; _choicePos = _arrive; } private static void UpdateChoice() { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) if (!_choice) { return; } Player local = Player.Local; Vector3 val; if (!((Object)(object)local == (Object)null) && !((Object)(object)Root == (Object)null) && !Cage.Batting && !(Time.time > _choiceAt + 45f)) { val = ((Component)local).transform.position - _choicePos; if (!(((Vector3)(ref val)).sqrMagnitude > 64f) && !LoadScreen.Covered) { if (FortifyApi.KeyDown((KeyCode)49) || FortifyApi.KeyDown((KeyCode)257)) { _choice = false; if ((Object)(object)_cageT != (Object)null) { Cage.EnterAt(_cageT, Cage.Venue.ParkCage); } } else if (FortifyApi.KeyDown((KeyCode)50) || FortifyApi.KeyDown((KeyCode)258)) { _choice = false; Cage.EnterAt(_home, Cage.Venue.Field); Cage.Derby(); } else if (FortifyApi.KeyDown((KeyCode)51) || FortifyApi.KeyDown((KeyCode)259) || FortifyApi.KeyDown((KeyCode)27)) { _choice = false; } return; } } if (!((Object)(object)Root == (Object)null) && !Cage.Batting && !(Time.time > _choiceAt + 45f)) { if (!((Object)(object)local != (Object)null)) { return; } val = ((Component)local).transform.position - _choicePos; if (!(((Vector3)(ref val)).sqrMagnitude > 64f)) { return; } } _choice = false; } private static void DrawChoice() { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_012c: 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_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: 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_024a: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) if (_choice && !((Object)(object)Root == (Object)null) && !LoadScreen.Covered && !Cursor.visible) { float num = Screen.width; float num2 = Screen.height; float num3 = num2 / 1080f; float num4 = 520f * num3; float num5 = 250f * num3; Rect r = default(Rect); ((Rect)(ref r))..ctor((num - num4) / 2f, num2 * 0.3f, num4, num5); WS_BC.FybCommon.Ui.Fill(r, new Color(0.03f, 0.06f, 0.13f, 0.85f)); WS_BC.FybCommon.Ui.Fill(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, ((Rect)(ref r)).width, 4f * num3), new Color(1f, 0.6f, 0.15f)); WS_BC.FybCommon.Ui.Text(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y + 14f * num3, num4, 40f * num3), "FLOODLIGHT PARK", Mathf.RoundToInt(30f * num3), new Color(1f, 0.8f, 0.3f), (TextAnchor)4, bold: true, wrap: false); WS_BC.FybCommon.Ui.Text(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y + 52f * num3, num4, 26f * num3), "What do you want to do?", Mathf.RoundToInt(17f * num3), Color.white, (TextAnchor)4, bold: false, wrap: false); string[] array = new string[3] { "1", "2", "3" }; string[] array2 = new string[3] { "Batting cage practice", "Home Run Derby on the field", "Look around the park" }; Rect r2 = default(Rect); for (int i = 0; i < 3; i++) { float num6 = ((Rect)(ref r)).y + 92f * num3 + (float)i * 46f * num3; ((Rect)(ref r2))..ctor(((Rect)(ref r)).x + 70f * num3, num6, 36f * num3, 36f * num3); WS_BC.FybCommon.Ui.Fill(r2, new Color(1f, 1f, 1f, 0.92f)); WS_BC.FybCommon.Ui.Text(r2, array[i], Mathf.RoundToInt(18f * num3), new Color(0.05f, 0.08f, 0.16f), (TextAnchor)4, bold: true, wrap: false); WS_BC.FybCommon.Ui.Text(new Rect(((Rect)(ref r2)).xMax + 16f * num3, num6, num4 - 140f * num3, 36f * num3), array2[i], Mathf.RoundToInt(19f * num3), Color.white, (TextAnchor)3, bold: false, wrap: false); } } } public static void BuildStop() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_stop != (Object)null) { return; } try { _stop = CageModels.Load("bc_FerryStop", "BC_FerryStop.glb"); _stop.transform.position = Ground(StopPos, StopYaw); _stop.transform.rotation = Quaternion.Euler(0f, StopYaw, 0f); Models.MeshColliders(_stop, "COL_"); _stopUse = CageModels.Find(_stop.transform, "FS_Use"); Transform val = CageModels.Find(_stop.transform, "FS_Lamp"); if ((Object)(object)val != (Object)null) { Light obj = new GameObject("bc_StopLamp").AddComponent(); ((Component)obj).transform.SetParent(val, false); obj.type = (LightType)2; obj.range = 10f; obj.intensity = 4f; obj.color = new Color(1f, 0.85f, 0.6f); obj.shadows = (LightShadows)0; } } catch (Exception ex) { MelonLogger.Warning("Floodlight ferry stop: " + ex.Message); } } public unsafe static string MoveStop(float x, float y, float z, float yaw) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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_0053: Unknown result type (might be due to invalid IL or missing references) StopPos = new Vector3(x, y, z); StopYaw = yaw; if ((Object)(object)_stop != (Object)null) { _stop.transform.position = Ground(StopPos, StopYaw); _stop.transform.rotation = Quaternion.Euler(0f, yaw, 0f); } Vector3 stopPos = StopPos; return "stop at " + ((object)(*(Vector3*)(&stopPos))/*cast due to .constrained prefix*/).ToString() + " yaw " + yaw; } private static Vector3 Ground(Vector3 p, float yaw) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_008a: 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) RaycastHit val = default(RaycastHit); if (Physics.Raycast(p + Quaternion.Euler(0f, yaw, 0f) * new Vector3(2f, 0f, -2.6f) + Vector3.up * 4f, Vector3.down, ref val, 8f, -5, (QueryTriggerInteraction)1) && Mathf.Abs(((RaycastHit)(ref val)).point.y - p.y) < 1.5f) { return new Vector3(p.x, ((RaycastHit)(ref val)).point.y, p.z); } return p; } private static void UpdateStop() { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_007b: 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) if ((Object)(object)_stopUse == (Object)null || Cage.Batting || _traveling || Cursor.visible || AtPark) { return; } Player local = Player.Local; if ((Object)(object)local == (Object)null) { return; } Vector3 val = ((Component)local).transform.position - _stopUse.position; if (!(((Vector3)(ref val)).sqrMagnitude > 10.240001f)) { _hint = $"[{FortifyApi.UseKey}] Take the ferry to Floodlight Park"; if (FortifyApi.KeyDown(FortifyApi.UseKey)) { Travel(); } } } public static void Draw() { //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) LoadScreen.Draw(); DrawChoice(); if (_hint.Length != 0 && !Cursor.visible) { float num = Screen.width; float num2 = Screen.height; float num3 = num2 / 1080f; Rect r = default(Rect); ((Rect)(ref r))..ctor(0f, num2 * 0.78f, num, 40f * num3); WS_BC.FybCommon.Ui.Text(new Rect(((Rect)(ref r)).x + 2f, ((Rect)(ref r)).y + 2f, ((Rect)(ref r)).width, ((Rect)(ref r)).height), _hint, Mathf.RoundToInt(22f * num3), new Color(0f, 0f, 0f, 0.6f), (TextAnchor)4, bold: true, wrap: false); WS_BC.FybCommon.Ui.Text(r, _hint, Mathf.RoundToInt(22f * num3), new Color(1f, 0.95f, 0.85f), (TextAnchor)4, bold: true, wrap: false); } } private static void BallCam() { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: 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_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) PlayerCamera instance; try { instance = PlayerSingleton.Instance; } catch { return; } if ((Object)(object)instance == (Object)null) { return; } if (Cage.BallCamWanted && Cage.BallPos(out var p) && CageCore.BallCam.Value) { if (!_camOn) { Vector3 ballVelocity = Cage.BallVelocity; Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(ballVelocity.x, 0f, ballVelocity.z); _camDir = ((((Vector3)(ref val)).sqrMagnitude > 0.5f) ? ((Vector3)(ref val)).normalized : (((Object)(object)_home != (Object)null) ? _home.forward : Vector3.forward)); } Vector3 val2; if (_camOn && Cage.BallLanded) { val2 = _camPos; } else { val2 = p - _camDir * 11f + Vector3.up * 4.5f; if (val2.y < Origin.y + 1.5f) { val2.y = Origin.y + 1.5f; } _camPos = val2; } Vector3 val3 = val2; Vector3 val4 = p - val2; instance.OverrideTransform(val3, Quaternion.LookRotation(((Vector3)(ref val4)).normalized, Vector3.up), 0f, false); if (!_camOn) { Cage.HideBat(hide: true); } _camOn = true; } else if (_camOn) { EndBallCam(); } } public static void EndBallCam() { if (!_camOn) { return; } _camOn = false; Cage.HideBat(hide: false); try { PlayerCamera instance = PlayerSingleton.Instance; if (instance != null) { instance.StopTransformOverride(0.35f, false, true); } } catch { } } public static void Crowd(float volume) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Root == (Object)null)) { Vector3 at = (((Object)(object)Camera.main != (Object)null) ? ((Component)Camera.main).transform.position : Origin); CageSound.Play(CageSound.Cheer, at, 0.55f * volume); } } public static void Splash(Vector3 at) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) MelonPreferences_Entry splashes = CageCore.Splashes; int value = splashes.Value; splashes.Value = value + 1; try { MelonPreferences.Save(); } catch { } if ((Object)(object)_home != (Object)null) { Scoreboard.Show(((Component)_home).gameObject, "SPLASH", CageCore.Splashes.Value); } CageSound.Play(CageSound.Thump, at, 0.5f); Crowd(1f); if (!((Object)(object)Root == (Object)null)) { Material sharedMaterial = Models.Mat("bc_splash", new Color(0.85f, 0.92f, 1f), 0f, 0.8f); for (int i = 0; i < 40; i++) { GameObject val = GameObject.CreatePrimitive((PrimitiveType)0); Object.Destroy((Object)(object)val.GetComponent()); val.transform.SetParent(Root.transform, true); val.transform.position = new Vector3(at.x, SeaY + 0.1f, at.z); val.transform.localScale = Vector3.one * (0.15f + (float)Rng.NextDouble() * 0.25f); val.GetComponent().sharedMaterial = sharedMaterial; float num = (float)Rng.NextDouble() * 6.28f; float num2 = 0.8f + (float)Rng.NextDouble() * 2.2f; Sparks.Add(new Spark { Go = val, V = new Vector3(Mathf.Cos(num) * num2, 4f + (float)Rng.NextDouble() * 5f, Mathf.Sin(num) * num2), Born = Time.time, Life = 1.6f }); } } } public static void Homer(Vector3 at) { //IL_002e: 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) Crowd(1f); Fireworks(); CageSound.Play(CageSound.Ding, ((Object)(object)Camera.main != (Object)null) ? ((Component)Camera.main).transform.position : at, 0.3f); } public static void Fireworks() { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Root == (Object)null || Sparks.Count > 400) { return; } if (_sparkMats == null) { _sparkMats = (Material[])(object)new Material[4] { FortifyApi.Emissive("bc_fw_gold", new Color(1f, 0.8f, 0.3f), new Color(6f, 4f, 1.2f)), FortifyApi.Emissive("bc_fw_red", new Color(1f, 0.25f, 0.2f), new Color(6f, 1f, 0.8f)), FortifyApi.Emissive("bc_fw_white", new Color(1f, 1f, 1f), new Color(5f, 5f, 5f)), FortifyApi.Emissive("bc_fw_blue", new Color(0.4f, 0.6f, 1f), new Color(1.2f, 2.2f, 6f)) }; } for (int i = 0; i < 4; i++) { Vector3 position = _home.TransformPoint(new Vector3(((float)i - 1.5f) * 22f, 42f + (float)(i % 2) * 8f, 135f + (float)(i % 3) * 6f)); Material sharedMaterial = _sparkMats[(i + Rng.Next(4)) % _sparkMats.Length]; float num = (float)i * 0.35f; for (int j = 0; j < 36; j++) { GameObject val = GameObject.CreatePrimitive((PrimitiveType)0); Object.Destroy((Object)(object)val.GetComponent()); ((Object)val).name = "bc_Spark"; val.transform.SetParent(Root.transform, true); val.transform.position = position; val.transform.localScale = Vector3.one * 0.55f; Renderer component = val.GetComponent(); component.sharedMaterial = sharedMaterial; component.shadowCastingMode = (ShadowCastingMode)0; val.SetActive(false); Vector3 v = Random.onUnitSphere * (13f + (float)Rng.NextDouble() * 5f); Sparks.Add(new Spark { Go = val, V = v, Born = Time.time + num, Life = 1.8f + (float)Rng.NextDouble() * 0.6f }); } } } private static void UpdateSparks() { //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) float deltaTime = Time.deltaTime; for (int num = Sparks.Count - 1; num >= 0; num--) { Spark spark = Sparks[num]; if ((Object)(object)spark.Go == (Object)null) { Sparks.RemoveAt(num); } else { float num2 = Time.time - spark.Born; if (!(num2 < 0f)) { if (!spark.Go.activeSelf) { spark.Go.SetActive(true); } if (num2 > spark.Life) { Object.Destroy((Object)(object)spark.Go); Sparks.RemoveAt(num); } else { spark.V += Vector3.down * 6f * deltaTime; spark.V *= 1f - 0.9f * deltaTime; Transform transform = spark.Go.transform; transform.position += spark.V * deltaTime; spark.Go.transform.localScale = Vector3.one * Mathf.Lerp(0.55f, 0.05f, num2 / spark.Life); } } } } } } internal static class LoadScreen { private static bool _open; private static bool _game; private static bool _overlay; private static bool _closing; private static float _openedAt; private static float _alpha; private static float _restoreAt = -1f; private static string _message = ""; private static LoadingScreen _ls; private static Il2CppReferenceArray _savedBg; private static Il2CppReferenceArray _savedCtx; private static Sprite _sprite; public static bool Covered { get { if (!_open) { return false; } if (_overlay) { return _alpha >= 0.999f; } try { if ((Object)(object)_ls != (Object)null && (Object)(object)_ls.Group != (Object)null && _ls.Group.alpha >= 0.99f) { return true; } } catch { } return Time.unscaledTime - _openedAt > 1.6f; } } public static void Open(string message, Sprite picture) { _open = true; _closing = false; _openedAt = Time.unscaledTime; _message = message ?? ""; _sprite = picture; _game = false; _overlay = false; try { _ls = Singleton.Instance; if ((Object)(object)_ls != (Object)null && !_ls.IsOpen) { if ((Object)(object)picture != (Object)null) { _savedBg = _ls.BackgroundImages; Il2CppReferenceArray val = new Il2CppReferenceArray(1L); ((Il2CppArrayBase)(object)val)[0] = picture; _ls.BackgroundImages = val; } _ls.Open(false); Paint(); _game = true; } } catch (Exception ex) { MelonLogger.Msg("Floodlight Park: using its own loading screen (" + ex.Message + ")."); _game = false; } if (!_game) { _overlay = true; _alpha = 0f; } } private static void Paint() { if ((Object)(object)_ls == (Object)null || (Object)(object)_sprite == (Object)null) { return; } try { if ((Object)(object)_ls.BackgroundImage1 != (Object)null && (Object)(object)_ls.BackgroundImage1.sprite != (Object)(object)_sprite) { _ls.BackgroundImage1.sprite = _sprite; } if ((Object)(object)_ls.BackgroundImage2 != (Object)null && (Object)(object)_ls.BackgroundImage2.sprite != (Object)(object)_sprite) { _ls.BackgroundImage2.sprite = _sprite; } if ((Object)(object)_ls.LoadingMessageLabel != (Object)null && ((TMP_Text)_ls.LoadingMessageLabel).text != _message) { ((TMP_Text)_ls.LoadingMessageLabel).text = _message; } if ((Object)(object)_ls.LoadStatusLabel != (Object)null && ((TMP_Text)_ls.LoadStatusLabel).text != "") { ((TMP_Text)_ls.LoadStatusLabel).text = ""; } } catch { } } public static void Close() { if (!_open) { return; } _open = false; if (_game) { try { LoadingScreen ls = _ls; if (ls != null) { ls.Close(); } } catch { } _game = false; _restoreAt = Time.unscaledTime + 2f; } if (_overlay) { _closing = true; } } public static void Reset() { if (_game) { try { if ((Object)(object)_ls != (Object)null && _ls.IsOpen) { _ls.Close(); } } catch { } } Restore(); _open = (_game = (_overlay = (_closing = false))); _alpha = 0f; } private static void Restore() { try { if ((Object)(object)_ls != (Object)null && _savedBg != null) { _ls.BackgroundImages = _savedBg; } } catch { } _savedBg = (_savedCtx = null); _restoreAt = -1f; } public static void Update() { if (_restoreAt > 0f && Time.unscaledTime >= _restoreAt) { Restore(); } if (_overlay) { _alpha = Mathf.MoveTowards(_alpha, _open ? 1f : 0f, Time.unscaledDeltaTime * 3.5f); if (_closing && _alpha <= 0.001f) { _overlay = (_closing = false); } } if (_open && _game) { Paint(); } } public static void Draw() { //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: 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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) if (_overlay && !(_alpha <= 0.001f)) { float num = Screen.width; float num2 = Screen.height; if ((Object)(object)_sprite != (Object)null && (Object)(object)_sprite.texture != (Object)null) { GUI.color = new Color(1f, 1f, 1f, _alpha); GUI.DrawTexture(new Rect(0f, 0f, num, num2), (Texture)(object)_sprite.texture, (ScaleMode)1); GUI.color = Color.white; } else { WS_BC.FybCommon.Ui.Fill(new Rect(0f, 0f, num, num2), new Color(0.02f, 0.03f, 0.07f, _alpha)); } WS_BC.FybCommon.Ui.Text(new Rect(0f, num2 * 0.86f, num, num2 * 0.05f), _message, Mathf.RoundToInt(num2 * 0.026f), new Color(1f, 1f, 1f, _alpha), (TextAnchor)4, bold: true, wrap: false); } } } }