public SpaceStationManager(
     Core.IEntityAccess entityAccess,
     Core.AbstractEntityManager <Entity.MarketEntry> marketEntryManager,
     Core.AbstractEntityManager <Entity.JumpConnection> jumpConnectionManager
     )
     : base(entityAccess)
 {
     _marketEntryManager    = marketEntryManager;
     _jumpConnectionManager = jumpConnectionManager;
 }
Example #2
0
        private void CreateUpdateOrDeleteMarketEntry(
            Core.AbstractEntityManager <Entity.MarketEntry> marketEntryManager, Entity.CommodityType commodityType, MarketEntryLine marketEntryLine,
            ref int createdEntries, ref int updatedEntries, ref int removedEntries, ref int skippedEntries
            )
        {
            var potentialMatches = marketEntryManager.GetAll().Where(x => x.CommodityType == commodityType && x.SpaceStation == _spaceStationComboBox.SelectedItem);

            if (marketEntryLine.IsEmpty())
            {
                // If there are no market entires for the current commodity type and space stations, skip this line
                if (potentialMatches.Count() == 0)
                {
                    skippedEntries++;
                    return;
                }

                // Otherwise: Delete the potential match (should only be one)
                marketEntryManager.RemoveObject(potentialMatches.First());
                removedEntries++;
                return;
            }

            // Else: If there is a matching entry, update that one, otherwise create a new one
            if (potentialMatches.Count() == 0)
            {
                _entityHandler.AddObject(
                    marketEntryLine.CreateMarketEntry(),
                    commodityType,
                    ((Entity.SpaceStation)_spaceStationComboBox.SelectedItem)
                    );
                createdEntries++;
            }
            else
            {
                var tempEntry   = marketEntryLine.CreateMarketEntry();
                var marketEntry = potentialMatches.First();

                // skip if nothing must be updated
                if (tempEntry.Equals(marketEntry))
                {
                    return;
                }

                marketEntry.SellToStationPrice  = tempEntry.SellToStationPrice;
                marketEntry.BuyFromStationPrice = tempEntry.BuyFromStationPrice;
                marketEntry.Demand = tempEntry.Demand;
                marketEntry.Supply = tempEntry.Supply;

                _entityHandler.UpdateObject(marketEntry);
                updatedEntries++;
            }
        }
Example #3
0
 public SolarSystemManager(Core.IEntityAccess entityAccess, Core.AbstractEntityManager <Entity.SpaceStation> spaceStationManager)
     : base(entityAccess)
 {
     _spaceStationManager = spaceStationManager;
 }
 public void Add <TEntity>(Core.AbstractEntityManager <TEntity> entityManager) where TEntity : Core.IEntity
 {
     _internalDictionary.Add(typeof(TEntity), entityManager);
 }
 public CommodityTypeManager(Core.IEntityAccess entityAccess, Core.AbstractEntityManager <Entity.MarketEntry> marketEntryManager)
     : base(entityAccess)
 {
     _marketEntryManager = marketEntryManager;
 }
 public CommodityGroupManager(Core.IEntityAccess entityAccess, Core.AbstractEntityManager <Entity.CommodityType> commodityTypeManager)
     : base(entityAccess)
 {
     _commodityTypeManager = commodityTypeManager;
 }