Beispiel #1
0
        public void SendShipInfo(ShipInformation si, MaterialCommoditiesList matcommod, int cargo, ShipInformation sicurrent, long cash, long loan,
                                 JournalProgress progress, JournalRank rank     // both may be null
                                 )
        {
            lock (LockShipInfo)               // lets not double send in different threads.
            {
                if (!si.Equals(LastShipInfo)) // if we are sending new ship info..
                {
                    System.Diagnostics.Debug.WriteLine("Update EDSM with ship info" + si.ID + " " + si.ShipType + " " + cargo);
                    CommanderUpdateShip(si.ID, si.ShipType.Alt("Unknown"), si, cargo);
                    LastShipInfo = si;
                }

                if (LastShipID != sicurrent.ID) // if we have a new current ship
                {
                    System.Diagnostics.Debug.WriteLine("Update EDSM with current ship" + sicurrent.ID);
                    CommanderSetCurrentShip(sicurrent.ID);
                    LastShipID = sicurrent.ID;
                }

                if (LastEDSMCredits != cash)    // if our cash has changed..
                {
                    System.Diagnostics.Debug.WriteLine("Update EDSM with credits" + cash);
                    SetCredits(cash, loan);
                    LastEDSMCredits = cash;
                }

                if (progress != null && rank != null && (!Object.ReferenceEquals(progress, LastProgress) || !Object.ReferenceEquals(rank, LastRank)))
                {
                    System.Diagnostics.Debug.WriteLine("Update EDSM with ranks");
                    SetRanks((int)rank.Combat, progress.Combat, (int)rank.Trade, progress.Trade, (int)rank.Explore, progress.Explore, (int)rank.CQC, progress.CQC, (int)rank.Federation, progress.Federation, (int)rank.Empire, progress.Empire);
                    LastProgress = progress;
                    LastRank     = rank;
                }

                if (matcommod != null && matcommod != LastMats)
                {
                    System.Diagnostics.Debug.WriteLine("Update EDSM with materials and cargo");
                    List <MaterialCommodities> lmats  = matcommod.Sort(false);
                    List <MaterialCommodities> lcargo = matcommod.Sort(true);
                    List <MaterialCommodities> ldata  = lmats.Where(m => m.category == MaterialCommodities.MaterialEncodedCategory).ToList();
                    lmats = lmats.Where(m => m.category != MaterialCommodities.MaterialEncodedCategory).ToList();
                    SetInventoryMaterials(lmats.Where(m => m.count > 0).ToDictionary(m => m.fdname, m => m.count));
                    SetInventoryData(ldata.Where(m => m.count > 0).ToDictionary(m => m.fdname, m => m.count));
                    SetInventoryCargo(lcargo.Where(m => m.count > 0).ToDictionary(m => m.fdname, m => m.count));
                    LastMats = matcommod;
                }
            }
        }
Beispiel #2
0
        public void SendShipInfo(ShipInformation si, int cargo, ShipInformation sicurrent, long cash, long loan,
                                 JournalProgress progress, JournalRank rank     // both may be null
                                 )
        {
            lock (LockShipInfo)               // lets not double send in different threads.
            {
                if (!si.Equals(LastShipInfo)) // if we are sending new ship info..
                {
                    System.Diagnostics.Debug.WriteLine("Update EDSM with ship info" + si.ID + " " + si.ShipType + " " + cargo);
                    CommanderUpdateShip(si.ID, si.ShipType.Alt("Unknown"), si, cargo);
                    LastShipInfo = si;
                }

                if (LastShipID != sicurrent.ID) // if we have a new current ship
                {
                    System.Diagnostics.Debug.WriteLine("Update EDSM with current ship" + sicurrent.ID);
                    CommanderSetCurrentShip(sicurrent.ID);
                    LastShipID = sicurrent.ID;
                }

                if (LastEDSMCredits != cash)    // if our cash has changed..
                {
                    System.Diagnostics.Debug.WriteLine("Update EDSM with credits" + cash);
                    SetCredits(cash, loan);
                    LastEDSMCredits = cash;
                }

                if (progress != null && rank != null && (!Object.ReferenceEquals(progress, LastProgress) || !Object.ReferenceEquals(rank, LastRank)))
                {
                    System.Diagnostics.Debug.WriteLine("Update EDSM with ranks");
                    SetRanks((int)rank.Combat, progress.Combat, (int)rank.Trade, progress.Trade, (int)rank.Explore, progress.Explore, (int)rank.CQC, progress.CQC, (int)rank.Federation, progress.Federation, (int)rank.Empire, progress.Empire);
                    LastProgress = progress;
                    LastRank     = rank;
                }
            }
        }