internal void ToggleTakedownLightControlTick() { Controls.ToggleTdl.Disable(); if (ELS.CurrentInputMode == InputMode.MouseAndKeyboard && !Game.IsControlPressed(0, Control.CharacterWheel)) { return; } if (Controls.ToggleTdl.IsDisabledJustPressed()) { ToggleTdl(); var dic = new Dictionary <string, object>(); if (_extras.TakedownLights != null) { dic.Add(DataNames.TakedownLights, _extras.TakedownLights.GetData()); } if (SpotLight != null) { dic.Add(DataNames.Spotlight, SpotLight.GetData()); } RemoteEventManager.SendLightEvent(ElsVehicle, dic); } }
public Dictionary <string, object> GetData() { var dic = new Dictionary <string, object>(); var prm = GetPrimaryLightsData(); var sec = GetSecondaryLightsData(); var wrn = GetWarningLightsData(); if (prm != null && prm.Count > 0) { dic.Add(DataNames.PRML, prm); } if (sec != null && sec.Count > 0) { dic.Add(DataNames.SECL, sec); } if (wrn != null && wrn.Count > 0) { dic.Add(DataNames.WRNL, wrn); } if (_extras.SteadyBurn != null) { dic.Add(DataNames.SteadyBurn, _extras.SteadyBurn.GetData()); } if (_extras.SceneLights != null) { dic.Add(DataNames.SceneLights, _extras.SceneLights.GetData()); } if (_extras.TakedownLights != null) { dic.Add(DataNames.TakedownLights, _extras.TakedownLights.GetData()); } if (_extras.Board?.HasBoard ?? false) { dic.Add(DataNames.Board, _extras.Board.GetData()); } if (CurrentPrmPattern != 0) { dic.Add(DataNames.PrimaryPattern, CurrentPrmPattern); } if (CurrentSecPattern != 0) { dic.Add(DataNames.SecondaryPattern, CurrentSecPattern); } if (CurrentWrnPattern != 0) { dic.Add(DataNames.WarningPattern, CurrentWrnPattern); } if (_stage.CurrentStage != 0) { dic.Add(DataNames.Stage, _stage.CurrentStage); } if (SpotLight != null) { dic.Add(DataNames.Spotlight, SpotLight.GetData()); } if (Scene != null) { dic.Add(DataNames.Scene, Scene.GetData()); } return(dic); }
public void SetData(IDictionary <string, object> data) { if (data.TryGetValue(DataNames.PRML, out var prml) && _extras.PrimaryLights != null) { IDictionary <string, object> prm = (IDictionary <string, object>)prml; foreach (Extra.Extra extra in _extras.PrimaryLights.Values) { prm.TryGetValue(extra.Id.ToString(), out var extraData); extra.SetData((IDictionary <string, object>)extraData); } } if (data.TryGetValue(DataNames.SECL, out var secl) && _extras.SecondaryLights != null) { IDictionary <string, object> sec = (IDictionary <string, object>)secl; foreach (Extra.Extra extra in _extras.SecondaryLights.Values) { sec.TryGetValue(extra.Id.ToString(), out var extraData); extra.SetData((IDictionary <string, object>)extraData); } } if (data.TryGetValue(DataNames.WRNL, out var wrnl) && _extras.WarningLights != null) { IDictionary <string, object> wrn = (IDictionary <string, object>)wrnl; foreach (Extra.Extra extra in _extras.WarningLights.Values) { wrn.TryGetValue(extra.Id.ToString(), out var extraData); extra.SetData((IDictionary <string, object>)extraData); } } if (data.TryGetValue(DataNames.SteadyBurn, out var sbrn)) { try { if (_extras.SteadyBurn == null) { CreateMissingExtra(10); } _extras.SteadyBurn.SetData((IDictionary <string, object>)sbrn); } catch (Exception e) { Utils.DebugWriteLine($"SBRN error: {e}"); } } if (data.TryGetValue(DataNames.SceneLights, out var scl)) { try { if (_extras.SceneLights == null) { CreateMissingExtra(12); } _extras.SceneLights.SetData((IDictionary <string, object>)scl); } catch (Exception e) { Utils.DebugWriteLine($"SCL error: {e}"); } } if (data.TryGetValue(DataNames.TakedownLights, out var tdl)) { try { if (_extras.TakedownLights == null) { CreateMissingExtra(11); } _extras.TakedownLights.SetData((IDictionary <string, object>)tdl); } catch (Exception e) { Utils.DebugWriteLine($"TDL error: {e}"); } } if (data.TryGetValue(DataNames.Board, out var brd)) { try { if (_extras.Board == null) { CreateBoard(); } _extras.Board.SetData((IDictionary <string, object>)brd); } catch (Exception e) { Utils.DebugWriteLine($"BRD error: {e}"); } } if (data.TryGetValue(DataNames.PrimaryPattern, out var prmPatt) && prmPatt != null) { CurrentPrmPattern = (int)prmPatt; } else { CurrentPrmPattern = 0; } if (data.TryGetValue(DataNames.SecondaryPattern, out var secPatt) && secPatt != null) { CurrentSecPattern = (int)secPatt; } else { CurrentSecPattern = 0; } if (data.TryGetValue(DataNames.WarningPattern, out var wrnPatt) && wrnPatt != null) { CurrentWrnPattern = (int)wrnPatt; } else { CurrentWrnPattern = 0; } if (data.TryGetValue(DataNames.Stage, out var stage) && stage != null) { _stage.SetStage((int)stage); } else { _stage.SetStage(0); } if (SpotLight != null && data.TryGetValue(DataNames.Spotlight, out var spotlight)) { SpotLight.SetData((IDictionary <string, object>)spotlight); } if (Scene != null && data.TryGetValue(DataNames.Scene, out var sceneLight)) { Scene.SetData((IDictionary <string, object>)sceneLight); } }
private void AddAllValidLightExtras() { for (int x = 1; x < 13; x++) { switch (x) { case 1: { if (API.DoesExtraExist(_vehicle.Handle, 1) && _vcfroot.EOVERRIDE.Extra01.IsElsControlled) { this._extras.PRML.Add(1, new Extra.Extra(this, 1, _vcfroot.EOVERRIDE.Extra01, _vcfroot.PRML.LightingFormat)); } } break; case 2: { if (API.DoesExtraExist(_vehicle.Handle, 2) && _vcfroot.EOVERRIDE.Extra02.IsElsControlled) { this._extras.PRML.Add(2, new Extra.Extra(this, 2, _vcfroot.EOVERRIDE.Extra02, _vcfroot.PRML.LightingFormat)); } } break; case 3: { if (API.DoesExtraExist(_vehicle.Handle, 3) && _vcfroot.EOVERRIDE.Extra03.IsElsControlled) { this._extras.PRML.Add(3, new Extra.Extra(this, 3, _vcfroot.EOVERRIDE.Extra03, _vcfroot.PRML.LightingFormat)); } } break; case 4: { if (API.DoesExtraExist(_vehicle.Handle, 4) && _vcfroot.EOVERRIDE.Extra04.IsElsControlled) { this._extras.PRML.Add(4, new Extra.Extra(this, 4, _vcfroot.EOVERRIDE.Extra04, _vcfroot.PRML.LightingFormat)); } } break; case 5: { if (API.DoesExtraExist(_vehicle.Handle, 5) && _vcfroot.EOVERRIDE.Extra05.IsElsControlled) { this._extras.WRNL.Add(5, new Extra.Extra(this, 5, _vcfroot.EOVERRIDE.Extra05, _vcfroot.WRNL.LightingFormat)); } } break; case 6: { if (API.DoesExtraExist(_vehicle.Handle, 6) && _vcfroot.EOVERRIDE.Extra06.IsElsControlled) { this._extras.WRNL.Add(6, new Extra.Extra(this, 6, _vcfroot.EOVERRIDE.Extra06, _vcfroot.WRNL.LightingFormat)); } } break; case 7: { if (API.DoesExtraExist(_vehicle.Handle, 7) && _vcfroot.EOVERRIDE.Extra07.IsElsControlled) { this._extras.SECL.Add(7, new Extra.Extra(this, 7, _vcfroot.EOVERRIDE.Extra07, _vcfroot.SECL.LightingFormat)); } } break; case 8: { if (API.DoesExtraExist(_vehicle.Handle, 8) && _vcfroot.EOVERRIDE.Extra08.IsElsControlled) { this._extras.SECL.Add(8, new Extra.Extra(this, 8, _vcfroot.EOVERRIDE.Extra08, _vcfroot.SECL.LightingFormat)); } } break; case 9: { if (API.DoesExtraExist(_vehicle.Handle, 9) && _vcfroot.EOVERRIDE.Extra09.IsElsControlled) { this._extras.SECL.Add(9, new Extra.Extra(this, 9, _vcfroot.EOVERRIDE.Extra09, _vcfroot.SECL.LightingFormat)); } } break; case 10: { if (API.DoesExtraExist(_vehicle.Handle, 10) && _vcfroot.EOVERRIDE.Extra10.IsElsControlled) { this._extras.SBRN = new Extra.Extra(this, 10, _vcfroot.EOVERRIDE.Extra10); } } break; case 11: { if (API.DoesExtraExist(_vehicle.Handle, 11) && _vcfroot.EOVERRIDE.Extra11.IsElsControlled && _vcfroot.MISC.Takedowns.AllowUse) { this._extras.TDL = new Extra.Extra(this, 11, _vcfroot.EOVERRIDE.Extra11); } else if (_vcfroot.MISC.Takedowns.AllowUse) { spotLight = new SpotLight(this); } } break; case 12: { if (API.DoesExtraExist(_vehicle.Handle, 12) && _vcfroot.EOVERRIDE.Extra12.IsElsControlled && _vcfroot.MISC.SceneLights.AllowUse) { this._extras.SCL = new Extra.Extra(this, 12, _vcfroot.EOVERRIDE.Extra12); } else if (_vcfroot.MISC.SceneLights.AllowUse) { scene = new Scene(this); } } break; } } if (!String.IsNullOrEmpty(_vcfroot.MISC.ArrowboardType)) { switch (_vcfroot.MISC.ArrowboardType) { case "bonnet": this._extras.BRD = new Board.ArrowBoard(this, _vcfroot.MISC); break; case "boot": this._extras.BRD = new Board.ArrowBoard(this, _vcfroot.MISC); break; case "boot2": this._extras.BRD = new Board.ArrowBoard(this, _vcfroot.MISC); break; case "boots": this._extras.BRD = new Board.ArrowBoard(this, _vcfroot.MISC); break; case "off": this._extras.BRD = new Board.ArrowBoard(this, _vcfroot.MISC); break; default: this._extras.BRD = new Board.ArrowBoard(this, _vcfroot.MISC); break; } } if (_vcfroot.MISC.HasLadderControl) { this._extras.LDR = new Gadgets.Ladder(this, _vcfroot.MISC); } }
public async void Ticker() { if (!Vehicle.Exists(ElsVehicle.Vehicle)) { Init(); if (!Vehicle.Exists(ElsVehicle.Vehicle)) { return; } } if (_extras.SteadyBurn != null) { _extras.SteadyBurn.ExtraTicker(); } if (_extras.SceneLights != null) { _extras.SceneLights.ExtraTicker(); } if (_extras.TakedownLights != null) { _extras.TakedownLights.ExtraTicker(); } if (SpotLight != null && SpotLight.TurnedOn) { SpotLight.RunTick(); } if (Scene != null && Scene.TurnedOn) { Scene.RunTick(); } var shouldRunScanTicker = false; if (_extras.PrimaryLights != null) { if (_stage != null && _scan) { switch (_stage.CurrentStage) { case 1: if (_stage.PRML.PresetPatterns.Lstg1.IsScanPattern) { shouldRunScanTicker = true; } break; case 2: if (_stage.PRML.PresetPatterns.Lstg2.IsScanPattern) { shouldRunScanTicker = true; } break; case 3: if (_stage.PRML.PresetPatterns.Lstg3.IsScanPattern) { shouldRunScanTicker = true; } break; } } for (int i = 0; i < _extras.PrimaryLights.Count; i++) { _extras.PrimaryLights.ElementAt(i).Value.ExtraTicker(); } } if (_extras.SecondaryLights != null) { if (!shouldRunScanTicker && _stage != null && _scan) { switch (_stage.CurrentStage) { case 1: if (_stage.SECL.PresetPatterns.Lstg1.IsScanPattern) { shouldRunScanTicker = true; } break; case 2: if (_stage.SECL.PresetPatterns.Lstg2.IsScanPattern) { shouldRunScanTicker = true; } break; case 3: if (_stage.SECL.PresetPatterns.Lstg3.IsScanPattern) { shouldRunScanTicker = true; } break; } } for (int i = 0; i < _extras.SecondaryLights.Count; i++) { _extras.SecondaryLights.ElementAt(i).Value.ExtraTicker(); } } if (_extras.WarningLights != null) { if (!shouldRunScanTicker && _stage != null && _scan) { switch (_stage.CurrentStage) { case 1: if (_stage.WRNL.PresetPatterns.Lstg1.IsScanPattern) { shouldRunScanTicker = true; } break; case 2: if (_stage.WRNL.PresetPatterns.Lstg2.IsScanPattern) { shouldRunScanTicker = true; } break; case 3: if (_stage.WRNL.PresetPatterns.Lstg3.IsScanPattern) { shouldRunScanTicker = true; } break; } } for (int i = 0; i < _extras.WarningLights.Count; i++) { _extras.WarningLights.ElementAt(i).Value.ExtraTicker(); } } if (shouldRunScanTicker) { ScanPatternTicker(); } }
private void CreateMissingExtra(int x) { switch (x) { case 1: { if (Vcfroot.EOVERRIDE.Extra01.IsElsControlled) { if (_extras.PrimaryLights == null) { _extras.PrimaryLights = new Dictionary <int, Extra.Extra>(); } _extras.PrimaryLights.Add(1, new Extra.Extra(this, 1, Vcfroot.EOVERRIDE.Extra01, Vcfroot.PRML.LightingFormat)); } } break; case 2: { if (Vcfroot.EOVERRIDE.Extra02.IsElsControlled) { if (_extras.PrimaryLights == null) { _extras.PrimaryLights = new Dictionary <int, Extra.Extra>(); } _extras.PrimaryLights.Add(2, new Extra.Extra(this, 2, Vcfroot.EOVERRIDE.Extra02, Vcfroot.PRML.LightingFormat)); } } break; case 3: { if (Vcfroot.EOVERRIDE.Extra03.IsElsControlled) { if (_extras.PrimaryLights == null) { _extras.PrimaryLights = new Dictionary <int, Extra.Extra>(); } _extras.PrimaryLights.Add(3, new Extra.Extra(this, 3, Vcfroot.EOVERRIDE.Extra03, Vcfroot.PRML.LightingFormat)); } } break; case 4: { if (Vcfroot.EOVERRIDE.Extra04.IsElsControlled) { if (_extras.PrimaryLights == null) { _extras.PrimaryLights = new Dictionary <int, Extra.Extra>(); } _extras.PrimaryLights.Add(4, new Extra.Extra(this, 4, Vcfroot.EOVERRIDE.Extra04, Vcfroot.PRML.LightingFormat)); } } break; case 5: { if (Vcfroot.EOVERRIDE.Extra05.IsElsControlled) { if (_extras.WarningLights == null) { _extras.WarningLights = new Dictionary <int, Extra.Extra>(); } _extras.WarningLights.Add(5, new Extra.Extra(this, 5, Vcfroot.EOVERRIDE.Extra05, Vcfroot.WRNL.LightingFormat)); } } break; case 6: { if (Vcfroot.EOVERRIDE.Extra06.IsElsControlled) { if (_extras.WarningLights == null) { _extras.WarningLights = new Dictionary <int, Extra.Extra>(); } _extras.WarningLights.Add(6, new Extra.Extra(this, 6, Vcfroot.EOVERRIDE.Extra06, Vcfroot.WRNL.LightingFormat)); } } break; case 7: { if (Vcfroot.EOVERRIDE.Extra07.IsElsControlled) { if (_extras.SecondaryLights == null) { _extras.SecondaryLights = new Dictionary <int, Extra.Extra>(); } _extras.SecondaryLights.Add(7, new Extra.Extra(this, 7, Vcfroot.EOVERRIDE.Extra07, Vcfroot.SECL.LightingFormat)); } } break; case 8: { if (Vcfroot.EOVERRIDE.Extra08.IsElsControlled) { if (_extras.SecondaryLights == null) { _extras.SecondaryLights = new Dictionary <int, Extra.Extra>(); } _extras.SecondaryLights.Add(8, new Extra.Extra(this, 8, Vcfroot.EOVERRIDE.Extra08, Vcfroot.SECL.LightingFormat)); } } break; case 9: { if (Vcfroot.EOVERRIDE.Extra09.IsElsControlled) { if (_extras.SecondaryLights == null) { _extras.SecondaryLights = new Dictionary <int, Extra.Extra>(); } _extras.SecondaryLights.Add(9, new Extra.Extra(this, 9, Vcfroot.EOVERRIDE.Extra09, Vcfroot.SECL.LightingFormat)); } } break; case 10: { if (Vcfroot.EOVERRIDE.Extra10.IsElsControlled) { _extras.SteadyBurn = new Extra.Extra(this, 10, Vcfroot.EOVERRIDE.Extra10); } } break; case 11: { if (Vcfroot.EOVERRIDE.Extra11.IsElsControlled && Vcfroot.MISC.Takedowns.AllowUse) { _extras.TakedownLights = new Extra.Extra(this, 11, Vcfroot.EOVERRIDE.Extra11); } else if (Vcfroot.MISC.Takedowns.AllowUse) { SpotLight = new SpotLight(this); } } break; case 12: { if (Vcfroot.EOVERRIDE.Extra12.IsElsControlled && Vcfroot.MISC.SceneLights.AllowUse) { _extras.SceneLights = new Extra.Extra(this, 12, Vcfroot.EOVERRIDE.Extra12); } else if (Vcfroot.MISC.SceneLights.AllowUse) { Scene = new Scene(this); } } break; } }