/// <summary> /// Accelerates the ship relative to the reference block. /// </summary> /// <param name="dir">The direction relative to the reference block in which the ship should be accelerated.</param> /// <param name="value">The amount of force to accelerate in Newton.</param> public void Accelerate(VRageMath.Vector3 dir, float value) { if ((value < MinAcceleration || value > MaxAcceleration) && value != DefaultAcceleration) { throw new Exception("Value '" + value + "' out of range [" + MinAcceleration + ", " + MaxAcceleration + "] + " + DefaultAcceleration + "."); } if (!thrusterBlocks.ContainsKey(dir)) { throw new Exception("Warning! No thruster in direction " + dir + "."); } var list = thrusterBlocks[dir]; for (int i = 0; i < list.Count; ++i) { IMyThrust thruster = list[i]; thruster.SetValueFloat("Override", value); } }
/// <summary> /// Accelerates the ship relative to the reference block. /// </summary> /// <param name="dir">The direction relative to the reference block in which the ship should be accelerated.</param> /// <param name="value">The amount of force to accelerate in Newton.</param> public void Accelerate(VRageMath.Vector3 dir, float value) { if (value < thrusterOverrideMin || value > thrusterOverrideMax) { throw new Exception("Value out of range [" + thrusterOverrideMin + ", " + thrusterOverrideMax + "]."); } VRageMath.Matrix local = new VRageMath.Matrix(); referenceBlock.Orientation.GetMatrix(out local); dir = VRageMath.Vector3.Transform(dir, local); if (!thrusters.ContainsKey(dir)) { throw new Exception("Warning! No thruster in direction " + dir + "."); } var list = thrusters[dir]; for (int i = 0; i < list.Count; ++i) { IMyThrust thruster = list[i]; thruster.SetValueFloat("Override", value); } }
void _set(double val) { th.SetValueFloat("Override", (float)val); }
public bool executeLaunchSequence() { if (currentLaunchOrder == "") { if (ExtractNextLaunchOrdner()) { //End of launch sequence //Switch to flight mode return(true); } if (!ParseLaunchOrder(currentLaunchOrder)) { //Could not be parsed currentLaunchOrder = ""; } } switch (currentCommand) { case LaunchOrders.BURN: foreach (IMyTerminalBlock block in currentBlocks) { try { IMyThrust thrust = block as IMyThrust; thrust.SetValueFloat("Override", value * thrust.MaxThrust); } catch (Exception) { mainProgram.Echo(block.CustomName + " is not a thruster"); } } currentLaunchOrder = ""; break; case LaunchOrders.SET: foreach (IMyTerminalBlock block in currentBlocks) { try { IMyFunctionalBlock funcBlock = block as IMyThrust; funcBlock.Enabled = setOn; } catch (Exception) { mainProgram.Echo(block.CustomName + " is not a functional block (cannot be turned on/off)"); } } currentLaunchOrder = ""; break; case LaunchOrders.WHEN: if (EvaluateCondition()) { ModifyCode(true); } else { ModifyCode(false); } currentLaunchOrder = ""; break; case LaunchOrders.WAIT: if (EvaluateCondition()) { currentLaunchOrder = ""; } break; } return(false); }