コード例 #1
0
    public static void SetHighStock(FreightCartStation station, ItemBase item, int stock)
    {
        if (item == null)
        {
            Debug.LogWarning("Freight cart window trying to set high stock for null item!");
        }
        int lowstock = FreightCartManager.instance.GetLowStock(station.NetworkID, station.massStorageCrate, item);

        FreightCartManager.instance.UpdateRegistry(station.NetworkID, station.massStorageCrate, item, -1, stock);
        // Decrease request amount if offer amount goes below it to prevent cart looping
        if (stock < lowstock)
        {
            FreightCartWindow.SetLowStock(station, item, stock);
        }
        if (!WorldScript.mbIsServer)
        {
            NetworkManager.instance.SendInterfaceCommand(InterfaceName, InterfaceSetHighStock, stock.ToString(), item, station, 0f);
        }
        FreightCartWindow.dirty = true;
        station.MarkDirtyDelayed();
        station.RequestImmediateNetworkUpdate();
    }
コード例 #2
0
    public override void HandleItemDrag(string name, ItemBase draggedItem, DragAndDropManager.DragRemoveItem dragDelegate, SegmentEntity targetEntity)
    {
        FreightCartStation station = targetEntity as FreightCartStation;

        if (station.massStorageCrate == null)
        {
            return;
        }

        if (name.Contains("registry")) // drag drop to a slot
        {
            int slotNum = -1;
            int.TryParse(name.Replace("registry", ""), out slotNum); //Get slot name as number

            if (slotNum == -1)                                       // valid slot
            {
                if (this.manager.mWindowLookup[name + "_icon"].GetComponent <UISprite>().spriteName == "empty")
                {
                    FreightCartWindow.AddRegistry(station, draggedItem);
                }
            }
        }
        else if (name == "hopitemoffer")
        {
            if (this.manager.mWindowLookup["hopitemoffer"].GetComponent <UISprite>().spriteName == "empty")
            {
                FreightCartWindow.SetHopperOfferItem(station, draggedItem);
            }
        }
        else if (name == "hopitemrequest")
        {
            if (this.manager.mWindowLookup["hopitemrequest"].GetComponent <UISprite>().spriteName == "empty")
            {
                FreightCartWindow.SetHopperRequestItem(station, draggedItem);
            }
        }

        return;
    }
