Exemplo n.º 1
0
    public override void UpdateMachine(SegmentEntity targetEntity)
    {
        FreightSystemMonitor monitor = targetEntity as FreightSystemMonitor;

        //Catch for when the window is called on an inappropriate machine
        if (monitor == null)
        {
            GenericMachinePanelScript.instance.Hide();
            UIManager.RemoveUIRules("Machine");
            return;
        }

        if (networkredraw)
        {
            this.manager.RedrawWindow();
        }

        GenericMachinePanelScript.instance.Scroll_Bar.GetComponent <UIScrollBar>().scrollValue -= Input.GetAxis("Mouse ScrollWheel");

        switch (this.CurrentWindow)
        {
        case WindowTypes.NetworkStatus:
            this.UpdateNetworkStatus();
            break;

        case WindowTypes.GlobalInventory:
            this.UpdateGlobalInventory();
            break;

        case WindowTypes.StorageInventory:
            this.UpdateStorageInventory();
            break;
        }
    }
    public static NetworkInterfaceResponse HandleNetworkCommand(Player player, NetworkInterfaceCommand nic)
    {
        FreightSystemMonitor monitor = nic.target as FreightSystemMonitor;
        string command = nic.command;

        if (command != null)
        {
            if (command == InterfaceNetStatus)
            {
                int Netindex = 0;
                int.TryParse(nic.payload ?? "-1", out Netindex);
                SystemMonitorWindow.RequestNetworkStatus(Netindex, player, monitor);
            }
            else if (command == InterfaceTrackSystems)
            {
                int      tracknetwork = -1;
                int      station      = -1;
                int      cart         = -1;
                string[] output       = nic.payload.Split(',');
                if (output.Length > 2)
                {
                    int.TryParse(output[0] ?? "-1", out tracknetwork);
                    int.TryParse(output[1] ?? "-1", out station);
                    int.TryParse(output[2] ?? "-1", out cart);
                }
                SystemMonitorWindow.RequestTrackNetworks(tracknetwork, station, cart, player, monitor);
            }
        }

        return(new NetworkInterfaceResponse
        {
            entity = monitor,
            inventory = player.mInventory
        });
    }
