Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added features described in issue #2319 #2355

Merged
merged 4 commits into from
Nov 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,6 @@ netkan.exe

#zip files for archived art assets
*.zip

# .swp files from vim (temporary files that vim creates when editing a file)
*.swp
15 changes: 15 additions & 0 deletions doc/source/structures/celestial_bodies/body.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ All of the main celestial bodies in the game are reserved variable names. The fo
:attr:`NAME` :ref:`string <string>`
:attr:`DESCRIPTION` :ref:`string <string>`
:attr:`MASS` :ref:`scalar <scalar>` (kg)
:attr:`HASOCEAN` :ref:`boolean <boolean>`
:attr:`HASSOLIDSURFACE` :ref:`boolean <boolean>`
:attr:`ORBITINGCHILDREN` :struct:`List`
:attr:`ALTITUDE` :ref:`scalar <scalar>` (m)
:attr:`ROTATIONPERIOD` :ref:`scalar <scalar>` (s)
:attr:`RADIUS` :ref:`scalar <scalar>` (m)
Expand Down Expand Up @@ -96,6 +99,18 @@ All of the main celestial bodies in the game are reserved variable names. The fo

The mass of the body in kilograms.

.. attribute:: Body:HASOCEAN

True if this body has an ocean.

.. attribute:: Body:HASSOLIDSURFACE

True if this body has a solid surface.

.. attribute:: Body:ORBITINGCHILDREN

A list of the bodies orbiting this body.

.. attribute:: Body:ALTITUDE

The altitude of this body above the sea level surface of its parent body. I.e. the altitude of Mun above Kerbin.
Expand Down
14 changes: 14 additions & 0 deletions src/kOS/Suffixed/BodyTarget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,16 @@ public static BodyTarget CreateOrGetExisting(string bodyName, SharedObjects shar
return CreateOrGetExisting(VesselUtils.GetBodyByName(bodyName), shared);
}



private void BodyInitializeSuffixes()
{
AddSuffix("NAME", new Suffix<StringValue>(() => Body.name));
AddSuffix("DESCRIPTION", new Suffix<StringValue>(() => Body.bodyDescription));
AddSuffix("MASS", new Suffix<ScalarValue>(() => Body.Mass));
AddSuffix("HASOCEAN", new Suffix<BooleanValue>(() => Body.ocean));
AddSuffix("HASSOLIDSURFACE", new Suffix<BooleanValue>(() => Body.hasSolidSurface));
AddSuffix("ORBITINGCHILDREN", new Suffix<ListValue>(GetOrbitingChildren));
AddSuffix("ALTITUDE", new Suffix<ScalarValue>(() => Body.orbit.altitude));
AddSuffix("RADIUS", new Suffix<ScalarValue>(() => Body.Radius));
AddSuffix("MU", new Suffix<ScalarValue>(() => Body.gravParameter));
Expand All @@ -107,6 +112,15 @@ private void BodyInitializeSuffixes()
"Given latitude and longitude, return the geoposition on this body corresponding to it."));
}

public ListValue GetOrbitingChildren()
{
var toReturn = new ListValue();
foreach (CelestialBody body in Body.orbitingBodies) {
toReturn.Add(CreateOrGetExisting(body,Shared));
}
return toReturn;
}

public override StringValue GetName()
{
return Body.name;
Expand Down