Resources

public class Resources

Represents the collection of resources stored in a vessel, stage or part. Created by calling Vessel.getResources(), Vessel.resourcesInDecoupleStage(int, boolean) or Part.getResources().

java.util.List<Resource> getAll()

All the individual resources that can be stored.

Game Scenes:

Flight

java.util.List<Resource> withResource(String name)

All the individual resources with the given name that can be stored.

Parameters:
Game Scenes:

Flight

java.util.List<String> getNames()

A list of resource names that can be stored.

Game Scenes:

Flight

boolean hasResource(String name)

Check whether the named resource can be stored.

Parameters:
  • name (String) – The name of the resource.

Game Scenes:

Flight

float amount(String name)

Returns the amount of a resource that is currently stored.

Parameters:
  • name (String) – The name of the resource.

Game Scenes:

Flight

float max(String name)

Returns the amount of a resource that can be stored.

Parameters:
  • name (String) – The name of the resource.

Game Scenes:

Flight

static float density(Connection connection, String name)

Returns the density of a resource, in \(kg/l\).

Parameters:
  • name (String) – The name of the resource.

Game Scenes:

Flight

static ResourceFlowMode flowMode(Connection connection, String name)

Returns the flow mode of a resource.

Parameters:
  • name (String) – The name of the resource.

Game Scenes:

Flight

boolean getEnabled()
void setEnabled(boolean value)

Whether use of all the resources are enabled.

Game Scenes:

Flight

Note

This is true if all of the resources are enabled. If any of the resources are not enabled, this is false.

public class Resource

An individual resource stored within a part. Created using methods in the Resources class.

String getName()

The name of the resource.

Part getPart()

The part containing the resource.

float getAmount()

The amount of the resource that is currently stored in the part.

float getMax()

The total amount of the resource that can be stored in the part.

float getDensity()

The density of the resource, in \(kg/l\).

ResourceFlowMode getFlowMode()

The flow mode of the resource.

boolean getEnabled()
void setEnabled(boolean value)

Whether use of this resource is enabled.

public class ResourceTransfer

Transfer resources between parts.

static ResourceTransfer start(Connection connection, Part fromPart, Part toPart, String resource, float maxAmount)

Start transferring a resource transfer between a pair of parts. The transfer will move at most maxAmount units of the resource, depending on how much of the resource is available in the source part and how much storage is available in the destination part. Use ResourceTransfer.getComplete() to check if the transfer is complete. Use ResourceTransfer.getAmount() to see how much of the resource has been transferred.

Parameters:
  • fromPart (Part) – The part to transfer to.

  • toPart (Part) – The part to transfer from.

  • resource (String) – The name of the resource to transfer.

  • maxAmount (float) – The maximum amount of resource to transfer.

float getAmount()

The amount of the resource that has been transferred.

boolean getComplete()

Whether the transfer has completed.

public enum ResourceFlowMode

The way in which a resource flows between parts. See Resources.flowMode(String).

public ResourceFlowMode VESSEL

The resource flows to any part in the vessel. For example, electric charge.

public ResourceFlowMode STAGE

The resource flows from parts in the first stage, followed by the second, and so on. For example, mono-propellant.

public ResourceFlowMode ADJACENT

The resource flows between adjacent parts within the vessel. For example, liquid fuel or oxidizer.

public ResourceFlowMode NONE

The resource does not flow. For example, solid fuel.