static bool Prefix(Job job, ref List <TemplatePaperData> __result)
        {
            if ((job.jobType != PassJobType.Express) &&
                (job.jobType != PassJobType.Commuter))
            {
                return(true);
            }

            if ((PassBookletUtil.ExtractStationFromId == null) ||
                (PassBookletUtil.CreateCoupleTaskData == null) ||
                (PassBookletUtil.CreateUncoupleTaskData == null) ||
                (PassBookletUtil.GetShuntingPickupsText == null) ||
                (PassBookletUtil.GetShuntingDropOffsText == null))
            {
                __result = null;
                PassengerJobs.ModEntry.Logger.Error("Couldn't connect to BookletCreator methods!");
                return(false);
            }

            // Express or branch service
            var startTask = job.GetJobData().First();
            var carsInfo  = PassBookletUtil.GetCarsInfo(startTask.cars);
            TemplatePaperData overviewPage = PassBookletUtil.CreateTransportDescriptionData(job, startTask.cars, carsInfo);

            __result = new List <TemplatePaperData>()
            {
                overviewPage
            };

            return(false);
        }
예제 #2
0
        static bool Prefix(Job job, ref List <TemplatePaperData> __result)
        {
            if ((job.jobType != PassJobType.Express) &&
                (job.jobType != PassJobType.Commuter))
            {
                return(true);
            }

            if ((PassBookletUtil.ExtractStationFromId == null) ||
                (PassBookletUtil.CreateCoupleTaskData == null) ||
                (PassBookletUtil.CreateUncoupleTaskData == null) ||
                (PassBookletUtil.GetShuntingPickupsText == null) ||
                (PassBookletUtil.GetShuntingDropOffsText == null))
            {
                __result = null;
                PassengerJobs.ModEntry.Logger.Error("Couldn't connect to BookletCreator methods!");
                return(false);
            }

            // Express or branch service
            var startTask = job.GetJobData().First();
            List <Tuple <TrainCarType, string> > carsInfo;

            if (startTask.type == TaskType.Sequential)
            {
                startTask = startTask.nestedTasks.First().GetTaskData();
            }

            // check for special
            string trainName;

            if ((job.jobType == PassJobType.Express) && SpecialConsistManager.JobToSpecialMap.TryGetValue(job.ID, out SpecialTrain special))
            {
                int    lastDashIdx = job.ID.LastIndexOf('-');
                string trainNum    = job.ID.Substring(lastDashIdx + 1);
                trainName = $"{special.Name} #{trainNum}";
            }
            else
            {
                trainName = "a regional express train";
            }
            // if jobtype is commuter then the name is ignored

            carsInfo = PassBookletUtil.GetCarsInfo(startTask.cars);

            TemplatePaperData overviewPage = PassBookletUtil.CreateTransportDescriptionData(job, trainName, startTask.cars, carsInfo);

            __result = new List <TemplatePaperData>()
            {
                overviewPage
            };

            return(false);
        }
