예제 #1
0
        private void InitFromWarehouseTask(WarehouseTask task)
        {
            Terminal.Log($"warehouse task nested: {task.GetTaskData().nestedTasks?.Count} cars: {task.GetTaskData().cars?.Count}");

            DestinationTrack = task.GetTaskData().destinationTrack;
            DVTask           = task;
            GetTrainsets(task.GetTaskData().cars);
        }
예제 #2
0
        protected override void GenerateJob(Station jobOriginStation, float jobTimeLimit = 0, float initialWage = 0, string forcedJobId = null, JobLicenses requiredLicenses = JobLicenses.Basic)
        {
            if ((trainCarsToTransport == null) || (trainCarsToTransport.Count == 0) ||
                (startingTrack == null) || (destinationTrack == null))
            {
                trainCarsToTransport = null;
                startingTrack        = null;
                destinationTrack     = null;
                return;
            }

            // Get total cargo capacity
            float totalCapacity = 0;

            foreach (var car in trainCarsToTransport)
            {
                //car.DumpCargo();
                totalCapacity += car.capacity;
            }

            Track departTrack = startingTrack;
            Track arriveTrack = destinationTrack;
            var   taskList    = new List <Task>();

            // Check for loading task
            PlatformController loadPlatform = null;

            if (loadMachine != null)
            {
                departTrack = loadMachine.WarehouseTrack;

                Task stageCarsTask = JobsGenerator.CreateTransportTask(trainCarsToTransport, departTrack, startingTrack);
                taskList.Add(stageCarsTask);

                Task loadTask = new WarehouseTask(trainCarsToTransport, WarehouseTaskType.Loading, loadMachine, CargoType.Passengers, totalCapacity);
                taskList.Add(loadTask);

                // check to register for unloading display
                if ((PlatformManager.GetPlatformByTrackId(loadMachine.WarehouseTrack.ID.FullID) is PlatformDefinition pdef) && pdef.Initialized)
                {
                    loadPlatform = pdef.Controller;
                }
            }
            else
            {
                foreach (var car in trainCarsToTransport)
                {
                    car.LoadCargo(car.capacity, CargoType.Passengers);
                }
            }

            if (unloadMachine != null)
            {
                arriveTrack = unloadMachine.WarehouseTrack;
            }

            // actual move between stations
            Task transportTask = JobsGenerator.CreateTransportTask(
                trainCarsToTransport, arriveTrack, departTrack,
                Enumerable.Repeat(CargoType.Passengers, trainCarsToTransport.Count).ToList());

            taskList.Add(transportTask);

            // check for unloading task
            PlatformController unloadPlatform = null;

            if (unloadMachine != null)
            {
                Task unloadTask = new WarehouseTask(trainCarsToTransport, WarehouseTaskType.Unloading, unloadMachine, CargoType.Passengers, totalCapacity);
                taskList.Add(unloadTask);

                Task storeCarsTask = JobsGenerator.CreateTransportTask(trainCarsToTransport, destinationTrack, arriveTrack);
                taskList.Add(storeCarsTask);

                // check to register for unloading display
                if ((PlatformManager.GetPlatformByTrackId(unloadMachine.WarehouseTrack.ID.FullID) is PlatformDefinition pdef) && pdef.Initialized)
                {
                    unloadPlatform = pdef.Controller;
                }
            }

            Task superTask = new SequentialTasks(taskList);

            // check if we should generate a special job ID
            if (string.IsNullOrEmpty(forcedJobId) && (specialDefinition != null))
            {
                forcedJobId = IG_GenerateJobId_Patch.GetNamedExpressId(specialDefinition);
            }

            job = new Job(superTask, subType, jobTimeLimit, initialWage, chainData, forcedJobId, requiredLicenses);

            // set up platform displays
            if (loadPlatform != null)
            {
                loadPlatform.AddOutgoingJobToDisplay(job);
            }
            if (unloadPlatform != null)
            {
                job.JobTaken += unloadPlatform.AddIncomingJobToDisplay;
            }

            // track the job if it's a special, for booklet info etc
            if (specialDefinition != null)
            {
                SpecialConsistManager.JobToSpecialMap.Add(job.ID, specialDefinition);
            }

            jobOriginStation.AddJobToStation(job);
        }
예제 #3
0
 public bool Update(WarehouseTask item)
 {
     throw new NotImplementedException();
 }
예제 #4
0
 public bool Delete(WarehouseTask Item)
 {
     return(Delete(db.WarehouseTasks, Item));
 }
예제 #5
0
 public bool Create(WarehouseTask item)
 {
     return(Create(db.WarehouseTasks, item));
 }