public void Update() { if (isFirstUpdate || configCache != Me.CustomData || Me.CustomData == "") { var config = new ConfigSection("main"); config.Read(Me.CustomData); blockGroupName = config.Get <string>("block_group_name", "Heli Assist"); start_mode = config.Get <string>("start_mode", "flight"); rememberLastMode = config.Get <bool>("remember_mode", true); maxFlightPitch = config.Get <float>("max_pitch", 40.0f); maxFlightRoll = config.Get <float>("max_roll", 40.0f); maxLandingPitch = config.Get <float>("max_landing_pitch", 15.0f); maxLandingRoll = config.Get <float>("max_landing_roll", 15.0f); precisionAimFactor = config.Get <float>("precision", 16.0f); mouseSpeed = config.Get <float>("mouse_speed", 0.5f); if (Me.CustomData == "") { Me.CustomData = configCache = config.write(); } else { configCache = Me.CustomData; } } var blockGroup = GridTerminalSystem.GetBlockGroupWithName(blockGroupName); if (blockGroup == null) { throw new Exception("Could not find block group with name '" + blockGroupName + "'"); } controllerCache.Clear(); blockGroup.GetBlocksOfType <IMyShipController>(controllerCache); if (!controllerCache.Any()) { throw new Exception("Ship must have at least one ship controller"); } controller = null; foreach (var controller in controllerCache) { if (controller.IsUnderControl || (controller.IsMainCockpit && this.controller == null)) { this.controller = controller; } } if (this.controller == null) { this.controller = controllerCache.First(); } gyroCache.Clear(); blockGroup.GetBlocksOfType <IMyGyro>(gyroCache); if (!gyroCache.Any()) { throw new Exception("Ship must have atleast one gyroscope"); } thrustCache.Clear(); blockGroup.GetBlocksOfType <IMyThrust>(thrustCache); if (!thrustCache.Any()) { throw new Exception("Ship must have atleast one thruster"); } if (thrustController == null) { thrustController = new ThrusterController(controller, thrustCache); } else { thrustController.Update(controller, thrustCache); } if (gyroController == null) { gyroController = new GyroController(controller, gyroCache); } else { gyroController.Update(controller, gyroCache); } if (isFirstUpdate && rememberLastMode && IsValidMode(Storage)) { SwitchToMode(Storage); } else if (isFirstUpdate) { SwitchToMode(start_mode); } isFirstUpdate = false; updateFinished = true; }