Beispiel #1
0
        private static StaticPassengerJobDefinition CreateSavedPassengerJob(GameObject jobChainGO, PassengerJobDefinitionData jobData)
        {
            // associated station
            if (!(GetStationWithId(jobData.stationId) is Station logicStation))
            {
                PrintError($"Couldn't find corresponding Station with ID: {jobData.stationId}! Skipping load of this job chain!");
                return(null);
            }

            // bonus time limit, base payment
            if (jobData.timeLimitForJob < 0f || jobData.initialWage < 0f ||
                string.IsNullOrEmpty(jobData.originStationId) || string.IsNullOrEmpty(jobData.destinationStationId))
            {
                PrintError("Invalid data! Skipping load of this job chain!");
                return(null);
            }

            // license requirements
            if (!LicenseManager.IsValidForParsingToJobLicense(jobData.requiredLicenses))
            {
                PrintError("Undefined job licenses requirement! Skipping load of this job chain!");
                return(null);
            }

            // starting track
            if (!(GetYardTrackWithId(jobData.startingTrack) is Track startTrack))
            {
                PrintError($"Couldn't find corresponding start Track with ID: {jobData.startingTrack}! Skipping load of this job chain!");
                return(null);
            }

            // destination track
            if (!(GetYardTrackWithId(jobData.destinationTrack) is Track destTrack))
            {
                PrintError($"Couldn't find corresponding destination Track with ID: {jobData.destinationTrack}! Skipping load of this job chain!");
                return(null);
            }

            // consist
            if (!(GetCarsFromCarGuids(jobData.trainCarGuids) is List <Car> consist))
            {
                PrintError("Couldn't find all carsToTransport with transportCarGuids! Skipping load of this job chain!");
                return(null);
            }

            StaticPassengerJobDefinition jobDefinition = jobChainGO.AddComponent <StaticPassengerJobDefinition>();
            var chainData = new StationsChainData(jobData.originStationId, jobData.destinationStationId);

            jobDefinition.PopulateBaseJobDefinition(logicStation, jobData.timeLimitForJob, jobData.initialWage, chainData, (JobLicenses)jobData.requiredLicenses);

            jobDefinition.subType              = (JobType)jobData.subType;
            jobDefinition.startingTrack        = startTrack;
            jobDefinition.destinationTrack     = destTrack;
            jobDefinition.trainCarsToTransport = consist;

            return(jobDefinition);
        }
Beispiel #2
0
        private static StaticPassengerJobDefinition PopulateTransportJobExistingCars(
            JobChainController chainController, Station startStation,
            Track startTrack, Track destTrack, List <Car> logicCars,
            StationsChainData chainData, float timeLimit, float initialPay)
        {
            // populate the actual job
            StaticPassengerJobDefinition jobDefinition = chainController.jobChainGO.AddComponent <StaticPassengerJobDefinition>();

            jobDefinition.PopulateBaseJobDefinition(startStation, timeLimit, initialPay, chainData, PassLicenses.Passengers1);

            jobDefinition.startingTrack        = startTrack;
            jobDefinition.trainCarsToTransport = logicCars;
            jobDefinition.destinationTrack     = destTrack;

            return(jobDefinition);
        }
Beispiel #3
0
        private static StaticPassengerJobDefinition CreateSavedPassengerJob(GameObject jobChainGO, PassengerJobDefinitionData jobData)
        {
            // associated station
            if (!(GetStationWithId(jobData.stationId) is Station logicStation))
            {
                PrintError($"Couldn't find corresponding Station with ID: {jobData.stationId}! Skipping load of this job chain!");
                return(null);
            }

            // bonus time limit, base payment
            if (jobData.timeLimitForJob < 0f || jobData.initialWage < 0f ||
                string.IsNullOrEmpty(jobData.originStationId) || string.IsNullOrEmpty(jobData.destinationStationId))
            {
                PrintError("Invalid data! Skipping load of this job chain!");
                return(null);
            }

            // license requirements
            if (!LicenseManager.IsValidForParsingToJobLicense(jobData.requiredLicenses))
            {
                PrintError("Undefined job licenses requirement! Skipping load of this job chain!");
                return(null);
            }

            // starting track
            if (!(GetYardTrackWithId(jobData.startingTrack) is Track startTrack))
            {
                PrintError($"Couldn't find corresponding start Track with ID: {jobData.startingTrack}! Skipping load of this job chain!");
                return(null);
            }

            // destination track
            if (!(GetYardTrackWithId(jobData.destinationTrack) is Track destTrack))
            {
                PrintError($"Couldn't find corresponding destination Track with ID: {jobData.destinationTrack}! Skipping load of this job chain!");
                return(null);
            }

            // consist
            if (!(GetCarsFromCarGuids(jobData.trainCarGuids) is List <Car> consist))
            {
                PrintError("Couldn't find all carsToTransport with transportCarGuids! Skipping load of this job chain!");
                return(null);
            }

            // loading platform
            WarehouseMachine loadMachine = null;

            if (!string.IsNullOrEmpty(jobData.loadingTrackId))
            {
                if (PlatformManager.GetPlatformByTrackId(jobData.loadingTrackId) is PlatformDefinition pd)
                {
                    loadMachine = pd.Controller.LogicMachine;
                }
            }

            // unloading platform
            WarehouseMachine unloadMachine = null;

            if (!string.IsNullOrEmpty(jobData.unloadingTrackId))
            {
                if (PlatformManager.GetPlatformByTrackId(jobData.unloadingTrackId) is PlatformDefinition pd)
                {
                    unloadMachine = pd.Controller.LogicMachine;
                }
            }

            // Named train
            SpecialTrain special = null;

            if (!string.IsNullOrWhiteSpace(jobData.specialName))
            {
                special = SpecialConsistManager.TrainDefinitions.Find(train => string.Equals(train.Name, jobData.specialName));
            }

            StaticPassengerJobDefinition jobDefinition = jobChainGO.AddComponent <StaticPassengerJobDefinition>();
            var chainData = new StationsChainData(jobData.originStationId, jobData.destinationStationId);

            jobDefinition.PopulateBaseJobDefinition(logicStation, jobData.timeLimitForJob, jobData.initialWage, chainData, (JobLicenses)jobData.requiredLicenses);

            jobDefinition.subType              = (JobType)jobData.subType;
            jobDefinition.startingTrack        = startTrack;
            jobDefinition.destinationTrack     = destTrack;
            jobDefinition.trainCarsToTransport = consist;
            jobDefinition.loadMachine          = loadMachine;
            jobDefinition.unloadMachine        = unloadMachine;
            jobDefinition.specialDefinition    = special;

            return(jobDefinition);
        }