コード例 #3
0
    public override bool ButtonClicked(string name, SegmentEntity targetEntity)
    {
        if (name == "nextnetwork") // Increment network count
        {
            this.SelectedNetwork++;
            if (this.SelectedNetwork >= fcm.Networks.Count)
            {
                this.SelectedNetwork = 0;
            }
            NetworkSync.NetworkStatus = null;
            this.manager.RedrawWindow();
            return(true);
        }
        else if (name == "prevnetwork") // Decrement network count
        {
            this.SelectedNetwork--;
            if (this.SelectedNetwork < 0)
            {
                this.SelectedNetwork = fcm.Networks.Count - 1;
            }
            NetworkSync.NetworkStatus = null;
            this.manager.RedrawWindow();
            return(true);
        }
        else if (name == "nextstorage") // Increment storage count
        {
            this.SelectedStorage++;
            if (this.SelectedStorage >= fcm.StationInventories.Count)
            {
                this.SelectedStorage = 0;
            }
            this.manager.RedrawWindow();
            return(true);
        }
        else if (name == "prevstorage") // Decrement storage count
        {
            this.SelectedStorage--;
            if (this.SelectedStorage < 0)
            {
                this.SelectedStorage = fcm.StationInventories.Count - 1;
            }
            this.manager.RedrawWindow();
            return(true);
        }
        else if (name == "allnetworks")
        {
            if (this.CurrentWindow == WindowTypes.GlobalInventory)
            {
                this.CurrentWindow = WindowTypes.NetworkStatus;
            }
            else
            {
                this.CurrentWindow = WindowTypes.GlobalInventory;
            }
            this.manager.RedrawWindow();
            return(true);
        }
        else if (name == "tracknetworks")
        {
            if (this.CurrentWindow == WindowTypes.TrackNetworks)
            {
                this.CurrentWindow = WindowTypes.NetworkStatus;
            }
            else
            {
                this.CurrentWindow = WindowTypes.TrackNetworks;
            }
            this.manager.RedrawWindow();
            return(true);
        }
        else if (name == "selnetwork")
        {
            if (this.CurrentWindow == WindowTypes.NetworkSelection)
            {
                this.CurrentWindow = WindowTypes.NetworkStatus;
            }
            else
            {
                this.CurrentWindow = WindowTypes.NetworkSelection;
            }
            this.manager.RedrawWindow();
            return(true);
        }
        else if (name == "viewinventory")
        {
            if (this.CurrentWindow == WindowTypes.StorageInventory)
            {
                this.CurrentWindow = WindowTypes.NetworkStatus;
            }
            else
            {
                this.CurrentWindow = WindowTypes.StorageInventory;
            }
            this.manager.RedrawWindow();
            return(true);
        }
        else if (name.Contains("networknum"))
        {
            int slotNum = -1;
            int.TryParse(name.Replace("networknum", ""), out slotNum); //Get slot name as number

            if (slotNum > -1)                                          // valid slot
            {
                this.SelectedNetwork      = slotNum;
                NetworkSync.NetworkStatus = null;
                this.CurrentWindow        = WindowTypes.NetworkStatus;
                this.manager.RedrawWindow();
                return(true);
            }
        }
        else if (name.Contains("trackicon"))
        {
            int slotNum = -1;
            int.TryParse(name.Replace("trackicon", ""), out slotNum); //Get slot name as number

            if (slotNum > -1)                                         // valid slot
            {
                if (this.TrackNetworkDisplay == slotNum)
                {
                    this.TrackNetworkDisplay = -1;
                }
                else
                {
                    this.TrackNetworkDisplay = slotNum;
                }
                this.StationDisplay = -1;
                this.CartDisplay    = -1;
                this.manager.RedrawWindow();
                return(true);
            }
        }
        else if (name.Contains("stationicon"))
        {
            int slotNum = -1;
            int.TryParse(name.Replace("stationicon", ""), out slotNum); //Get slot name as number

            if (slotNum > -1)                                           // valid slot
            {
                if (this.StationDisplay == slotNum)
                {
                    this.StationDisplay = -1;
                }
                else
                {
                    this.StationDisplay = slotNum;
                }
                this.CartDisplay = -1;
                this.manager.ClearWindow();
                this.manager.RedrawWindow();
                return(true);
            }
        }
        else if (name.Contains("carticon"))
        {
            int slotNum = -1;
            int.TryParse(name.Replace("carticon", ""), out slotNum); //Get slot name as number

            if (slotNum > -1)                                        // valid slot
            {
                if (this.CartDisplay == slotNum)
                {
                    this.CartDisplay = -1;
                }
                else
                {
                    this.CartDisplay = slotNum;
                }
                this.manager.RedrawWindow();
                return(true);
            }
        }
        else if (name == "addcart")
        {
            int amount = 1;
            if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift))
            {
                amount = 10;
            }
            FreightCartWindow.SetCartAssignment(this.CurrentStation, this.CurrentStation.AssignedCarts + amount);
            this.manager.UpdateLabel("stationcarts" + this.StationDisplay.ToString(), "Carts: " + this.CurrentStation.AvailableCarts.ToString() + " / " + this.CurrentStation.AssignedCarts.ToString(), this.CurrentStation.AvailableCarts > this.CurrentStation.AssignedCarts ? Color.green : this.CurrentStation.AvailableCarts == this.CurrentStation.AssignedCarts ? Color.white : Color.red);
            return(true);
        }
        else if (name == "removecart")
        {
            int amount = 1;
            if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift))
            {
                amount = 10;
            }
            FreightCartWindow.SetCartAssignment(this.CurrentStation, this.CurrentStation.AssignedCarts - amount < 0 ? 0 : this.CurrentStation.AssignedCarts - amount);
            this.manager.UpdateLabel("stationcarts" + this.StationDisplay.ToString(), "Carts: " + this.CurrentStation.AvailableCarts.ToString() + " / " + this.CurrentStation.AssignedCarts.ToString(), this.CurrentStation.AvailableCarts > this.CurrentStation.AssignedCarts ? Color.green : this.CurrentStation.AvailableCarts == this.CurrentStation.AssignedCarts ? Color.white : Color.red);
            return(true);
        }
        else if (name == "ordername")
        {
            this.OrderByName = true;
            this.manager.RedrawWindow();
        }
        else if (name == "ordercount")
        {
            this.OrderByName = false;
            this.manager.RedrawWindow();
        }
        else if (name == "togglelayout")
        {
            this.CompactLayout = !this.CompactLayout;
            this.manager.RedrawWindow();
        }

        return(false);
    }
