Ejemplo n.º 1
0
        public static void MoveUpStage(ActiveVehicle activeVeh, bool isDLS = false, bool isMan = false)
        {
            if (isDLS)
            {
                activeVeh.SirenStage = GetNextStage(activeVeh.SirenStage);
            }
            else
            {
                switch (activeVeh.SirenStage)
                {
                case SirenStage.Off:
                    activeVeh.SirenStage = SirenStage.One;
                    break;

                case SirenStage.One:
                    activeVeh.SirenStage = SirenStage.Two;
                    break;

                case SirenStage.Two:
                    activeVeh.SirenStage = SirenStage.Warning;
                    break;

                case SirenStage.Warning:
                    activeVeh.SirenStage = SirenStage.Warning2;
                    break;

                case SirenStage.Warning2:
                    activeVeh.SirenStage = SirenStage.Off;
                    break;
                }
            }
            Update(activeVeh, isDLS);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Retrieve Diagnostic data for the active vehicle
        /// </summary>
        /// <returns></returns>
        public async Task <DiagnosticResponse[]> GetDiagnostics()
        {
            var cmdInfo = ActiveVehicle.GetCommand("diagnostics");

            var reqObj = new JObject()
            {
                ["diagnosticsRequest"] = new JObject()
                {
                    ["diagnosticItem"] = new JArray(cmdInfo.CommandData.SupportedDiagnostics.SupportedDiagnostic)
                }
            };

            var result = await InitiateCommandAndWait("diagnostics", reqObj);

            if (result == null)
            {
                return(null);
            }
            if ("success".Equals(result.Status, StringComparison.OrdinalIgnoreCase))
            {
                return(result.Body.DiagnosticResponse);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Connect to vehicle. Must be called before issuing commands
        /// </summary>
        /// <param name="vin"></param>
        /// <returns></returns>
        async Task <CommandResponse> VehicleConnect()
        {
            if (ActiveVehicle == null)
            {
                throw new InvalidOperationException("ActiveVehicle must be populated");
            }
            using (var response = await PostAsync(ActiveVehicle.GetCommand("connect").Url, new StringContent("{}", Encoding.UTF8, "application/json")))
            {
                if (response.IsSuccessStatusCode)
                {
                    var respString = await response.Content.ReadAsStringAsync();

                    var respObj = JsonConvert.DeserializeObject <CommandRequestResponse>(respString);
                    if (respObj == null || respObj.CommandResponse == null)
                    {
                        return(null);
                    }
                    return(respObj.CommandResponse);
                }
                else
                {
                    var error = await response.Content.ReadAsStringAsync();

                    return(null);
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Submit the initial call for a command
        /// NOTE: this will be changing to use the URLs defined in vehicle configuration
        /// </summary>
        /// <param name="vin">Vehicle VIN</param>
        /// <param name="pin">OnStar PIN</param>
        /// <param name="command">command name</param>
        /// <returns></returns>
        async Task <CommandResponse> InitiateCommand(string command, JObject requestParameters)
        {
            if (ActiveVehicle == null)
            {
                throw new InvalidOperationException("ActiveVehicle must be populated");
            }

            var cmdInfo = ActiveVehicle.GetCommand(command);

            if (cmdInfo == null)
            {
                throw new InvalidOperationException("Unsupported command");
            }

            if (cmdInfo.IsPrivSessionRequired.GetValueOrDefault())
            {
                if (!IsUpgraded)
                {
                    //TODO: need to determine how long an upgrade lasts - do we reset it when refreshing the token?
                    // Also if the android app saves the PIN, should we save the PIN?
                    throw new InvalidOperationException("Command requires upgraded login");
                }
            }

            if (!_isConnected)
            {
                await VehicleConnect();

                _isConnected = true;
            }


            JObject reqObj = requestParameters;

            if (reqObj == null)
            {
                reqObj = new JObject();
            }



            using (var response = await PostAsync(cmdInfo.Url, new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(reqObj), Encoding.UTF8, "application/json")))
            {
                if (!response.IsSuccessStatusCode)
                {
                    var error = await response.Content.ReadAsStringAsync();

                    //todo: is this needed with the fancy post?
                    return(null);
                }

                var commandResult = await response.Content.ReadAsAsync <CommandRequestResponse>();

                return(commandResult.CommandResponse);
            }
        }
Ejemplo n.º 5
0
        public static int NewSoundID(ActiveVehicle activeVeh)
        {
            if (activeVeh.SoundId != 999)
            {
                NativeFunction.Natives.STOP_SOUND(activeVeh.SoundId);
                NativeFunction.Natives.RELEASE_SOUND_ID(activeVeh.SoundId);
                Entrypoint.UsedSoundIDs.Remove(activeVeh.SoundId);
                ("Deallocated SoundID " + activeVeh.SoundId).ToLog();
            }
            int newID = NativeFunction.Natives.GET_SOUND_ID <int>();

            activeVeh.SoundId = newID;
            Entrypoint.UsedSoundIDs.Add(newID);
            ("Allocated SoundID " + newID).ToLog();
            return(newID);
        }
Ejemplo n.º 6
0
        internal static bool IsPlayerVehicle(this Vehicle veh)
        {
            ActiveVehicle vehActive = veh.GetActiveVehicle();

            if (Game.LocalPlayer.Character.CurrentVehicle == veh || Game.LocalPlayer.Character.LastVehicle == veh)
            {
                return(true);
            }
            foreach (ActiveVehicle activeVeh in Entrypoint.activeVehicles)
            {
                if (activeVeh == vehActive && activeVeh.PlayerVehicle)
                {
                    return(true);
                }
            }
            return(false);
        }
Ejemplo n.º 7
0
        public static bool GetSirenKill(ActiveVehicle activeVehicle)
        {
            Vehicle veh = activeVehicle.Vehicle;

            if (veh)
            {
                DLSModel dlsModel = veh.GetDLS();
                if (dlsModel != null)
                {
                    bool _ = Entrypoint.SirenKill;
                    if (dlsModel.SoundSettings.SirenKillOverride.ToBoolean() == true)
                    {
                        _ = dlsModel.SoundSettings.SirenKillOverride.ToBoolean();
                    }
                    return(_);
                }
            }
            return(false);
        }
Ejemplo n.º 8
0
        public static EmergencyLighting GetEL(Vehicle veh, ActiveVehicle activeVeh = null)
        {
            DLSModel dlsModel = veh.GetDLS();

            if (activeVeh == null)
            {
                activeVeh = veh.GetActiveVehicle();
            }
            string            name = dlsModel.Name + " | " + activeVeh.LightStage.ToString() + " | " + activeVeh.TAStage.ToString() + " | " + activeVeh.SBOn.ToString();
            uint              key  = Game.GetHashKey(name);
            EmergencyLighting eL;

            if (Entrypoint.UsedPool.Count > 0 && Entrypoint.UsedPool.ContainsKey(key))
            {
                eL = Entrypoint.UsedPool[key];
                ("Allocated \"" + name + "\" (" + key + ") for " + veh.Handle + " from Used Pool").ToLog();
            }
            else if (Entrypoint.AvailablePool.Count > 0)
            {
                eL = Entrypoint.AvailablePool[0];
                Entrypoint.AvailablePool.Remove(eL);
                ("Removed \"" + eL.Name + "\" from Available Pool").ToLog();
                ("Allocated \"" + name + "\" (" + key + ") for " + veh.Handle + " from Available Pool").ToLog();
            }
            else
            {
                if (EmergencyLighting.GetByName(name) == null)
                {
                    Model model = new Model("police");
                    eL      = model.EmergencyLighting.Clone();
                    eL.Name = name;
                    ("Created \"" + name + "\" (" + key + ") for " + veh.Handle).ToLog();
                }
                else
                {
                    eL = EmergencyLighting.GetByName(name);
                    ("Allocated \"" + name + "\" (" + key + ") for " + veh.Handle + " from Game Memory").ToLog();
                }
            }
            if (activeVeh.LightStage != LightStage.Off && activeVeh.LightStage != LightStage.Empty)
            {
                switch (activeVeh.LightStage)
                {
                case LightStage.One:
                    SirenApply.ApplySirenSettingsToEmergencyLighting(dlsModel.Sirens.Stage1Setting, eL);
                    break;

                case LightStage.Two:
                    SirenApply.ApplySirenSettingsToEmergencyLighting(dlsModel.Sirens.Stage2Setting, eL);
                    break;

                case LightStage.Three:
                    SirenApply.ApplySirenSettingsToEmergencyLighting(dlsModel.Sirens.Stage3Setting, eL);
                    break;

                case LightStage.CustomOne:
                    SirenApply.ApplySirenSettingsToEmergencyLighting(dlsModel.Sirens.CustomStage1, eL);
                    break;

                case LightStage.CustomTwo:
                    SirenApply.ApplySirenSettingsToEmergencyLighting(dlsModel.Sirens.CustomStage2, eL);
                    break;

                default:
                    SirenApply.ApplySirenSettingsToEmergencyLighting(dlsModel.Sirens.Stage3Setting, eL);
                    break;
                }
            }
            else
            {
                SirenApply.ApplySirenSettingsToEmergencyLighting(dlsModel.Sirens.Stage3Setting, eL);
                eL.LeftHeadLightSequence  = "00000000000000000000000000000000";
                eL.LeftTailLightSequence  = "00000000000000000000000000000000";
                eL.RightHeadLightSequence = "00000000000000000000000000000000";
                eL.RightTailLightSequence = "00000000000000000000000000000000";
                for (int i = 0; i < eL.Lights.Length; i++)
                {
                    EmergencyLight eLig = eL.Lights[i];
                    eLig.FlashinessSequence = "00000000000000000000000000000000";
                    eLig.RotationSequence   = "00000000000000000000000000000000";
                }
            }
            if (!Entrypoint.UsedPool.ContainsKey(key))
            {
                Entrypoint.UsedPool.Add(key, eL);
            }
            activeVeh.CurrentHash = key;
            return(eL);
        }
Ejemplo n.º 9
0
        public static void Update(ActiveVehicle activeVeh, bool dls = true)
        {
            switch (activeVeh.SirenStage)
            {
            case SirenStage.Off:
                Sound.NewSoundID(activeVeh);
                break;

            case SirenStage.One:
                if (dls)
                {
                    NativeFunction.Natives.PLAY_SOUND_FROM_ENTITY(Sound.NewSoundID(activeVeh), activeVeh.Vehicle.GetDLS().SoundSettings.Tone1, activeVeh.Vehicle, 0, 0, 0);
                }
                else
                {
                    NativeFunction.Natives.PLAY_SOUND_FROM_ENTITY(Sound.NewSoundID(activeVeh), "VEHICLES_HORNS_SIREN_1", activeVeh.Vehicle, 0, 0, 0);
                }
                break;

            case SirenStage.Two:
                if (dls)
                {
                    NativeFunction.Natives.PLAY_SOUND_FROM_ENTITY(Sound.NewSoundID(activeVeh), activeVeh.Vehicle.GetDLS().SoundSettings.Tone2, activeVeh.Vehicle, 0, 0, 0);
                }
                else
                {
                    NativeFunction.Natives.PLAY_SOUND_FROM_ENTITY(Sound.NewSoundID(activeVeh), "VEHICLES_HORNS_SIREN_2", activeVeh.Vehicle, 0, 0, 0);
                }
                break;

            case SirenStage.Warning:
                if (dls)
                {
                    NativeFunction.Natives.PLAY_SOUND_FROM_ENTITY(Sound.NewSoundID(activeVeh), activeVeh.Vehicle.GetDLS().SoundSettings.Tone3, activeVeh.Vehicle, 0, 0, 0);
                }
                else
                {
                    NativeFunction.Natives.PLAY_SOUND_FROM_ENTITY(Sound.NewSoundID(activeVeh), "VEHICLES_HORNS_POLICE_WARNING", activeVeh.Vehicle, 0, 0, 0);
                }
                break;

            case SirenStage.Warning2:
                if (dls)
                {
                    NativeFunction.Natives.PLAY_SOUND_FROM_ENTITY(Sound.NewSoundID(activeVeh), activeVeh.Vehicle.GetDLS().SoundSettings.Tone4, activeVeh.Vehicle, 0, 0, 0);
                }
                else
                {
                    NativeFunction.Natives.PLAY_SOUND_FROM_ENTITY(Sound.NewSoundID(activeVeh), "VEHICLES_HORNS_AMBULANCE_WARNING", activeVeh.Vehicle, 0, 0, 0);
                }
                break;

            case SirenStage.Horn:
                if (dls)
                {
                    NativeFunction.Natives.PLAY_SOUND_FROM_ENTITY(Sound.NewSoundID(activeVeh), activeVeh.Vehicle.GetDLS().SoundSettings.Horn, activeVeh.Vehicle, 0, 0, 0);
                }
                else
                {
                    NativeFunction.Natives.PLAY_SOUND_FROM_ENTITY(Sound.NewSoundID(activeVeh), "SIRENS_AIRHORN", activeVeh.Vehicle, 0, 0, 0);
                }
                break;

            default:
                break;
            }
        }
Ejemplo n.º 10
0
        static void RawFrameRender(object sender, GraphicsEventArgs e)
        {
            int    w           = Game.Resolution.Width;
            int    h           = Game.Resolution.Height;
            string text        = "Warning - DLS Key Lock Active";
            float  size        = 16.0f;
            SizeF  graphicSize = Rage.Graphics.MeasureText(text, "Arial Bold", size);

            if (!Game.IsPaused && Entrypoint.keysLocked)
            {
                if (IsUIOn)
                {
                    e.Graphics.DrawText(text, "Arial Bold", size, new PointF(w - graphicSize.Width - 8, h + graphicSize.Height - sizeY), Color.DarkRed);
                }
                else
                {
                    e.Graphics.DrawText(text, "Arial Bold", size, new PointF(w - graphicSize.Width - 8, h - graphicSize.Height - 8), Color.DarkRed);
                }
            }
            Ped player = UIHelper.player;

            if (IsUIOn && UIHelper.IsUIAbleToDisplay && UIHelper.IsInAnyVehicle)
            {
                Vehicle veh = UIHelper.currentVehicle;
                if (UIHelper.IsUIAbleToDisplay && UIHelper.IsVehicleValid && UIHelper.IsPlayerDriver &&
                    (UIHelper.dlsModel != null || Entrypoint.SCforNDLS) &&
                    UIHelper.activeVeh != null)
                {
                    ActiveVehicle aVeh = UIHelper.activeVeh;
                    Background.Draw(e.Graphics);
                    if (Entrypoint.IndEnabled)
                    {
                        switch (aVeh.IndStatus)
                        {
                        case IndStatus.Off:
                            Hazard_Off.Draw(e.Graphics);
                            Lind_Off.Draw(e.Graphics);
                            Rind_Off.Draw(e.Graphics);
                            break;

                        case IndStatus.Both:
                            Hazard_On.Draw(e.Graphics);
                            Lind_Off.Draw(e.Graphics);
                            Rind_Off.Draw(e.Graphics);
                            break;

                        case IndStatus.Left:
                            Hazard_Off.Draw(e.Graphics);
                            Lind_On.Draw(e.Graphics);
                            Rind_Off.Draw(e.Graphics);
                            break;

                        case IndStatus.Right:
                            Hazard_Off.Draw(e.Graphics);
                            Lind_Off.Draw(e.Graphics);
                            Rind_On.Draw(e.Graphics);
                            break;

                        default:
                            Hazard_Off.Draw(e.Graphics);
                            Lind_Off.Draw(e.Graphics);
                            Rind_Off.Draw(e.Graphics);
                            break;
                        }
                    }
                    else
                    {
                        Hazard_Off.Draw(e.Graphics);
                        Lind_Off.Draw(e.Graphics);
                        Rind_Off.Draw(e.Graphics);
                    }
                    switch (aVeh.SirenStage)
                    {
                    case SirenStage.Off:
                        Wail_Off.Draw(e.Graphics);
                        Yelp_Off.Draw(e.Graphics);
                        Ext1_Off.Draw(e.Graphics);
                        Ext2_Off.Draw(e.Graphics);
                        break;

                    case SirenStage.One:
                        Wail_On.Draw(e.Graphics);
                        Yelp_Off.Draw(e.Graphics);
                        Ext1_Off.Draw(e.Graphics);
                        Ext2_Off.Draw(e.Graphics);
                        break;

                    case SirenStage.Two:
                        Wail_Off.Draw(e.Graphics);
                        Yelp_On.Draw(e.Graphics);
                        Ext1_Off.Draw(e.Graphics);
                        Ext2_Off.Draw(e.Graphics);
                        break;

                    case SirenStage.Warning:
                        Wail_Off.Draw(e.Graphics);
                        Yelp_Off.Draw(e.Graphics);
                        Ext1_On.Draw(e.Graphics);
                        Ext2_Off.Draw(e.Graphics);
                        break;

                    case SirenStage.Warning2:
                        Wail_Off.Draw(e.Graphics);
                        Yelp_Off.Draw(e.Graphics);
                        Ext1_Off.Draw(e.Graphics);
                        Ext2_On.Draw(e.Graphics);
                        break;

                    case SirenStage.Horn:
                        Wail_Off.Draw(e.Graphics);
                        Yelp_Off.Draw(e.Graphics);
                        Ext1_Off.Draw(e.Graphics);
                        Ext2_Off.Draw(e.Graphics);
                        break;

                    default:
                        Wail_Off.Draw(e.Graphics);
                        Yelp_Off.Draw(e.Graphics);
                        Ext1_Off.Draw(e.Graphics);
                        Ext2_Off.Draw(e.Graphics);
                        break;
                    }
                    switch (aVeh.LightStage)
                    {
                    case LightStage.Off:
                        S1_Off.Draw(e.Graphics);
                        S2_Off.Draw(e.Graphics);
                        S3_Off.Draw(e.Graphics);
                        break;

                    case LightStage.One:
                        S1_On.Draw(e.Graphics);
                        S2_Off.Draw(e.Graphics);
                        S3_Off.Draw(e.Graphics);
                        break;

                    case LightStage.Two:
                        S1_Off.Draw(e.Graphics);
                        S2_On.Draw(e.Graphics);
                        S3_Off.Draw(e.Graphics);
                        break;

                    case LightStage.Three:
                        S1_Off.Draw(e.Graphics);
                        S2_Off.Draw(e.Graphics);
                        S3_On.Draw(e.Graphics);
                        break;

                    default:
                        S1_Off.Draw(e.Graphics);
                        S2_Off.Draw(e.Graphics);
                        S3_Off.Draw(e.Graphics);
                        break;
                    }
                    switch (aVeh.TAStage)
                    {
                    case TAStage.Off:
                        Taleft_Off.Draw(e.Graphics);
                        Tadiv_Off.Draw(e.Graphics);
                        Taright_Off.Draw(e.Graphics);
                        Tawarn_Off.Draw(e.Graphics);
                        break;

                    case TAStage.Left:
                        Taleft_On.Draw(e.Graphics);
                        Tadiv_Off.Draw(e.Graphics);
                        Taright_Off.Draw(e.Graphics);
                        Tawarn_Off.Draw(e.Graphics);
                        break;

                    case TAStage.Diverge:
                        Taleft_Off.Draw(e.Graphics);
                        Tadiv_On.Draw(e.Graphics);
                        Taright_Off.Draw(e.Graphics);
                        Tawarn_Off.Draw(e.Graphics);
                        break;

                    case TAStage.Right:
                        Taleft_Off.Draw(e.Graphics);
                        Tadiv_Off.Draw(e.Graphics);
                        Taright_On.Draw(e.Graphics);
                        Tawarn_Off.Draw(e.Graphics);
                        break;

                    case TAStage.Warn:
                        Taleft_Off.Draw(e.Graphics);
                        Tadiv_Off.Draw(e.Graphics);
                        Taright_Off.Draw(e.Graphics);
                        Tawarn_On.Draw(e.Graphics);
                        break;

                    default:
                        Taleft_Off.Draw(e.Graphics);
                        Tadiv_Off.Draw(e.Graphics);
                        Taright_Off.Draw(e.Graphics);
                        Tawarn_Off.Draw(e.Graphics);
                        break;
                    }
                    if (PlayerController.hornButtonDown)
                    {
                        Horn_On.Draw(e.Graphics);
                    }
                    else
                    {
                        Horn_Off.Draw(e.Graphics);
                    }
                    if (aVeh.SBOn)
                    {
                        SB_On.Draw(e.Graphics);
                    }
                    else
                    {
                        SB_Off.Draw(e.Graphics);
                    }
                    if (aVeh.IntLightOn)
                    {
                        Intlt_On.Draw(e.Graphics);
                    }
                    else
                    {
                        Intlt_Off.Draw(e.Graphics);
                    }
                    if (PlayerController.manButtonDown)
                    {
                        Manual_On.Draw(e.Graphics);
                    }
                    else
                    {
                        Manual_Off.Draw(e.Graphics);
                    }
                    if (PlayerController.blktOn)
                    {
                        Blkt_On.Draw(e.Graphics);
                    }
                    else
                    {
                        Blkt_Off.Draw(e.Graphics);
                    }
                    if (UIHelper.dlsModel != null)
                    {
                        DLSModel dlsModel = UIHelper.dlsModel;
                        switch (aVeh.TAType)
                        {
                        case "three":
                            if (aVeh.TAStage != TAStage.Off && UIHelper.IsSirenOn[dlsModel.TrafficAdvisory.l.ToInt32() - 1] == SirenStatus.On)
                            {
                                _3_l_On.Draw(e.Graphics);
                            }
                            else
                            {
                                _3_l_Off.Draw(e.Graphics);
                            }
                            if (aVeh.TAStage != TAStage.Off && UIHelper.IsSirenOn[dlsModel.TrafficAdvisory.c.ToInt32() - 1] == SirenStatus.On)
                            {
                                _3_c_On.Draw(e.Graphics);
                            }
                            else
                            {
                                _3_c_Off.Draw(e.Graphics);
                            }
                            if (aVeh.TAStage != TAStage.Off && UIHelper.IsSirenOn[dlsModel.TrafficAdvisory.r.ToInt32() - 1] == SirenStatus.On)
                            {
                                _3_r_On.Draw(e.Graphics);
                            }
                            else
                            {
                                _3_r_Off.Draw(e.Graphics);
                            }
                            break;

                        case "four":
                            if (aVeh.TAStage != TAStage.Off && UIHelper.IsSirenOn[dlsModel.TrafficAdvisory.l.ToInt32() - 1] == SirenStatus.On)
                            {
                                _4_l_On.Draw(e.Graphics);
                            }
                            else
                            {
                                _4_l_Off.Draw(e.Graphics);
                            }
                            if (aVeh.TAStage != TAStage.Off && UIHelper.IsSirenOn[dlsModel.TrafficAdvisory.cl.ToInt32() - 1] == SirenStatus.On)
                            {
                                _4_cl_On.Draw(e.Graphics);
                            }
                            else
                            {
                                _4_cl_Off.Draw(e.Graphics);
                            }
                            if (aVeh.TAStage != TAStage.Off && UIHelper.IsSirenOn[dlsModel.TrafficAdvisory.cr.ToInt32() - 1] == SirenStatus.On)
                            {
                                _4_cr_On.Draw(e.Graphics);
                            }
                            else
                            {
                                _4_cr_Off.Draw(e.Graphics);
                            }
                            if (aVeh.TAStage != TAStage.Off && UIHelper.IsSirenOn[dlsModel.TrafficAdvisory.r.ToInt32() - 1] == SirenStatus.On)
                            {
                                _4_r_On.Draw(e.Graphics);
                            }
                            else
                            {
                                _4_r_Off.Draw(e.Graphics);
                            }
                            break;

                        case "five":
                            if (aVeh.TAStage != TAStage.Off && UIHelper.IsSirenOn[dlsModel.TrafficAdvisory.l.ToInt32() - 1] == SirenStatus.On)
                            {
                                _5_l_On.Draw(e.Graphics);
                            }
                            else
                            {
                                _5_l_Off.Draw(e.Graphics);
                            }
                            if (aVeh.TAStage != TAStage.Off && UIHelper.IsSirenOn[dlsModel.TrafficAdvisory.cl.ToInt32() - 1] == SirenStatus.On)
                            {
                                _5_cl_On.Draw(e.Graphics);
                            }
                            else
                            {
                                _5_cl_Off.Draw(e.Graphics);
                            }
                            if (aVeh.TAStage != TAStage.Off && UIHelper.IsSirenOn[dlsModel.TrafficAdvisory.c.ToInt32() - 1] == SirenStatus.On)
                            {
                                _5_c_On.Draw(e.Graphics);
                            }
                            else
                            {
                                _5_c_Off.Draw(e.Graphics);
                            }
                            if (aVeh.TAStage != TAStage.Off && UIHelper.IsSirenOn[dlsModel.TrafficAdvisory.cr.ToInt32() - 1] == SirenStatus.On)
                            {
                                _5_cr_On.Draw(e.Graphics);
                            }
                            else
                            {
                                _5_cr_Off.Draw(e.Graphics);
                            }
                            if (aVeh.TAStage != TAStage.Off && UIHelper.IsSirenOn[dlsModel.TrafficAdvisory.r.ToInt32() - 1] == SirenStatus.On)
                            {
                                _5_r_On.Draw(e.Graphics);
                            }
                            else
                            {
                                _5_r_Off.Draw(e.Graphics);
                            }
                            break;

                        case "six":
                            if (aVeh.TAStage != TAStage.Off && UIHelper.IsSirenOn[dlsModel.TrafficAdvisory.l.ToInt32() - 1] == SirenStatus.On)
                            {
                                _6_l_On.Draw(e.Graphics);
                            }
                            else
                            {
                                _6_l_Off.Draw(e.Graphics);
                            }
                            if (aVeh.TAStage != TAStage.Off && UIHelper.IsSirenOn[dlsModel.TrafficAdvisory.el.ToInt32() - 1] == SirenStatus.On)
                            {
                                _6_el_On.Draw(e.Graphics);
                            }
                            else
                            {
                                _6_el_Off.Draw(e.Graphics);
                            }
                            if (aVeh.TAStage != TAStage.Off && UIHelper.IsSirenOn[dlsModel.TrafficAdvisory.cl.ToInt32() - 1] == SirenStatus.On)
                            {
                                _6_cl_On.Draw(e.Graphics);
                            }
                            else
                            {
                                _6_cl_Off.Draw(e.Graphics);
                            }
                            if (aVeh.TAStage != TAStage.Off && UIHelper.IsSirenOn[dlsModel.TrafficAdvisory.cr.ToInt32() - 1] == SirenStatus.On)
                            {
                                _6_cr_On.Draw(e.Graphics);
                            }
                            else
                            {
                                _6_cr_Off.Draw(e.Graphics);
                            }
                            if (aVeh.TAStage != TAStage.Off && UIHelper.IsSirenOn[dlsModel.TrafficAdvisory.er.ToInt32() - 1] == SirenStatus.On)
                            {
                                _6_er_On.Draw(e.Graphics);
                            }
                            else
                            {
                                _6_er_Off.Draw(e.Graphics);
                            }
                            if (aVeh.TAStage != TAStage.Off && UIHelper.IsSirenOn[dlsModel.TrafficAdvisory.r.ToInt32() - 1] == SirenStatus.On)
                            {
                                _6_r_On.Draw(e.Graphics);
                            }
                            else
                            {
                                _6_r_Off.Draw(e.Graphics);
                            }
                            break;

                        default:
                            _6_l_Off.Draw(e.Graphics);
                            _6_el_Off.Draw(e.Graphics);
                            _6_cl_Off.Draw(e.Graphics);
                            _6_cr_Off.Draw(e.Graphics);
                            _6_er_Off.Draw(e.Graphics);
                            _6_r_Off.Draw(e.Graphics);
                            break;
                        }
                    }
                    else
                    {
                        _6_l_Off.Draw(e.Graphics);
                        _6_el_Off.Draw(e.Graphics);
                        _6_cl_Off.Draw(e.Graphics);
                        _6_cr_Off.Draw(e.Graphics);
                        _6_er_Off.Draw(e.Graphics);
                        _6_r_Off.Draw(e.Graphics);
                    }
                }
            }
        }
Ejemplo n.º 11
0
        public static void ProcessAI()
        {
            uint lastProcessTime   = Game.GameTime;
            int  timeBetweenChecks = 500;
            int  yieldAfterChecks  = 50;

            while (true)
            {
                int checksDone = 0;

                if (Entrypoint.AILightsC)
                {
                    Vehicle[] allWorldVehicles = World.GetAllVehicles();
                    foreach (Vehicle veh in allWorldVehicles)
                    {
                        if (veh && veh.HasSiren && veh.GetDLS() != null && !veh.IsPlayerVehicle())
                        {
                            if (veh.GetActiveVehicle() == null)
                            {
                                if (veh.IsSirenOn)
                                {
                                    if (!veh.IsSirenSilent)
                                    {
                                        Entrypoint.activeVehicles.Add(new ActiveVehicle(veh, false, LightStage.Three, SirenStage.One));
                                    }
                                    else
                                    {
                                        Entrypoint.activeVehicles.Add(new ActiveVehicle(veh, false, LightStage.Three, SirenStage.Off));
                                    }
                                }
                                else
                                {
                                    Entrypoint.activeVehicles.Add(new ActiveVehicle(veh, false));
                                }
                            }
                            ActiveVehicle activeVeh = veh.GetActiveVehicle();
                            DLSModel      dlsModel;
                            if (veh)
                            {
                                dlsModel = veh.GetDLS();
                            }
                            else
                            {
                                dlsModel = null;
                            }
                            if (veh.IsSirenOn && veh.IsSirenSilent == false && activeVeh.SirenStage == SirenStage.Off)
                            {
                                activeVeh.SirenStage = SirenStage.One;
                            }
                            if (veh.IsSirenOn && activeVeh.LightStage == LightStage.Off)
                            {
                                activeVeh.LightStage = LightStage.Three;
                            }
                            if (dlsModel != null && dlsModel.SpecialModes.PresetSirenOnLeaveVehicle != "none" &&
                                veh.IsSirenOn)
                            {
                                if (!veh.HasDriver)
                                {
                                    if (!veh.IsEngineOn)
                                    {
                                        veh.IsEngineOn = true;
                                    }
                                    string presetSiren = dlsModel.SpecialModes.PresetSirenOnLeaveVehicle;
                                    switch (presetSiren)
                                    {
                                    case "stage1":
                                        if (activeVeh.LightStage != LightStage.One)
                                        {
                                            activeVeh.LightStage = LightStage.One;
                                            Lights.Update(activeVeh);
                                        }
                                        break;

                                    case "stage2":
                                        if (activeVeh.LightStage != LightStage.Two)
                                        {
                                            activeVeh.LightStage = LightStage.Two;
                                            Lights.Update(activeVeh);
                                        }
                                        break;

                                    case "stage3":
                                        if (activeVeh.LightStage != LightStage.Three)
                                        {
                                            activeVeh.LightStage = LightStage.Three;
                                            Lights.Update(activeVeh);
                                        }
                                        break;

                                    case "custom1":
                                        if (activeVeh.LightStage != LightStage.CustomOne)
                                        {
                                            activeVeh.LightStage = LightStage.CustomOne;
                                            Lights.Update(activeVeh);
                                        }
                                        break;

                                    case "custom2":
                                        if (activeVeh.LightStage != LightStage.CustomTwo)
                                        {
                                            activeVeh.LightStage = LightStage.CustomTwo;
                                            Lights.Update(activeVeh);
                                        }
                                        break;
                                    }
                                }

                                if (dlsModel.DoesVehicleHaveLightStage(LightStage.Three) &&
                                    veh.HasDriver &&
                                    veh.EmergencyLighting.Name != dlsModel.Name + " | " + activeVeh.LightStage.ToString() + " | " + activeVeh.TAStage.ToString() + " | " + activeVeh.SBOn.ToString())
                                {
                                    activeVeh.LightStage = LightStage.Three;
                                    Lights.Update(activeVeh);
                                }
                            }
                        }
                    }

                    checksDone++;
                    if (checksDone % yieldAfterChecks == 0)
                    {
                        GameFiber.Yield();
                    }
                }
                GameFiber.Sleep((int)Math.Max(timeBetweenChecks, Game.GameTime - lastProcessTime));
                lastProcessTime = Game.GameTime;
            }
        }
Ejemplo n.º 12
0
        public static void ProcessPlayer()
        {
            uint lastProcessTime   = Game.GameTime;
            int  timeBetweenChecks = 100;

            while (true)
            {
                Vehicle veh = Game.LocalPlayer.Character.CurrentVehicle;
                if (veh && veh.HasSiren && veh.GetDLS() != null)
                {
                    if (veh.GetActiveVehicle() == null)
                    {
                        if (veh.IsSirenOn)
                        {
                            if (!veh.IsSirenSilent)
                            {
                                Entrypoint.activeVehicles.Add(new ActiveVehicle(veh, true, LightStage.Three, SirenStage.One));
                            }
                            else
                            {
                                Entrypoint.activeVehicles.Add(new ActiveVehicle(veh, true, LightStage.Three, SirenStage.Off));
                            }
                        }
                        else
                        {
                            Entrypoint.activeVehicles.Add(new ActiveVehicle(veh, true));
                        }
                    }
                    ActiveVehicle activeVeh = veh.GetActiveVehicle();
                    DLSModel      vehDLS;
                    if (veh)
                    {
                        vehDLS = veh.GetDLS();
                    }
                    else
                    {
                        vehDLS = null;
                    }
                    if (vehDLS.SpecialModes.WailSetup.WailSetupEnabled.ToBoolean())
                    {
                        if (activeVeh.LightStage != LightStage.Off && activeVeh.LightStage != LightStage.Empty &&
                            activeVeh.SirenStage == (SirenStage)vehDLS.SpecialModes.WailSetup.WailSirenTone.ToInt32() &&
                            activeVeh.LightStage != (LightStage)vehDLS.SpecialModes.WailSetup.WailLightStage.ToInt32())
                        {
                            activeVeh.TempWailLightStage = activeVeh.LightStage;
                            activeVeh.LightStage         = (LightStage)vehDLS.SpecialModes.WailSetup.WailLightStage.ToInt32();
                            Lights.Update(activeVeh);
                            activeVeh.Wailing = true;
                        }
                        if (activeVeh.Wailing &&
                            activeVeh.SirenStage != (SirenStage)vehDLS.SpecialModes.WailSetup.WailSirenTone.ToInt32())
                        {
                            activeVeh.LightStage = veh.GetActiveVehicle().TempWailLightStage;
                            Lights.Update(activeVeh);
                            activeVeh.Wailing = false;
                        }
                    }
                }
                GameFiber.Sleep((int)Math.Max(timeBetweenChecks, Game.GameTime - lastProcessTime));
                lastProcessTime = Game.GameTime;
            }
        }