Example #1
0
        public void DataUpdate()
        {
            var WearAverageCalculationValue = WearAverageCalculation();

            if (WearAverageCalculationValue > WearAverage)
            {
                Base.TriggerEvent("DamageIncrease");
            }

            WearAverage = WearAverageCalculationValue;

            Base.SetProp("Damage.WearAverage", WearAverageCalculationValue);
            Base.SetProp("Damage.WearWarning", WearAverageCalculationValue > Base.Settings.WearWarningLevel);
        }
Example #2
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;
            }
        }