/// <summary> /// Subscribes to messages from devices to translate them. /// </summary> public static void InitRealDevices() { BodyModule.Init(); Bordmonitor.Init(); Immobiliser.Init(); InstrumentClusterElectronics.Init(); LightControlModule.Init(); MultiFunctionSteeringWheel.Init(); Radio.Init(); }
private void Button_Click(object sender, RoutedEventArgs e) { if (BodyModule.IsCarLocked) { BodyModule.UnlockDoors(); } else { BodyModule.LockDoors(); } }
// Constructors. public UnitCore( BodyModule body = null, DurabilityModule durability = null, IConditionModule condition = null, AbilityCollectionModule abilityCollection = null, IntelligenceModule intelligence = null) { // Modules. this.body = body?.Clone() ?? new BodyModule(); this.body.Connect(Presentation); this.durability = durability?.Clone() ?? new DurabilityModule(); this.durability.Connect(Presentation); this.condition = condition?.Clone() ?? this.durability.CreateUsualCondition(); this.condition.Connect(Presentation); this.abilityCollection = abilityCollection?.Clone() ?? new AbilityCollectionModule(); this.abilityCollection.Connect(Presentation); this.intelligence = intelligence?.Clone() ?? new IntelligenceModule(); this.intelligence.Connect(Presentation); }
public override void AwakeOnServer() { var rigidBody = GetComponent <Rigidbody>(); if (rigidBody == null) { throw new NullReferenceException(); } ServerSession.Instance.AddPlayerEntity(this); BodyModule.Initialize(this); MoveModule.Initialize(this); MoveModule.Setup(this, rigidBody); AnimationModule.Initialize(this); BodyModule.OnStateChanged += OnStateChanged; MoveModule.OnStateChanged += OnStateChanged; AnimationModule.OnStateChanged += OnStateChanged; }
public override void AwakeOnClient() { var rigidBody = GetComponent <Rigidbody>(); if (rigidBody == null) { throw new NullReferenceException(); } rigidBody.useGravity = false; BodyModule.Initialize(this); MoveModule.Initialize(this); MoveModule.Setup(this, rigidBody); AnimationModule.Initialize(this); definedModules.Add(BodyModule.ID, BodyModule); definedModules.Add(MoveModule.ID, MoveModule); definedModules.Add(AnimationModule.ID, AnimationModule); }
private static void ProcessCommand(object o) { var c = (Command)o; switch (c) { // TODO Fix windows closing: current commands close them just by half case Command.FullCloseWindows: BodyModule.CloseWindows(); Thread.Sleep(3000); BodyModule.CloseWindows(); Thread.Sleep(3000); BodyModule.CloseWindows(); break; case Command.FullOpenWindows: BodyModule.OpenWindows(); Thread.Sleep(3000); BodyModule.OpenWindows(); Thread.Sleep(3000); BodyModule.OpenWindows(); break; } }
public static void Init() { iBus.Manager.AddMessageReceiverForDestinationDevice(iBus.DeviceAddress.CDChanger, (m) => { // "Change CD" message from radio to CDC: 38 06 XX if (m.Data.Length == 3 && m.Data[0] == 0x38 && m.Data[1] == 0x06) { byte cdNumber = m.Data[2]; switch (cdNumber) { case 0x06: // CD6 button: Open trunk when ignition isn't off and not driving if (InstrumentClusterElectronics.CurrentIgnitionState != IgnitionState.Off) { if (InstrumentClusterElectronics.CurrentSpeed == 0) { BodyModule.OpenTrunk(); Radio.DisplayTextWithDelay("Trunk open", TextAlign.Center); } else { Radio.DisplayTextWithDelay("Stop car", TextAlign.Center); } } else { Radio.DisplayTextWithDelay("Turn on ign", TextAlign.Center); } break; case 0x05: // CD5 button: Toggle current speed and RPM showing on radio display showSpeedRpm = !showSpeedRpm; if (showSpeedRpm) { ShowSpeedRPM(InstrumentClusterElectronics.CurrentSpeed, InstrumentClusterElectronics.CurrentRPM, true); } else { Radio.DisplayTextWithDelay("Speed off", TextAlign.Center); } break; case 0x04: Radio.DisplayTextWithDelay("Close winds"); BodyModule.CloseWindows(); break; case 0x03: Features.Comfort.NextComfortCloseEnabled = !Features.Comfort.NextComfortCloseEnabled; Radio.DisplayTextWithDelay("[" + (Features.Comfort.NextComfortCloseEnabled ? "X" : " ") + "]Comf cls"); break; case 0x02: Radio.DisplayTextWithDelay(DateTime.Now.ToString("ddHH") + " " + maxMessagesSpan.GetTotalMinutes() + "\"" + maxMessagesSpan.Seconds); // dd HH:mm:ss break; case 0x01: Radio.DisplayTextWithDelay(":)", TextAlign.Center); break; } m.ReceiverDescription = "Change CD" + cdNumber; } }); InstrumentClusterElectronics.SpeedRPMChanged += (e) => { if (showSpeedRpm) { ShowSpeedRPM(e.Speed, e.RPM); } }; iBus.Manager.AfterMessageReceived += (m) => { var now = DateTime.Now; var span = now - lastMessage; lastMessage = now; if (span > maxMessagesSpan) { maxMessagesSpan = span; } }; /*InstrumentClusterElectronics.IgnitionStateChanged += (e) => * { * if (e.CurrentIgnitionState != IgnitionState.Off && e.PreviousIgnitionState == IgnitionState.Off) * { * iBus.Manager.EnqueueMessage(new iBus.Message(iBus.DeviceAddress.Diagnostic, iBus.DeviceAddress.GlobalBroadcastAddress, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x06)); * } * };*/ }
private void CloseDoorsButton_Click(object sender, RoutedEventArgs e) { BodyModule.LockDoors(); }
private void OpenDoorsButton_Click(object sender, RoutedEventArgs e) { BodyModule.UnlockDoors(); }
private void Button_Click_2(object sender, RoutedEventArgs e) { BodyModule.CloseWindows(); }
private void Button_Click_1(object sender, RoutedEventArgs e) { BodyModule.OpenWindows(); }
protected void UpdateVoltage() { needUpdateVoltage = false; BodyModule.UpdateBatteryVoltage(); }
static Comfort() { commands = new QueueThreadWorker(ProcessCommand); InstrumentClusterElectronics.SpeedRPMChanged += (e) => { if (needLockDoors && e.Speed > DoorsLockSpeed) { if (AutoLockDoors) { BodyModule.LockDoors(); } needLockDoors = false; needUnlockDoors = true; } if (e.Speed == 0) { needLockDoors = true; } }; InstrumentClusterElectronics.IgnitionStateChanged += (e) => { if (!needComfortClose && e.CurrentIgnitionState != IgnitionState.Off && e.PreviousIgnitionState == IgnitionState.Off) { needComfortClose = true; } if (needUnlockDoors && e.CurrentIgnitionState == IgnitionState.Off) { if (AutoUnlockDoors) { BodyModule.UnlockDoors(); } needUnlockDoors = false; needLockDoors = true; } }; BodyModule.RemoteKeyButtonPressed += (e) => { if (e.Button == RemoteKeyButton.Lock && needComfortClose) { needComfortClose = false; if (AutoCloseWindows) { commands.Enqueue(Command.FullCloseWindows); } if (AutoCloseSunroof) { BodyModule.CloseSunroof(); } if (AutoFoldMirrors) { BodyModule.FoldMirrors(); } } if (e.Button == RemoteKeyButton.Unlock) { if (AutoUnfoldMirrors) { BodyModule.UnfoldMirrors(); } } }; }