Click or drag to resize

VelocityType Class

Localized message formatting class for a numeric value that represents a velocity. The resulted message may have a unit specification.
Inheritance Hierarchy
SystemObject
  KSPDev.GUIUtils.TypeFormattersVelocityType

Namespace:  KSPDev.GUIUtils.TypeFormatters
Assembly:  KSPDev_Utils.2.0 (in KSPDev_Utils.2.0.dll) Version: 2.0 for KSP v1.8+
Syntax
C#
public sealed class VelocityType
Request Example View Source

The VelocityType type exposes the following members.

Constructors
  NameDescription
Public methodCode exampleVelocityType
Constructs an object from a numeric value.
Top
Methods
  NameDescription
Public methodStatic memberCode exampleFormat
Formats the value into a human friendly string with a unit specification.
Public methodToString
Returns a string formatted as a human friendly pressure specification.
(Overrides ObjectToString.)
Top
Operators
Fields
  NameDescription
Public fieldStatic memberkilometerPerSecond
Localized suffix for the "kilometer per second" units. Scale x1000.
Public fieldStatic memberKilometerPerSecondLocTag
Localization tag for the "kilometer per second" units.
Public fieldStatic membermegameterPerSecond
Localized suffix for the "megameter per second" units. Scale x1000000.
Public fieldStatic memberMegameterPerSecondLocTag
Localization tag for the "megameter per second" units.
Public fieldStatic membermeterPerSecond
Localized suffix for the "meter per second" units. Scale x1.
Public fieldStatic memberMeterPerSecondLocTag
Localization tag for the "meter per second" units.
Public fieldvalue
A wrapped numeric value.
Top
Remarks

Use it as a generic parameter when creating a LocalizableMessage descendants.

The class uses the unit name localizations from the stock module InternalSpeed. In case of this module is deprecated or the tags are changed, the default English values will be used for the unit names.

Examples
public class VelocityTypeDemo1 : PartModule {
  static readonly Message<VelocityType> msg1 = new Message<VelocityType>(
      "#TypeDemo_msg1", defaultTemplate: "Speed is: <<1>>");

  void Show() {
    Debug.Log(msg1.Format(0.051));
    // Prints: "Speed is: 0.051m/s"
    Debug.Log(msg1.Format(0.45));
    // Prints: "Speed is: 0.45m/s"
    Debug.Log(msg1.Format(95.45));
    // Prints: "Speed is: 95.5m/s"
    Debug.Log(msg1.Format(120.45));
    // Prints: "Speed is: 121m/s"
    Debug.Log(msg1.Format(9535.45));
    // Prints: "Speed is: 9.54km/s"
  }
}
Examples
Debug.Log(VelocityType.Format(0.051));
// Prints: "Speed is: 0.051m/s"
Debug.Log(VelocityType.Format(0.45));
// Prints: "Speed is: 0.45m/s"
Debug.Log(VelocityType.Format(95.45));
// Prints: "Speed is: 95.5m/s"
Debug.Log(VelocityType.Format(120.45));
// Prints: "Speed is: 121m/s"
Debug.Log(VelocityType.Format(9535.45));
// Prints: "Speed is: 9.54km/s"
Examples
Debug.Log(VelocityType.Format(1234.5678, format: "0.0000"));
// Prints: "1234.5678m/s"
Debug.Log(VelocityType.Format(1234.5678, format: "0.00"));
// Prints: "1234.57m/s"
Debug.Log(VelocityType.Format(1234.5678, format: "#,##0.00"));
// Prints: "1,234.57m/s"
See Also

Reference

KSPDev.GUIUtils.TypeFormattersVelocityType