/// <summary> /// Add or remove a thruster from thrustProfile, if appropriate. /// </summary> private void enableDisableThruster(ThrusterProperties properties, bool enable) { if (properties.isEnabled == enable) { if (enable) { log("already enabled. " + properties, "enableDisableThruster()", Logger.severity.DEBUG); } else { log("already disabled. " + properties, "enableDisableThruster()", Logger.severity.DEBUG); } return; } properties.isEnabled = enable; float change = properties.forceDamping; Base6Directions.Direction direction = properties.forceDirect; if (!enable) { change = -change; } thrustProfile[direction] += change; //log("thrust power change = " + change + ", total power = " + thrustProfile[direction] + ", direction = " + direction, "enableDisableThruster()", Logger.severity.TRACE); }
/// <summary> /// Creates properties for a thruster and adds it to allMyThrusters. If the thruster is working, calls enableDisableThruster(true). /// </summary> /// <param name="thruster">The new thruster</param> private void newThruster(IMySlimBlock thruster) { float dampingForce = 10 * (MyDefinitionManager.Static.GetCubeBlockDefinition(thruster.GetObjectBuilder()) as MyThrustDefinition).ForceMagnitude; ThrusterProperties properties = new ThrusterProperties(dampingForce, Base6Directions.GetFlippedDirection(thruster.FatBlock.Orientation.Forward)); allMyThrusters.Add(thruster.FatBlock, properties); thruster.FatBlock.IsWorkingChanged += block_IsWorkingChanged; if (thruster.FatBlock.IsWorking) { enableDisableThruster(properties, true); } return; }
/// <summary> /// Creates properties for a thruster and adds it to allMyThrusters. If the thruster is working, calls enableDisableThruster(true). /// </summary> /// <param name="thruster">The new thruster</param> private void newThruster(IMySlimBlock thruster) { ThrusterProperties properties = new ThrusterProperties(thruster.FatBlock as IMyThrust); allMyThrusters.Add(thruster.FatBlock as IMyThrust, properties); thrustersInDirection[properties.forceDirect].Add(properties); return; }