Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of BountyBoard v0.1.0
BountyBoard.dll
Decompiled 14 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.IO.Compression; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using LethalLib.Modules; using Microsoft.CodeAnalysis; using ModMenu; using TMPro; using Unity.Collections; using Unity.Netcode; using UnityEngine; using UnityEngine.Rendering; using UnityEngine.Rendering.HighDefinition; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("BountyBoard")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.1.0.0")] [assembly: AssemblyInformationalVersion("0.1.0+18b499c6f808df06b7ff50b14bf2bb30dc33a138")] [assembly: AssemblyProduct("BountyBoard")] [assembly: AssemblyTitle("BountyBoard")] [assembly: AssemblyVersion("0.1.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace BountyBoard { internal static class Art { internal const float W = 1.2f; internal const float H = 0.8f; internal const float D = 0.045f; internal const float CorkZ = 0.028f; internal const float CardW = 0.29f; internal const float CardH = 0.4f; internal const float HeadW = 0.7f; internal const float HeadH = 0.095f; internal static readonly Vector3[] Cards = (Vector3[])(object)new Vector3[3] { new Vector3(0.375f, 0.345f, 2.2f), new Vector3(0f, 0.335f, -1.4f), new Vector3(-0.375f, 0.35f, 1f) }; internal static readonly Vector3 Head = new Vector3(0f, 0.665f, -0.4f); internal static readonly Dictionary<string, Mesh> Meshes = new Dictionary<string, Mesh>(); internal static Texture2D Wood; internal static Texture2D Cork; internal static Texture2D Paper; internal static Texture2D StampPaid; internal static Texture2D StampVoid; internal static AudioClip Stamp; internal static AudioClip Chime; internal static void Load() { try { ReadMeshes(Res("board.bin")); Wood = Tex("wood"); Cork = Tex("cork"); Paper = Tex("paper"); StampPaid = Tex("stamp_paid"); StampVoid = Tex("stamp_void"); Stamp = Wav(Res("stamp.wav"), "BountyBoard_stamp"); Chime = Wav(Res("chime.wav"), "BountyBoard_chime"); } catch (Exception ex) { Plugin.Log.LogError((object)("Bounty Board: art failed to load: " + ex)); } string[] array = new string[5] { "Frame", "Cork", "Card", "Header", "Pin" }; foreach (string text in array) { if (!Meshes.ContainsKey(text)) { Plugin.Log.LogError((object)("Bounty Board: mesh " + text + " missing from board.bin.")); } } } private static Stream Res(string name) { return typeof(Art).Assembly.GetManifestResourceStream("BountyBoard." + name); } private static void ReadMeshes(Stream s) { //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_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_00fc: 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_0137: 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_0150: Expected O, but got Unknown if (s == null) { Plugin.Log.LogError((object)"Bounty Board: board.bin is missing."); return; } using (s) { using GZipStream input = new GZipStream(s, CompressionMode.Decompress); using BinaryReader binaryReader = new BinaryReader(input); if (Encoding.ASCII.GetString(binaryReader.ReadBytes(4)) != "BBD1") { Plugin.Log.LogError((object)"Bounty Board: board.bin isn't BBD1."); return; } int num = binaryReader.ReadInt32(); for (int i = 0; i < num; i++) { string text = Encoding.UTF8.GetString(binaryReader.ReadBytes(binaryReader.ReadInt32())); int num2 = binaryReader.ReadInt32(); int num3 = binaryReader.ReadInt32(); Vector3[] array = (Vector3[])(object)new Vector3[num2]; Vector3[] array2 = (Vector3[])(object)new Vector3[num2]; Vector2[] array3 = (Vector2[])(object)new Vector2[num2]; for (int j = 0; j < num2; j++) { array[j] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); array2[j] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); array3[j] = new Vector2(binaryReader.ReadSingle(), binaryReader.ReadSingle()); } int[] array4 = new int[num3]; for (int k = 0; k < num3; k++) { array4[k] = binaryReader.ReadUInt16(); } Mesh val = new Mesh { name = "BountyBoard." + text }; val.vertices = array; val.normals = array2; val.uv = array3; val.triangles = array4; val.RecalculateBounds(); val.RecalculateTangents(); val.UploadMeshData(true); Meshes[text] = val; } } } private static Texture2D Tex(string name) { //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_0059: 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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Expected O, but got Unknown //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Expected O, but got Unknown using Stream stream = Res(name + ".png"); if (stream == null) { Plugin.Log.LogError((object)("Bounty Board: texture " + name + " is missing.")); return null; } MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); Texture2D val = new Texture2D(2, 2, (TextureFormat)4, true) { name = "BountyBoard." + name, wrapMode = (TextureWrapMode)1, anisoLevel = 4 }; ImageConversion.LoadImage(val, memoryStream.ToArray(), false); ((Texture)val).filterMode = (FilterMode)2; return val; } private static AudioClip Wav(Stream s, string name) { if (s == null) { Plugin.Log.LogError((object)("Bounty Board: sound " + name + " is missing.")); return null; } using (s) { using BinaryReader binaryReader = new BinaryReader(s); binaryReader.ReadBytes(12); int num = 1; int num2 = 44100; int num3 = 16; byte[] array = null; while (binaryReader.BaseStream.Position < binaryReader.BaseStream.Length - 8) { string text = Encoding.ASCII.GetString(binaryReader.ReadBytes(4)); int num4 = binaryReader.ReadInt32(); if (text == "fmt ") { binaryReader.ReadInt16(); num = binaryReader.ReadInt16(); num2 = binaryReader.ReadInt32(); binaryReader.ReadInt32(); binaryReader.ReadInt16(); num3 = binaryReader.ReadInt16(); if (num4 > 16) { binaryReader.ReadBytes(num4 - 16); } } else { if (text == "data") { array = binaryReader.ReadBytes(num4); break; } binaryReader.ReadBytes(num4); } } if (array == null || num3 != 16) { Plugin.Log.LogError((object)("Bounty Board: sound " + name + " isn't 16-bit PCM.")); return null; } int num5 = array.Length / 2; float[] array2 = new float[num5]; for (int i = 0; i < num5; i++) { array2[i] = (float)BitConverter.ToInt16(array, i * 2) / 32768f; } AudioClip obj = AudioClip.Create(name, num5 / num, num, num2, false); obj.SetData(array2, 0); return obj; } } } internal static class Board { private sealed class Canvas2 { internal GameObject Root; internal Camera Cam; internal RenderTexture Rt; internal Transform C; internal int W; internal int H; } private struct Avoid { public Vector3 P; public float R; public string Name; } private const int Layer = 5; private static readonly Vector3 Spot = new Vector3(0f, 3300f, 0f); private const float FaceW = 512f; private const float FaceH = 706.2069f; internal static GameObject Root; private static Vector3 _builtPos; private static Vector3 _builtNormal; private static readonly MeshRenderer[] _cards = (MeshRenderer[])(object)new MeshRenderer[3]; private static MeshRenderer _head; private static AudioSource _audio; private static readonly Texture2D[] _faceTex = (Texture2D[])(object)new Texture2D[4]; private static readonly string[] _faceKey = new string[4]; private static readonly string[] _wantKey = new string[4]; private static float _chimeAt = -1f; internal static string Where = ""; private static int _shownDay; private static CardState[] _shownStates = new CardState[0]; private static readonly Color Ink = new Color(0.11f, 0.11f, 0.15f); private static readonly Color Red = new Color(0.55f, 0.07f, 0.05f); private static GameObject _hullSeen; private static bool _hullKnown; private static float _nextProbe; private static float _nextValidate; internal static bool Built => (Object)(object)Root != (Object)null; private static int Walls => LayerMask.GetMask(new string[3] { "Room", "Colliders", "Default" }); private static int Obstacles => Walls | LayerMask.GetMask(new string[5] { "InteractableObject", "PlaceableShipObjects", "Props", "Railing", "PlacementBlocker" }); internal static void Remove() { if ((Object)(object)Root != (Object)null) { Object.Destroy((Object)(object)Root); } Root = null; for (int i = 0; i < 4; i++) { _faceKey[i] = null; if ((Object)(object)_faceTex[i] != (Object)null) { Object.Destroy((Object)(object)_faceTex[i]); } _faceTex[i] = null; } } internal static void Received(BoardState s) { if (s.Day != 0 && s.Day == _shownDay) { for (int i = 0; i < s.Cards.Count && i < _shownStates.Length; i++) { Contract contract = s.Cards[i]; if (_shownStates[i] == CardState.Open && contract.State != CardState.Open) { if (contract.State == CardState.Paid) { PlayStamp(); Tip("CONTRACT PAID", $"{contract.Title}: +${contract.Reward}"); } else { Tip("CONTRACT VOID", contract.Title); } } } } _shownDay = s.Day; _shownStates = s.Cards.Select((Contract c) => c.State).ToArray(); } private static void Tip(string head, string body) { if (!Plugin.Tips.Value || (Object)(object)HUDManager.Instance == (Object)null || !Store.Unlocked) { return; } try { HUDManager.Instance.DisplayTip(head, body, false, false, "LC_Tip1"); } catch (Exception) { } } private static void PlayStamp() { if (!((Object)(object)_audio == (Object)null) && !((Object)(object)Art.Stamp == (Object)null)) { _audio.PlayOneShot(Art.Stamp, 0.9f * Plugin.Volume.Value); _chimeAt = Time.time + 0.32f; } } internal static void Tick() { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) BoardState state = Contracts.State; StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance == (Object)null || (Object)(object)instance.elevatorTransform == (Object)null) { return; } if (!state.HasSpot) { if (Built) { Remove(); } return; } if (Built) { Vector3 val = state.Pos - _builtPos; if (!(((Vector3)(ref val)).sqrMagnitude > 1E-06f)) { val = state.Normal - _builtNormal; if (!(((Vector3)(ref val)).sqrMagnitude > 1E-06f)) { goto IL_0085; } } } Build(instance, state); goto IL_0085; IL_0085: if (!Built) { return; } if (_chimeAt > 0f && Time.time >= _chimeAt) { _chimeAt = -1f; if ((Object)(object)Art.Chime != (Object)null) { _audio.PlayOneShot(Art.Chime, 0.8f * Plugin.Volume.Value); } } _wantKey[3] = ((state.Day == 0) ? "none" : ("day|" + state.Moon)); for (int i = 0; i < 3; i++) { Contract contract = ((i < state.Cards.Count) ? state.Cards[i] : null); _wantKey[i] = ((contract == null) ? null : $"{state.Day}|{contract.Kind}|{contract.Target}|{contract.Need}|{contract.Reward}|{contract.Deadline}|{contract.State}|{contract.Progress}"); ((Component)_cards[i]).gameObject.SetActive(contract != null); } for (int j = 0; j < 4; j++) { if (_wantKey[j] != null && !(_wantKey[j] == _faceKey[j])) { _faceKey[j] = _wantKey[j]; Texture2D val2 = _faceTex[j]; _faceTex[j] = ((j == 3) ? RenderHeader(state) : RenderCard(state.Cards[j], state.Day, j)); SetMap(((Renderer)((j == 3) ? _head : _cards[j])).sharedMaterial, (Texture)(object)_faceTex[j]); if ((Object)(object)val2 != (Object)null) { Object.Destroy((Object)(object)val2); } break; } } } private static void Build(StartOfRound sor, BoardState s) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown //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_0048: 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_005b: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: 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_00e8: 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_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_01bf: 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_0208: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_022a: 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_027c: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: 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_02e1: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_040e: Unknown result type (might be due to invalid IL or missing references) //IL_0413: 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_0429: 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_0369: Unknown result type (might be due to invalid IL or missing references) Remove(); if (Art.Meshes.ContainsKey("Frame")) { Transform elevatorTransform = sor.elevatorTransform; GameObject val = new GameObject("BountyBoard.Board"); val.transform.SetParent(elevatorTransform, false); Vector3 normalized = ((Vector3)(ref s.Normal)).normalized; Quaternion val2 = Quaternion.LookRotation(normalized, Vector3.up); val.transform.localRotation = val2; val.transform.localPosition = s.Pos + normalized * 0.004f - val2 * new Vector3(0f, 0.4f, 0f); Material src = LitSource(sor); Part(val.transform, "Frame", Art.Meshes["Frame"], Mat(src, "Frame", (Texture)(object)Art.Wood, Color.white, 0.25f), Vector3.zero, 0f); Part(val.transform, "Cork", Art.Meshes["Cork"], Mat(src, "Cork", (Texture)(object)Art.Cork, Color.white, 0.05f), Vector3.zero, 0f); Material[] array = ((IEnumerable<Color>)(object)new Color[3] { new Color(0.7f, 0.05f, 0.04f), new Color(0.85f, 0.65f, 0.05f), new Color(0.08f, 0.25f, 0.7f) }).Select((Color c, int i) => Mat(src, "Pin" + i, null, c, 0.65f)).ToArray(); for (int num = 0; num < 3; num++) { Vector3 val3 = Art.Cards[num]; GameObject val4 = Part(val.transform, "Card" + num, Art.Meshes["Card"], Mat(src, "Card" + num, (Texture)(object)Art.Paper, Color.white, 0.1f), new Vector3(val3.x, val3.y, 0.028600002f), 0f - val3.z); _cards[num] = val4.GetComponent<MeshRenderer>(); Part(val4.transform, "Pin", Art.Meshes["Pin"], array[num], new Vector3(0f, 0.172f, 0.0012f), 0f); } Vector3 head = Art.Head; GameObject val5 = Part(val.transform, "Header", Art.Meshes["Header"], Mat(src, "Header", (Texture)(object)Art.Paper, Color.white, 0.1f), new Vector3(head.x, head.y, 0.028600002f), 0f - head.z); _head = val5.GetComponent<MeshRenderer>(); float[] array2 = new float[2] { -0.32f, 0.32f }; foreach (float num3 in array2) { Part(val5.transform, "Pin", Art.Meshes["Pin"], array[(!(num3 < 0f)) ? 2 : 0], new Vector3(0f - num3, 0.019499999f, 0.0012f), 0f); } _audio = val.AddComponent<AudioSource>(); _audio.playOnAwake = false; _audio.spatialBlend = 1f; _audio.rolloffMode = (AudioRolloffMode)1; _audio.minDistance = 2f; _audio.maxDistance = 28f; _audio.dopplerLevel = 0f; if ((Object)(object)sor.ship3DAudio != (Object)null) { _audio.outputAudioMixerGroup = sor.ship3DAudio.outputAudioMixerGroup; } Root = val; _builtPos = s.Pos; _builtNormal = s.Normal; Plugin.Debug($"board up at ship {s.Pos} facing {s.Normal}"); } } private static GameObject Part(Transform parent, string name, Mesh mesh, Material mat, Vector3 local, float zDeg) { //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_0020: 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_003c: 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_005c: Expected O, but got Unknown GameObject val = new GameObject(name); val.transform.SetParent(parent, false); val.transform.localPosition = local; val.transform.localRotation = Quaternion.Euler(0f, 0f, zDeg); val.AddComponent<MeshFilter>().sharedMesh = mesh; MeshRenderer obj = val.AddComponent<MeshRenderer>(); ((Renderer)obj).sharedMaterial = mat; ((Renderer)obj).shadowCastingMode = (ShadowCastingMode)1; return val; } private static Material LitSource(StartOfRound sor) { //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Expected O, but got Unknown ManualCameraRenderer ms = sor.mapScreen; if ((Object)(object)ms != (Object)null && (Object)(object)ms.mesh != (Object)null) { Material val = ((Renderer)ms.mesh).sharedMaterials.Where((Material x, int i) => i != ms.materialIndex && (Object)(object)x != (Object)null && (Object)(object)x.shader != (Object)null && ((Object)x.shader).name.Contains("Lit") && !((Object)x.shader).name.Contains("Unlit")).FirstOrDefault(); if ((Object)(object)val != (Object)null) { return val; } } Material val2 = (from r in ((Component)sor.elevatorTransform).GetComponentsInChildren<MeshRenderer>(true) select ((Renderer)r).sharedMaterial).FirstOrDefault((Func<Material, bool>)((Material x) => (Object)(object)x != (Object)null && (Object)(object)x.shader != (Object)null && ((Object)x.shader).name == "HDRP/Lit")); if ((Object)(object)val2 != (Object)null) { return val2; } Shader val3 = Shader.Find("HDRP/Lit"); if (!((Object)(object)val3 != (Object)null)) { return null; } return new Material(val3); } private static Material Mat(Material src, string name, Texture tex, Color tint, float smooth) { //IL_001b: 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_0021: Expected O, but got Unknown //IL_00fa: 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_0130: Unknown result type (might be due to invalid IL or missing references) Material val = (((Object)(object)src != (Object)null) ? new Material(src) : new Material(Shader.Find("Standard"))); ((Object)val).name = "BountyBoard." + name; string[] array = new string[7] { "_NORMALMAP", "_NORMALMAP_TANGENT_SPACE", "_MASKMAP", "_DETAIL_MAP", "_EMISSIVE_COLOR_MAP", "_BENTNORMALMAP", "_HEIGHTMAP" }; foreach (string text in array) { val.DisableKeyword(text); } array = new string[6] { "_NormalMap", "_MaskMap", "_DetailMap", "_EmissiveColorMap", "_BentNormalMap", "_HeightMap" }; foreach (string text2 in array) { if (val.HasProperty(text2)) { val.SetTexture(text2, (Texture)null); } } if (val.HasProperty("_EmissiveColor")) { val.SetColor("_EmissiveColor", Color.black); } if (val.HasProperty("_BaseColor")) { val.SetColor("_BaseColor", tint); } if (val.HasProperty("_Color")) { val.SetColor("_Color", tint); } if (val.HasProperty("_Metallic")) { val.SetFloat("_Metallic", 0f); } if (val.HasProperty("_Smoothness")) { val.SetFloat("_Smoothness", smooth); } SetMap(val, tex); return val; } private static void SetMap(Material mat, Texture tex) { if (!((Object)(object)mat == (Object)null)) { if (mat.HasProperty("_BaseColorMap")) { mat.SetTexture("_BaseColorMap", tex); } if (mat.HasProperty("_MainTex")) { mat.SetTexture("_MainTex", tex); } } } private static TMP_FontAsset Font() { StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance != (Object)null && (Object)(object)instance.screenLevelDescription != (Object)null && (Object)(object)((TMP_Text)instance.screenLevelDescription).font != (Object)null) { return ((TMP_Text)instance.screenLevelDescription).font; } Terminal val = Object.FindObjectOfType<Terminal>(); if ((Object)(object)val != (Object)null && (Object)(object)val.screenText != (Object)null && (Object)(object)val.screenText.textComponent != (Object)null) { return val.screenText.textComponent.font; } return TMP_Settings.defaultFontAsset; } private static Canvas2 Begin(int w, int h) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown //IL_0052: 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_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_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_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Expected O, but got Unknown //IL_0156: Unknown result type (might be due to invalid IL or missing references) Canvas2 canvas = new Canvas2 { W = w, H = h }; canvas.Rt = new RenderTexture(w, h, 24, (RenderTextureFormat)0); canvas.Rt.Create(); canvas.Root = new GameObject("BountyBoard.Face") { layer = 5 }; canvas.Root.transform.position = Spot; Camera val = (canvas.Cam = canvas.Root.AddComponent<Camera>()); ((Behaviour)val).enabled = false; val.clearFlags = (CameraClearFlags)2; val.backgroundColor = new Color(0.9f, 0.86f, 0.76f); val.cullingMask = 32; val.orthographic = true; val.orthographicSize = 1f; val.nearClipPlane = 0.01f; val.farClipPlane = 10f; val.targetTexture = canvas.Rt; HDAdditionalCameraData obj = canvas.Root.AddComponent<HDAdditionalCameraData>(); obj.clearColorMode = (ClearColorMode)1; obj.backgroundColorHDR = val.backgroundColor; obj.volumeLayerMask = LayerMask.op_Implicit(0); GameObject val2 = new GameObject("Canvas") { layer = 5 }; val2.transform.SetParent(canvas.Root.transform, false); Canvas obj2 = val2.AddComponent<Canvas>(); obj2.renderMode = (RenderMode)1; obj2.worldCamera = val; obj2.planeDistance = 1f; CanvasScaler obj3 = val2.AddComponent<CanvasScaler>(); obj3.uiScaleMode = (ScaleMode)1; obj3.referenceResolution = new Vector2((float)w, (float)h); canvas.C = val2.transform; return canvas; } private static Texture2D End(Canvas2 k, string name) { //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_0093: 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_00a1: 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_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_0108: Expected O, but got Unknown Transform[] componentsInChildren = k.Root.GetComponentsInChildren<Transform>(true); for (int i = 0; i < componentsInChildren.Length; i++) { ((Component)componentsInChildren[i]).gameObject.layer = 5; } Canvas.ForceUpdateCanvases(); TextMeshProUGUI[] componentsInChildren2 = k.Root.GetComponentsInChildren<TextMeshProUGUI>(); for (int i = 0; i < componentsInChildren2.Length; i++) { ((TMP_Text)componentsInChildren2[i]).ForceMeshUpdate(false, false); } k.Cam.Render(); k.Cam.Render(); RenderTexture active = RenderTexture.active; RenderTexture.active = k.Rt; Texture2D val = new Texture2D(k.W, k.H, (TextureFormat)3, true) { name = name, filterMode = (FilterMode)2, anisoLevel = 8, wrapMode = (TextureWrapMode)1 }; val.ReadPixels(new Rect(0f, 0f, (float)k.W, (float)k.H), 0, 0); val.Apply(true); RenderTexture.active = active; k.Cam.targetTexture = null; k.Rt.Release(); Object.Destroy((Object)(object)k.Rt); Object.Destroy((Object)(object)k.Root); return val; } private static void Paper(Canvas2 k, int seed, float aspect) { //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_002b: 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_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_0049: 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_0062: 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_0084: 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_0136: 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) Random random = new Random(seed); GameObject val = new GameObject("Paper", new Type[1] { typeof(RectTransform) }) { layer = 5 }; val.transform.SetParent(k.C, false); RectTransform val2 = (RectTransform)val.transform; Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor(0.5f, 0.5f); val2.anchorMax = val3; val2.anchorMin = val3; val2.sizeDelta = new Vector2((float)k.W * 1.12f, (float)k.H * 1.12f); ((Transform)val2).localRotation = Quaternion.Euler(0f, 0f, (float)(random.NextDouble() * 4.0 - 2.0)); RawImage obj = val.AddComponent<RawImage>(); obj.texture = (Texture)(object)Art.Paper; float num = 0.55f + 0.2f * (float)random.NextDouble(); float num2 = Mathf.Min(0.98f, num * aspect); bool flag = random.Next(2) == 0; float num3 = (float)random.NextDouble() * (1f - num); float num4 = (float)random.NextDouble() * (1f - num2); obj.uvRect = (flag ? new Rect(num3 + num, num4, 0f - num, num2) : new Rect(num3, num4, num, num2)); ((Graphic)obj).raycastTarget = false; } private static TextMeshProUGUI Text(Transform c, string text, float size, Color col, TextAlignmentOptions align, float y, float w, float h, float minSize, FontStyles style = (FontStyles)0) { //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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_0066: 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_0079: 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_00c6: 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_00d5: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Text", new Type[1] { typeof(RectTransform) }) { layer = 5 }; val.transform.SetParent(c, false); RectTransform val2 = (RectTransform)val.transform; Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor(0.5f, 1f); val2.anchorMax = val3; val2.anchorMin = val3; val2.pivot = new Vector2(0.5f, 1f); val2.anchoredPosition = new Vector2(0f, 0f - y); val2.sizeDelta = new Vector2(w, h); TextMeshProUGUI obj = val.AddComponent<TextMeshProUGUI>(); ((TMP_Text)obj).font = Font(); ((TMP_Text)obj).text = text; ((TMP_Text)obj).fontSize = size; ((TMP_Text)obj).enableAutoSizing = true; ((TMP_Text)obj).fontSizeMin = minSize; ((TMP_Text)obj).fontSizeMax = size; ((Graphic)obj).color = col; ((TMP_Text)obj).alignment = align; ((TMP_Text)obj).fontStyle = style; ((TMP_Text)obj).enableWordWrapping = true; ((TMP_Text)obj).overflowMode = (TextOverflowModes)3; ((Graphic)obj).raycastTarget = false; return obj; } private static void Rule(Transform c, float y, float w, Color col) { //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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_0066: 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_0078: 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_0098: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Rule", new Type[1] { typeof(RectTransform) }) { layer = 5 }; val.transform.SetParent(c, false); RectTransform val2 = (RectTransform)val.transform; Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor(0.5f, 1f); val2.anchorMax = val3; val2.anchorMin = val3; val2.pivot = new Vector2(0.5f, 1f); val2.anchoredPosition = new Vector2(0f, 0f - y); val2.sizeDelta = new Vector2(w, 4f); Image obj = val.AddComponent<Image>(); ((Graphic)obj).color = col; ((Graphic)obj).raycastTarget = false; } private static Texture2D RenderCard(Contract c, int day, int slot) { //IL_0050: 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_0090: 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_0111: 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_0182: 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_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_022d: 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_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0245: 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_0258: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_0313: Unknown result type (might be due to invalid IL or missing references) //IL_033f: Unknown result type (might be due to invalid IL or missing references) int num = 512; int num2 = Mathf.RoundToInt(706.2069f); Canvas2 canvas = Begin(num, num2); Paper(canvas, day * 31 + slot * 977 + (int)c.Kind, (float)num2 / (float)num); Transform c2 = canvas.C; float num3 = num - 56; Text(c2, "THE COMPANY - CONTRACT", 24f, Red, (TextAlignmentOptions)514, 30f, num3, 30f, 16f, (FontStyles)1); Rule(c2, 66f, num3, Red); Text(c2, c.Title, 54f, Ink, (TextAlignmentOptions)514, 84f, num3, 70f, 30f, (FontStyles)1); Text(c2, c.Task, 40f, Ink, (TextAlignmentOptions)258, 176f, num3, 250f, 24f, (FontStyles)0); Rule(c2, 446f, num3 * 0.7f, new Color(Ink.r, Ink.g, Ink.b, 0.5f)); Text(c2, (c.State == CardState.Open) ? c.Progress : ((c.State == CardState.Paid) ? "settled" : "not met"), 32f, new Color(0.25f, 0.25f, 0.3f), (TextAlignmentOptions)514, 466f, num3, 44f, 20f, (FontStyles)2); Text(c2, "REWARD", 26f, Red, (TextAlignmentOptions)514, num2 - 186, num3, 34f, 18f, (FontStyles)1); Text(c2, $"${c.Reward}", 80f, Ink, (TextAlignmentOptions)514, num2 - 152, num3, 96f, 40f, (FontStyles)1); if (c.State != CardState.Open) { Texture2D texture = ((c.State == CardState.Paid) ? Art.StampPaid : Art.StampVoid); GameObject val = new GameObject("Stamp", new Type[1] { typeof(RectTransform) }) { layer = 5 }; val.transform.SetParent(c2, false); RectTransform val2 = (RectTransform)val.transform; Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor(0.5f, 0.5f); val2.anchorMax = val3; val2.anchorMin = val3; Random random = new Random(day * 13 + slot); val2.anchoredPosition = new Vector2((float)(random.NextDouble() * 40.0 - 20.0), -40f + (float)(random.NextDouble() * 40.0 - 20.0)); val2.sizeDelta = new Vector2((float)num * 0.86f, (float)num * 0.86f * 300f / 640f); ((Transform)val2).localRotation = Quaternion.Euler(0f, 0f, (float)(random.NextDouble() * 14.0 + 8.0) * (float)((slot != 1) ? 1 : (-1))); RawImage obj = val.AddComponent<RawImage>(); obj.texture = (Texture)(object)texture; ((Graphic)obj).color = new Color(1f, 1f, 1f, 0.92f); ((Graphic)obj).raycastTarget = false; } return End(canvas, "BountyBoard.Card" + slot); } private static Texture2D RenderHeader(BoardState s) { //IL_0053: 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) int num = 1024; int num2 = Mathf.RoundToInt(138.97144f); Canvas2 canvas = Begin(num, num2); Paper(canvas, s.Day * 7 + 5, (float)num2 / (float)num); string text = ((s.Day == 0) ? "" : s.Moon); Text(canvas.C, "COMPANY BOUNTIES", 64f, Red, (TextAlignmentOptions)514, 6f, num - 60, 76f, 30f, (FontStyles)1); Text(canvas.C, (s.Day == 0) ? "contracts are pinned when you land" : text.ToUpperInvariant(), 34f, Ink, (TextAlignmentOptions)514, 84f, num - 60, 46f, 18f, (FontStyles)0); return End(canvas, "BountyBoard.Header"); } internal static bool HostCheckSpot(BoardState s) { //IL_0118: 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_011f: 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) StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance == (Object)null || (Object)(object)instance.elevatorTransform == (Object)null || (Object)(object)instance.shipInnerRoomBounds == (Object)null) { return false; } GameObject hull = Hooks.Hull; if (!_hullKnown) { _hullSeen = hull; _hullKnown = true; } if ((Object)(object)hull != (Object)(object)_hullSeen) { _hullSeen = hull; Plugin.Log.LogInfo((object)"Bounty Board: the ship's hull changed; finding the board a wall again."); _nextProbe = Time.time + 2f; if (s.HasSpot) { s.HasSpot = false; return true; } return false; } if (s.HasSpot) { if (Time.time < _nextValidate) { return false; } _nextValidate = Time.time + 5f; if (StillWall(instance, s)) { return false; } Plugin.Log.LogInfo((object)"Bounty Board: the board's wall is gone; finding another."); s.HasSpot = false; _nextProbe = Time.time + 2f; return true; } if (Time.time < _nextProbe) { return false; } _nextProbe = Time.time + 5f; if (!FindSpot(instance, out var pos, out var normal)) { return false; } s.HasSpot = true; s.Pos = pos; s.Normal = normal; _nextValidate = Time.time + 5f; return true; } internal static void OnSessionStart() { _hullKnown = false; _nextProbe = 0f; _nextValidate = 0f; _shownDay = 0; _shownStates = new CardState[0]; } private static bool StillWall(StartOfRound sor, BoardState s) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: 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_001e: 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_0026: 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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) Transform elevatorTransform = sor.elevatorTransform; Vector3 val = elevatorTransform.TransformPoint(s.Pos); Vector3 val2 = elevatorTransform.TransformDirection(s.Normal); Vector3 normalized = ((Vector3)(ref val2)).normalized; RaycastHit val3 = default(RaycastHit); if (Physics.Raycast(val + normalized * 0.5f, -normalized, ref val3, 0.6f, Walls, (QueryTriggerInteraction)1)) { return Mathf.Abs(Vector3.Dot(((RaycastHit)(ref val3)).point - val, normalized)) < 0.04f; } return false; } private static List<Avoid> AvoidPoints(StartOfRound sor) { //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_0224: 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_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) //IL_01aa: 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_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) //IL_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) List<Avoid> list = new List<Avoid>(); Add((Component)(object)Object.FindObjectOfType<HangarShipDoor>(), 2.2f, "door"); Add((Component)(object)Object.FindObjectOfType<Terminal>(), 1.5f, "terminal"); Add((Component)(object)Object.FindObjectOfType<StartMatchLever>(), 1.3f, "lever"); Add((Component)(object)Object.FindObjectOfType<ItemCharger>(), 1f, "charger"); ShipTeleporter[] array = Object.FindObjectsOfType<ShipTeleporter>(); for (int i = 0; i < array.Length; i++) { Add((Component)(object)array[i], 1f, "teleporter"); } UnlockableSuit[] array2 = Object.FindObjectsOfType<UnlockableSuit>(); for (int i = 0; i < array2.Length; i++) { Add((Component)(object)array2[i], 1.1f, "suit rack"); } PlaceableShipObject[] array3 = Object.FindObjectsOfType<PlaceableShipObject>(); foreach (PlaceableShipObject val in array3) { if ((Object)(object)val != (Object)null && ((object)val).GetType().Name == "GunRackMount") { Add((Component)(object)val, 1.3f, "gun rack"); } } GameObject val2 = GameObject.Find("CrewAwards.Plaque"); if ((Object)(object)val2 != (Object)null) { list.Add(new Avoid { P = val2.transform.position, R = 1.1f, Name = "plaque" }); } ManualCameraRenderer mapScreen = sor.mapScreen; Bounds bounds; if ((Object)(object)mapScreen != (Object)null && (Object)(object)mapScreen.mesh != (Object)null) { List<Avoid> list2 = list; Avoid item = default(Avoid); bounds = ((Renderer)mapScreen.mesh).bounds; item.P = ((Bounds)(ref bounds)).center; bounds = ((Renderer)mapScreen.mesh).bounds; Vector3 extents = ((Bounds)(ref bounds)).extents; item.R = Mathf.Max(1.6f, ((Vector3)(ref extents)).magnitude + 0.8f); item.Name = "monitors"; list2.Add(item); } if ((Object)(object)sor.screenLevelDescription != (Object)null) { list.Add(new Avoid { P = ((TMP_Text)sor.screenLevelDescription).transform.position, R = 1.2f, Name = "monitors" }); } ManualCameraRenderer securityCameraScreen = sor.securityCameraScreen; if ((Object)(object)securityCameraScreen != (Object)null && (Object)(object)securityCameraScreen.mesh != (Object)null) { List<Avoid> list3 = list; Avoid item = default(Avoid); bounds = ((Renderer)securityCameraScreen.mesh).bounds; item.P = ((Bounds)(ref bounds)).center; item.R = 1.2f; item.Name = "monitors"; list3.Add(item); } return list; void Add(Component c, float r, string name) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)c != (Object)null) { list.Add(new Avoid { P = c.transform.position, R = r, Name = name }); } } } private static bool FindSpot(StartOfRound sor, out Vector3 pos, out Vector3 normal) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_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_0011: 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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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_0060: 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_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_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_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_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: 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_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_0107: 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_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: 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_0141: Unknown result type (might be due to invalid IL or missing references) //IL_014f: 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_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_05ad: Unknown result type (might be due to invalid IL or missing references) //IL_05b2: Unknown result type (might be due to invalid IL or missing references) //IL_05b7: Unknown result type (might be due to invalid IL or missing references) //IL_05bf: Unknown result type (might be due to invalid IL or missing references) //IL_05c4: Unknown result type (might be due to invalid IL or missing references) //IL_05c9: 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_01fc: 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_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_0219: 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_022f: 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_0246: 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) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_026d: 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_0276: Unknown result type (might be due to invalid IL or missing references) //IL_027b: 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_0294: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: 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_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_02c2: Unknown result type (might be due to invalid IL or missing references) //IL_02da: 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_02f8: Unknown result type (might be due to invalid IL or missing references) //IL_02fd: Unknown result type (might be due to invalid IL or missing references) //IL_0304: 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_030e: Unknown result type (might be due to invalid IL or missing references) //IL_0312: Unknown result type (might be due to invalid IL or missing references) //IL_031b: Unknown result type (might be due to invalid IL or missing references) //IL_032c: Unknown result type (might be due to invalid IL or missing references) //IL_0331: Unknown result type (might be due to invalid IL or missing references) //IL_034c: Unknown result type (might be due to invalid IL or missing references) //IL_0351: Unknown result type (might be due to invalid IL or missing references) //IL_0358: 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_0362: Unknown result type (might be due to invalid IL or missing references) //IL_0373: 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_037d: Unknown result type (might be due to invalid IL or missing references) //IL_03e5: Unknown result type (might be due to invalid IL or missing references) //IL_03ec: Unknown result type (might be due to invalid IL or missing references) //IL_047c: Unknown result type (might be due to invalid IL or missing references) //IL_0481: 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_0489: Unknown result type (might be due to invalid IL or missing references) //IL_0493: Unknown result type (might be due to invalid IL or missing references) Vector3 val = (pos = (normal = Vector3.zero)); Transform elevatorTransform = sor.elevatorTransform; Bounds bounds = sor.shipInnerRoomBounds.bounds; int walls = Walls; int obstacles = Obstacles; RaycastHit val2 = default(RaycastHit); float num = (Physics.Raycast(((Bounds)(ref bounds)).center, Vector3.down, ref val2, ((Bounds)(ref bounds)).extents.y + 2f, walls, (QueryTriggerInteraction)1) ? ((RaycastHit)(ref val2)).point.y : ((Bounds)(ref bounds)).min.y); List<Avoid> list = AvoidPoints(sor); Bounds val3 = bounds; ((Bounds)(ref val3)).Expand(0.8f); float num2 = float.NegativeInfinity; int num3 = 0; int num4 = 0; int num5 = 0; int num6 = 0; int num7 = 0; string text = ""; Vector3[] array = (Vector3[])(object)new Vector3[4] { elevatorTransform.forward, -elevatorTransform.forward, elevatorTransform.right, -elevatorTransform.right }; RaycastHit val5 = default(RaycastHit); Vector3 val9 = default(Vector3); foreach (Vector3 val4 in array) { val = new Vector3(val4.x, 0f, val4.z); Vector3 normalized = ((Vector3)(ref val)).normalized; val = Vector3.Cross(Vector3.up, normalized); Vector3 normalized2 = ((Vector3)(ref val)).normalized; float num8 = Mathf.Abs(normalized2.x) * ((Bounds)(ref bounds)).extents.x + Mathf.Abs(normalized2.z) * ((Bounds)(ref bounds)).extents.z; float num9 = Mathf.Abs(normalized.x) * ((Bounds)(ref bounds)).extents.x + Mathf.Abs(normalized.z) * ((Bounds)(ref bounds)).extents.z + 1.5f; for (float num10 = 0f - num8 + 0.6f; num10 <= num8 - 0.6f + 0.001f; num10 += 0.2f) { float[] array2 = new float[3] { 1.55f, 1.4f, 1.7f }; foreach (float num11 in array2) { num3++; if (!Physics.Raycast(new Vector3(((Bounds)(ref bounds)).center.x, num + num11, ((Bounds)(ref bounds)).center.z) + normalized2 * num10, normalized, ref val5, num9, walls, (QueryTriggerInteraction)1) || Vector3.Dot(((RaycastHit)(ref val5)).normal, -normalized) < 0.95f || !((Bounds)(ref val3)).Contains(((RaycastHit)(ref val5)).point)) { num4++; continue; } Vector3 val6 = -normalized; Quaternion val7 = Quaternion.LookRotation(val6, Vector3.up); if (!Flat(((RaycastHit)(ref val5)).point, val6, val7, walls)) { num5++; continue; } Vector3 val8 = ((RaycastHit)(ref val5)).point + val6 * 0.114999995f; ((Vector3)(ref val9))..ctor(0.63f, 0.43f, 0.08f); if (Physics.CheckBox(val8, val9, val7, obstacles, (QueryTriggerInteraction)1)) { num6++; continue; } Vector3 val10 = new Vector3(((RaycastHit)(ref val5)).point.x, num + 1.1f, ((RaycastHit)(ref val5)).point.z) + val6 * 0.8f; if (!((Bounds)(ref bounds)).Contains(val10) || Physics.CheckBox(val10, new Vector3(0.3f, 0.5f, 0.3f), val7, obstacles, (QueryTriggerInteraction)1)) { num6++; continue; } bool flag = false; Collider[] array3 = Physics.OverlapBox(((RaycastHit)(ref val5)).point + val6 * 0.3f, val9 + new Vector3(0f, 0f, 0.3f), val7, -1, (QueryTriggerInteraction)2); for (int k = 0; k < array3.Length; k++) { if ((Object)(object)((Component)array3[k]).GetComponentInParent<InteractTrigger>() != (Object)null) { flag = true; break; } } if (flag) { num6++; continue; } float num12 = 3f; string text2 = ""; foreach (Avoid item in list) { float num13 = Vector3.Distance(item.P, ((RaycastHit)(ref val5)).point) - item.R - 0.6f; if (num13 < num12) { num12 = num13; text2 = item.Name; } } if (num12 < 0f) { num7++; text = text2; continue; } float num14 = Mathf.Min(num12, 2.5f) - 0.6f * Mathf.Abs(num11 - 1.55f); if (num14 > num2 + 0.0001f) { num2 = num14; pos = ((RaycastHit)(ref val5)).point; normal = val6; Where = $"wall facing {val6}, {num12:0.0} m clear of the {text2}"; } } } } Plugin.Debug($"wall probe: {num3} tried, no wall {num4}, not flat {num5}, blocked {num6}, too near {num7} ({text})"); if (float.IsNegativeInfinity(num2)) { Plugin.Log.LogWarning((object)$"Bounty Board: no clear wall for the board yet (probed {num3}: no wall {num4}, not flat {num5}, blocked {num6}, too near a fixture {num7})."); return false; } Plugin.Log.LogInfo((object)("Bounty Board: board on the " + Where)); pos = elevatorTransform.InverseTransformPoint(pos); normal = elevatorTransform.InverseTransformDirection(normal); return true; } private static bool Flat(Vector3 at, Vector3 n, Quaternion face, int walls) { //IL_000e: 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_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_0034: 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_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) //IL_0045: 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) //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) RaycastHit val = default(RaycastHit); for (int i = -1; i <= 1; i++) { for (int j = -1; j <= 1; j++) { if (!Physics.Raycast(at + face * new Vector3((float)i * 0.59000003f, (float)j * 0.39000002f, 0f) + n * 0.5f, -n, ref val, 0.8f, walls, (QueryTriggerInteraction)1)) { return false; } if (Mathf.Abs(Vector3.Dot(((RaycastHit)(ref val)).point - at, n)) > 0.03f || Vector3.Dot(((RaycastHit)(ref val)).normal, n) < 0.9f) { return false; } } } return true; } internal static string Refit() { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) BoardState state = Contracts.State; StartOfRound instance = StartOfRound.Instance; if (!Net.IsHost || (Object)(object)instance == (Object)null) { return null; } if (!FindSpot(instance, out var pos, out var normal)) { return "no clear wall found (see the log)"; } state.HasSpot = true; state.Pos = pos; state.Normal = normal; Net.Broadcast(); return "board on the " + Where; } } internal enum Kind : byte { Scan, Heavy, Early, Vault, Collect } internal enum CardState : byte { Open, Paid, Void } internal sealed class Contract { public Kind Kind; public string Target = ""; public int Need; public int Have; public int Reward; public int Deadline; public CardState State; public string Title => Kind switch { Kind.Scan => "SPECIMEN SCAN", Kind.Heavy => "HEAVY HAUL", Kind.Early => "EARLY DEPARTURE", Kind.Vault => "VAULT JOB", _ => "COLLECTION ORDER", }; public string Task => Kind switch { Kind.Scan => "Scan a " + Target + " with your scanner.", Kind.Heavy => $"Bring {Need} pieces of Heavy Scrap aboard.", Kind.Early => $"Take off before {Contracts.Clock(Deadline)} with ${Need} of new scrap aboard.", Kind.Vault => "Open the Vault on this moon.", _ => $"Bring {Need} {Plural(Target, Need)} aboard.", }; public string Progress => Kind switch { Kind.Scan => (Have > 0) ? "scanned" : "not scanned yet", Kind.Vault => (Have > 0) ? "open" : "still sealed", Kind.Early => $"${Have} / ${Need} aboard", _ => $"{Mathf.Min(Have, Need)} / {Need} aboard", }; private static string Plural(string name, int n) { if (n != 1 && !name.EndsWith("s")) { return name + "s"; } return name; } } internal sealed class BoardState { public int Rev; public int Day; public string Moon = ""; public List<Contract> Cards = new List<Contract>(); public bool HasSpot; public Vector3 Pos; public Vector3 Normal; } [HarmonyPatch] internal static class Contracts { internal static BoardState State = new BoardState(); private static readonly HashSet<ulong> Baseline = new HashSet<ulong>(); private static int _pinnedSeed = int.MinValue; private static bool _wasLanded; internal static void OnSessionStart() { State = new BoardState(); Baseline.Clear(); _pinnedSeed = int.MinValue; _wasLanded = false; } internal static string Clock(int minutes) { int num = minutes / 60 % 24; int num2 = minutes % 60; int num3 = ((num % 12 == 0) ? 12 : (num % 12)); return string.Format("{0}:{1:00} {2}", num3, num2, (num < 12) ? "AM" : "PM"); } internal static int ClockNow() { TimeOfDay instance = TimeOfDay.Instance; if ((Object)(object)instance == (Object)null) { return 0; } return (int)(instance.normalizedTimeOfDay * (60f * (float)instance.numberOfHours)) + 360; } internal static void HostSecond(bool unlocked) { StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance == (Object)null || !unlocked) { return; } if (Board.HostCheckSpot(State)) { Net.Broadcast(); } int num; if (instance.shipHasLanded && !instance.inShipPhase) { num = ((!instance.shipIsLeaving) ? 1 : 0); if (num != 0 && !_wasLanded && instance.randomMapSeed != _pinnedSeed && CanPin(instance.currentLevel)) { Pin(instance.randomMapSeed, instance.currentLevel); } } else { num = 0; } _wasLanded = (byte)num != 0; if (num != 0 && State.Cards.Any((Contract c) => c.State == CardState.Open)) { Count(takingOff: false); } } internal static void HostFrame() { } private static bool CanPin(SelectableLevel level) { if ((Object)(object)level != (Object)null && level.planetHasTime && level.spawnEnemiesAndScrap) { return level.levelID != 3; } return false; } internal static void Pin(int seed, SelectableLevel level) { _pinnedSeed = seed; Random rng = new Random(seed * 7919 + 1301); List<Contract> list = new List<Contract>(); List<Kind> list2 = new List<Kind>(); if (Plugin.ScanContracts.Value && Enemies(level).Count > 0) { list2.Add(Kind.Scan); } if (Plugin.HeavyContracts.Value && Hooks.HeavyLoaded) { list2.Add(Kind.Heavy); } if (Plugin.EarlyContracts.Value) { list2.Add(Kind.Early); } if (Plugin.VaultContracts.Value && Hooks.VaultToday()) { list2.Add(Kind.Vault); } if (Plugin.CollectContracts.Value && Scrap(level).Count > 0) { list2.Add(Kind.Collect); } foreach (Kind item in list2.OrderBy((Kind _) => rng.Next()).ToList()) { if (list.Count >= 3) { break; } Contract contract = Make(item, level, rng, list); if (contract != null) { list.Add(contract); } } int num = 0; while (list.Count < 3 && num < 6) { List<Kind> list3 = list2.Where((Kind k) => k == Kind.Scan || k == Kind.Collect).ToList(); if (list3.Count == 0) { break; } Contract contract2 = Make(list3[rng.Next(list3.Count)], level, rng, list); if (contract2 != null) { list.Add(contract2); } num++; } Baseline.Clear(); GrabbableObject[] array = Object.FindObjectsOfType<GrabbableObject>(); foreach (GrabbableObject val in array) { if ((Object)(object)val != (Object)null && val.isInShipRoom && (Object)(object)((NetworkBehaviour)val).NetworkObject != (Object)null) { Baseline.Add(((NetworkBehaviour)val).NetworkObjectId); } } State.Day = seed; State.Moon = level.PlanetName ?? ""; State.Cards = list; Plugin.Log.LogInfo((object)($"Bounty Board: pinned {list.Count} contracts on {State.Moon} (seed {seed}): " + string.Join("; ", list.Select((Contract c) => $"{c.Title}: {c.Task} ${c.Reward}")))); Net.Broadcast(); } private static Contract Make(Kind k, SelectableLevel level, Random rng, List<Contract> taken) { switch (k) { case Kind.Scan: { List<KeyValuePair<string, int>> list2 = (from e in Enemies(level) where taken.All((Contract t) => t.Kind != Kind.Scan || t.Target != e.Key) select e).ToList(); if (list2.Count == 0) { return null; } KeyValuePair<string, int> keyValuePair2 = Weighted(list2, rng); float num13 = 1f - Mathf.Clamp01((float)keyValuePair2.Value / (float)list2.Max((KeyValuePair<string, int> p) => p.Value)); return new Contract { Kind = k, Target = keyValuePair2.Key, Need = 1, Reward = Pay(0.05f + 0.35f * num13, 0.25f + 0.45f * num13) }; } case Kind.Heavy: return new Contract { Kind = k, Need = Plugin.HeavyCount.Value, Reward = Pay(0.75f, 1f) }; case Kind.Early: { int num6 = Mathf.Min(Plugin.EarlyHourMin.Value, Plugin.EarlyHourMax.Value); int num7 = Mathf.Max(Plugin.EarlyHourMin.Value, Plugin.EarlyHourMax.Value); int num8 = rng.Next(num6, num7 + 1); int num9 = Mathf.Min(Plugin.EarlyValueMin.Value, Plugin.EarlyValueMax.Value); int num10 = Mathf.Max(Plugin.EarlyValueMin.Value, Plugin.EarlyValueMax.Value); int num11 = Mathf.RoundToInt(Mathf.Lerp((float)num9, (float)num10, (float)rng.NextDouble()) / 10f) * 10; float num12 = 0.5f * (1f - (float)(num8 - num6) / (float)Mathf.Max(1, num7 - num6)) + 0.5f * ((float)(num11 - num9) / (float)Mathf.Max(1, num10 - num9)); return new Contract { Kind = k, Need = num11, Deadline = num8 * 60, Reward = Pay(0.25f + 0.4f * num12, 0.35f + 0.5f * num12) }; } case Kind.Vault: return new Contract { Kind = k, Need = 1, Reward = Pay(0.65f, 1f) }; default: { List<KeyValuePair<string, int>> list = (from e in Scrap(level) where taken.All((Contract t) => t.Kind != Kind.Collect || t.Target != e.Key) select e).ToList(); if (list.Count == 0) { return null; } KeyValuePair<string, int> keyValuePair = Weighted(list, rng); int num = Mathf.Min(Plugin.CollectMin.Value, Plugin.CollectMax.Value); int num2 = Mathf.Max(Plugin.CollectMin.Value, Plugin.CollectMax.Value); float num3 = Mathf.Clamp01((float)keyValuePair.Value / (float)list.Max((KeyValuePair<string, int> p) => p.Value)); int num4 = Mathf.Clamp(Mathf.RoundToInt(Mathf.Lerp((float)num, (float)num2, num3)), num, num2); float num5 = (1f - num3) * 0.6f + (float)(num4 - num) / (float)Mathf.Max(1, num2 - num) * 0.4f; return new Contract { Kind = k, Target = keyValuePair.Key, Need = num4, Reward = Pay(0.15f + 0.4f * num5, 0.3f + 0.5f * num5) }; } } int Pay(float lo, float hi) { float num14 = lo + (float)rng.NextDouble() * (hi - lo); int num15 = Mathf.Min(Plugin.RewardMin.Value, Plugin.RewardMax.Value); int num16 = Mathf.Max(Plugin.RewardMin.Value, Plugin.RewardMax.Value); return Mathf.RoundToInt(Mathf.Lerp((float)num15, (float)num16, num14) / 5f) * 5; } } private static KeyValuePair<string, int> Weighted(List<KeyValuePair<string, int>> pool, Random rng) { int maxValue = pool.Sum((KeyValuePair<string, int> p) => Mathf.Max(1, p.Value)); int num = rng.Next(maxValue); foreach (KeyValuePair<string, int> item in pool) { num -= Mathf.Max(1, item.Value); if (num < 0) { return item; } } return pool[pool.Count - 1]; } private static List<KeyValuePair<string, int>> Enemies(SelectableLevel level) { Dictionary<string, int> dictionary = new Dictionary<string, int>(); List<SpawnableEnemyWithRarity>[] array = new List<SpawnableEnemyWithRarity>[3] { level.Enemies, level.OutsideEnemies, level.DaytimeEnemies }; foreach (List<SpawnableEnemyWithRarity> list in array) { if (list == null) { continue; } foreach (SpawnableEnemyWithRarity item in list) { EnemyType val = item?.enemyType; if (!((Object)(object)val == (Object)null) && item.rarity > 0 && !string.IsNullOrEmpty(val.enemyName) && !((Object)(object)val.enemyPrefab == (Object)null) && !((Object)(object)val.enemyPrefab.GetComponentInChildren<ScanNodeProperties>(true) == (Object)null)) { dictionary[val.enemyName] = (dictionary.TryGetValue(val.enemyName, out var value) ? value : 0) + item.rarity; } } } return dictionary.OrderBy<KeyValuePair<string, int>, string>((KeyValuePair<string, int> p) => p.Key, StringComparer.Ordinal).ToList(); } private static List<KeyValuePair<string, int>> Scrap(SelectableLevel level) { Dictionary<string, int> dictionary = new Dictionary<string, int>(); if (level.spawnableScrap != null) { foreach (SpawnableItemWithRarity item in level.spawnableScrap) { Item val = item?.spawnableItem; if (!((Object)(object)val == (Object)null) && item.rarity > 0 && val.isScrap && !string.IsNullOrEmpty(val.itemName) && !Hooks.IsHeavyItem(val)) { dictionary[val.itemName] = (dictionary.TryGetValue(val.itemName, out var value) ? value : 0) + item.rarity; } } } return dictionary.OrderBy<KeyValuePair<string, int>, string>((KeyValuePair<string, int> p) => p.Key, StringComparer.Ordinal).ToList(); } internal static void Count(bool takingOff) { bool flag = false; int num = 0; int num2 = 0; Dictionary<string, int> dictionary = new Dictionary<string, int>(); GrabbableObject[] array = Object.FindObjectsOfType<GrabbableObject>(); foreach (GrabbableObject val in array) { if (!((Object)(object)val == (Object)null) && val.isInShipRoom && !((Object)(object)val.itemProperties == (Object)null) && !val.deactivated && (!((Object)(object)((NetworkBehaviour)val).NetworkObject != (Object)null) || !Baseline.Contains(((NetworkBehaviour)val).NetworkObjectId))) { if (Hooks.IsHeavy(val)) { num++; } if (val.itemProperties.isScrap) { num2 += val.scrapValue; string key = val.itemProperties.itemName ?? ""; dictionary[key] = (dictionary.TryGetValue(key, out var value) ? value : 0) + 1; } } } int num3 = ClockNow(); bool flag2 = Hooks.VaultOpen(); StartOfRound instance = StartOfRound.Instance; foreach (Contract card in State.Cards) { if (card.State != CardState.Open) { continue; } int have = card.Have; switch (card.Kind) { case Kind.Heavy: card.Have = num; if (num >= card.Need) { flag |= Settle(card, CardState.Paid); } break; case Kind.Collect: { card.Have = (dictionary.TryGetValue(card.Target, out var value2) ? value2 : 0); if (card.Have >= card.Need) { flag |= Settle(card, CardState.Paid); } break; } case Kind.Vault: card.Have = (flag2 ? 1 : 0); if (flag2) { flag |= Settle(card, CardState.Paid); } break; case Kind.Early: card.Have = num2; if (takingOff) { bool flag3 = num3 < card.Deadline && (Object)(object)instance != (Object)null && !instance.shipLeftAutomatically; flag |= Settle(card, (flag3 && num2 >= card.Need) ? CardState.Paid : CardState.Void); } else if (num3 >= card.Deadline) { flag |= Settle(card, CardState.Void); } break; } flag |= card.Have != have; } if (flag) { Net.Broadcast(); } } internal static void Scanned(string enemy) { StartOfRound instance = StartOfRound.Instance; if (!((Object)(object)instance == (Object)null) && (instance.shipHasLanded || instance.shipIsLeaving)) { Contract contract = State.Cards.FirstOrDefault((Contract x) => x.Kind == Kind.Scan && x.State == CardState.Open && x.Target == enemy); if (contract != null) { contract.Have = 1; Settle(contract, CardState.Paid); Net.Broadcast(); } } } private static bool Settle(Contract c, CardState to) { if (c.State != CardState.Open) { return false; } c.State = to; if (to == CardState.Paid) { Terminal val = Object.FindObjectOfType<Terminal>(); if ((Object)(object)val != (Object)null) { val.groupCredits = Mathf.Clamp(val.groupCredits + c.Reward, 0, 10000000); val.SyncGroupCreditsClientRpc(val.groupCredits, val.numberOfItemsInDropship); } } Plugin.Log.LogInfo((object)("Bounty Board: " + c.Title + " " + ((to == CardState.Paid) ? $"PAID ${c.Reward}" : "VOID") + " (" + c.Progress + ").")); return true; } internal static string DebugPay(int i) { if (!Net.IsHost) { return null; } if (i < 0 || i >= State.Cards.Count) { return "no contract there; pin some first"; } Contract contract = State.Cards[i]; if (contract.State != CardState.Open) { return $"contract {i + 1} is already {contract.State.ToString().ToUpperInvariant()}"; } Settle(contract, CardState.Paid); Net.Broadcast(); return $"contract {i + 1} paid ${contract.Reward}"; } internal static string DebugPin() { StartOfRound instance = StartOfRound.Instance; if (!Net.IsHost || (Object)(object)instance == (Object)null || (Object)(object)instance.currentLevel == (Object)null) { return null; } Pin(instance.shipHasLanded ? instance.randomMapSeed : Random.Range(1, 100000000), instance.currentLevel); return $"pinned {State.Cards.Count} contracts for {State.Moon}"; } internal static string TerminalText() { BoardState state = State; StringBuilder stringBuilder = new StringBuilder("BOUNTY BOARD\n\n"); if (!Store.Unlocked) { return stringBuilder.Append("The Bounty Board isn't aboard. Type INFO BOUNTY.\n\n").ToString(); } if (state.Day == 0 || state.Cards.Count == 0) { return stringBuilder.Append("No contracts pinned. They go up when you land on a moon.\n\n").ToString(); } stringBuilder.Append("Contracts for " + state.Moon + ":\n\n"); for (int i = 0; i < state.Cards.Count; i++) { Contract contract = state.Cards[i]; string text = ((contract.State == CardState.Paid) ? "PAID" : ((contract.State == CardState.Void) ? "VOID" : contract.Progress)); stringBuilder.Append($"* {contract.Title} ${contract.Reward}\n {contract.Task}\n [{text}]\n\n"); } return stringBuilder.ToString(); } [HarmonyPatch(typeof(StartOfRound), "ShipLeave")] [HarmonyPostfix] private static void OnShipLeave() { if (!Net.IsHost || State.Cards.Count == 0) { return; } try { Count(takingOff: true); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Bounty Board: take-off count: " + ex.Message)); } } [HarmonyPatch(typeof(StartOfRound), "ShipHasLeft")] [HarmonyPostfix] private static void OnShipHasLeft() { if (!Net.IsHost || State.Cards.Count == 0) { return; } bool flag = false; foreach (Contract card in State.Cards) { flag |= Settle(card, CardState.Void); } if (flag) { Net.Broadcast(); } } [HarmonyPatch(typeof(HUDManager), "AssignNodeToUIElement")] [HarmonyPostfix] private static void OnScanNode(ScanNodeProperties node) { try { if ((Object)(object)node == (Object)null || node.nodeType != 1 || !Net.Online) { return; } string name = ((Component)node).GetComponentInParent<EnemyAI>()?.enemyType?.enemyName; if (!string.IsNullOrEmpty(name) && State.Cards.Any((Contract c) => c.Kind == Kind.Scan && c.State == CardState.Open && c.Target == name)) { if (Net.IsHost) { Scanned(name); } else { Net.SendScan(name); } } } catch (Exception ex) { Plugin.Debug("scan hook: " + ex.Message); } } } internal static class Hooks { internal const string HeavyGuid = "daniel.lethalcompany.heavyscrap"; internal const string VaultGuid = "daniel.lethalcompany.vault"; internal const string NewShipGuid = "daniel.lethalcompany.newship"; private static FieldInfo _vaultCurrent; private static FieldInfo _vaultSeed; private static FieldInfo _vaultTile; private static FieldInfo _vaultDoor; private static Func<GameObject> _hull; internal static bool HeavyLoaded { get; private set; } internal static GameObject Hull { get { try { return _hull?.Invoke(); } catch (Exception) { return null; } } } internal static void Init(Harmony harmony) { HeavyLoaded = Chainloader.PluginInfos.ContainsKey("daniel.lethalcompany.heavyscrap"); if (Chainloader.PluginInfos.TryGetValue("daniel.lethalcompany.vault", out var value)) { Type type = ((object)value.Instance).GetType().Assembly.GetType("Vault.Puzzle"); Type type2 = ((object)value.Instance).GetType().Assembly.GetType("Vault.Snapshot"); _vaultCurrent = ((type != null) ? AccessTools.Field(type, "Current") : null); _vaultSeed = ((type2 != null) ? AccessTools.Field(type2, "Seed") : null); _vaultTile = ((type2 != null) ? AccessTools.Field(type2, "Tile") : null); _vaultDoor = ((type2 != null) ? AccessTools.Field(type2, "Door") : null); if (_vaultCurrent == null || _vaultTile == null || _vaultDoor == null) { _vaultCurrent = null; Plugin.Log.LogWarning((object)"Bounty Board: couldn't read the Vault mod's state; no Vault contracts."); } } if (Chainloader.PluginInfos.TryGetValue("daniel.lethalcompany.newship", out var value2)) { Type type3 = ((object)value2.Instance).GetType().Assembly.GetType("NewShip.Applier"); MethodInfo methodInfo = ((type3 != null) ? AccessTools.PropertyGetter(type3, "Instance") : null); if (methodInfo != null) { _hull = (Func<GameObject>)methodInfo.CreateDelegate(typeof(Func<GameObject>)); } } } private static bool IsHeavyType(Type t) { while (t != null && t != typeof(GrabbableObject)) { if (t.Name == "HeavyCargo") { return true; } t = t.BaseType; } return false; } internal static bool IsHeavy(GrabbableObject g) { if (HeavyLoaded && (Object)(object)g != (Object)null) { return IsHeavyType(((object)g).GetType()); } return false; } internal static bool IsHeavyItem(Item it) { if (!HeavyLoaded || (Object)(object)it == (Object)null || (Object)(object)it.spawnPrefab == (Object)null) { return false; } GrabbableObject component = it.spawnPrefab.GetComponent<GrabbableObject>(); if ((Object)(object)component != (Object)null) { return IsHeavyType(((object)component).GetType()); } return false; } private static object VaultSnapshot() { if (_vaultCurrent == null) { return null; } object value = _vaultCurrent.GetValue(null); if (value == null) { return null; } StartOfRound instance = StartOfRound.Instance; if (_vaultSeed != null && (Object)(object)instance != (Object)null && (int)_vaultSeed.GetValue(value) != instance.randomMapSeed) { return null; } return value; } internal static bool VaultToday() { try { object obj = VaultSnapshot(); return obj != null && Convert.ToInt32(_vaultTile.GetValue(obj)) >= 0; } catch (Exception) { return false; } } internal static bool VaultOpen() { try { object obj = VaultSnapshot(); return obj != null && Convert.ToInt32(_vaultTile.GetValue(obj)) >= 0 && _vaultDoor.GetValue(obj)?.ToString() == "Open"; } catch (Exception) { return false; } } } internal static class MenuHooks { internal const string ModMenuGuid = "daniel.lethalcompany.modmenu"; private const string Tab = "Bounty Board"; [MethodImpl(MethodImplOptions.NoInlining)] internal static void Register() { MenuApi.Button("Bounty Board", "Unlock the board (free)", (Func<string>)Store.HostUnlockFree, true, true, (Func<string>)(() => (Store.Index >= 0) ? ((!Store.Unlocked) ? null : "already aboard") : "join a lobby first"), (string)null); MenuApi.Button("Bounty Board", "Pin new contracts now", (Func<string>)Contracts.DebugPin, true, true, (Func<string>)(() => Store.Unlocked ? null : "unlock the board first"), "on the moon the ship is at or routed to; in orbit with a random seed"); for (int num = 0; num < 3; num++) { int k = num; MenuApi.Button("Bounty Board", $"Stamp contract {k + 1} PAID", (Func<string>)(() => Contracts.DebugPay(k)), true, true, (Func<string>)(() => (k < Contracts.State.Cards.Count) ? null : "no contract there"), "pays its reward, plays the stamp and chime"); } MenuApi.Button("Bounty Board", "Find the board's wall again", (Func<string>)Board.Refit, true, false, (Func<string>)(() => Store.Unlocked ? null : "unlock the board first"), (string)null); try { RegisterSettings(); } catch (Exception ex) { Plugin.Log.LogInfo((object)("Bounty Board: settings rows need Mod Menu 0.3.6 or later (" + ex.GetType().Name + ")")); } } [MethodImpl(MethodImplOptions.NoInlining)] private static void RegisterSettings() { MenuApi.Setting("Bounty Board", (ConfigEntryBase)(object)Plugin.Price, "Price", true, "the store price, sent to every player", (Func<string>)null); MenuApi.Setting("Bounty Board", (ConfigEntryBase)(object)Plugin.ScanContracts, "Scan contracts", true, "from the next landing", (Func<string>)null); MenuApi.Setting("Bounty Board", (ConfigEntryBase)(object)Plugin.HeavyContracts, "Heavy Scrap contracts", true, "needs the Heavy Scrap mod; from the next landing", (Func<string>)null); MenuApi.Setting("Bounty Board", (ConfigEntryBase)(object)Plugin.EarlyContracts, "Early leave contracts", true, "from the next landing", (Func<string>)null); MenuApi.Setting("Bounty Board", (ConfigEntryBase)(object)Plugin.VaultContracts, "Vault contracts", true, "needs the Vault mod; from the next landing", (Func<string>)null); MenuApi.Setting("Bounty Board", (ConfigEntryBase)(object)Plugin.CollectContracts, "Collect contracts", true, "from the next landing", (Func<string>)null); MenuApi.Setting("Bounty Board", (ConfigEntryBase)(object)Plugin.Tips, "Pay-out tips", false, "a tip on your screen when a contract is paid or voided", (Func<string>)null); MenuApi.Setting("Bounty Board", (ConfigEntryBase)(object)Plugin.Volume, "Volume", false, "stamp and chime, 0 to 1", (Func<string>)null); MenuApi.Setting("Bounty Board", (ConfigEntryBase)(object)Plugin.VerboseLog, "Verbose log", false, "testing: contract progress and the wall probe", (Func<string>)null); MenuApi.Tuning((Action)delegate { MenuApi.Setting("Bounty Board", (ConfigEntryBase)(object)Plugin.RewardMin, "Reward min ($)", true, (string)null, (Func<string>)null); MenuApi.Setting("Bounty Board", (ConfigEntryBase)(object)Plugin.RewardMax, "Reward max ($)", true, (string)null, (Func<string>)null); MenuApi.Setting("Bounty Board", (ConfigEntryBase)(object)Plugin.HeavyCount, "Heavy Scrap count", true, (string)null, (Func<string>)null); MenuApi.Setting("Bounty Board", (ConfigEntryBase)(object)Plugin.EarlyValueMin, "Early leave value min ($)", true, (string)null, (Func<string>)null); MenuApi.Setting("Bounty Board", (ConfigEntryBase)(object)Plugin.EarlyValueMax, "Early leave value max ($)", true, (string)null, (Func<string>)null); MenuApi.Setting("Bounty Board", (ConfigEntryBase)(object)Plugin.EarlyHourMin, "Early leave hour min", true, "24 h clock, 14 = 2 PM", (Func<string>)null); MenuApi.Setting("Bounty Board", (ConfigEntryBase)(object)Plugin.EarlyHourMax, "Early leave hour max", true, "24 h clock, 17 = 5 PM", (Func<string>)null); MenuApi.Setting("Bounty Board", (ConfigEntryBase)(object)Plugin.CollectMin, "Collect count min", true, (string)null, (Func<string>)null); MenuApi.Setting("Bounty Board", (ConfigEntryBase)(object)Plugin.CollectMax, "Collect count max", true, (string)null, (Func<string>)null); }); } } internal static class Net { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static HandleNamedMessageDelegate <>9__12_0; public static HandleNamedMessageDelegate <>9__12_1; public static HandleNamedMessageDelegate <>9__12_2; internal void <Register>b__12_0(ulong sender, FastBufferReader r) { if (IsHost) { SendTo(sender); } } internal void <Register>b__12_1(ulong sender, FastBufferReader r) { if (IsHost) { string enemy = default(string); ((FastBufferReader)(ref r)).ReadValueSafe(ref enemy, false); Contracts.Scanned(enemy); } } internal void <Register>b__12_2(ulong sender, FastBufferReader r) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (!IsHost) { int price; BoardState boardState = Read(r, out price); if (boardState != null) { Store.ApplyPrice(price); Board.Received(boardState); Contracts.State = boardState; } } } } private const string Hello = "BountyBoard.Hello"; private const string StateMsg = "BountyBoard.State"; private const string Scan = "BountyBoard.Scan"; private const byte Version = 1; private static CustomMessagingManager _registeredOn; private static bool _helloSent; internal static NetworkManager NM => NetworkManager.Singleton; internal static bool Online { get { if ((Object)(object)NM != (Object)null && NM.IsListening) { return NM.CustomMessagingManager != null; } return false; } } internal static bool IsHost { get { if (Online) { return NM.IsServer; } return false; } } internal static void Register() { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Expected O, but got Unknown //IL_00b8: 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_00c3: Expected O, but got Unknown NetworkManager nM = NM; if ((Object)(object)nM == (Object)null || nM.CustomMessagingManager == null || _registeredOn == nM.CustomMessagingManager) { return; } _registeredOn = nM.CustomMessagingManager; _helloSent = false; Contracts.OnSessionStart(); Board.OnSessionStart(); Board.Remove(); CustomMessagingManager customMessagingManager = nM.CustomMessagingManager; object obj = <>c.<>9__12_0; if (obj == null) { HandleNamedMessageDelegate val = delegate(ulong sender, FastBufferReader r) { if (IsHost) { SendTo(sender); } }; <>c.<>9__12_0 = val; obj = (object)val; } customMessagingManager.RegisterNamedMessageHandler("BountyBoard.Hello", (HandleNamedMessageDelegate)obj); object obj2 = <>c.<>9__12_1; if (obj2 == null) { HandleNamedMessageDelegate val2 = delegate(ulong sender, FastBufferReader r) { if (IsHost) { string enemy = default(string); ((FastBufferReader)(ref r)).ReadValueSafe(ref enemy, false); Contracts.Scanned(enemy); } }; <>c.<>9__12_1 = val2; obj2 = (object)val2; } customMessagingManager.RegisterNamedMessageHandler("BountyBoard.Scan", (HandleNamedMessageDelegate)obj2); object obj3 = <>c.<>9__12_2; if (obj3 == null) { HandleNamedMessageDelegate val3 = delegate(ulong sender, FastBufferReader r) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (!IsHost) { int price; BoardState boardState = Read(r, out price); if (boardState != null) { Store.ApplyPrice(price); Board.Received(boardState); Contracts.State = boardState; } } }; <>c.<>9__12_2 = val3; obj3 = (object)val3; } customMessagingManager.RegisterNamedMessageHandler("BountyBoard.State", (HandleNamedMessageDelegate)obj3); } internal unsafe static void SayHello() { //IL_003d: Unknown result type (might be due to invalid IL or missing references) if (_helloSent || !Online || IsHost || !NM.IsConnectedClient) { return; } FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(8, (Allocator)2, -1); try { NM.CustomMessagingManager.SendNamedMessage("BountyBoard.Hello", 0uL, val, (NetworkDelivery)3); _helloSent = true; } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } internal unsafe static void SendScan(string enemy) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) if (!Online || IsHost) { return; } FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(256, (Allocator)2, 4096); try { ((FastBufferWriter)(ref val)).WriteValueSafe(enemy ?? "", false); NM.CustomMessagingManager.SendNamedMessage("BountyBoard.Scan", 0uL, val, (NetworkDelivery)3); } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } internal static void Broadcast() { if (!IsHost) { return; } BoardState state = Contracts.State; state.Rev++; Board.Received(state); foreach (ulong connectedClientsId in NM.ConnectedClientsIds) { if (connectedClientsId != 0L) { SendTo(connectedClientsId); } } } private unsafe static void SendTo(ulong cid) { //IL_0028: 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_0041: 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_0057: 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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_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_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0151: 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_0168: 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_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0185: 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_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) if (!IsHost) { return; } BoardState state = Contracts.State; FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(1024, (Allocator)2, 65536); try { byte b = 1; ((FastBufferWriter)(ref val)).WriteValueSafe<byte>(ref b, default(ForPrimitives)); int currentPrice = Store.CurrentPrice; ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref currentPrice, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref state.Rev, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref state.Day, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe(state.Moon ?? "", false); ((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref state.HasSpot, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe(ref state.Pos); ((FastBufferWriter)(ref val)).WriteValueSafe(ref state.Normal); b = (byte)state.Cards.Count; ((FastBufferWriter)(ref val)).WriteValueSafe<byte>(ref b, default(ForPrimitives)); foreach (Contract card in state.Cards) { b = (byte)card.Kind; ((FastBufferWriter)(ref val)).WriteValueSafe<byte>