Exemplo n.º 3
0
    private void SpawnNetworkStatus(FreightSystemMonitor monitor)
    {
        this.manager.SetTitle("Freight System Status");

        this.manager.AddButton("prevnetwork", "Previous Network", buttonx1, 0);
        this.manager.AddButton("allnetworks", "Global Inventory", buttonx2, 0);
        this.manager.AddButton("selnetwork", "Select Network", buttonx3, 0);
        this.manager.AddButton("tracknetworks", "Track Systems", buttonx4, 0);
        this.manager.AddButton("viewinventory", "View Inventory", buttonx5, 0);
        this.manager.AddButton("nextnetwork", "Next Network", buttonx6, 0);

        if (NetworkSync.NetworkStatus == null)
        {
            SystemMonitorWindow.RequestNetworkStatus(this.SelectedNetwork, WorldScript.mLocalPlayer, monitor);
        }

        if (NetworkSync.NetworkStatus != null)
        {
            int spacing     = 60;                  //Spacing between each registry line
            int count       = 0;
            int yoffset     = 100;                 //Offset below button row
            int col2xoffset = 350 + globalxoffset; //Col 2 offset from the left
            int col3xoffset = 125 + col2xoffset;   //Col 3 offset from the left
            int col4xoffset = 125 + col3xoffset;   //Col 3 offset from the left
            int col5xoffset = 125 + col4xoffset;   //Col 4 offset from the left

            //this.Registries = new List<FreightRegistry>();
            //this.FullInventory = new Dictionary<ItemBase, int>(new ItemBaseComparer());
            //this.Registries = fcm.GetNetworkRegistries(this.SelectedNetwork);
            count = NetworkSync.NetworkStatus.Registries.Count;
            //Debug.Log("After registeries counting " + count);
            this.manager.AddBigLabel("nameofnetworktitle", "Viewing status of freight network: ", Color.cyan, 350, 50);
            this.manager.AddBigLabel("nameofnetwork", NetworkSync.NetworkStatus.NetworkID, Color.cyan, 650, 50);
            //Debug.Log("Spawning window with network: " + fcm.Networks[this.SelectedNetwork]);
            for (int n = 0; n < count; n++)
            {
                //Debug.Log("Catch error at n = " + n);
                this.manager.AddIcon("item" + n, "empty", Color.white, globalxoffset + 40, yoffset + (spacing * n));
                this.manager.AddBigLabel("registrytitle" + n, "Registry Item", Color.white, 100 + globalxoffset, yoffset + (spacing * n));
                this.manager.AddLabel(GenericMachineManager.LabelType.OneLineHalfWidth, "deficittitle" + n, "Network Deficit", Color.white, false, col2xoffset, yoffset + (spacing * n));
                this.manager.AddLabel(GenericMachineManager.LabelType.OneLineHalfWidth, "surptitle" + n, "Network Surplus", Color.white, false, col3xoffset, yoffset + (spacing * n));
                this.manager.AddLabel(GenericMachineManager.LabelType.OneLineHalfWidth, "stocktitle" + n, "In Transit", Color.white, false, col4xoffset, yoffset + (spacing * n));
                this.manager.AddLabel(GenericMachineManager.LabelType.OneLineHalfWidth, "invtitle" + n, "Network Inventory", Color.white, false, col5xoffset, yoffset + (spacing * n));
                this.manager.AddLabel(GenericMachineManager.LabelType.OneLineHalfWidth, "deficit" + n, "0", Color.white, false, col2xoffset, yoffset + (spacing * n + 20));
                this.manager.AddLabel(GenericMachineManager.LabelType.OneLineHalfWidth, "surplus" + n, "0", Color.white, false, col3xoffset, yoffset + (spacing * n + 20));
                this.manager.AddLabel(GenericMachineManager.LabelType.OneLineHalfWidth, "stock" + n, "0", Color.white, false, col4xoffset, yoffset + (spacing * n + 20));
                this.manager.AddLabel(GenericMachineManager.LabelType.OneLineHalfWidth, "totalinv" + n, "0", Color.white, false, col5xoffset, yoffset + (spacing * n + 20));
            }
        }
        else if (WorldScript.mbIsServer)
        {
            this.manager.AddBigLabel("loadingnetworks", "No Freight Networks found...", Color.red, 225, 150);
        }
        else
        {
            this.manager.AddBigLabel("loadingnetworks", "Waiting for server...", Color.red, 225, 150);
        }
    }
Exemplo n.º 4
0
 public static void RequestNetworkStatus(int netindex, Player player, FreightSystemMonitor monitor)
 {
     if (WorldScript.mbIsServer)
     {
         NetworkSync.GetNetworkStatus(netindex, player);
     }
     else
     {
         NetworkManager.instance.SendInterfaceCommand(InterfaceName, InterfaceNetStatus, netindex.ToString(), null, monitor, 0f);
     }
 }
Exemplo n.º 5
0
    public override void SpawnWindow(SegmentEntity targetEntity)
    {
        FreightSystemMonitor monitor = targetEntity as FreightSystemMonitor;

        //Catch for when the window is called on an inappropriate machine
        if (monitor == null)
        {
            //GenericMachinePanelScript.instance.Hide();
            UIManager.RemoveUIRules("Machine");

            return;
        }

        //Debug.LogWarning("first area test fsm");
        if (fcm == null)
        {
            Debug.LogWarning("Freight cart manager instance is null in System Monitor Window SpawnWindow!!");
        }
        if (fcm != null && this.SelectedNetwork >= fcm.Networks.Count)
        {
            this.SelectedNetwork = 0;
        }

        if (!firstopen)
        {
            this.InitializeWindow();
        }

        switch (this.CurrentWindow)
        {
        case WindowTypes.NetworkStatus:
            this.SpawnNetworkStatus(monitor);
            break;

        case WindowTypes.NetworkSelection:
            this.SpawnNetworkSelection();
            break;

        case WindowTypes.TrackNetworks:
            this.SpawnTrackNetworks();
            break;

        case WindowTypes.GlobalInventory:
            this.SpawnGlobalInventory();
            break;

        case WindowTypes.StorageInventory:
            this.SpawnStorageInventory();
            break;
        }
        this.dirty    = true;
        networkredraw = false;
    }
