private void DisplayTrackNetworks(TrackNetworkStats network, int n, ref int ycursor, int trackiconx, int trackxoffset, int tracklabel)
 {
     this.manager.AddIcon("trackicon" + n, "Track Straight", Color.white, trackiconx, ycursor);
     this.manager.AddBigLabel("trackjunctions" + n, "ID: " + network.NetworkID.ToString() + "   " + network.JunctionCount.ToString() + " Junctions   Carts: ", network.NetworkClosed ? Color.white : Color.red, trackxoffset, ycursor);
     this.manager.AddBigLabel("trackcarts" + n, network.AvailableCarts.ToString() + " / " + network.AssignedCarts.ToString(), network.AvailableCarts > network.AssignedCarts ? Color.green : network.AvailableCarts == network.AssignedCarts ? Color.white : Color.red, tracklabel, ycursor);
     ycursor += 60;
 }
示例#2
0
    public void Read(NetIncomingMessage message)
    {
        // Track Networks
        this.NetworkCount = message.ReadInt32();
        this.NetworkStats = new List <TrackNetworkStats>(this.NetworkCount);
        for (int n = 0; n < NetworkCount; n++)
        {
            TrackNetworkStats stats = new TrackNetworkStats();
            stats.Read(message);
            this.NetworkStats.Add(stats);
        }

        // Stations
        this.StationCount = message.ReadInt32();
        if (this.StationCount > 0)
        {
            this.Stations = new List <StationStats>(this.StationCount);
            for (int n = 0; n < StationCount; n++)
            {
                StationStats stats = new StationStats();
                stats.Read(message);
                this.Stations.Add(stats);
            }
        }

        ReadRegistries(message, true);
        ReadRegistries(message, false);

        // Carts
        this.CartCount = message.ReadInt32();
        if (this.CartCount > 0)
        {
            this.Carts = new List <CartStats>(this.CartCount);
            for (int n = 0; n < CartCount; n++)
            {
                CartStats stats = new CartStats();
                stats.Read(message);
                this.Carts.Add(stats);
            }
        }

        // Displayed Cart
        int count = message.ReadInt32();

        CartInventory = new List <ItemBase>(count);
        for (int n = 0; n < count; n++)
        {
            ItemBase item;
            item = ItemReader(message);
            if (item != null)
            {
                CartInventory.Add(item);
            }
        }
    }
    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);
        }
    }