public HoverModule(CustomDataConfig config, GyroController gyroController, IMyShipController cockpit) { this.config = config; this.gyroController = gyroController; this.cockpit = cockpit; gyroResponsiveness = config.Get <int>("gyroResponsiveness"); maxPitch = config.Get <double>("maxPitch"); maxRoll = config.Get <double>("maxRoll"); AddAction("disabled", (args) => { gyroController.SetGyroOverride(false); }, null); AddAction("smart", (string[] args) => { smartDelayTimer = 0; setSpeed = (args.Length > 0 && args[0] != null) ? Int32.Parse(args[0]) : 0; }, () => { if (cockpit.MoveIndicator.Length() > 0.0f || cockpit.RotationIndicator.Length() > 0.0f) { desiredPitch = -(pitch - 90); desiredRoll = (roll - 90); gyroController.SetGyroOverride(false); smartDelayTimer = 0; } else if (smartDelayTimer > config.Get <int>("smartDelayTime")) { gyroController.SetGyroOverride(true); desiredPitch = Math.Atan((worldSpeedForward - setSpeed) / gyroResponsiveness) / Helpers.halfPi * maxPitch; desiredRoll = Math.Atan(worldSpeedRight / gyroResponsiveness) / Helpers.halfPi * maxRoll; } else { smartDelayTimer++; } }); AddAction("stop", null, () => { desiredPitch = Math.Atan(worldSpeedForward / gyroResponsiveness) / Helpers.halfPi * maxPitch; desiredRoll = Math.Atan(worldSpeedRight / gyroResponsiveness) / Helpers.halfPi * maxRoll; }); AddAction("glide", null, () => { desiredPitch = 0; desiredRoll = Math.Atan(worldSpeedRight / gyroResponsiveness) / Helpers.halfPi * maxRoll; }); AddAction("freeglide", null, () => { desiredPitch = 0; desiredRoll = 0; }); }
public VectorModule(CustomDataConfig config, GyroController gyroController, IMyShipController cockpit) { this.gyroController = gyroController; this.cockpit = cockpit; thrustVector = GetThrustVector(config.Get <string>("spaceMainThrust")); AddAction("disabled", (args) => { gyroController.SetGyroOverride(false); }, null); AddAction("brake", (args) => { startSpeed = cockpit.GetShipSpeed(); cockpit.DampenersOverride = false; }, SpaceBrake); AddAction("prograde", null, () => { TargetOrientation(-Vector3D.Normalize(cockpit.GetShipVelocities().LinearVelocity)); }); AddAction("retrograde", null, () => { TargetOrientation(Vector3D.Normalize(cockpit.GetShipVelocities().LinearVelocity)); }); }
public Program() { Runtime.UpdateFrequency = UpdateFrequency.Update1; configReader = new CustomDataConfig(Me, defaultConfig); GetBlocks(); gyroController = new GyroController(gyros, cockpit); hoverModule = new HoverModule(configReader, gyroController, cockpit); vectorModule = new VectorModule(configReader, gyroController, cockpit); string startCommand = configReader.Get <string>("startCommand"); if (startCommand != null) { ProcessCommand(startCommand); } else { gyroController.SetGyroOverride(false); } }