Пример #1
0
 protected internal void ArriveAtRouteDestination()
 {
     _currentLocation = _currentRoute.ToLocation;
     _eta             = 0;
     _events.Add(new TransportEvent
     {
         Event       = "ARRIVE",
         Time        = _clock.ElapsedTime,
         TransportId = Id,
         Kind        = _vessel.Kind,
         Location    = _currentRoute?.FromLocation?.Name,
         Destination = _currentRoute?.ToLocation?.Name,
         Cargo       = _loadedCargoes.Any() ?
                       _loadedCargoes.Select(c => CargoTravelInfo.FromCargo(c)).ToArray() :
                       null
     });
 }
Пример #2
0
 protected internal void ReturnToOrigin()
 {
     _currentLocation = null;
     _eta             = _clock.ElapsedTime + _currentRoute.Distance;
     _events.Add(new TransportEvent
     {
         Event       = "DEPART",
         Time        = _clock.ElapsedTime,
         TransportId = Id,
         Kind        = _vessel.Kind,
         Location    = _currentRoute?.ToLocation?.Name,
         Destination = _currentRoute?.FromLocation?.Name,
         Cargo       = _loadedCargoes.Any() ?
                       _loadedCargoes.Select(c => CargoTravelInfo.FromCargo(c)).ToArray() :
                       null
     });
 }
Пример #3
0
 protected internal void StartUnloading()
 {
     _loadUnloadEta = _vessel.CalculateLoadUnloadEta(_clock.ElapsedTime);
     _events.Add(new TransportEvent
     {
         Event       = "UNLOAD",
         Time        = _clock.ElapsedTime,
         TransportId = Id,
         Kind        = _vessel.Kind,
         Location    = _currentRoute?.FromLocation?.Name,
         Destination = _currentRoute?.ToLocation?.Name,
         Duration    = _vessel.CalculateLoadUnloadEta(0),
         Cargo       = _loadedCargoes.Any() ?
                       _loadedCargoes.Select(c => CargoTravelInfo.FromCargo(c)).ToArray() :
                       null
     });
 }
Пример #4
0
        protected internal void LoadCargo()
        {
            var countBefroe = _loadedCargoes.Count;
            var firstCargo  = _loadedCargoes.FirstOrDefault();

            if (firstCargo == null)
            {
                firstCargo = _currentLocation.LoadCargo();
                if (firstCargo == null)
                {
                    return;
                }
                _loadedCargoes.Add(firstCargo);
                _loadUnloadEta = _vessel.CalculateLoadUnloadEta(_clock.ElapsedTime);
            }
            while (_vessel.CanLoad(_loadedCargoes.Count))
            {
                var cargoToLoad = _currentLocation.LoadCargoHeadingTo(firstCargo.NextRoute().ToLocation);
                if (cargoToLoad != null)
                {
                    _loadedCargoes.Add(cargoToLoad);
                }
                else
                {
                    break;
                }
            }
            if (_loadedCargoes.Count == countBefroe)
            {
                return;
            }

            _events.Add(new TransportEvent
            {
                Event       = "LOAD",
                Time        = _clock.ElapsedTime,
                TransportId = Id,
                Kind        = _vessel.Kind,
                Location    = _currentRoute?.FromLocation?.Name,
                Destination = _currentRoute?.ToLocation?.Name,
                Duration    = _vessel.CalculateLoadUnloadEta(0),
                Cargo       = _loadedCargoes.Select(c => CargoTravelInfo.FromCargo(c)).ToArray()
            });
        }