C# Class kOS.Utilities.Utils

Mostra file Open project: KSP-KOS/KOS

Public Methods

Method Description
BodyOrbitsBody ( CelestialBody a, CelestialBody b ) : System.Boolean

Returns true if body a orbits body b, either directly or through a grandparent chain.

DegreeFix ( double inAngle, double rangeStart ) : double

Fix the strange too-large or too-small angle degrees that are sometimes returned by KSP, normalizing them into a constrained 360 degree range.

DegreesToRadians ( double degrees ) : double
GetAssemblyFileVersion ( ) : string
GetCurrentCamera ( ) : Camera
GetSkinCopy ( GUISkin toCopy ) : GUISkin
IsResource ( string insensitiveName, int &foundId ) : bool

Determines if a given case insensitive name corresponds with a defined resource, and outputs the resource id for easy access from Squad's lists.

IsResource ( string insensitiveName, string &fixedName ) : bool

Determines if a given case insensitive name corresponds with a defined resource, and outputs the case sensitive name for easy access from Squad's lists.

IsValidNumber ( double input ) : bool
IsValidRotation ( Quaternion quaternion ) : bool
IsValidVector ( kOS.Suffixed.Vector vector ) : bool
IsValidVector ( Vector3 vector ) : bool
IsValidVector ( UnityEngine.Vector3d vector ) : bool
KOSExtensionGetObtVelocity ( this body, SharedObjects shared ) : UnityEngine.Vector3d

Meant to be an override for stock KSP's CelestialBody.GetObtVelocity(), which (literally) always stack overflows because it's implemented as just infinite recursion without a base case.
Returns the celestial body's velocity relative to the current universe's SOI body. It's identical to body.orbit.GetVel() except that it also works for The Sun, which normally can't call that because it's orbit is null.

KOSExtensionGetParentBody ( this body ) : CelestialBody

Return the parent body of this body, just like KSP's built-in referenceBody, except that it exhibits more sane behavior in the case of the Sun where there is no parent. Default KSP's referenceBody will sometimes return null and sometimes return the Sun itself as the parent of the Sun. This makes it always return null as the parent of the Sun no matter what.

KOSType ( Type type ) : string

Given any CSharp object, return the string name of the type in a way that makes more sense to kOS users, using kOS names rather than Csharp names.

RadiansToDegrees ( double radians ) : double

Private Methods

Method Description
GetActualAttachedNodes ( Part checkPart ) : IEnumerable

Gets the *actual* list of attachnodes for a part. Use as a replacement for the KSP API property part.attachNodes because that doesn't seem to reliably include the surface attached attachnodes all of the time.

Method Details

BodyOrbitsBody() public static method

Returns true if body a orbits body b, either directly or through a grandparent chain.
public static BodyOrbitsBody ( CelestialBody a, CelestialBody b ) : System.Boolean
a CelestialBody Does this body
b CelestialBody Orbit around this body
return System.Boolean

DegreeFix() public static method

Fix the strange too-large or too-small angle degrees that are sometimes returned by KSP, normalizing them into a constrained 360 degree range.
public static DegreeFix ( double inAngle, double rangeStart ) : double
inAngle double input angle in degrees
rangeStart double /// Bottom of 360 degree range to normalize to. /// ( 0 means the range [0..360]), while -180 means [-180,180] ) ///
return double

DegreesToRadians() public static method

public static DegreesToRadians ( double degrees ) : double
degrees double
return double

GetAssemblyFileVersion() public static method

public static GetAssemblyFileVersion ( ) : string
return string

GetCurrentCamera() public static method

public static GetCurrentCamera ( ) : Camera
return UnityEngine.Camera

GetSkinCopy() public static method

public static GetSkinCopy ( GUISkin toCopy ) : GUISkin
toCopy UnityEngine.GUISkin
return UnityEngine.GUISkin

IsResource() public static method

Determines if a given case insensitive name corresponds with a defined resource, and outputs the resource id for easy access from Squad's lists.
public static IsResource ( string insensitiveName, int &foundId ) : bool
insensitiveName string case insensitive name
foundId int output id of the found resource, zero if none found
return bool

IsResource() public static method

Determines if a given case insensitive name corresponds with a defined resource, and outputs the case sensitive name for easy access from Squad's lists.
public static IsResource ( string insensitiveName, string &fixedName ) : bool
insensitiveName string case insensitive name
fixedName string output case sensitive name
return bool

IsValidNumber() public static method

public static IsValidNumber ( double input ) : bool
input double
return bool

IsValidRotation() public static method

public static IsValidRotation ( Quaternion quaternion ) : bool
quaternion UnityEngine.Quaternion
return bool

IsValidVector() public static method

public static IsValidVector ( kOS.Suffixed.Vector vector ) : bool
vector kOS.Suffixed.Vector
return bool

IsValidVector() public static method

public static IsValidVector ( Vector3 vector ) : bool
vector Vector3
return bool

IsValidVector() public static method

public static IsValidVector ( UnityEngine.Vector3d vector ) : bool
vector UnityEngine.Vector3d
return bool

KOSExtensionGetObtVelocity() public static method

Meant to be an override for stock KSP's CelestialBody.GetObtVelocity(), which (literally) always stack overflows because it's implemented as just infinite recursion without a base case.
Returns the celestial body's velocity relative to the current universe's SOI body. It's identical to body.orbit.GetVel() except that it also works for The Sun, which normally can't call that because it's orbit is null.
public static KOSExtensionGetObtVelocity ( this body, SharedObjects shared ) : UnityEngine.Vector3d
body this The body to get the value for. (this will be hidden when this is an extension method of CelestialBody).
shared SharedObjects Ubiquitous shared objects
return UnityEngine.Vector3d

KOSExtensionGetParentBody() public static method

Return the parent body of this body, just like KSP's built-in referenceBody, except that it exhibits more sane behavior in the case of the Sun where there is no parent. Default KSP's referenceBody will sometimes return null and sometimes return the Sun itself as the parent of the Sun. This makes it always return null as the parent of the Sun no matter what.
public static KOSExtensionGetParentBody ( this body ) : CelestialBody
body this Body to get parent of (this will be hidden when called as an extension method)
return CelestialBody

KOSType() public static method

Given any CSharp object, return the string name of the type in a way that makes more sense to kOS users, using kOS names rather than Csharp names.
public static KOSType ( Type type ) : string
type System.Type native c-sharp object
return string

RadiansToDegrees() public static method

public static RadiansToDegrees ( double radians ) : double
radians double
return double