Exemplo n.º 6
0
    public static NetworkInterfaceResponse HandleNetworkCommand(Player player, NetworkInterfaceCommand nic)
    {
        FreightSystemMonitor monitor = nic.target as FreightSystemMonitor;
        string command = nic.command;

        if (command != null)
        {
            if (command == InterfaceNetStatus)
            {
                int Netindex = 0;
                int.TryParse(nic.payload ?? "-1", out Netindex);
                SystemMonitorWindow.RequestNetworkStatus(Netindex, player, monitor);
            }
        }

        return(new NetworkInterfaceResponse
        {
            entity = monitor,
            inventory = player.mInventory
        });
    }
Exemplo n.º 7
0
    public override void ButtonEnter(string name, SegmentEntity targetEntity)
    {
        FreightSystemMonitor monitor = targetEntity as FreightSystemMonitor;

        if (this.CurrentWindow != WindowTypes.GlobalInventory)
        {
            return;
        }
        string   str = string.Empty;
        int      count;
        ItemBase itemForSlot = this.GetItemForSlot(name, out count);

        if (itemForSlot == null)
        {
            return;
        }
        if (HotBarManager.mbInited)
        {
            HotBarManager.SetCurrentBlockLabel(ItemManager.GetItemName(itemForSlot));
        }
        else
        {
            if (!SurvivalHotBarManager.mbInited)
            {
                return;
            }
            string name1 = !WorldScript.mLocalPlayer.mResearch.IsKnown(itemForSlot) ? "Unknown Material" : ItemManager.GetItemName(itemForSlot);
            if (count > 1)
            {
                SurvivalHotBarManager.SetCurrentBlockLabel(string.Format("{0} {1}", count, name1));
            }
            else
            {
                SurvivalHotBarManager.SetCurrentBlockLabel(name1);
            }
        }
    }
    private void SpawnTrackNetworks(FreightSystemMonitor monitor)
    {
        this.manager.SetTitle("Track Systems");
        this.manager.AddButton("allnetworks", "Global Inventory", buttonx2, 0);
        this.manager.AddButton("selnetwork", "Select Network", buttonx3, 0);
        this.manager.AddButton("tracknetworks", "Network Status", buttonx4, 0);
        this.manager.AddButton("viewinventory", "View Inventory", buttonx5, 0);

        int ycursor      = 65;
        int trackiconx   = globalxoffset + 175;
        int trackxoffset = trackiconx + 65;
        int tracklabel   = trackxoffset + 250;
        int stationxicon = trackiconx + 50;
        int stationlabel = stationxicon + 65;
        int cartxicon    = stationxicon + 50;
        int cartlabel    = cartxicon + 65;
        int invxicon     = cartxicon + 50;
        int invlabel     = invxicon + 65;

        if (NetworkSync.TrackNetworks == null)
        {
            SystemMonitorWindow.RequestTrackNetworks(this.TrackNetworkDisplay, this.StationDisplay, this.CartDisplay, WorldScript.mLocalPlayer, monitor);
        }

        //int networkcount = FreightCartManager.instance.GlobalTrackNetworks.Count;

        if (NetworkSync.TrackNetworks != null && NetworkSync.TrackNetworks.NetworkCount > 0)
        {
            for (int n = 0; n < NetworkSync.TrackNetworks.NetworkCount; n++)
            {
                TrackNetworkStats network = NetworkSync.TrackNetworks.NetworkStats[n];
                if (network == null)
                {
                    continue;
                }
                this.DisplayTrackNetworks(network, n, ref ycursor, trackiconx, trackxoffset, tracklabel);

                if (this.TrackNetworkDisplay == n)
                {
                    List <StationStats> stations = NetworkSync.TrackNetworks.Stations;
                    for (int m = 0; m < NetworkSync.TrackNetworks.StationCount; m++)
                    {
                        StationStats station = NetworkSync.TrackNetworks.Stations[m];
                        this.DisplayStation(station, m, ref ycursor, stationxicon, stationlabel);

                        if (this.StationDisplay == m)
                        {
                            // How do I network this? ...
                            //this.manager.AddButton("addcart", "Add Cart", stationlabel + 475, ycursor - 60);
                            //this.manager.AddButton("removecart", "Remove Cart", stationlabel + 475, ycursor - 10);
                            //this.CurrentStation = station;

                            //List<FreightRegistry> LocalDeficits = new List<FreightRegistry>();
                            //List<FreightRegistry> LocalSurplus = new List<FreightRegistry>();
                            //if (station.massStorageCrate != null)
                            //{
                            //    LocalDeficits = FreightCartManager.instance.GetLocalDeficit(station.NetworkID, station.massStorageCrate);
                            //    LocalSurplus = FreightCartManager.instance.GetLocalSurplus(station.NetworkID, station.massStorageCrate);
                            //}
                            //else if (station.HopperInterface != null)
                            //{
                            //    LocalDeficits = this.FreightListingConversion(station.HopperInterface.FreightRequests.OrderByDescending(x => x.Quantity).Take(3).ToList());
                            //    LocalSurplus = this.FreightListingConversion(station.HopperInterface.FreightOfferings.OrderByDescending(x => x.Quantity).Take(3).ToList());
                            //}
                            //else if (station.AttachedInterface != null)
                            //{
                            //    LocalDeficits = this.FreightListingConversion(station.AttachedInterface.FreightRequests.OrderByDescending(x => x.Quantity).Take(3).ToList());
                            //    LocalSurplus = this.FreightListingConversion(station.AttachedInterface.FreightOfferings.OrderByDescending(x => x.Quantity).Take(3).ToList());
                            //}
                            this.DisplayDefSur(ref ycursor, stationlabel);

                            for (int p = 0; p < NetworkSync.TrackNetworks.CartCount; p++)
                            {
                                CartStats cart = NetworkSync.TrackNetworks.Carts[p];
                                this.DisplayCart(cart, p, ref ycursor, cartlabel, cartxicon);

                                if (p == CartDisplay)
                                {
                                    this.DisplayCartInventory(cart, ref ycursor, invxicon, invlabel);
                                }
                            }
                        }
                    }
                    //Insert Tour cart staion listing here
                }
            }
        }
        else if (WorldScript.mbIsServer || (NetworkSync.TrackNetworks != null && NetworkSync.TrackNetworks.NetworkCount == 0))
        {
            this.manager.AddBigLabel("notracknetworks", "No track networks found...", Color.red, 225, 150);
        }
        else
        {
            this.manager.AddBigLabel("notracknetworks", "Waiting for server...", Color.red, 225, 150);
        }
    }
 public static void RequestTrackNetworks(int tracknetwork, int station, int cart, Player player, FreightSystemMonitor monitor)
 {
     if (WorldScript.mbIsServer)
     {
         NetworkSync.GetTrackNetworks(tracknetwork, station, cart, player);
     }
     else
     {
         NetworkManager.instance.SendInterfaceCommand(InterfaceName, InterfaceTrackSystems, tracknetwork.ToString() + "," + station.ToString() + "," + cart.ToString(), null, monitor, 0f);
     }
 }