コード例 #4
0
    public override bool ButtonClicked(string name, SegmentEntity targetEntity)
    {
        FreightCartStation station = targetEntity as FreightCartStation;

        if (name.Contains("registry")) // drag drop to a slot
        {
            int slotNum = -1;
            int.TryParse(name.Replace("registry", ""), out slotNum); //Get slot name as number
            List <FreightRegistry> registries = FreightCartManager.instance.GetFreightEntries(station.NetworkID, station.massStorageCrate);

            if (slotNum > -1) // valid slot
            {
                FreightCartWindow.RemoveRegistry(station, registries[slotNum].FreightItem);
            }
            return(true);
        }
        else if (name == "hopitemoffer")
        {
            if (station.HopperInterface.OfferItem == null)
            {
                return(true);
            }
            FreightCartWindow.SetHopperOfferItem(station, null);
            this.manager.RedrawWindow();
            return(true);
        }
        else if (name == "hopitemrequest")
        {
            if (station.HopperInterface.RequestItem == null)
            {
                return(true);
            }
            FreightCartWindow.SetHopperRequestItem(station, null);
            this.manager.RedrawWindow();
            return(true);
        }
        else if (name.Contains("switchlowstock"))
        {
            this.ChooseLowStock = true;
            this.manager.RedrawWindow();
            return(true);
        }
        else if (name.Contains("switchhighstock"))
        {
            this.ChooseLowStock = false;
            this.manager.RedrawWindow();
            return(true);
        }
        else if (name.Contains("decreasestock"))
        {
            int slotNum = -1;
            int.TryParse(name.Replace("decreasestock", ""), out slotNum); //Get slot name as number
            List <FreightRegistry> registries = FreightCartManager.instance.GetFreightEntries(station.NetworkID, station.massStorageCrate);

            if (slotNum > -1) // valid slot
            {
                int amount = 100;
                if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift))
                {
                    amount = 10;
                }
                if (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl))
                {
                    amount = 1;
                }
                if (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt))
                {
                    amount = 1000;
                }

                int stock;
                if (this.ChooseLowStock)
                {
                    stock = registries[slotNum].LowStock - amount;
                    if (stock < 0)
                    {
                        stock = 0;
                    }
                    FreightCartWindow.SetLowStock(station, registries[slotNum].FreightItem, stock);
                    return(true);
                }
                else
                {
                    stock = registries[slotNum].HighStock - amount;
                    if (stock < 0)
                    {
                        stock = 0;
                    }
                    FreightCartWindow.SetHighStock(station, registries[slotNum].FreightItem, stock);
                    return(true);
                }
            }
        }
        else if (name.Contains("increasestock"))
        {
            int slotNum = -1;
            int.TryParse(name.Replace("increasestock", ""), out slotNum); //Get slot name as number
            List <FreightRegistry> registries = FreightCartManager.instance.GetFreightEntries(station.NetworkID, station.massStorageCrate);

            if (slotNum > -1) // valid slot
            {
                int amount = this.ModifierItemCount();
                int stock;
                if (this.ChooseLowStock)
                {
                    stock = registries[slotNum].LowStock + amount;
                    FreightCartWindow.SetLowStock(station, registries[slotNum].FreightItem, stock);
                    return(true);
                }
                else
                {
                    stock = registries[slotNum].HighStock + amount;
                    FreightCartWindow.SetHighStock(station, registries[slotNum].FreightItem, stock);
                    return(true);
                }
            }
        }
        else if (name == "hopofferdown")
        {
            int amount = station.HopperInterface.OfferLimit - this.ModifierItemCount();
            if (amount < 0)
            {
                amount = 0;
            }
            FreightCartWindow.SetHopperOffer(station, amount);
            return(true);
        }
        else if (name == "hopofferup")
        {
            int amount = station.HopperInterface.OfferLimit + this.ModifierItemCount();
            if (amount > station.HopperInterface.Machine.TotalCapacity)
            {
                amount = station.HopperInterface.Machine.TotalCapacity;
            }
            FreightCartWindow.SetHopperOffer(station, amount);
            return(true);
        }
        else if (name == "hoprequestdown")
        {
            int amount = station.HopperInterface.RequestLimit - this.ModifierItemCount();
            if (amount < 0)
            {
                amount = 0;
            }
            FreightCartWindow.SetHopperRequest(station, amount);
            return(true);
        }
        else if (name == "hoprequestup")
        {
            int amount = station.HopperInterface.RequestLimit + this.ModifierItemCount();
            FreightCartWindow.SetHopperRequest(station, amount);
            return(true);
        }
        else if (name.Contains("searchcancel"))
        {
            this.ItemSearchWindow        = false;
            this.SearchResults           = null;
            UIManager.mbEditingTextField = false;
            UIManager.RemoveUIRules("TextEntry");
            this.EntryString = "";
            GenericMachinePanelScript.instance.Scroll_Bar.GetComponent <UIScrollBar>().scrollValue = 0.0f;
            this.manager.RedrawWindow();
            return(true);
        }
        else if (name.Contains("itemicon"))
        {
            int slotNum = -1;
            int.TryParse(name.Replace("itemicon", ""), out slotNum); //Get slot name as number
            if (slotNum > -1)
            {
                switch (eSearchType)
                {
                case SearchType.Registry:
                    FreightCartWindow.AddRegistry(station, this.SearchResults[slotNum]);
                    break;

                case SearchType.HopperOffer:
                    FreightCartWindow.SetHopperOfferItem(station, this.SearchResults[slotNum]);
                    break;

                case SearchType.HopperRequest:
                    FreightCartWindow.SetHopperRequestItem(station, this.SearchResults[slotNum]);
                    break;
                }
                this.SearchResults    = null;
                this.ItemSearchWindow = false;
                this.EntryString      = "";
                GenericMachinePanelScript.instance.Scroll_Bar.GetComponent <UIScrollBar>().scrollValue = 0.0f;
                return(true);
            }
        }
        else if (name == "namenetwork")
        {
            this.SetNetworkID = true;
            this.Redraw(targetEntity);
            return(true);
        }
        else if (name == "stationname")
        {
            this.SetName = true;
            this.Redraw(targetEntity);
            return(true);
        }
        else if (name == "namestorage")
        {
            this.SetInventoryName = true;
            this.Redraw(targetEntity);
            return(true);
        }
        else if (name == "networkidcancel")
        {
            this.SetNetworkID            = false;
            this.SetName                 = false;
            this.SetInventoryName        = false;
            UIManager.mbEditingTextField = false;
            UIManager.RemoveUIRules("TextEntry");
            this.EntryString = "";
            if (string.IsNullOrEmpty(station.NetworkID))
            {
                GenericMachinePanelScript.instance.Hide();
                return(true);
            }
            this.manager.RedrawWindow();
        }
        else if (name == "setfreight")
        {
            this.SetFreightItems = true;
            this.manager.RedrawWindow();
            return(true);
        }
        else if (name == "freightdone")
        {
            this.SetFreightItems = false;
            this.manager.RedrawWindow();
            return(true);
        }
        else if (name == "increasecarts")
        {
            int amount = 1;
            if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift))
            {
                amount = 10;
            }
            FreightCartWindow.SetCartAssignment(station, station.AssignedCarts + amount);
            return(true);
        }
        else if (name == "decreasecarts")
        {
            int amount = 1;
            if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift))
            {
                amount = 10;
            }
            FreightCartWindow.SetCartAssignment(station, station.AssignedCarts - amount < 0 ? 0 : station.AssignedCarts - amount);
            return(true);
        }
        else if (name == "toggleload")
        {
            FreightCartWindow.ToggleLoadStatus(station, !station.mbWaitForFullLoad ? "Full" : "Any");
            return(true);
        }
        else if (name == "toggleoffer")
        {
            FreightCartWindow.ToggleOfferAll(station, !station.OfferAll ? "All" : "registry");
            return(true);
        }
        else if (name == "togglecarttier")
        {
            FreightCartWindow.ToggleCartTier(station, station.CartTier);
            return(true);
        }

        return(false);
    }
コード例 #5
0
    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;
    }
コード例 #6
0
    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
        });
    }