Resources#

class Resources#

Represents the collection of resources stored in a vessel, stage or part. Created by calling Vessel.Resources, Stage.Resources, EditorVessel.Resources or Part.Resources.

IList<Resource> All { get; }#

All the individual resources that can be stored.

Game Scenes:

Flight, Editor Vab, Editor Sph

IList<Resource> WithResource (string name)#

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

Parameters:

Game Scenes:

Flight, Editor Vab, Editor Sph

IList<string> Names { get; }#

A list of resource names that can be stored.

Game Scenes:

Flight, Editor Vab, Editor Sph

bool HasResource (string name)#

Check whether the named resource can be stored.

Parameters:
  • name – The name of the resource.

Game Scenes:

Flight, Editor Vab, Editor Sph

float Amount (string name)#

Returns the amount of a resource that is currently stored.

Parameters:
  • name – The name of the resource.

Game Scenes:

Flight, Editor Vab, Editor Sph

float Max (string name)#

Returns the amount of a resource that can be stored.

Parameters:
  • name – The name of the resource.

Game Scenes:

Flight, Editor Vab, Editor Sph

static float Density (IConnection connection, string name)#

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

Parameters:
  • name – The name of the resource.

Game Scenes:

Flight, Editor Vab, Editor Sph

static ResourceFlowMode FlowMode (IConnection connection, string name)#

Returns the flow mode of a resource.

Parameters:
  • name – The name of the resource.

Game Scenes:

Flight, Editor Vab, Editor Sph

bool Enabled { get; set; }#

Whether use of all the resources are enabled.

Game Scenes:

Flight, Editor Vab, Editor Sph

Note

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

class Resource#

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

string Name { get; }#

The name of the resource.

Game Scenes:

Flight, Editor Vab, Editor Sph

Part Part { get; }#

The part containing the resource.

Game Scenes:

Flight, Editor Vab, Editor Sph

float Amount { get; }#

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

Game Scenes:

Flight, Editor Vab, Editor Sph

float Max { get; }#

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

Game Scenes:

Flight, Editor Vab, Editor Sph

float Density { get; }#

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

Game Scenes:

Flight, Editor Vab, Editor Sph

ResourceFlowMode FlowMode { get; }#

The flow mode of the resource.

Game Scenes:

Flight, Editor Vab, Editor Sph

bool Enabled { get; set; }#

Whether use of this resource is enabled.

Game Scenes:

Flight, Editor Vab, Editor Sph

class ResourceTransfer#

Transfer resources between parts.

static ResourceTransfer Start (IConnection 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.Complete to check if the transfer is complete. Use ResourceTransfer.Amount to see how much of the resource has been transferred.

Parameters:
  • fromPart – The part to transfer to.

  • toPart – The part to transfer from.

  • resource – The name of the resource to transfer.

  • maxAmount – The maximum amount of resource to transfer.

Game Scenes:

All

Note

Use ResourceTransfer.Cancel to stop the transfer before it finishes; a canceled transfer is marked as complete. Use ResourceTransfer.Remove to release the memory the server holds for a transfer that is done with. A transfer is stopped and removed if the client that started it disconnects, or if the flight it runs in is left.

void Cancel ()#

Cancel the transfer. No more of the resource is moved and ResourceTransfer.Complete becomes true.

Game Scenes:

All

void Remove ()#

Remove the transfer, releasing the memory the server holds for it. The transfer is canceled if it has not finished.

Game Scenes:

All

Note

Any further use of this object throws an exception. A transfer that is left is held until the parts it runs between are gone, the flight it runs in is left, or the client that started it disconnects, whichever comes first; the first of those may be the rest of the flight away.

float Amount { get; }#

The amount of the resource that has been transferred.

Game Scenes:

All

bool Complete { get; }#

Whether the transfer has completed. Also becomes true if the transfer is canceled by calling ResourceTransfer.Cancel.

Game Scenes:

All

enum ResourceFlowMode#

The way in which a resource flows between parts. See Resources.FlowMode.

Vessel#

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

Stage#

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

Adjacent#

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

None#

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