예제 #3
0
        static List <TemplatePaperData> GetCommuterBookletData(Job job)
        {
            var pages      = new List <TemplatePaperData>();
            int pageNum    = 1;
            int totalPages = 6;

            TaskData superTask = job.GetJobData().FirstOrDefault();

            if (superTask == null)
            {
                return(pages);
            }

            TaskData stageTask     = null;
            TaskData loadTask      = null;
            TaskData transportTask = null;
            TaskData unloadTask    = null;
            TaskData storeTask     = null;

            if (superTask.type == TaskType.Sequential)
            {
                TaskData[] tasks = superTask.nestedTasks.Select(t => t.GetTaskData()).ToArray();
                loadTask   = tasks.FirstOrDefault(td => td.warehouseTaskType == WarehouseTaskType.Loading);
                unloadTask = tasks.FirstOrDefault(td => td.warehouseTaskType == WarehouseTaskType.Unloading);

                int offset = 0;
                if (loadTask != null)
                {
                    stageTask   = tasks[0];
                    offset      = 2;
                    totalPages += 1; // add load page
                }

                transportTask = tasks[offset];

                if (unloadTask != null)
                {
                    storeTask   = tasks[2 + offset];
                    totalPages += 1; // add unload page
                }
            }
            else if (superTask.type == TaskType.Transport)
            {
                transportTask = superTask;
            }
            else
            {
                PassengerJobs.ModEntry.Logger.Warning($"Invalid tasks in job {job.ID}");
                return(pages);
            }

            var carsInfo = PassBookletUtil.GetCarsInfo(transportTask.cars);

            StationInfo startStation = PassBookletUtil.ExtractStationFromId(job.chainData.chainOriginYardId);
            StationInfo endStation   = PassBookletUtil.ExtractStationFromId(job.chainData.chainDestinationYardId);

            // Cover page
            var coverPage = new CoverPageTemplatePaperData(job.ID, PassBookletUtil.COMMUTE_JOB_TITLE, pageNum.ToString(), totalPages.ToString());

            pages.Add(coverPage);
            pageNum += 1;

            // Description page
            var descriptionPage = PassBookletUtil.CreateTransportDescriptionData(job, PassBookletUtil.COMMUTE_JOB_TITLE, transportTask.cars, carsInfo, pageNum, totalPages);

            pages.Add(descriptionPage);
            pageNum += 1;

            // Task pages
            int taskNum = 1;

            // initial coupling
            Track pickupTrack = stageTask?.startTrack ?? transportTask.startTrack;

            var couplePage = PassBookletUtil.CreateCoupleTaskData(
                taskNum, startStation.YardID, startStation.StationColor, pickupTrack.ID.TrackPartOnly,
                carsInfo, null,
                pageNum, totalPages);

            pages.Add(couplePage);
            pageNum += 1;
            taskNum += 1;

            // passenger loading
            if (loadTask != null)
            {
                const string LOAD_TASK_TYPE = "LOAD";
                const string LOAD_TASK_DESC = "Load train at station platform:";

                string platformName = loadTask.destinationTrack.ID.TrackPartOnly;

                var loadPage = new TaskTemplatePaperData(
                    taskNum.ToString(), LOAD_TASK_TYPE, LOAD_TASK_DESC,
                    startStation.YardID, startStation.StationColor, platformName, TRACK_COLOR,
                    "", "", TemplatePaperData.NOT_USED_COLOR,
                    carsInfo, null, pageNum.ToString(), totalPages.ToString());

                pages.Add(loadPage);
                pageNum += 1;
                taskNum += 1;
            }

            // Transport task
            const string TASK_DESC = "Haul train to the following location:";
            var          haulPage  = new TaskTemplatePaperData(
                taskNum.ToString(), "HAUL", TASK_DESC, "", TemplatePaperData.NOT_USED_COLOR, "", TemplatePaperData.NOT_USED_COLOR,
                endStation.Name, endStation.Type, endStation.StationColor,
                carsInfo, null, pageNum.ToString(), totalPages.ToString());

            pages.Add(haulPage);
            taskNum += 1;
            pageNum += 1;

            // unload at destination
            if (unloadTask != null)
            {
                const string UNLOAD_TASK_TYPE = "UNLOAD";
                const string UNLOAD_TASK_DESC = "Unload train at station platform:";

                string platformName = unloadTask.destinationTrack.ID.TrackPartOnly;

                var unloadPage = new TaskTemplatePaperData(
                    taskNum.ToString(), UNLOAD_TASK_TYPE, UNLOAD_TASK_DESC,
                    endStation.YardID, endStation.StationColor, platformName, TRACK_COLOR,
                    "", "", TemplatePaperData.NOT_USED_COLOR,
                    carsInfo, null, pageNum.ToString(), totalPages.ToString());

                pages.Add(unloadPage);
                pageNum += 1;
                taskNum += 1;
            }

            // uncouple at destination task
            Track dropoffTrack = storeTask?.destinationTrack ?? transportTask.destinationTrack;

            var uncouplePage = PassBookletUtil.CreateUncoupleTaskData(
                taskNum, endStation.YardID, endStation.StationColor, dropoffTrack.ID.TrackPartOnly,
                carsInfo, null, pageNum, totalPages);

            pages.Add(uncouplePage);
            pageNum += 1;
            taskNum += 1;

            pages.Add(new ValidateJobTaskTemplatePaperData(taskNum.ToString(), pageNum.ToString(), totalPages.ToString()));
            return(pages);
        }
