Class UnitsData
Last update: 09.03.2026Namespace: OpenTD
Assembly: OpenTD.dll
Describes a system of units. Can be inconsistent.
[MessagePackObject(true)]
public class UnitsData : IEquatable<UnitsData>
Inheritance
Implements
Inherited Members
object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object?, object?), object.ToString()
Constructors
UnitsData()
public UnitsData()
UnitsData(string)
Initializes a new instance of the
public UnitsData(string unitsExpression)
Parameters
unitsExpression string
UnitsData(long, long)
Initializes a new instance of the
public UnitsData(long TdUnits, long TdUnits2)
Parameters
TdUnits long
TdUnits2 long
UnitsData(UnitsData)
Copy constructor.
public UnitsData(UnitsData source)
Parameters
source UnitsData
Properties
FlocadOutputUnits
public UnitsData.FlocadOutputUnitsType FlocadOutputUnits { get; set; }
Property Value
UnitsData.FlocadOutputUnitsType
angle
public UnitsData.Angle angle { get; set; }
Property Value
current
public UnitsData.Current current { get; set; }
Property Value
def
Use def to create arbitrary combinations of units (advanced).
public UnitsDefData def { get; set; }
Property Value
energy
public UnitsData.Energy energy { get; set; }
Property Value
force
public UnitsData.Force force { get; set; }
Property Value
mass
public UnitsData.Mass mass { get; set; }
Property Value
modelLength
public UnitsData.ModelLength modelLength { get; set; }
Property Value
orbitLength
public UnitsData.OrbitLength orbitLength { get; set; }
Property Value
pressure
public UnitsData.Pressure pressure { get; set; }
Property Value
temp
public UnitsData.Temp temp { get; set; }
Property Value
time
public UnitsData.Time time { get; set; }
Property Value
voltage
public UnitsData.Voltage voltage { get; set; }
Property Value
Methods
Equals(UnitsData)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(UnitsData x)
Parameters
Returns
true if the current object is equal to the other parameter; otherwise, false.
Equals(object)
Determines whether the specified object is equal to the current object.
public override bool Equals(object obj)
Parameters
obj object
The object to compare with the current object.
Returns
true if the specified object is equal to the current object; otherwise, false.
GetHashCode()
Serves as the default hash function.
public override int GetHashCode()
Returns
A hash code for the current object.
GetName(UnitsType)
public static string GetName(UnitsData.UnitsType type)
Parameters
Returns
GetTitle(UnitsType)
public string GetTitle(UnitsData.UnitsType type)
Parameters
Returns
GetUnitsName(UnitsType)
public string GetUnitsName(UnitsData.UnitsType type)
Parameters
Returns
SetFrom(UnitsData)
public void SetFrom(UnitsData source)
Parameters
source UnitsData
SetFromDataset(long, long)
Set this units system based on 64-bit integers written to a save file or CSR by Sinda.
public void SetFromDataset(long TdUnits, long TdUnits2)
Parameters
TdUnits long
TdUnits2 long
Exceptions
Problem decoding TdUnits. or Problem decoding TdUnits2.
SetFromUnitsExpression(string)
Sets this UnitsData using the supplied string. Use with basic units (m, hr, Btu, etc.) or compound units expressions (Btu/hr/ft^2/F, kg/m-s, etc.). For basic units, SetFromBasicUnit(string str) will be more efficient. Recognizes strings in the same format output by TD. Accepted operators : ( ) / - ^ Exponents denoted with optional ^, e.g. m^3 and m3 are both valid W can be substituted for J/s 1 can be used, as in 1/m^3 Revolution can be used, as in Revolution/s Case-insensitive For overlapping model length and orbit length units (m and ft), assumes model length
public bool SetFromUnitsExpression(string str)
Parameters
str string
Returns
SetToEng()
public void SetToEng()
SetToSI()
public void SetToSI()
Text(OrbitLength)
public static string Text(UnitsData.OrbitLength units)
Parameters
units UnitsData.OrbitLength
Returns
Text(ModelLength)
public static string Text(UnitsData.ModelLength units)
Parameters
units UnitsData.ModelLength
Returns
Text(Time)
public static string Text(UnitsData.Time units)
Parameters
Returns
Text(Energy)
public static string Text(UnitsData.Energy units)
Parameters
Returns
Text(Temp)
public static string Text(UnitsData.Temp units)
Parameters
Returns
Text(Mass)
public static string Text(UnitsData.Mass units)
Parameters
Returns
Text(Pressure)
public static string Text(UnitsData.Pressure units)
Parameters
Returns
Text(Angle)
public static string Text(UnitsData.Angle units)
Parameters
Returns
Text(Force)
public static string Text(UnitsData.Force units)
Parameters
Returns
Text(Current)
public static string Text(UnitsData.Current units)
Parameters
Returns
Text(Voltage)
public static string Text(UnitsData.Voltage units)
Parameters
Returns
Text(Resistance)
public static string Text(UnitsData.Resistance units)
Parameters
units UnitsData.Resistance
Returns
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
A string that represents the current object.
Operators
operator ==(UnitsData, UnitsData)
public static bool operator ==(UnitsData x1, UnitsData x2)
Parameters
x1 UnitsData
x2 UnitsData
Returns
operator !=(UnitsData, UnitsData)
public static bool operator !=(UnitsData x1, UnitsData x2)
Parameters
x1 UnitsData
x2 UnitsData