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 RepoCraft v0.1.0
RepoCraft.dll
Decompiled 2 hours agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using ExitGames.Client.Photon; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using Photon.Realtime; using UnityEngine; using UnityEngine.SceneManagement; [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("RepoCraft")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("RepoCraft")] [assembly: AssemblyTitle("RepoCraft")] [assembly: AssemblyVersion("1.0.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 RepoCraft { [BepInPlugin("den.repo.craft", "REPO Craft", "0.1.0")] [DefaultExecutionOrder(10000)] public sealed class Plugin : BaseUnityPlugin { private sealed class Recipe { public string Name; public string Key; public int[] Cost; public Recipe(string n, string k, params int[] c) { Name = n; Key = k; Cost = c; } } private sealed class MaterialDrop { public int Id; public int Kind; public int Amount; } private const string StockKey = "den.craft.stock.v1"; private const string CatalogKey = "den.craft.catalog.v1"; private const string SessionKey = "den.craft.session.v1"; private const string MessageKey = "den.craft.notice.v1"; private const string Wire = "den.craft.request.v1"; private const byte CraftEvent = 187; private const int Count = 7; private static Plugin self; private readonly string[] names = new string[7] { "Scrap", "Metal", "Circuit", "Glass", "Wood", "Energy", "Monster Core" }; private readonly Recipe[] recipes = new Recipe[13] { new Recipe("Handgun", "Item Gun Handgun", 8, 8, 4, 0, 0, 3, 0), new Recipe("Shotgun", "Item Gun Shotgun", 12, 14, 5, 0, 2, 5, 0), new Recipe("Stun Gun", "Item Gun Stun", 8, 5, 8, 0, 0, 6, 0), new Recipe("Tranq Gun", "Item Gun Tranq", 8, 7, 6, 2, 0, 5, 0), new Recipe("Shockwave Gun", "Item Gun Shockwave", 10, 12, 7, 0, 0, 8, 1), new Recipe("Laser Gun", "Item Gun Laser", 14, 10, 12, 6, 0, 12, 2), new Recipe("Baseball Bat", "Item Melee Baseball Bat", 6, 2, 0, 0, 9, 0, 0), new Recipe("Frying Pan", "Item Melee Frying Pan", 6, 9, 0, 0, 0, 0, 0), new Recipe("Sledge Hammer", "Item Melee Sledge Hammer", 8, 15, 0, 0, 5, 0, 0), new Recipe("Inflatable Hammer", "Item Melee Inflatable Hammer", 7, 5, 0, 0, 5, 0, 0), new Recipe("Explosive Grenade", "Item Grenade Explosive", 5, 6, 2, 0, 0, 3, 0), new Recipe("Stun Grenade", "Item Grenade Stun", 4, 4, 3, 0, 0, 3, 0), new Recipe("Power Crystal", "Item Power Crystal", 8, 0, 5, 4, 0, 12, 1) }; private readonly Dictionary<int, List<MaterialDrop>> pending = new Dictionary<int, List<MaterialDrop>>(); private readonly HashSet<int> completed = new HashSet<int>(); private readonly HashSet<int> awarded = new HashSet<int>(); private readonly HashSet<string> requests = new HashSet<string>(); private readonly ConfigEntry<string>[] keywords = new ConfigEntry<string>[7]; private readonly ConfigEntry<string>[] recipeCost = new ConfigEntry<string>[13]; private readonly int[] stock = new int[7]; private ConfigEntry<bool> active; private ConfigEntry<int> valuableBonus; private ConfigEntry<int> maxCrafts; private FieldInfo start; private FieldInfo volume; private FieldInfo valuableRoom; private FieldInfo rooms; private FieldInfo inExtraction; private FieldInfo value; private FieldInfo haulList; private FieldInfo itemDictionary; private FieldInfo purchased; private FieldInfo purchasedTotal; private Harmony harmony; private bool ready; private bool blocked; private bool hadRoom; private bool menu; private CursorLockMode savedLock; private bool savedVisible; private int originalMaster; private int crafts; private string room = ""; private string session = ""; private string file; private string notice = ""; private string lastNotice = ""; private string lastPublished = ""; private float nextTick; private float noticeUntil; private float nextRequest; private Vector2 scroll; private bool Host { get { if (SemiFunc.IsMultiplayer()) { return PhotonNetwork.IsMasterClient; } return true; } } private bool Stage { get { if ((Object)(object)RunManager.instance != (Object)null) { return SemiFunc.RunIsLevel(); } return false; } } private bool Shop { get { if ((Object)(object)RunManager.instance != (Object)null) { return SemiFunc.RunIsShop(); } return false; } } private bool CanHost { get { if (ready && active.Value && Host) { return !blocked; } return false; } } private void Awake() { //IL_0365: Unknown result type (might be due to invalid IL or missing references) //IL_036f: Expected O, but got Unknown //IL_0386: Unknown result type (might be due to invalid IL or missing references) //IL_0394: Expected O, but got Unknown //IL_03f9: 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_041b: Expected O, but got Unknown //IL_041b: Expected O, but got Unknown //IL_03d3: Unknown result type (might be due to invalid IL or missing references) //IL_03e1: Expected O, but got Unknown self = this; active = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Enable crafting and materials"); valuableBonus = ((BaseUnityPlugin)this).Config.Bind<int>("Materials", "BonusValueThreshold", 10000, "Items at or above this dollar value grant 2 instead of 1"); maxCrafts = ((BaseUnityPlugin)this).Config.Bind<int>("Crafting", "MaxCraftsPerShop", 4, "Limit team crafts per shop; 0 disables crafting"); string[] array = new string[7] { "", "metal,iron,steel,pot,pan,knife,tool,anvil,gear,chain,can,pipe,clock,robot", "computer,laptop,phone,radio,monitor,television,camera,keyboard,console,remote,electronic,calculator", "glass,vase,bottle,mirror,crystal,jar,porcelain,ceramic,lamp,bulb", "wood,chair,table,desk,book,shelf,crate,box,plank,stool,violin,piano,painting", "battery,power,energy,cell,circuit,charger,motor,capacitor", "enemy valuable,enemyvaluable,monster core,enemy orb" }; for (int i = 1; i < 7; i++) { keywords[i] = ((BaseUnityPlugin)this).Config.Bind<string>("Classification", names[i].Replace(" ", "") + "Keywords", array[i], "Prefab-name keyword list, comma separated"); } for (int j = 0; j < recipes.Length; j++) { recipeCost[j] = ((BaseUnityPlugin)this).Config.Bind<string>("Recipes", recipes[j].Key.Replace(" ", ""), string.Join(",", recipes[j].Cost), "Scrap,Metal,Circuit,Glass,Wood,Energy,MonsterCore"); } file = Path.Combine(Paths.ConfigPath, "den.repo.craft.shared.tsv"); Load(); start = AccessTools.Field(typeof(ExtractionPoint), "stateStart"); volume = AccessTools.Field(typeof(ExtractionPoint), "roomVolume"); valuableRoom = AccessTools.Field(typeof(ValuableObject), "roomVolumeCheck"); rooms = AccessTools.Field(typeof(RoomVolumeCheck), "CurrentRooms"); inExtraction = AccessTools.Field(typeof(RoomVolumeCheck), "inExtractionPoint"); value = AccessTools.Field(typeof(ValuableObject), "dollarValueCurrent"); haulList = AccessTools.Field(typeof(RoundDirector), "dollarHaulList"); itemDictionary = AccessTools.Field(typeof(StatsManager), "itemDictionary"); purchased = AccessTools.Field(typeof(StatsManager), "itemsPurchased"); purchasedTotal = AccessTools.Field(typeof(StatsManager), "itemsPurchasedTotal"); MethodInfo methodInfo = AccessTools.Method(typeof(ExtractionPoint), "StateSet", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(ExtractionPoint), "StateComplete", Type.EmptyTypes, (Type[])null); if (new FieldInfo[10] { start, volume, valuableRoom, rooms, inExtraction, value, haulList, itemDictionary, purchased, purchasedTotal }.Any((FieldInfo f) => f == null) || methodInfo == null || methodInfo2 == null) { ((BaseUnityPlugin)this).Logger.LogError((object)"REPO Craft: unsupported extraction or item API. Disabled."); return; } harmony = new Harmony("den.repo.craft"); try { harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(Plugin), "StateSetBefore", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); MethodInfo methodInfo3 = AccessTools.Method(typeof(ExtractionPoint), "StateExtracting", Type.EmptyTypes, (Type[])null); if (methodInfo3 != null) { harmony.Patch((MethodBase)methodInfo3, new HarmonyMethod(typeof(Plugin), "ExtractingBefore", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } harmony.Patch((MethodBase)methodInfo2, new HarmonyMethod(typeof(Plugin), "CompleteBefore", (Type[])null), new HarmonyMethod(typeof(Plugin), "CompleteAfter", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); SceneManager.sceneLoaded += OnScene; PhotonNetwork.NetworkingClient.EventReceived += OnEvent; ready = true; ((BaseUnityPlugin)this).Logger.LogInfo((object)"REPO Craft initialized"); } catch (Exception ex) { harmony.UnpatchSelf(); ((BaseUnityPlugin)this).Logger.LogError((object)ex); } } private void OnDestroy() { SetMenu(open: false); if (ready) { SceneManager.sceneLoaded -= OnScene; PhotonNetwork.NetworkingClient.EventReceived -= OnEvent; } Harmony obj = harmony; if (obj != null) { obj.UnpatchSelf(); } if ((Object)(object)self == (Object)(object)this) { self = null; } } private void OnDisable() { SetMenu(open: false); } private void OnApplicationFocus(bool focus) { if (!focus) { SetMenu(open: false); } } private void OnScene(Scene s, LoadSceneMode m) { pending.Clear(); completed.Clear(); awarded.Clear(); requests.Clear(); crafts = 0; SetMenu(open: false); lastPublished = ""; if (Host) { session = Guid.NewGuid().ToString("N"); Publish(); } } private void Load() { try { if (!File.Exists(file)) { return; } string[] array = File.ReadAllText(file).Trim().Split('\t'); if (array.Length != 8 || array[0] != "v1") { blocked = true; ((BaseUnityPlugin)this).Logger.LogError((object)"Invalid material file; no overwrite."); return; } for (int i = 0; i < 7; i++) { if (!int.TryParse(array[i + 1], out stock[i]) || stock[i] < 0 || stock[i] > 1000000) { blocked = true; ((BaseUnityPlugin)this).Logger.LogError((object)"Invalid material count; no overwrite."); break; } } } catch (Exception ex) { blocked = true; ((BaseUnityPlugin)this).Logger.LogError((object)ex); } } private bool Save(int[] next) { try { string text = file + ".tmp"; File.WriteAllText(text, "v1\t" + string.Join("\t", next) + "\n"); if (File.Exists(file)) { File.Replace(text, file, file + ".bak"); } else { File.Move(text, file); } Array.Copy(next, stock, 7); return true; } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)ex); return false; } } private int Classify(string prefab) { string n = (prefab ?? "").ToLowerInvariant(); int[] array = new int[6] { 6, 5, 2, 3, 4, 1 }; foreach (int num in array) { if ((from k in keywords[num].Value.Split(',') select k.Trim().ToLowerInvariant()).Any((string k) => k.Length > 0 && n.Contains(k))) { return num; } } return 0; } private static void StateSetBefore(ExtractionPoint __instance, object[] __args) { try { if ((Object)(object)self != (Object)null && __args != null && __args.Length != 0 && __args[0]?.ToString() == "Extracting") { self.Snapshot(__instance, retry: false); } } catch (Exception ex) { Plugin plugin = self; if (plugin != null) { ((BaseUnityPlugin)plugin).Logger.LogWarning((object)ex); } } } private static void ExtractingBefore(ExtractionPoint __instance) { try { bool flag = default(bool); int num; if ((Object)(object)self != (Object)null && (Object)(object)__instance != (Object)null) { object obj = self.start.GetValue(__instance); if (obj is bool) { flag = (bool)obj; num = 1; } else { num = 0; } } else { num = 0; } if (((uint)num & (flag ? 1u : 0u)) != 0) { self.Snapshot(__instance, retry: true); } } catch (Exception ex) { Plugin plugin = self; if (plugin != null) { ((BaseUnityPlugin)plugin).Logger.LogWarning((object)ex); } } } private void Snapshot(ExtractionPoint point, bool retry) { if (!CanHost || !Stage || (Object)(object)point == (Object)null || (Object)(object)RoundDirector.instance == (Object)null) { return; } int instanceID = ((Object)point).GetInstanceID(); if (completed.Contains(instanceID) || (pending.TryGetValue(instanceID, out var list) && (!retry || list.Count > 0))) { return; } object? obj = volume.GetValue(point); GameObject val = (GameObject)((obj is GameObject) ? obj : null); IEnumerable enumerable = haulList.GetValue(RoundDirector.instance) as IEnumerable; if ((Object)(object)val == (Object)null || enumerable == null) { return; } List<MaterialDrop> list2 = new List<MaterialDrop>(); HashSet<int> hashSet = new HashSet<int>(); foreach (object item in enumerable) { GameObject val2 = (GameObject)((item is GameObject) ? item : null); if ((Object)(object)val2 == (Object)null) { continue; } ValuableObject component = val2.GetComponent<ValuableObject>(); if ((Object)(object)component == (Object)null) { continue; } int instanceID2 = ((Object)component).GetInstanceID(); if (awarded.Contains(instanceID2) || !hashSet.Add(instanceID2)) { continue; } object? obj2 = valuableRoom.GetValue(component); RoomVolumeCheck val3 = (RoomVolumeCheck)((obj2 is RoomVolumeCheck) ? obj2 : null); if ((Object)(object)val3 == (Object)null) { continue; } object obj3 = inExtraction.GetValue(val3); if (!(obj3 is bool) || !(bool)obj3 || !(rooms.GetValue(val3) is IEnumerable enumerable2)) { continue; } bool flag = false; foreach (object item2 in enumerable2) { Component val4 = (Component)((item2 is Component) ? item2 : null); if ((Object)(object)val4 != (Object)null && ((Object)(object)val4.gameObject == (Object)(object)val || val4.transform.IsChildOf(val.transform) || val.transform.IsChildOf(val4.transform))) { flag = true; break; } } if (flag) { float num = Convert.ToSingle(value.GetValue(component)); if (!(num <= 0f)) { int kind = Classify(((Object)((Component)component).gameObject).name); list2.Add(new MaterialDrop { Id = instanceID2, Kind = kind, Amount = ((!(num >= (float)Mathf.Max(1000, valuableBonus.Value))) ? 1 : 2) }); } } } pending[instanceID] = list2; ((BaseUnityPlugin)this).Logger.LogInfo((object)("Craft snapshot: " + list2.Count + " valuables")); } private static void CompleteBefore(ExtractionPoint __instance, out int __state) { __state = 0; try { if (!((Object)(object)self == (Object)null) && self.CanHost && self.Stage && !((Object)(object)__instance == (Object)null)) { object obj = self.start.GetValue(__instance); if (obj is bool && (bool)obj) { __state = ((Object)__instance).GetInstanceID(); } } } catch (Exception ex) { Plugin plugin = self; if (plugin != null) { ((BaseUnityPlugin)plugin).Logger.LogWarning((object)ex); } } } private static void CompleteAfter(int __state) { try { if ((Object)(object)self != (Object)null && __state != 0) { self.CommitExtraction(__state); } } catch (Exception ex) { Plugin plugin = self; if (plugin != null) { ((BaseUnityPlugin)plugin).Logger.LogError((object)ex); } } } private void CommitExtraction(int id) { if (!CanHost || !completed.Add(id)) { return; } if (!pending.TryGetValue(id, out var list)) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"Craft: extraction complete without snapshot"); return; } int[] array = (int[])stock.Clone(); int[] gained = new int[7]; List<int> list2 = new List<int>(); foreach (MaterialDrop item in list) { if (!awarded.Contains(item.Id) && !list2.Contains(item.Id)) { int num = Math.Min(1000000 - array[item.Kind], item.Amount); array[item.Kind] += num; gained[item.Kind] += num; list2.Add(item.Id); } } if (list2.Count == 0 || !Save(array)) { return; } foreach (int item2 in list2) { awarded.Add(item2); } pending.Remove(id); Tell("Materials recovered: " + string.Join(" ", from i in Enumerable.Range(0, 7) where gained[i] > 0 select names[i] + " +" + gained[i])); Publish(); } private IDictionary Dict(FieldInfo f) { if (!((Object)(object)StatsManager.instance == (Object)null)) { return f.GetValue(StatsManager.instance) as IDictionary; } return null; } private int[] Cost(int index) { string[] array = recipeCost[index].Value.Split(','); int[] array2 = new int[7]; if (array.Length == 7) { bool flag = true; for (int i = 0; i < 7; i++) { if (!int.TryParse(array[i], out array2[i]) || array2[i] < 0 || array2[i] > 100000) { flag = false; } } if (flag && array2.Sum() > 0) { return array2; } } return recipes[index].Cost; } private string CostsWire() { return string.Join(";", from i in Enumerable.Range(0, recipes.Length) select string.Join(",", Cost(i))); } private int AvailableMask() { IDictionary dictionary = Dict(itemDictionary); if (dictionary == null) { return 0; } int num = 0; for (int i = 0; i < recipes.Length; i++) { if (dictionary.Contains(recipes[i].Key)) { num |= 1 << i; } } return num; } private int GetInt(IDictionary d, string key) { if (!d.Contains(key)) { return 0; } return Convert.ToInt32(d[key]); } private bool Enough(int[] a, int[] b) { return Enumerable.Range(0, 7).All((int i) => a[i] >= b[i]); } private void Craft(int index) { if (!CanHost || !Shop || index < 0 || index >= recipes.Length || crafts >= Mathf.Clamp(maxCrafts.Value, 0, 50)) { return; } string key = recipes[index].Key; IDictionary dictionary = Dict(itemDictionary); IDictionary dictionary2 = Dict(purchased); IDictionary dictionary3 = Dict(purchasedTotal); if (dictionary == null || dictionary2 == null || dictionary3 == null || !dictionary.Contains(key)) { Tell("Item not available in this game version"); return; } int[] costs = Cost(index); if (!Enough(stock, costs)) { Tell("Not enough team materials"); return; } int num = GetInt(dictionary2, key); int num2 = GetInt(dictionary3, key); if (num < 0 || num >= 1000 || num2 < 0 || num2 >= 100000) { return; } bool flag = dictionary2.Contains(key); bool flag2 = dictionary3.Contains(key); int[] next = stock.Select((int v, int i) => v - costs[i]).ToArray(); try { dictionary2[key] = num + 1; dictionary3[key] = num2 + 1; if (!Save(next)) { if (flag) { dictionary2[key] = num; } else { dictionary2.Remove(key); } if (flag2) { dictionary3[key] = num2; } else { dictionary3.Remove(key); } return; } } catch (Exception ex) { if (flag) { dictionary2[key] = num; } else { dictionary2.Remove(key); } if (flag2) { dictionary3[key] = num2; } else { dictionary3.Remove(key); } ((BaseUnityPlugin)this).Logger.LogError((object)ex); return; } crafts++; Tell("CRAFTED: " + recipes[index].Name + " - next truck delivery"); Publish(); ((BaseUnityPlugin)this).Logger.LogInfo((object)("Crafted " + key + "; purchased " + num + " -> " + (num + 1))); } private void Tell(string text) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Expected O, but got Unknown //IL_006c: Expected O, but got Unknown notice = text; noticeUntil = Time.unscaledTime + 7f; ((BaseUnityPlugin)this).Logger.LogInfo((object)text); if (PhotonNetwork.InRoom && Host) { Room currentRoom = PhotonNetwork.CurrentRoom; Hashtable val = new Hashtable(); ((Dictionary<object, object>)val).Add((object)"den.craft.notice.v1", (object)(Guid.NewGuid().ToString("N") + "|" + text)); currentRoom.SetCustomProperties(val, (Hashtable)null, (WebFlags)null); } } private void Publish() { //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Expected O, but got Unknown //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Expected O, but got Unknown //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Expected O, but got Unknown //IL_011f: Expected O, but got Unknown if (!CanHost || !PhotonNetwork.InRoom) { return; } if (string.IsNullOrEmpty(session)) { session = Guid.NewGuid().ToString("N"); } string text = string.Join(",", stock); string text2 = AvailableMask() + "|" + Math.Max(0, Mathf.Clamp(maxCrafts.Value, 0, 50) - crafts) + "|" + CostsWire(); string text3 = session + "|" + text + "|" + text2; if (!(text3 == lastPublished)) { Room currentRoom = PhotonNetwork.CurrentRoom; Hashtable val = new Hashtable(); ((Dictionary<object, object>)val).Add((object)"den.craft.session.v1", (object)session); ((Dictionary<object, object>)val).Add((object)"den.craft.stock.v1", (object)text); ((Dictionary<object, object>)val).Add((object)"den.craft.catalog.v1", (object)text2); if (currentRoom.SetCustomProperties(val, (Hashtable)null, (WebFlags)null)) { lastPublished = text3; } } } private bool ReadRoom(out int[] quantities, out int mask, out int left, out int[][] costs) { quantities = (int[])stock.Clone(); mask = AvailableMask(); left = Math.Max(0, Mathf.Clamp(maxCrafts.Value, 0, 50) - crafts); costs = Enumerable.Range(0, recipes.Length).Select(Cost).ToArray(); if (Host) { return CanHost; } if (!PhotonNetwork.InRoom) { return false; } Hashtable customProperties = ((RoomInfo)PhotonNetwork.CurrentRoom).CustomProperties; if (!((Dictionary<object, object>)(object)customProperties).TryGetValue((object)"den.craft.stock.v1", out object obj) || !(obj is string text) || !((Dictionary<object, object>)(object)customProperties).TryGetValue((object)"den.craft.catalog.v1", out object obj2) || !(obj2 is string text2)) { return false; } string[] array = text.Split(','); if (array.Length != 7) { return false; } for (int i = 0; i < 7; i++) { if (!int.TryParse(array[i], out quantities[i]) || quantities[i] < 0 || quantities[i] > 1000000) { return false; } } string[] array2 = text2.Split('|'); if (array2.Length != 3 || !int.TryParse(array2[0], out mask) || !int.TryParse(array2[1], out left) || left < 0 || left > 50) { return false; } string[] array3 = array2[2].Split(';'); if (array3.Length != recipes.Length) { return false; } for (int j = 0; j < array3.Length; j++) { string[] array4 = array3[j].Split(','); if (array4.Length != 7) { return false; } for (int k = 0; k < 7; k++) { if (!int.TryParse(array4[k], out costs[j][k]) || costs[j][k] < 0 || costs[j][k] > 100000) { return false; } } } return true; } private void Request(int i) { //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Expected O, but got Unknown if (Shop && !(Time.unscaledTime < nextRequest)) { nextRequest = Time.unscaledTime + 0.5f; object obj; if (Host) { Craft(i); } else if (PhotonNetwork.InRoom && ((Dictionary<object, object>)(object)((RoomInfo)PhotonNetwork.CurrentRoom).CustomProperties).TryGetValue((object)"den.craft.session.v1", out obj) && obj is string text) { PhotonNetwork.RaiseEvent((byte)187, (object)new object[4] { "den.craft.request.v1", text, i, Guid.NewGuid().ToString("N") }, new RaiseEventOptions { Receivers = (ReceiverGroup)2 }, SendOptions.SendReliable); } } } private void OnEvent(EventData e) { if (e.Code != 187 || !CanHost || !Shop || !PhotonNetwork.InRoom || !(e.CustomData is object[] array) || array.Length != 4 || !object.Equals(array[0], "den.craft.request.v1") || !object.Equals(array[1], session) || !(array[2] is int num) || num < 0 || num >= recipes.Length || !(array[3] is string text) || !Guid.TryParseExact(text, "N", out var _) || PhotonNetwork.CurrentRoom.GetPlayer(e.Sender, false) == null || requests.Count >= 5000 || !requests.Add(e.Sender + ":" + text)) { return; } try { Craft(num); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)ex); } } private void SetMenu(bool open) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) if (menu == open) { return; } if (open) { if (ready && active.Value && Shop) { savedLock = Cursor.lockState; savedVisible = Cursor.visible; menu = true; Hold(); } } else { menu = false; Cursor.lockState = savedLock; Cursor.visible = savedVisible; } } private void Hold() { if (menu) { Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; if ((Object)(object)GameDirector.instance != (Object)null) { GameDirector.instance.SetDisableInput(0.1f); } if ((Object)(object)PlayerController.instance != (Object)null) { PlayerController.instance.InputDisable(0.1f); } if ((Object)(object)InputManager.instance != (Object)null) { SemiFunc.InputDisableMovement(); SemiFunc.InputDisableAiming(); } } } private void LateUpdate() { if (menu) { Hold(); } } private void Update() { if (!ready) { return; } string text = (PhotonNetwork.InRoom ? PhotonNetwork.CurrentRoom.Name : ""); if (text != room || hadRoom != PhotonNetwork.InRoom) { room = text; hadRoom = PhotonNetwork.InRoom; requests.Clear(); lastPublished = ""; lastNotice = ""; originalMaster = ((PhotonNetwork.InRoom && PhotonNetwork.MasterClient != null) ? PhotonNetwork.MasterClient.ActorNumber : 0); session = Guid.NewGuid().ToString("N"); } if (PhotonNetwork.InRoom && PhotonNetwork.MasterClient != null && PhotonNetwork.MasterClient.ActorNumber != originalMaster) { blocked = true; } if (Input.GetKeyDown((KeyCode)288)) { SetMenu(!menu); } if (menu && (!Shop || Input.GetKeyDown((KeyCode)27))) { SetMenu(open: false); } if (menu) { Hold(); } if (Time.unscaledTime < nextTick) { return; } nextTick = Time.unscaledTime + 1f; try { if (CanHost) { Publish(); } if (!Host && PhotonNetwork.InRoom && ((Dictionary<object, object>)(object)((RoomInfo)PhotonNetwork.CurrentRoom).CustomProperties).TryGetValue((object)"den.craft.notice.v1", out object obj) && obj is string text2 && text2 != lastNotice) { lastNotice = text2; int num = text2.IndexOf('|'); if (num >= 0) { notice = text2.Substring(num + 1); noticeUntil = Time.unscaledTime + 7f; } } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)ex); } } private void OnGUI() { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_044b: Unknown result type (might be due to invalid IL or missing references) //IL_0369: Unknown result type (might be due to invalid IL or missing references) //IL_03de: Unknown result type (might be due to invalid IL or missing references) if (!ready || !active.Value || (Object)(object)RunManager.instance == (Object)null) { return; } if (Time.unscaledTime < noticeUntil) { GUI.Box(new Rect((float)((Screen.width - 620) / 2), 95f, 620f, 42f), notice); } if (Stage || Shop || SemiFunc.RunIsLobby() || SemiFunc.RunIsLobbyMenu()) { GUI.Box(new Rect((float)(Screen.width - 265), 90f, 246f, 30f), Shop ? "F7: Craft Menu" : "F7: Craft Menu (Shop only)"); } if (!Shop || !menu) { return; } float num = Mathf.Min(740, Screen.width - 24); float num2 = Mathf.Min(510, Screen.height - 24); float num3 = ((float)Screen.width - num) / 2f; float num4 = ((float)Screen.height - num2) / 2f; GUI.Box(new Rect(num3, num4, num, num2), "TEAM CRAFTING - Materials only"); if (!ReadRoom(out var q, out var mask, out var left, out var costs) || blocked) { GUI.Label(new Rect(num3 + 20f, num4 + 30f, num - 40f, 28f), "Waiting for host / crafting suspended"); return; } GUI.Label(new Rect(num3 + 18f, num4 + 28f, num - 36f, 24f), string.Join(" | ", from num6 in Enumerable.Range(0, 4) select names[num6] + ": " + q[num6])); GUI.Label(new Rect(num3 + 18f, num4 + 52f, num - 36f, 24f), string.Join(" | ", from num6 in Enumerable.Range(4, 3) select names[num6] + ": " + q[num6])); GUI.Label(new Rect(num3 + 18f, num4 + 75f, num - 36f, 24f), "Remaining crafts this shop: " + left + " | delivery next truck"); scroll = GUI.BeginScrollView(new Rect(num3 + 12f, num4 + 102f, num - 24f, num2 - 146f), scroll, new Rect(0f, 0f, num - 48f, (float)(recipes.Length * 56))); int i; for (i = 0; i < recipes.Length; i++) { float num5 = i * 56; bool flag = (mask & (1 << i)) != 0; GUI.Label(new Rect(4f, num5, num - 160f, 24f), recipes[i].Name + (flag ? "" : " (Unavailable)")); string text = string.Join(" ", from j in Enumerable.Range(0, 7) where costs[i][j] > 0 select names[j] + ":" + costs[i][j]); GUI.Label(new Rect(4f, num5 + 22f, num - 160f, 25f), text); bool enabled = GUI.enabled; GUI.enabled = enabled && flag && left > 0 && Enough(q, costs[i]) && Time.unscaledTime >= nextRequest; if (GUI.Button(new Rect(num - 154f, num5 + 9f, 96f, 32f), "Craft")) { Request(i); } GUI.enabled = enabled; } GUI.EndScrollView(); if (GUI.Button(new Rect(num3 + num - 130f, num4 + num2 - 36f, 112f, 27f), "Close (F7)")) { SetMenu(open: false); } } } }