public void PilotAssist() { this.controller1.CustomData = @"[pilot-assist] assist=true controllers=Controller 1 sensitivity=5"; var ini = new Program.IniWatcher(this.controller1, this.spawner); var deactivator = new Program.MockDeactivator(); var pa = new Program.PilotAssist(this.gts, ini, null, this.spawner, this.mockWheelsController); pa.AddDeactivator(deactivator); this.controller1.MoveIndicator = new VRageMath.Vector3(0, 0, 2); this.spawner.MockProcessTick(); Assert.AreEqual(-0.4f, this.mockWheelsController.Power); Assert.AreEqual(0, this.mockWheelsController.Steer); this.controller1.MoveIndicator = new VRageMath.Vector3(4, 0, 0); this.spawner.MockProcessTick(); Assert.AreEqual(0, this.mockWheelsController.Power); Assert.AreEqual(0.8f, this.mockWheelsController.Steer); deactivator.Deactivate = true; this.controller1.MoveIndicator = new VRageMath.Vector3(0, 0, 4); this.spawner.MockProcessTick(); Assert.AreEqual(0, this.mockWheelsController.Power, "When deactivated, the controls are left as is"); Assert.AreEqual(0.8f, this.mockWheelsController.Steer); }
public void AutoBrake() { this.controller1.CustomData = @"[pilot-assist] controllers=Controller 1"; var ini = new Program.IniWatcher(this.controller1, this.spawner); var handbraker = new Program.MockBraker(); var deactivator = new Program.MockDeactivator(); var pa = new Program.PilotAssist(this.gts, ini, null, this.spawner, this.mockWheelsController); pa.AddBraker(handbraker); pa.AddDeactivator(deactivator); Assert.IsTrue(this.controller1.IsUnderControl); this.spawner.MockProcessTick(); Assert.IsFalse(this.controller1.HandBrake); this.controller1.IsUnderControl = false; this.spawner.MockProcessTick(); Assert.IsTrue(this.controller1.HandBrake); this.controller1.IsUnderControl = true; this.spawner.MockProcessTick(); Assert.IsFalse(this.controller1.HandBrake); handbraker.Handbrake = true; this.spawner.MockProcessTick(); Assert.IsTrue(this.controller1.HandBrake); deactivator.Deactivate = true; this.spawner.MockProcessTick(); Assert.IsTrue(this.controller1.HandBrake, "When deactivated, the handbrake is neither engaged nor disengaged automatically"); handbraker.Handbrake = false; deactivator.Deactivate = false; this.spawner.MockProcessTick(); Assert.IsFalse(this.controller1.HandBrake); handbraker.Handbrake = true; deactivator.Deactivate = true; this.controller1.IsUnderControl = false; this.spawner.MockProcessTick(); Assert.IsFalse(this.controller1.HandBrake, "When deactivated, the handbrake is neither engaged nor disengaged automatically"); }
public void InitWithoutAssistWithHandbrake() { this.controller1.CustomData = @"[pilot-assist] controllers=Controller 2"; var ini = new Program.IniWatcher(this.controller1, this.spawner); this.controller2.ControlWheels = false; this.controller2.HandBrake = true; var pa = new Program.PilotAssist(this.gts, ini, null, this.spawner, this.mockWheelsController); Assert.IsTrue(this.controller2.ControlWheels); Assert.IsTrue(this.controller2.HandBrake); Assert.IsTrue(pa.ManuallyBraked); }
public void InitWithAssistWithoutHandbrake() { this.controller1.CustomData = @"[pilot-assist] assist=true controllers=Controller 1,Controller 2"; var ini = new Program.IniWatcher(this.controller1, this.spawner); Assert.IsTrue(this.controller2.ControlWheels); Assert.IsFalse(this.controller1.HandBrake); var pa = new Program.PilotAssist(this.gts, ini, null, this.spawner, this.mockWheelsController); Assert.IsFalse(this.controller1.ControlWheels, "When assist is true, the controllers no longer control the wheels directly"); Assert.IsFalse(this.controller2.ControlWheels); Assert.IsFalse(this.controller1.HandBrake); Assert.IsTrue(this.spawner.HasOnSave); Assert.IsFalse(pa.ManuallyBraked); }
public void DetectHandbrake() { this.controller1.CustomData = @"[pilot-assist] controllers=Controller 1"; var ini = new Program.IniWatcher(this.controller1, this.spawner); var pa = new Program.PilotAssist(this.gts, ini, null, this.spawner, this.mockWheelsController); this.spawner.MockProcessTick(); Assert.IsFalse(pa.ManuallyBraked); this.controller1.HandBrake = true; this.spawner.MockProcessTick(); Assert.IsTrue(pa.ManuallyBraked); this.controller1.HandBrake = false; this.spawner.MockProcessTick(); Assert.IsFalse(pa.ManuallyBraked); }