예제 #4
0
        static List <TemplatePaperData> GetTransportBookletData(Job job)
        {
            var pages      = new List <TemplatePaperData>();
            int pageNum    = 1;
            int totalPages = 6;

            TaskData superTask = job.GetJobData().FirstOrDefault();

            if (superTask == null)
            {
                return(pages);
            }

            TaskData stageTask     = null;
            TaskData loadTask      = null;
            TaskData transportTask = null;
            TaskData unloadTask    = null;
            TaskData storeTask     = null;

            if (superTask.type == TaskType.Sequential)
            {
                TaskData[] tasks = superTask.nestedTasks.Select(t => t.GetTaskData()).ToArray();
                loadTask   = tasks.FirstOrDefault(td => td.warehouseTaskType == WarehouseTaskType.Loading);
                unloadTask = tasks.FirstOrDefault(td => td.warehouseTaskType == WarehouseTaskType.Unloading);

                int offset = 0;
                if (loadTask != null)
                {
                    stageTask   = tasks[0];
                    offset      = 2;
                    totalPages += 1; // add load page
                }

                transportTask = tasks[offset];

                if (unloadTask != null)
                {
                    storeTask   = tasks[2 + offset];
                    totalPages += 1; // add unload page
                }
            }
            else if (superTask.type == TaskType.Transport)
            {
                transportTask = superTask;
            }
            else
            {
                PassengerJobs.ModEntry.Logger.Warning($"Invalid tasks in job {job.ID}");
                return(pages);
            }

            // check for speciality
            string coverTitle;
            string trainName;

            if (SpecialConsistManager.JobToSpecialMap.TryGetValue(job.ID, out SpecialTrain special))
            {
                coverTitle = special.Name.ToUpper();

                int    lastDashIdx = job.ID.LastIndexOf('-');
                string trainNum    = job.ID.Substring(lastDashIdx + 1);
                trainName = $"{special.Name} #{trainNum}";
            }
            else
            {
                coverTitle = PassBookletUtil.EXPRESS_JOB_TITLE;
                trainName  = "a regional express train";
            }

            List <Tuple <TrainCarType, string> > carsInfo;

            carsInfo = PassBookletUtil.GetCarsInfo(transportTask.cars);

            // Cover page
            var coverPage = new CoverPageTemplatePaperData(job.ID, coverTitle, pageNum.ToString(), totalPages.ToString());

            pages.Add(coverPage);
            pageNum += 1;

            // Job description page
            StationInfo startStation = PassBookletUtil.ExtractStationFromId(job.chainData.chainOriginYardId);
            StationInfo endStation   = PassBookletUtil.ExtractStationFromId(job.chainData.chainDestinationYardId);

            var descriptionPage = PassBookletUtil.CreateTransportDescriptionData(job, trainName, transportTask.cars, carsInfo, pageNum, totalPages);

            pages.Add(descriptionPage);
            pageNum += 1;

            // Task pages
            int taskNum = 1;

            // initial coupling
            Track pickupTrack = stageTask?.startTrack ?? transportTask.startTrack;

            var couplePage = PassBookletUtil.CreateCoupleTaskData(
                taskNum, startStation.YardID, startStation.StationColor, pickupTrack.ID.TrackPartOnly,
                carsInfo, null, pageNum, totalPages);

            pages.Add(couplePage);
            pageNum += 1;
            taskNum += 1;

            // passenger loading
            if (loadTask != null)
            {
                const string LOAD_TASK_TYPE = "LOAD";
                const string LOAD_TASK_DESC = "Load train at station platform:";

                string platformName = loadTask.destinationTrack.ID.TrackPartOnly;

                var loadPage = new TaskTemplatePaperData(
                    taskNum.ToString(), LOAD_TASK_TYPE, LOAD_TASK_DESC,
                    startStation.YardID, startStation.StationColor, platformName, TRACK_COLOR,
                    "", "", TemplatePaperData.NOT_USED_COLOR,
                    carsInfo, null, pageNum.ToString(), totalPages.ToString());

                pages.Add(loadPage);
                pageNum += 1;
                taskNum += 1;
            }

            // transport leg
            var    destYard      = SingletonBehaviour <LogicController> .Instance.YardIdToStationController[job.chainData.chainDestinationYardId];
            string destTrackName = transportTask.destinationTrack.ID.TrackPartOnly;

            const string HAUL_TASK_TYPE = "HAUL";
            const string HAUL_TASK_DESC = "Haul train to the following station/track:";

            var taskPage = new TaskTemplatePaperData(
                taskNum.ToString(), HAUL_TASK_TYPE, HAUL_TASK_DESC,
                destYard.stationInfo.YardID, destYard.stationInfo.StationColor, destTrackName, TRACK_COLOR,
                "", "", TemplatePaperData.NOT_USED_COLOR,
                carsInfo, null,
                pageNum.ToString(), totalPages.ToString());

            pages.Add(taskPage);
            pageNum += 1;
            taskNum += 1;

            // unload at destination
            if (unloadTask != null)
            {
                const string UNLOAD_TASK_TYPE = "UNLOAD";
                const string UNLOAD_TASK_DESC = "Unload train at station platform:";

                string platformName = unloadTask.destinationTrack.ID.TrackPartOnly;

                var unloadPage = new TaskTemplatePaperData(
                    taskNum.ToString(), UNLOAD_TASK_TYPE, UNLOAD_TASK_DESC,
                    endStation.YardID, endStation.StationColor, platformName, TRACK_COLOR,
                    "", "", TemplatePaperData.NOT_USED_COLOR,
                    carsInfo, null, pageNum.ToString(), totalPages.ToString());

                pages.Add(unloadPage);
                pageNum += 1;
                taskNum += 1;
            }

            // final uncoupling
            Track dropoffTrack = storeTask?.destinationTrack ?? transportTask.destinationTrack;

            var uncouplePage = PassBookletUtil.CreateUncoupleTaskData(
                taskNum, endStation.YardID, endStation.StationColor, dropoffTrack.ID.TrackPartOnly,
                carsInfo, null,
                pageNum, totalPages);

            pages.Add(uncouplePage);
            pageNum += 1;
            taskNum += 1;

            pages.Add(new ValidateJobTaskTemplatePaperData(taskNum.ToString(), pageNum.ToString(), totalPages.ToString()));

            return(pages);
        }
        static List <TemplatePaperData> GetCommuterBookletData(Job job)
        {
            var      tasks         = job.GetJobData();
            TaskData startTaskData = tasks.First();

            var pages      = new List <TemplatePaperData>();
            int pageNum    = 1;
            int totalPages = 6;

            var         carsInfo     = PassBookletUtil.GetCarsInfo(startTaskData.cars);
            StationInfo startStation = PassBookletUtil.ExtractStationFromId(job.chainData.chainOriginYardId);
            StationInfo endStation   = PassBookletUtil.ExtractStationFromId(job.chainData.chainDestinationYardId);

            // Cover page
            var coverPage = new CoverPageTemplatePaperData(job.ID, PassBookletUtil.COMMUTE_JOB_TITLE, pageNum.ToString(), totalPages.ToString());

            pages.Add(coverPage);
            pageNum += 1;

            // Description page
            var descriptionPage = PassBookletUtil.CreateTransportDescriptionData(job, startTaskData.cars, carsInfo, pageNum, totalPages);

            pages.Add(descriptionPage);
            pageNum += 1;

            // Task pages
            int taskNum = 1;

            // initial coupling
            var couplePage = PassBookletUtil.CreateCoupleTaskData(
                taskNum, startStation.YardID, startStation.StationColor, startTaskData.startTrack.ID.TrackPartOnly,
                carsInfo, startTaskData.cargoTypePerCar,
                pageNum, totalPages);

            pages.Add(couplePage);
            pageNum += 1;
            taskNum += 1;

            // Transport task
            const string TASK_DESC = "Haul train to the following location:";
            var          haulPage  = new TaskTemplatePaperData(
                taskNum.ToString(), "HAUL", TASK_DESC, "", TemplatePaperData.NOT_USED_COLOR, "", TemplatePaperData.NOT_USED_COLOR,
                endStation.Name, endStation.Type, endStation.StationColor,
                carsInfo, startTaskData.cargoTypePerCar, pageNum.ToString(), totalPages.ToString());

            pages.Add(haulPage);
            taskNum += 1;
            pageNum += 1;

            // uncouple at destination task
            var uncouplePage = PassBookletUtil.CreateUncoupleTaskData(
                taskNum, endStation.YardID, endStation.StationColor, startTaskData.destinationTrack.ID.TrackPartOnly,
                carsInfo, startTaskData.cargoTypePerCar,
                pageNum, totalPages);

            pages.Add(uncouplePage);
            pageNum += 1;
            taskNum += 1;

            pages.Add(new ValidateJobTaskTemplatePaperData(taskNum.ToString(), pageNum.ToString(), totalPages.ToString()));
            return(pages);
        }
        static List <TemplatePaperData> GetTransportBookletData(Job job)
        {
            var      tasks         = job.GetJobData();
            TaskData transportTask = tasks.First();

            var pages      = new List <TemplatePaperData>();
            int pageNum    = 1;
            int totalPages = 6;

            var carsInfo = PassBookletUtil.GetCarsInfo(transportTask.cars);

            // Cover page
            var coverPage = new CoverPageTemplatePaperData(job.ID, PassBookletUtil.EXPRESS_JOB_TITLE, pageNum.ToString(), totalPages.ToString());

            pages.Add(coverPage);
            pageNum += 1;

            // Job description page
            StationInfo startStation = PassBookletUtil.ExtractStationFromId(job.chainData.chainOriginYardId);
            StationInfo endStation   = PassBookletUtil.ExtractStationFromId(job.chainData.chainDestinationYardId);

            var descriptionPage = PassBookletUtil.CreateTransportDescriptionData(job, transportTask.cars, carsInfo, pageNum, totalPages);

            pages.Add(descriptionPage);
            pageNum += 1;

            // Task pages
            int taskNum = 1;

            // initial coupling
            var couplePage = PassBookletUtil.CreateCoupleTaskData(
                taskNum, startStation.YardID, startStation.StationColor, transportTask.startTrack.ID.TrackPartOnly,
                carsInfo, transportTask.cargoTypePerCar,
                pageNum, totalPages);

            pages.Add(couplePage);
            pageNum += 1;
            taskNum += 1;

            // transport leg
            var    destYard      = SingletonBehaviour <LogicController> .Instance.YardIdToStationController[job.chainData.chainDestinationYardId];
            string destTrackName = transportTask.destinationTrack.ID.TrackPartOnly;

            const string HAUL_TASK_TYPE = "HAUL";
            const string HAUL_TASK_DESC = "Haul train to the following station platform:";

            var taskPage = new TaskTemplatePaperData(
                taskNum.ToString(), HAUL_TASK_TYPE, HAUL_TASK_DESC,
                destYard.stationInfo.YardID, destYard.stationInfo.StationColor, destTrackName, TRACK_COLOR,
                "", "", TemplatePaperData.NOT_USED_COLOR,
                carsInfo, transportTask.cargoTypePerCar,
                pageNum.ToString(), totalPages.ToString());

            pages.Add(taskPage);
            pageNum += 1;
            taskNum += 1;

            // final uncoupling
            var uncouplePage = PassBookletUtil.CreateUncoupleTaskData(
                taskNum, endStation.YardID, endStation.StationColor, transportTask.destinationTrack.ID.TrackPartOnly,
                carsInfo, transportTask.cargoTypePerCar,
                pageNum, totalPages);

            pages.Add(uncouplePage);
            pageNum += 1;
            taskNum += 1;
            pages.Add(new ValidateJobTaskTemplatePaperData(taskNum.ToString(), pageNum.ToString(), totalPages.ToString()));

            return(pages);
        }