public override void UpdateMachine(SegmentEntity targetEntity) { FreightCartStation station = targetEntity as FreightCartStation; //Catch for when the window is called on an inappropriate machine if (station == null) { GenericMachinePanelScript.instance.Hide(); UIManager.RemoveUIRules("Machine"); return; } GenericMachinePanelScript.instance.Scroll_Bar.GetComponent <UIScrollBar>().scrollValue -= Input.GetAxis("Mouse ScrollWheel"); if (networkredraw) { this.manager.RedrawWindow(); } if (!dirty) { return; } if (!SetFreightItems && !ItemSearchWindow && !SetNetworkID && !SetName && !SetInventoryName && !string.IsNullOrEmpty(station.NetworkID)) { this.manager.UpdateLabel("assignedcarts", "Assigned Carts: " + station.AssignedCarts.ToString(), Color.white); this.manager.UpdateLabel("loadstatus", "Wait for " + (station.mbWaitForFullLoad ? "Full" : "Any"), Color.white); this.manager.UpdateLabel("offerlabel", (station.OfferAll ? "Offer All" : "Use Offer List"), Color.white); this.manager.UpdateLabel("carttier", "Cart Tier: " + station.CartTierLabel(), Color.white); } else if (SetFreightItems && !ItemSearchWindow && !SetNetworkID && !SetName && !SetInventoryName && station.NetworkID != null) { if (station.massStorageCrate != null) { List <FreightRegistry> registries = new List <FreightRegistry>(); registries = FreightCartManager.instance.GetFreightEntries(station.NetworkID, station.massStorageCrate); for (int index = 0; index < registries.Count; index++) { ItemBase item = registries[index].FreightItem; int lowstock = registries[index].LowStock; int highstock = registries[index].HighStock; string itemname = ItemManager.GetItemName(item); string iconname = ItemManager.GetItemIcon(item); this.manager.UpdateIcon("registry" + index, iconname, Color.white); this.manager.UpdateLabel("registrytitle" + index, itemname, Color.white); this.manager.UpdateLabel("lowstock" + index, registries[index].LowStock.ToString(), this.ChooseLowStock == true ? Color.white : Color.gray); this.manager.UpdateLabel("highstock" + index, registries[index].HighStock.ToString(), this.ChooseLowStock == false ? Color.white : Color.gray); this.manager.UpdateLabel("lowstocktitle" + index, "Request if below", this.ChooseLowStock == true ? Color.white : Color.gray); this.manager.UpdateLabel("highstocktitle" + index, "Offer if above", this.ChooseLowStock == false ? Color.white : Color.gray); } } else if (station.HopperInterface != null) { ItemBase item = station.HopperInterface.OfferItem; string itemname; string iconname; if (item != null) { itemname = ItemManager.GetItemName(item); iconname = ItemManager.GetItemIcon(item); this.manager.UpdateIcon("hopitemoffer", iconname, Color.white); this.manager.UpdateLabel("registrytitle0", itemname, Color.white); } this.manager.UpdateLabel("highstock", station.HopperInterface.OfferLimit.ToString(), Color.white); item = station.HopperInterface.RequestItem; if (item != null) { itemname = ItemManager.GetItemName(item); iconname = ItemManager.GetItemIcon(item); this.manager.UpdateIcon("hopitemrequest", iconname, Color.white); this.manager.UpdateLabel("registrytitle1", itemname, Color.white); } this.manager.UpdateLabel("lowstock", station.HopperInterface.RequestLimit.ToString(), Color.white); } else { this.manager.UpdateLabel("registrytitle-1", "Connect to Freight provider", Color.red); return; } } else if (ItemSearchWindow) { if (this.SearchResults == null) { this.Counter++; foreach (char c in Input.inputString) { if (c == "\b"[0]) //Backspace { if (this.EntryString.Length != 0) { this.EntryString = this.EntryString.Substring(0, this.EntryString.Length - 1); } } else if (c == "\n"[0] || c == "\r"[0]) //Enter or Return { this.SearchResults = new List <ItemBase>(); for (int n = 0; n < ItemEntry.mEntries.Length; n++) { if (ItemEntry.mEntries[n] == null) { continue; } if (ItemEntry.mEntries[n].Name.ToLower().Contains(this.EntryString.ToLower())) { this.SearchResults.Add(ItemManager.SpawnItem(ItemEntry.mEntries[n].ItemID)); } } for (int n = 0; n < TerrainData.mEntries.Length; n++) { bool foundvalue = false; TerrainDataEntry entry = TerrainData.mEntries[n]; if (entry == null) { continue; } if (entry.Name.ToLower().Contains(this.EntryString.ToLower())) { int count = entry.Values.Count; for (int m = 0; m < count; m++) { if (entry.Values[m].Name.ToLower().Contains(this.EntryString.ToLower())) { if (string.IsNullOrEmpty(entry.PickReplacement)) { this.SearchResults.Add(ItemManager.SpawnCubeStack(entry.CubeType, entry.Values[m].Value, 1)); foundvalue = true; } } } if (!foundvalue && string.IsNullOrEmpty(entry.PickReplacement)) { this.SearchResults.Add(ItemManager.SpawnCubeStack(entry.CubeType, entry.DefaultValue, 1)); } } if ((this.EntryString.ToLower().Contains("component") || this.EntryString.ToLower().Contains("placement") || this.EntryString.ToLower().Contains("multi")) && entry.CubeType == 600) { int count = entry.Values.Count; for (int m = 0; m < count; m++) { this.SearchResults.Add(ItemManager.SpawnCubeStack(600, entry.Values[m].Value, 1)); } } } if (this.SearchResults.Count == 0) { this.SearchResults = null; } UIManager.mbEditingTextField = false; UIManager.RemoveUIRules("TextEntry"); this.manager.RedrawWindow(); return; } else { this.EntryString += c; } } this.manager.UpdateLabel("searchtext", this.EntryString + (this.Counter % 20 > 10 ? "_" : ""), Color.cyan); dirty = true; return; } else { this.manager.UpdateLabel("searchtitle", "Searching for:", Color.white); this.manager.UpdateLabel("searchtext", this.EntryString, Color.cyan); int count = this.SearchResults.Count; for (int n = 0; n < count; n++) { ItemBase item = this.SearchResults[n]; string itemname = ItemManager.GetItemName(item); string iconname = ItemManager.GetItemIcon(item); this.manager.UpdateIcon("itemicon" + n, iconname, Color.white); this.manager.UpdateLabel("iteminfo" + n, itemname, Color.white); } } } else if (SetNetworkID || string.IsNullOrEmpty(station.NetworkID) || SetName || SetInventoryName) { this.Counter++; foreach (char c in Input.inputString) { if (c == "\b"[0]) //Backspace { if (this.EntryString.Length != 0) { this.EntryString = this.EntryString.Substring(0, this.EntryString.Length - 1); } } else if (c == "\n"[0] || c == "\r"[0]) //Enter or Return { if (SetName) { FreightCartWindow.SetStationName(station, this.EntryString); this.SetName = false; } else if (SetInventoryName) { FreightCartWindow.NameInventory(station, this.EntryString); this.SetInventoryName = false; } else { FreightCartWindow.SetNetwork(station, this.EntryString); this.SetNetworkID = false; } this.EntryString = ""; UIManager.mbEditingTextField = false; UIManager.RemoveUIRules("TextEntry"); return; } else { this.EntryString += c; } } this.manager.UpdateLabel("networkentry", this.EntryString + (this.Counter % 20 > 10 ? "_" : ""), Color.cyan); dirty = true; return; } dirty = false; }
public static NetworkInterfaceResponse HandleNetworkCommand(Player player, NetworkInterfaceCommand nic) { FreightCartStation station = nic.target as FreightCartStation; string command = nic.command; if (command != null) { if (command == InterfaceRemoveReg) { FreightCartWindow.RemoveRegistry(station, nic.itemContext); } else if (command == InterfaceSetLowStock) { int stock = -1; int.TryParse(nic.payload ?? "-1", out stock); FreightCartWindow.SetLowStock(station, nic.itemContext, stock); } else if (command == InterfaceSetHighStock) { int stock = -1; int.TryParse(nic.payload ?? "-1", out stock); FreightCartWindow.SetHighStock(station, nic.itemContext, stock); } else if (command == InterfaceAssignedCarts) { int carts = 0; int.TryParse(nic.payload ?? "-1", out carts); FreightCartWindow.SetCartAssignment(station, carts); } else if (command == InterfaceCartTier) { int carttier = 0; int.TryParse(nic.payload ?? "2", out carttier); FreightCartWindow.ToggleCartTier(station, carttier); } else if (command == InterfaceHopperHigh) { int offer = -1; int.TryParse(nic.payload ?? "-1", out offer); FreightCartWindow.SetHopperOffer(station, offer); } else if (command == InterfaceHopperLow) { int request = -1; int.TryParse(nic.payload ?? "-1", out request); FreightCartWindow.SetHopperRequest(station, request); } else if (command == InterfaceToggleLoad) { FreightCartWindow.ToggleLoadStatus(station, nic.payload); } else if (command == InterfaceToggleOffer) { FreightCartWindow.ToggleOfferAll(station, nic.payload); } else if (command == InterfaceAddReg) { FreightCartWindow.AddRegistry(station, nic.itemContext); } else if (command == InterfaceSetNetwork) { FreightCartWindow.SetNetwork(station, nic.payload); } else if (command == InterfaceSetName) { FreightCartWindow.SetStationName(station, nic.payload); } else if (command == InterfaceSetInventoryName) { FreightCartWindow.NameInventory(station, nic.payload); } else if (command == InterfaceCopyFreight) { FreightCartWindow.CopyFreight(station); } else if (command == InterfacePasteFreight) { FreightCartWindow.PasteFreight(station); } else if (command == InterfaceHopperOffer) { FreightCartWindow.SetHopperOfferItem(station, nic.itemContext); } else if (command == InterfaceHopperRequest) { FreightCartWindow.SetHopperRequestItem(station, nic.itemContext); } } return(new NetworkInterfaceResponse { entity = station, inventory = player.mInventory }); }