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); }
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); }
public static List <DLSModel> GetAllModels() { string path = @"Plugins\DLS\"; _ = new DLSModel(); List <DLSModel> listModels = new List <DLSModel>(); foreach (string file in Directory.EnumerateFiles(path, "*.xml")) { try { XmlSerializer mySerializer = new XmlSerializer(typeof(DLSModel)); StreamReader streamReader = new StreamReader(file); DLSModel model = (DLSModel)mySerializer.Deserialize(streamReader); streamReader.Close(); model.Name = Game.GetHashKey(Path.GetFileNameWithoutExtension(file)).ToString(); model.AvailableLightStages.Add(LightStage.Off); if (model.Sirens.Stage1Setting != null) { model.AvailableLightStages.Add(LightStage.One); } if (model.Sirens.Stage2Setting != null) { model.AvailableLightStages.Add(LightStage.Two); } if (model.Sirens.Stage3Setting != null) { model.AvailableLightStages.Add(LightStage.Three); } model.AvailableSirenStages.Add(SirenStage.Off); if (model.SoundSettings.Tone1 != "") { model.AvailableSirenStages.Add(SirenStage.One); } if (model.SoundSettings.Tone2 != "") { model.AvailableSirenStages.Add(SirenStage.Two); } if (model.SoundSettings.Tone3 != "") { model.AvailableSirenStages.Add(SirenStage.Warning); } if (model.SoundSettings.Tone4 != "") { model.AvailableSirenStages.Add(SirenStage.Warning2); } listModels.Add(model); ("Added: " + model.Name).ToLog(); } catch (Exception e) { ("VCF IMPORT ERROR (" + Path.GetFileNameWithoutExtension(file) + "): " + e.Message).ToLog(); Game.LogTrivial("VCF IMPORT ERROR (" + Path.GetFileNameWithoutExtension(file) + "): " + e.Message); } } return(listModels); }
public static SirenStage GetNextStage(SirenStage sirenStage, DLSModel vehDLS) { return(vehDLS.AvailableSirenStages.NextSirenStage(sirenStage, false)); }
internal static bool DoesVehicleHaveSirenStage(this DLSModel dlsModel, SirenStage sirenStage) { return(dlsModel.AvailableSirenStages.Contains(sirenStage)); }
internal static bool DoesVehicleHaveLightStage(this DLSModel dlsModel, LightStage lightStage) { return(dlsModel.AvailableLightStages.Contains(lightStage)); }
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); } } } }