public void ShouldBeConstructed() { var service = new Mock <IWheelService>(); var controller = new WheelsController(service.Object); Assert.NotNull(controller); }
/// <summary>Creates a PilotAssist</summary> /// <param name="gts">To get the different blocks</param> /// <param name="ini">Parsed ini that contains the configuration. See <see cref="Read(Ini)"/> for more information</param> /// <param name="logger">Optional logger</param> /// <param name="manager">Used to schedule itself</param> /// <param name="wc">Wheel controller used to actually controll the wheels</param> public PilotAssist(IMyGridTerminalSystem gts, IniWatcher ini, Action <string> logger, ISaveManager manager, WheelsController wc) { this.logger = logger; this.wheelControllers = wc; this.gts = gts; this.Read(ini); this.ManuallyBraked = !this.shouldBrake() && this.Braked; this.wasPreviouslyAutoBraked = this.shouldBrake(); manager.Spawn(this.handle, "pilot-assist"); manager.AddOnSave(this.save); ini.Add(this); }
public ArmAutoControl(MyIni ini, float angle, WheelsController wc, List <IMyFunctionalBlock> tools) { this.tools = tools; this.wc = wc; if (ini.ContainsSection(SECTION)) { this.Target = new ArmPos(ini.Get(SECTION, "pos").ToString()); } else { this.SetTarget(new ArmPos(angle)); } }
public async Task ShouldCreate() { var service = new Mock <IWheelService>(); var controller = new WheelsController(service.Object); var viewModel = new WheelViewModel { Size = 16, Width = 5 }; service.Setup(x => x.CreateNewWheel(viewModel)).Returns(Task.FromResult(true)); var result = await controller.Post(viewModel); Assert.IsType <NoContentResult>(result); }
/// <summary>Creates a new Autopilot</summary> /// <param name="ini"></param> /// <param name="wheels"></param> /// <param name="cmd"></param> /// <param name="remote"></param> /// <param name="logger"></param> /// <param name="manager"></param> public Autopilot(MyIni ini, WheelsController wheels, CommandLine cmd, IMyRemoteControl remote, Action <string> logger, ISaveManager manager) { this.activated = ini.Get("auto-pilot", "activated").ToBoolean(); this.logger = logger; Process p = manager.Spawn(this.handle, "ap-handle"); this.Network = new WPNetwork(remote, logger, p); this.remote = remote; this.transformer = new CoordinatesTransformer(remote, p); this.wheels = wheels; cmd.RegisterCommand(new Command("ap-move", Command.Wrap(this.move), "Move forward", minArgs: 1, maxArgs: 2)); cmd.RegisterCommand(new Command("ap-goto", Command.Wrap(this.GoTo), "Go to the waypoint", nArgs: 1)); cmd.RegisterCommand(new Command("ap-switch", Command.Wrap(this.Switch), "Switches the autopilot on/off", nArgs: 1)); cmd.RegisterCommand(new Command("ap-save", Command.Wrap(this.Save), "Save the current position", nArgs: 1)); manager.AddOnSave(this.save); }
public Program() { this.Runtime.UpdateFrequency = UpdateFrequency.Update1; this.manager = Process.CreateManager(this.Echo); var screen = this.GridTerminalSystem.GetBlockWithName("SMB LCD (Rear Seat)") as IMyTextPanel; var logger = new Logger(this.manager, screen); this.cmd = new CommandLine("Small Mobile Base", logger.Log, this.manager); var ini = new IniWatcher(this.Me, this.manager); var controller = this.GridTerminalSystem.GetBlockWithName("SMB Remote Control (Forward)") as IMyShipController; var transformer = new CoordinatesTransformer(controller, this.manager); var wheelsController = new WheelsController(this.cmd, controller, this.GridTerminalSystem, ini, this.manager, transformer); new ConnectionClient(ini, this.GridTerminalSystem, this.IGC, this.cmd, this.manager, logger.Log); new CameraTurret(this.GridTerminalSystem, this.manager); new PilotAssist(this.GridTerminalSystem, ini, logger.Log, this.manager, wheelsController); }
public void ShouldGet() { var service = new Mock <IWheelService>(); var controller = new WheelsController(service.Object); var payload = new WheelViewModel[] { new WheelViewModel { Size = 16, Width = 5 } }; service.Setup(x => x.GetWheels()).Returns(payload); var result = controller.Get(); Assert.IsType <OkObjectResult>(result); Assert.Equal(((OkObjectResult)result).Value, payload); }
public Program() { this.Runtime.UpdateFrequency = UpdateFrequency.Update1; var cockpits = new List <IMyCockpit>(); this.GridTerminalSystem.GetBlocksOfType(cockpits, c => c.CubeGrid == this.Me.CubeGrid); IMyCockpit cockpit = cockpits.First(); this.manager = Process.CreateManager(this.Echo); var ct = new CoordinatesTransformer(cockpit, this.manager); var logger = new Logger(this.manager, cockpit.GetSurface(0), new Color(0, 39, 15), new Color(27, 228, 33), this.Echo, 1.0f); this.cmd = new CommandLine("Small welder", logger.Log, this.manager); var ini = new IniWatcher(this.Me, this.manager); var wc = new WheelsController(this.cmd, cockpit, this.GridTerminalSystem, ini, this.manager, ct); var ac = new ArmController(ini, this, this.cmd, cockpit, wc, this.manager); var client = new ConnectionClient(ini, this.GridTerminalSystem, this.IGC, this.cmd, this.manager, logger.Log); var ah = new PilotAssist(this.GridTerminalSystem, ini, logger.Log, this.manager, wc); ah.AddBraker(client); }
public Program() { this.Runtime.UpdateFrequency = UpdateFrequency.Update1; var topLefts = new List <IMyTextSurface>(); var topRights = new List <IMyTextSurface>(); IMyTextSurface keyboard; IMyCockpit cockpit; this.manager = Process.CreateManager(this.Echo); this.initCockpit(out cockpit, topLefts, topRights, out keyboard); var ct = new CoordinatesTransformer(cockpit, this.manager); var logger = new Logger(this.manager, keyboard, new Color(0, 39, 15), new Color(27, 228, 33), this.Echo, 1.0f); this.cmd = new CommandLine("Boring machine", logger.Log, this.manager); var ini = new IniWatcher(this.Me, this.manager); var wc = new WheelsController(this.cmd, cockpit, this.GridTerminalSystem, ini, this.manager, ct); var ac = new ArmController(ini, this, this.cmd, cockpit, wc, this.manager); var iw = new InventoryWatcher(this.cmd, this.GridTerminalSystem, cockpit); var cc = new ConnectionClient(ini, this.GridTerminalSystem, this.IGC, this.cmd, this.manager, logger.Log); var rcs = new List <IMyRemoteControl>(); this.GridTerminalSystem.GetBlocksOfType(rcs, r => r.CubeGrid == this.Me.CubeGrid); IMyRemoteControl frc = rcs.First(r => r.DisplayNameText.Contains("Forward")); IMyRemoteControl brc = rcs.First(r => r.DisplayNameText.Contains("Backward")); var ap = new Autopilot(ini, wc, this.cmd, frc, logger.Log, this.manager); var ah = new PilotAssist(this.GridTerminalSystem, ini, logger.Log, this.manager, wc); ah.AddBraker(cc); ah.AddDeactivator(ap); var ar = new AutoRoutineHandler(this.cmd); // TODO parse routines new MiningRoutines(ini, this.cmd, ap, this.manager); var progs = new List <IMyProgrammableBlock>(); this.GridTerminalSystem.GetBlocksOfType(progs, pr => pr.CubeGrid == this.Me.CubeGrid); var genStatus = new GeneralStatus(this, ac, cc); new ScreensController(genStatus, iw, topLefts, topRights, this.scheme, cockpit.CustomData, this.manager); }
private void Awake() { lastMessage = new Message_PlaneUpdate(false, 0, 0, 0, 0, 0, 0, false, false, networkUID); lastFiringMessage = new Message_WeaponFiring(-1, networkUID); lastStoppedFiringMessage = new Message_WeaponStoppedFiring(networkUID); wheelsController = GetComponent <WheelsController>(); aeroController = GetComponent <AeroController>(); vRThrottle = gameObject.GetComponentInChildren <VRThrottle>(); if (vRThrottle == null) { Debug.Log("Cound't find throttle"); } else { vRThrottle.OnSetThrottle.AddListener(SetThrottle); } weaponManager = GetComponent <WeaponManager>(); if (weaponManager == null) { Debug.LogError("Weapon Manager was null on our vehicle"); } cmManager = GetComponentInChildren <CountermeasureManager>(); if (cmManager == null) { Debug.LogError("CountermeasureManager was null on our vehicle"); } fuelTank = GetComponent <FuelTank>(); if (fuelTank == null) { Debug.LogError("FuelTank was null on our vehicle"); } Networker.WeaponSet += WeaponSet; traverse = Traverse.Create(weaponManager); Debug.Log("Done Plane Sender"); }
private void Awake() { actor = gameObject.GetComponent <Actor>(); lastFiringMessage = new Message_WeaponFiring(-1, false, false, networkUID); // lastStoppedFiringMessage = new Message_WeaponStoppedFiring(networkUID); lastCountermeasureMessage = new Message_FireCountermeasure(true, true, networkUID); lastDeathMessage = new Message_Death(networkUID, false); wheelsController = GetComponent <WheelsController>(); aeroController = GetComponent <AeroController>(); isPlayer = actor.isPlayer; sequenceNumber = 0; lastMessage = new Message_PlaneUpdate(false, 0, 0, 0, 0, 0, 0, false, false, false, networkUID, sequenceNumber); engine = gameObject.GetComponentInChildren <ModuleEngine>(); if (engine == null) { Debug.Log("engine was null on vehicle " + gameObject.name); } weaponManager = GetComponent <WeaponManager>(); if (weaponManager == null) { Debug.LogError("Weapon Manager was null on vehicle " + gameObject.name); } else { traverse = Traverse.Create(weaponManager); Networker.WeaponSet += WeaponSet; //weaponManager.OnWeaponEquipped += Rearm; //weaponManager.OnWeaponUnequippedHPIdx +=Rearm; //detect player rearm PlayerVehicleSetup pv = gameObject.GetComponent <PlayerVehicleSetup>(); if (pv != null) { pv.OnEndRearming.AddListener(Rearm); } if (actor.isPlayer && weaponManager.GetIWBForEquip(3) != null) { iwb = weaponManager.GetIWBForEquip(3); } } cmManager = GetComponentInChildren <CountermeasureManager>(); if (cmManager == null) { Debug.LogError("CountermeasureManager was null on vehicle " + gameObject.name); } else { cmManager.OnFiredCM += FireCountermeasure; } fuelTank = GetComponent <FuelTank>(); if (fuelTank == null) { Debug.LogError("FuelTank was null on vehicle " + gameObject.name); } Debug.Log("Done Plane Sender"); tailhook = GetComponentInChildren <Tailhook>(); launchBar = GetComponentInChildren <CatapultHook>(); refuelPort = GetComponentInChildren <RefuelPort>(); }
public static Behavior BasicOffense(BotController bot, WheelsController wheels) { return(new Behavior(bot, () => !bot.isDead, () => wheels.SetForward(1f))); }
public ArmController(MyIni ini, MyGridProgram p, CommandLine cmd, IMyShipController cont, WheelsController wCont, ISaveManager manager) { var rotors = new List <IMyMotorStator>(); p.GridTerminalSystem.GetBlocksOfType(rotors, r => r.CubeGrid == p.Me.CubeGrid && r.DisplayNameText.Contains("Arm Rotor")); this.rotors = rotors.Select(r => new ArmRotor(r, r.WorldMatrix.Up.Dot(cont.WorldMatrix.Right) > 0)).ToList(); var keys = new List <MyIniKey>(); ini.GetKeys(SECTION, keys); this.pos = keys.Where(k => !k.Name.StartsWith("$")).ToDictionary(k => k.Name, k => new ArmPos(ini.Get(k).ToString())); this.pos["$top"] = new ArmPos(this.rotors[0].Max); this.pos["$mid"] = new ArmPos(0.2f); this.pos["$bottom"] = new ArmPos(this.rotors[0].Min); this.pos["$auto-high"] = new ArmPos(ArmPos.R_ELEVATION, 0); this.pos["$auto-low"] = new ArmPos(ArmPos.L_ELEVATION, 0); var tools = new List <IMyFunctionalBlock>(); p.GridTerminalSystem.GetBlocksOfType(tools, t => t.IsSameConstructAs(cont) && (t is IMyShipToolBase || t is IMyShipDrill)); this.autoCont = new ArmAutoControl(ini, this.Angle, wCont, tools); cmd.RegisterCommand(new Command("arm-del", Command.Wrap(this.deletePosition), "Deletes a saved position of the arm", nArgs: 1)); cmd.RegisterCommand(new Command("arm-elevation", Command.Wrap(this.autoElevate), "Makes the arm elevate at the correct position", detailedHelp: @"First argument is elevation ('high'/'low'/float) Second argument is angle", maxArgs: 2)); cmd.RegisterCommand(new Command("arm-drill", Command.Wrap(this.drill), "Engages the drills and move slowly to position", nArgs: 1)); cmd.RegisterCommand(new Command("arm-recall", Command.Wrap(this.recallPosition), "Recalls a saved position of the arm", nArgs: 1)); cmd.RegisterCommand(new Command("arm-save", Command.Wrap(this.savePosition), "Saves the current position of the arm", nArgs: 1)); manager.Spawn(pc => this.updateRotors(cont), "arm-handle"); manager.AddOnSave(this.save); }