コード例 #1
0
        public void DataUpdate()
        {
            if (Base.PluginManager.GameName == "ETS2")
            {
                Cities.TryGetValue((string)Base.GetProp("Job.CitySource"), out TruckSimulatorPluginCity CitySource);
                Cities.TryGetValue((string)Base.GetProp("Job.CityDestination"), out TruckSimulatorPluginCity CityDestination);

                if (CitySource != null)
                {
                    Base.SetProp("L.Job.CitySource", CitySource.translation);
                    Base.SetProp("L.Job.CountrySource", CitySource.country_translation);
                    Base.SetProp("L.A.Job.CitySourceFromSDK", CitySource.api_ascii);
                    Base.SetProp("L.A.Job.CitySource", CitySource.translation_ascii);
                    Base.SetProp("L.A.Job.CountrySource", CitySource.country_translation_ascii);
                }

                if (CityDestination != null)
                {
                    Base.SetProp("L.Job.CityDestination", CityDestination.translation);
                    Base.SetProp("L.Job.CountryDestination", CityDestination.country_translation);
                    Base.SetProp("L.A.Job.CityDestinationFromSDK", CityDestination.api_ascii);
                    Base.SetProp("L.A.Job.CityDestination", CityDestination.translation_ascii);
                    Base.SetProp("L.A.Job.CountryDestination", CityDestination.country_translation_ascii);
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Maintains your fuel range indication to avoid dips to 0 constantly.
        /// </summary>
        private float FuelRangeStable()
        {
            var FuelRangeCurrentValue = (float)Base.GetProp("Drivetrain.FuelRange");

            FuelRangeStableValue = FuelRangeCurrentValue > 0
                ? FuelRangeCurrentValue
                : FuelRangeStableValue;

            return(FuelRangeStableValue);
        }
コード例 #3
0
        /**
         * @deprecated: Use `SpecialEventsValues.OnJob` natively instead.
         */
        private bool InProgress()
        {
            if (Base.HasProp("SpecialEventsValues.OnJob"))
            {
                return(Base.GetProp("SpecialEventsValues.OnJob"));
            }

            return(InProgressStatuses.Contains(CurrentStatus));
        }
コード例 #4
0
        /// <summary>
        /// The average damage across all connected parts of the truck.
        /// </summary>
        private float WearAverageCalculation()
        {
            float[] totalWear =
            {
                (float)Base.GetProp("TruckValues.CurrentValues.DamageValues.Cabin"),
                (float)Base.GetProp("TruckValues.CurrentValues.DamageValues.Chassis"),
                (float)Base.GetProp("TruckValues.CurrentValues.DamageValues.Engine"),
                (float)Base.GetProp("TruckValues.CurrentValues.DamageValues.Transmission"),
                (float)Base.GetProp("TruckValues.CurrentValues.DamageValues.WheelsAvg"),
            };

            return(totalWear.Sum() / totalWear.Length * 100);
        }
コード例 #5
0
        public void DataUpdate(ref GameData data)
        {
            var FuelAverageConsumptionCurrentValue = (float)Base.GetProp("TruckValues.CurrentValues.DashboardValues.FuelValue.AverageConsumption");

            FuelAverageConsumption = FuelAverageConsumptionCurrentValue > 0
                ? FuelAverageConsumptionCurrentValue
                : FuelAverageConsumption;

            Base.SetProp("Drivetrain.EcoRange", EcoRange(data.NewData.Rpms));
            Base.SetProp("Drivetrain.FuelRangeStable", FuelRangeStable());
            Base.SetProp("Drivetrain.FuelValue.AverageConsumptionLitresPer100Mile", FuelAverageConsumption * (float)160.9344);
            Base.SetProp("Drivetrain.FuelValue.AverageConsumptionMilesPerGallonUK", FuelAverageConsumption * (float)2.824809363);
            Base.SetProp("Drivetrain.FuelValue.AverageConsumptionMilesPerGallonUS", FuelAverageConsumption * (float)2.352145833);
            Base.SetProp("Drivetrain.GearDashboard", DrivetrainGearDashboardWithCrawler());
        }
コード例 #6
0
        public void DataUpdate()
        {
            var NavigationTime = (TimeSpan)Base.GetProp("Job.NavigationTime");

            Base.SetProp("Navigation.TotalDaysLeft", NavigationTime.Days);
            Base.SetProp("Navigation.TotalHoursLeft", NavigationTime.Hours);
            Base.SetProp("Navigation.Minutes", NavigationTime.Minutes);
        }
コード例 #7
0
        /// <summary>
        /// The average of wear across all connected parts of the truck and trailer.
        /// </summary>
        private float WearAverageCalculation()
        {
            var totalWear = (float)Base.GetProp("Damage.WearCabin")
                            + (float)Base.GetProp("Damage.WearChassis")
                            + (float)Base.GetProp("Damage.WearEngine")
                            + (float)Base.GetProp("Damage.WearTrailer")
                            + (float)Base.GetProp("Damage.WearTransmission")
                            + (float)Base.GetProp("Damage.WearWheels");

            return((totalWear / 6) * 100);
        }
コード例 #8
0
        /// <summary>
        /// If both blinkers are on, then we can consider the hazard lights as on, as you can't indicate
        /// both ways in normal circumstances.
        /// </summary>
        private bool HazardWarningOn()
        {
            var now = DateTime.Now;
            var bothBlinkersAreOn = (bool)Base.GetProp("Lights.BlinkerLeftOn") && (bool)Base.GetProp("Lights.BlinkerRightOn");

            if (bothBlinkersAreOn)
            {
                HazardLightsOnAt  = now;
                AreHazardLightsOn = true;
            }

            if (!bothBlinkersAreOn && now > HazardLightsOnAt.AddSeconds(1))
            {
                AreHazardLightsOn = false;
            }

            return(AreHazardLightsOn);
        }
コード例 #9
0
        public void DataUpdate()
        {
            Base.SetProp("Job.OverSpeedLimit", OverSpeedLimit());
            Base.SetProp("Job.OverSpeedLimitPercentage", OverSpeedLimitPercentage());

            Base.SetProp("Job.NextRestWarning", ((TimeSpan)Base.GetProp("NextRestStopTime")).Hours < 1);

            var RemainingTime = (TimeSpan)Base.GetProp("JobValues.RemainingDeliveryTime.Time");

            Base.SetProp("Job.RemainingDeliveryTime.Time.Days", RemainingTime.Days);
            Base.SetProp("Job.RemainingDeliveryTime.Time.Hours", RemainingTime.Hours);
            Base.SetProp("Job.RemainingDeliveryTime.Time.Minutes", RemainingTime.Minutes);
        }
コード例 #10
0
 public void DataUpdate(ref GameData data)
 {
     Base.SetProp("Engine.Starting", ((bool)Base.GetProp("Drivetrain.EngineEnabled")) == false && data.NewData.Rpms > 0);
 }
コード例 #11
0
        private void JobStatusUpdate()
        {
            var CurrentJob = String.Format("{0}__{1}__{2}__{3}__{4}",
                                           (string)Base.GetProp("Job.Cargo"),
                                           (string)Base.GetProp("Job.CompanySource"),
                                           (string)Base.GetProp("Job.CitySource"),
                                           (string)Base.GetProp("Job.CompanyDestination"),
                                           (string)Base.GetProp("Job.CityDestination")
                                           ).Replace(" ", "-").Replace("________", "").ToLower();

            if (CurrentJob == "")
            {
                CurrentStatus = Status.None;
                return;
            }

            var NavDistanceLeft = (float)Base.GetProp("Job.NavigationDistanceLeft");

            if (NavDistanceLeft == 0 && HasNavigationDistanceZeroSet == false)
            {
                NavigationDistanceLastZeroedAt = DateTime.Now.AddSeconds(2);
                HasNavigationDistanceZeroSet   = true;
            }

            if (NavDistanceLeft > 0 && HasNavigationDistanceZeroSet == true)
            {
                NavigationDistanceLastZeroedAt = DateTime.Now.AddYears(1);
                HasNavigationDistanceZeroSet   = false;
            }

            var NavEnded   = HasNavigationDistanceZeroSet && DateTime.Now > NavigationDistanceLastZeroedAt;
            var SpeedLimit = (float)Base.GetProp("Job.SpeedLimit");

            if (CurrentStatus == Status.None && CurrentJob != CurrentJobIdentifier && DateTime.Now > LatchStatusUntil)
            {
                CurrentStatus = Status.Taken;
                Base.TriggerEvent("JobTaken");

                LatchStatusUntil          = DateTime.Now.AddYears(1);
                CurrentJobIdentifier      = CurrentJob;
                HasSeenSpeedLimit         = false;
                HasBeenCloseToDestination = false;

                return;
            }

            if (CurrentStatus == Status.Taken && NavEnded)
            {
                CurrentStatus = Status.Loading;
                Base.TriggerEvent("JobLoading");

                return;
            }

            if ((CurrentStatus == Status.Taken || CurrentStatus == Status.Loading) && NavDistanceLeft > 0)
            {
                CurrentStatus = Status.Ongoing;
                Base.TriggerEvent("JobOngoing");

                return;
            }

            if (CurrentStatus == Status.Ongoing)
            {
                if (SpeedLimit > 0 && HasSeenSpeedLimit == false)
                {
                    HasSeenSpeedLimit = true;
                }

                if (NavDistanceLeft < 30 && NavDistanceLeft > 0 && HasSeenSpeedLimit && HasBeenCloseToDestination == false)
                {
                    HasBeenCloseToDestination = true;
                }

                if (HasSeenSpeedLimit && HasBeenCloseToDestination)
                {
                    if ((CurrentJob != CurrentJobIdentifier) ||
                        (CurrentJob == CurrentJobIdentifier && (NavEnded || HasNavigationDistanceJumped)))
                    {
                        CurrentStatus    = Status.Completed;
                        LatchStatusUntil = DateTime.Now.AddSeconds(2);
                        Base.TriggerEvent("JobCompleted");

                        return;
                    }
                }
                else
                {
                    if (CurrentJob != CurrentJobIdentifier)
                    {
                        CurrentStatus    = Status.Abandoned;
                        LatchStatusUntil = DateTime.Now.AddSeconds(2);
                        Base.TriggerEvent("JobAbandoned");

                        return;
                    }
                }
            }

            if ((CurrentStatus == Status.Completed || CurrentStatus == Status.Abandoned) && DateTime.Now > LatchStatusUntil)
            {
                CurrentStatus    = Status.None;
                LatchStatusUntil = DateTime.Now.AddSeconds(2);

                HasSeenSpeedLimit         = false;
                HasBeenCloseToDestination = false;

                return;
            }
        }