public virtual CargoResult AddStatefulCargo(StatefulCargo c, bool suspendBoundsChecking)
        {
#if !ADMIN
            if (suspendBoundsChecking || CheckCargoSpace(c.CargoType, 1))
            {
#endif
            if (!_model.StatefulCargo.ContainsKey(c.Id))
            {
                _model.StatefulCargo.Add(c.Id, c);
                _model.FilledHolds += StatefulCargo.SpacePerObject(c.CargoType);
                _incrementStatefulCargoCount(c.CargoType);
                return(CargoResult.Success);
            }
            else
            {
                return(CargoResult.StatefulCargoIDAlreadyAdded);
            }
#if !ADMIN
        }

        else
        {
            return(CargoResult.NotEnoughCargoSpace);
        }
#endif
        }
示例#2
0
        public override CargoResult AddStatefulCargo(StatefulCargo c, bool suspendBoundsChecking)
        {
            _model.StatefulCargo.Add(c.Id, c);
            _model.FilledHolds += StatefulCargo.SpacePerObject(c.CargoType);
            _incrementStatefulCargoCount(c.CargoType);
            if (StatefulCargoPriceGetter != null)
            {
                SetCargoPurchasePrice(PortHelper.GetPortWareIdentifier(c.CargoType), StatefulCargoPriceGetter(new StatefulCargo_RO(c), GetCargoAmount(c.CargoType), PriceType.PortPurchasing));
                SetCargoSalePrice(PortHelper.GetPortWareIdentifier(c.CargoType), StatefulCargoPriceGetter(new StatefulCargo_RO(c), GetCargoAmount(c.CargoType), PriceType.PortSelling));
            }

            PortWareIdentifier identifier;

            if (c.CargoType == StatefulCargoTypes.Module)
            {
                _model.UIComponent.Modules.Add(c.Id, UIHelper.GetUIData((Module)c));
            }
            else if (Enum.TryParse(c.CargoType.ToString(), out identifier))
            {
                UpdateGoodCounts(identifier, +1);
                UpdateUIStatLists(identifier, c, true);
            }

            return(CargoResult.Success);
        }
示例#3
0
 public virtual bool CheckCargoSpace(Dictionary <StatefulCargoTypes, float> typesAndQuantities, ref float spaceOccupied)
 {
     foreach (var t in typesAndQuantities)
     {
         spaceOccupied += StatefulCargo.SpacePerObject(t.Key) * (int)t.Value;
     }
     return(spaceOccupied <= _model.TotalHolds - _model.FilledHolds);
 }
示例#4
0
        public virtual bool CheckCargoSpace(IEnumerable <StatefulCargo> statefulCargo, ref float spaceOccupied)
        {
            foreach (var s in statefulCargo)
            {
                spaceOccupied += StatefulCargo.SpacePerObject(s.CargoType);
            }

            return(spaceOccupied <= _model.TotalHolds - _model.FilledHolds);
        }