.. default-domain:: java .. highlight:: java .. package:: krpc.client.services.SpaceCenter SpaceCenter =========== .. type:: public class SpaceCenter Provides functionality to interact with Kerbal Space Program. This includes controlling the active vessel, managing its resources, planning maneuver nodes and auto-piloting. .. method:: float getScience() The current amount of science. .. method:: double getFunds() The current amount of funds. .. method:: float getReputation() The current amount of reputation. .. method:: Vessel getActiveVessel() .. method:: void setActiveVessel(Vessel value) The currently active vessel. :Game Scenes: Flight .. method:: java.util.List getVessels() A list of all the vessels in the game. .. method:: java.util.List getLaunchSites() A list of available launch sites. .. method:: java.util.Map getBodies() A dictionary of all celestial bodies (planets, moons, etc.) in the game, keyed by the name of the body. .. method:: CelestialBody getTargetBody() .. method:: void setTargetBody(CelestialBody value) The currently targeted celestial body. :Game Scenes: Flight .. method:: Vessel getTargetVessel() .. method:: void setTargetVessel(Vessel value) The currently targeted vessel. :Game Scenes: Flight .. method:: DockingPort getTargetDockingPort() .. method:: void setTargetDockingPort(DockingPort value) The currently targeted docking port. :Game Scenes: Flight .. method:: void clearTarget() Clears the current target. :Game Scenes: Flight .. method:: java.util.List launchableVessels(String craftDirectory) Returns a list of vessels from the given *craftDirectory* that can be launched. :param String craftDirectory: Name of the directory in the current saves "Ships" directory. For example ``"VAB"`` or ``"SPH"``. .. method:: void launchVessel(String craftDirectory, String name, String launchSite, boolean recover, java.util.List crew, String flagUrl) Launch a vessel. :param String craftDirectory: Name of the directory in the current saves "Ships" directory, that contains the craft file. For example ``"VAB"`` or ``"SPH"``. :param String name: Name of the vessel to launch. This is the name of the ".craft" file in the save directory, without the ".craft" file extension. :param String launchSite: Name of the launch site. For example ``"LaunchPad"`` or ``"Runway"``. :param boolean recover: If true and there is a vessel on the launch site, recover it before launching. :param java.util.List crew: If not ``null``, a list of names of Kerbals to place in the craft. Otherwise the crew will use default assignments. :param String flagUrl: If not ``null``, the asset URL of the mission flag to use for the launch. .. note:: Throws an exception if any of the games pre-flight checks fail. .. method:: void launchVesselFromVAB(String name, boolean recover) Launch a new vessel from the VAB onto the launchpad. :param String name: Name of the vessel to launch. :param boolean recover: If true and there is a vessel on the launch pad, recover it before launching. .. note:: This is equivalent to calling :meth:`launchVessel(String, String, String, boolean, java.util.List, String)` with the craft directory set to "VAB" and the launch site set to "LaunchPad". Throws an exception if any of the games pre-flight checks fail. .. method:: void launchVesselFromSPH(String name, boolean recover) Launch a new vessel from the SPH onto the runway. :param String name: Name of the vessel to launch. :param boolean recover: If true and there is a vessel on the runway, recover it before launching. .. note:: This is equivalent to calling :meth:`launchVessel(String, String, String, boolean, java.util.List, String)` with the craft directory set to "SPH" and the launch site set to "Runway". Throws an exception if any of the games pre-flight checks fail. .. method:: void save(String name) Save the game with a given name. This will create a save file called ``name.sfs`` in the folder of the current save game. :param String name: Name of the save. .. method:: void load(String name) Load the game with the given name. This will create a load a save file called ``name.sfs`` from the folder of the current save game. :param String name: Name of the save. .. method:: void quicksave() Save a quicksave. .. note:: This is the same as calling :meth:`save(String)` with the name "quicksave". .. method:: void quickload() Load a quicksave. .. note:: This is the same as calling :meth:`load(String)` with the name "quicksave". .. method:: boolean canRevertToLaunch() Whether the current flight can be reverted to launch. .. method:: void revertToLaunch() Revert the current flight to launch. .. method:: void transferCrew(CrewMember crewMember, Part targetPart) Transfers a crew member to a different part. :param CrewMember crewMember: The crew member to transfer. :param Part targetPart: The part to move them to. :Game Scenes: Flight .. method:: boolean getUIVisible() .. method:: void setUIVisible(boolean value) Whether the UI is visible. :Game Scenes: Flight .. method:: boolean getNavball() .. method:: void setNavball(boolean value) Whether the navball is visible. :Game Scenes: Flight .. method:: double getUT() The current universal time in seconds. .. method:: double getG() The value of the `gravitational constant `_ G in :math:`N(m/kg)^2`. .. method:: float getWarpRate() The current warp rate. This is the rate at which time is passing for either on-rails or physical time warp. For example, a value of 10 means time is passing 10x faster than normal. Returns 1 if time warp is not active. :Game Scenes: Flight .. method:: float getWarpFactor() The current warp factor. This is the index of the rate at which time is passing for either regular "on-rails" or physical time warp. Returns 0 if time warp is not active. When in on-rails time warp, this is equal to :meth:`getRailsWarpFactor()`, and in physics time warp, this is equal to :meth:`getPhysicsWarpFactor()`. :Game Scenes: Flight .. method:: int getRailsWarpFactor() .. method:: void setRailsWarpFactor(int value) The time warp rate, using regular "on-rails" time warp. A value between 0 and 7 inclusive. 0 means no time warp. Returns 0 if physical time warp is active. If requested time warp factor cannot be set, it will be set to the next lowest possible value. For example, if the vessel is too close to a planet. See `the KSP wiki `_ for details. :Game Scenes: Flight .. method:: int getPhysicsWarpFactor() .. method:: void setPhysicsWarpFactor(int value) The physical time warp rate. A value between 0 and 3 inclusive. 0 means no time warp. Returns 0 if regular "on-rails" time warp is active. :Game Scenes: Flight .. method:: boolean canRailsWarpAt(int factor) Returns ``true`` if regular "on-rails" time warp can be used, at the specified warp *factor*. The maximum time warp rate is limited by various things, including how close the active vessel is to a planet. See `the KSP wiki `_ for details. :param int factor: The warp factor to check. :Game Scenes: Flight .. method:: int getMaximumRailsWarpFactor() The current maximum regular "on-rails" warp factor that can be set. A value between 0 and 7 inclusive. See `the KSP wiki `_ for details. :Game Scenes: Flight .. method:: void warpTo(double ut, float maxRailsRate, float maxPhysicsRate) Uses time acceleration to warp forward to a time in the future, specified by universal time *ut*. This call blocks until the desired time is reached. Uses regular "on-rails" or physical time warp as appropriate. For example, physical time warp is used when the active vessel is traveling through an atmosphere. When using regular "on-rails" time warp, the warp rate is limited by *maxRailsRate*, and when using physical time warp, the warp rate is limited by *maxPhysicsRate*. :param double ut: The universal time to warp to, in seconds. :param float maxRailsRate: The maximum warp rate in regular "on-rails" time warp. :param float maxPhysicsRate: The maximum warp rate in physical time warp. :returns: When the time warp is complete. :Game Scenes: Flight .. method:: org.javatuples.Triplet transformPosition(org.javatuples.Triplet position, ReferenceFrame from, ReferenceFrame to) Converts a position from one reference frame to another. :param org.javatuples.Triplet position: Position, as a vector, in reference frame *from*. :param ReferenceFrame from: The reference frame that the position is in. :param ReferenceFrame to: The reference frame to covert the position to. :returns: The corresponding position, as a vector, in reference frame *to*. .. method:: org.javatuples.Triplet transformDirection(org.javatuples.Triplet direction, ReferenceFrame from, ReferenceFrame to) Converts a direction from one reference frame to another. :param org.javatuples.Triplet direction: Direction, as a vector, in reference frame *from*. :param ReferenceFrame from: The reference frame that the direction is in. :param ReferenceFrame to: The reference frame to covert the direction to. :returns: The corresponding direction, as a vector, in reference frame *to*. .. method:: org.javatuples.Quartet transformRotation(org.javatuples.Quartet rotation, ReferenceFrame from, ReferenceFrame to) Converts a rotation from one reference frame to another. :param org.javatuples.Quartet rotation: Rotation, as a quaternion of the form :math:`(x, y, z, w)`, in reference frame *from*. :param ReferenceFrame from: The reference frame that the rotation is in. :param ReferenceFrame to: The reference frame to covert the rotation to. :returns: The corresponding rotation, as a quaternion of the form :math:`(x, y, z, w)`, in reference frame *to*. .. method:: org.javatuples.Triplet transformVelocity(org.javatuples.Triplet position, org.javatuples.Triplet velocity, ReferenceFrame from, ReferenceFrame to) Converts a velocity (acting at the specified position) from one reference frame to another. The position is required to take the relative angular velocity of the reference frames into account. :param org.javatuples.Triplet position: Position, as a vector, in reference frame *from*. :param org.javatuples.Triplet velocity: Velocity, as a vector that points in the direction of travel and whose magnitude is the speed in meters per second, in reference frame *from*. :param ReferenceFrame from: The reference frame that the position and velocity are in. :param ReferenceFrame to: The reference frame to covert the velocity to. :returns: The corresponding velocity, as a vector, in reference frame *to*. .. method:: double raycastDistance(org.javatuples.Triplet position, org.javatuples.Triplet direction, ReferenceFrame referenceFrame) Cast a ray from a given position in a given direction, and return the distance to the hit point. If no hit occurs, returns infinity. :param org.javatuples.Triplet position: Position, as a vector, of the origin of the ray. :param org.javatuples.Triplet direction: Direction of the ray, as a unit vector. :param ReferenceFrame referenceFrame: The reference frame that the position and direction are in. :returns: The distance to the hit, in meters, or infinity if there was no hit. .. method:: Part raycastPart(org.javatuples.Triplet position, org.javatuples.Triplet direction, ReferenceFrame referenceFrame) Cast a ray from a given position in a given direction, and return the part that it hits. If no hit occurs, returns ``null``. :param org.javatuples.Triplet position: Position, as a vector, of the origin of the ray. :param org.javatuples.Triplet direction: Direction of the ray, as a unit vector. :param ReferenceFrame referenceFrame: The reference frame that the position and direction are in. :returns: The part that was hit or ``null`` if there was no hit. :Game Scenes: Flight .. method:: boolean getFARAvailable() Whether `Ferram Aerospace Research `_ is installed. .. method:: void createKerbal(String name, String job, boolean male) Creates a Kerbal. :param String name: :param String job: :param boolean male: .. method:: CrewMember getKerbal(String name) Find a Kerbal by name. :param String name: .. method:: void loadSpaceCenter() Switch to the space center view. .. method:: MapFilterType getMapFilter() .. method:: void setMapFilter(MapFilterType value) The visible objects in map mode. .. method:: void screenshot(String filePath, int scale) Saves a screenshot. :param String filePath: The path of the file to save. :param int scale: Resolution scaling factor :Game Scenes: Flight .. method:: GameMode getGameMode() The current mode the game is in. .. method:: WarpMode getWarpMode() The current time warp mode. Returns :meth:`WarpMode.NONE` if time warp is not active, :meth:`WarpMode.RAILS` if regular "on-rails" time warp is active, or :meth:`WarpMode.PHYSICS` if physical time warp is active. :Game Scenes: Flight .. method:: Camera getCamera() An object that can be used to control the camera. :Game Scenes: Flight .. method:: WaypointManager getWaypointManager() The waypoint manager. :Game Scenes: Flight .. method:: ContractManager getContractManager() The contract manager. .. method:: AlarmManager getAlarmManager() The alarm manager. .. type:: public enum GameMode The game mode. Returned by :type:`GameMode` .. field:: public GameMode SANDBOX Sandbox mode. .. field:: public GameMode CAREER Career mode. .. field:: public GameMode SCIENCE Science career mode. .. field:: public GameMode SCIENCE_SANDBOX Science sandbox mode. .. field:: public GameMode MISSION Mission mode. .. field:: public GameMode MISSION_BUILDER Mission builder mode. .. field:: public GameMode SCENARIO Scenario mode. .. field:: public GameMode SCENARIO_NON_RESUMABLE Scenario mode that cannot be resumed. .. type:: public enum WarpMode The time warp mode. Returned by :type:`WarpMode` .. field:: public WarpMode RAILS Time warp is active, and in regular "on-rails" mode. .. field:: public WarpMode PHYSICS Time warp is active, and in physical time warp mode. .. field:: public WarpMode NONE Time warp is not active. .. type:: public enum MapFilterType The set of things that are visible in map mode. These may be combined with bitwise logic. .. field:: public MapFilterType ALL Everything. .. field:: public MapFilterType NONE Nothing. .. field:: public MapFilterType DEBRIS Debris. .. field:: public MapFilterType UNKNOWN Unknown. .. field:: public MapFilterType SPACE_OBJECTS SpaceObjects. .. field:: public MapFilterType PROBES Probes. .. field:: public MapFilterType ROVERS Rovers. .. field:: public MapFilterType LANDERS Landers. .. field:: public MapFilterType SHIPS Ships. .. field:: public MapFilterType STATIONS Stations. .. field:: public MapFilterType BASES Bases. .. field:: public MapFilterType EV_AS EVAs. .. field:: public MapFilterType FLAGS Flags. .. field:: public MapFilterType PLANE Planes. .. field:: public MapFilterType RELAY Relays. .. field:: public MapFilterType SITE Launch Sites. .. field:: public MapFilterType DEPLOYED_SCIENCE_CONTROLLER Deployed Science Controllers. .. type:: public class LaunchSite A place where craft can be launched from. More of these can be added with mods like Kerbal Konstructs. .. method:: String getName() The name of the launch site. .. method:: CelestialBody getBody() The celestial body the launch site is on. .. method:: EditorFacility getEditorFacility() Which editor is normally used for this launch site. .. type:: public enum EditorFacility Editor facility. See :meth:`LaunchSite.getEditorFacility()`. .. field:: public EditorFacility VAB Vehicle Assembly Building. .. field:: public EditorFacility SPH Space Plane Hanger. .. field:: public EditorFacility NONE None.