Exemple #1
0
        /// <summary>
        /// Registers a terminal with a depot.
        /// </summary>
        /// <param name="depot"></param>
        /// <returns>A unique id for the terminal</returns>
        public string CreateTerminal(IDepot depot)
        {
            var terminal = new TerminalMetadata(depot);

            Terminals.Add(terminal);

            return(terminal.Id);
        }
Exemple #2
0
        public bool TryGetDepot(string body, string biome, out IDepot depot)
        {
            depot = Depots
                    .Where(d => d.Body == body && d.Biome == biome)
                    .FirstOrDefault();

            return(depot != null);
        }
Exemple #3
0
        /// <summary>
        /// Registers a hopper with a depot.
        /// </summary>
        /// <param name="depot"></param>
        /// <param name="recipe"></param>
        /// <returns>The module id for the hopper.</returns>
        public string CreateHopper(IDepot depot, IRecipe recipe)
        {
            var hopper = new HopperMetadata(depot, recipe);

            Hoppers.Add(hopper);

            return(hopper.Id);
        }
Exemple #4
0
 public bool HasTerminal(string id, IDepot depot)
 {
     if (Terminals == null || Terminals.Count < 1)
     {
         return(false);
     }
     return(Terminals.Any(t => t.Id == id &&
                          t.Body == depot.Body &&
                          t.Biome == depot.Biome));
 }
Exemple #5
0
        protected override bool CanConnectToOrigin(IDepot depot, out string errorMessage)
        {
            if (base.CanConnectToOrigin(depot, out errorMessage))
            {
                var vesselMass = Convert.ToInt32(vessel.totalMass);
                if (vesselMass < MINIMUM_PAYLOAD)
                {
                    DisplayMessage(INSUFFICIENT_PAYLOAD_MESSAGE);
                    return(false);
                }
            }

            return(true);
        }
Exemple #6
0
 public AlbumService(IFactory factory, IBus bus, IDepot storage)
 {
     Factory = factory;
     Bus     = bus;
     Storage = storage;
 }
Exemple #7
0
 public TerminalMetadata(IDepot depot)
 {
     Id    = Guid.NewGuid().ToString("N");
     Body  = depot.Body;
     Biome = depot.Biome;
 }
Exemple #8
0
 private void CacheDepotResources(IDepot depot)
 {
     _depotResources = depot.GetResources();
 }
        protected bool CheckBerthCost(IDepot depot, CrewRoutePayload routePayload)
        {
            var depotResources   = depot.GetResources();
            var economyBerthCost = routePayload.EconomyBerths * BERTH_COST_MULTIPLIER;
            var luxuryBerthCost  = routePayload.LuxuryBerths * BERTH_COST_MULTIPLIER;
            var totalBerthCost   = economyBerthCost + luxuryBerthCost;
            var originHab        = depotResources
                                   .FirstOrDefault(r => r.ResourceName == "Habitation");

            if (originHab == null)
            {
                DisplayMessage(string.Format(
                                   _insufficientHabitationMessage,
                                   totalBerthCost));
                return(false);
            }
            if (originHab.Available < totalBerthCost)
            {
                DisplayMessage(string.Format(
                                   _insufficientHabitationMessage,
                                   totalBerthCost - originHab.Available));
                return(false);
            }
            var originLifeSupport = depotResources
                                    .FirstOrDefault(r => r.ResourceName == "LifeSupport");

            if (originLifeSupport == null)
            {
                DisplayMessage(string.Format(
                                   _insufficientLifeSupportMessage,
                                   totalBerthCost));
                return(false);
            }
            if (originLifeSupport.Available < totalBerthCost)
            {
                DisplayMessage(string.Format(
                                   _insufficientLifeSupportMessage,
                                   totalBerthCost - originLifeSupport.Available));
                return(false);
            }
            if (luxuryBerthCost > 0)
            {
                var originColonySupplies = depotResources
                                           .FirstOrDefault(r => r.ResourceName == "ColonySupplies");
                if (originColonySupplies == null)
                {
                    DisplayMessage(string.Format(
                                       _insufficientColonySuppliesMessage,
                                       luxuryBerthCost));
                    return(false);
                }
                if (originColonySupplies.Available < luxuryBerthCost)
                {
                    DisplayMessage(string.Format(
                                       _insufficientColonySuppliesMessage,
                                       luxuryBerthCost - originColonySupplies.Available));
                    return(false);
                }
            }
            return(true);
        }
 /// <summary>
 /// Override to add additional checks before connecting to destination
 /// </summary>
 /// <param name="routePayload"></param>
 /// <param name="errorMessage">Message to display if not able to connect</param>
 /// <param name="originDepot"></param>
 /// <param name="destinationDepot"></param>
 /// <param name="routeCost"></param>
 /// <returns>Return value indicates whether vessel is able to connect to destination or not</returns>
 protected virtual bool CanConnectToDestination(IDepot originDepot, IDepot destinationDepot, int routeCost, int routePayload, out string errorMessage)
 {
     errorMessage = null;
     return(true);
 }
 /// <summary>
 /// Checks if the current vessel is able to connect to origin depot
 /// </summary>
 /// <param name="depot">The depot to connect to</param>
 /// <param name="errorMessage">Message to display if not able to connect</param>
 /// <returns>Return value indicates whether vessel is able to connect to origin or not</returns>
 protected virtual bool CanConnectToOrigin(IDepot depot, out string errorMessage)
 {
     errorMessage = null;
     return(true);
 }
Exemple #12
0
 public HopperMetadata(IDepot depot, IRecipe recipe)
     : this(depot)
 {
     Recipe = recipe;
 }
Exemple #13
0
 public HopperMetadata(IDepot depot)
 {
     Id    = Guid.NewGuid().ToString();
     Depot = depot;
 }