Skip to content

ResearchBodies Reflection wrapper API

Jamie Leighton edited this page Jul 14, 2016 · 5 revisions

This reflection wrapper API is used to interface to ResearchBodies.
Before you re-distribute or wish to integrate to this DLL please drop me a PM on the KSP forums, Thanks!
You can find the Wrapper Class here:-
https://github.com/JPLRepo/ResearchBodies/blob/Dev/API/RBWrapper.cs

Usage:

Setup:

First change the Namespace to your project Namespace.
You must initialise the Wrapper before trying to access it by calling:

RBWrapper.InitRBWrapper();

this method will return a bool indicating success. You can check that the Wrapper has been initialised and is ready by checking the bool:

RBWrapper.APIRBReady

You access the fields and methods of the API by accessing the object eg:

RBWrapper.RBactualAPI.enabled

The fields available are:

  • bool enabled - True if ResearchBodies is enabled in the current save game. Otherwise, False.
  • Dictionary<CelestialBody, CelestialBodyInfo> CelestialBodies - A dictionary keyed by CelestialBody of CelestialBodyInfo class (defined below).

The methods available are:

  • bool FoundBody(int scienceReward, CelestialBody bodyFound, out bool withParent, out CelestialBody parentBody) - called when a CelestialBody is intially found. If the body is already found, it will do nothing.
    • scienceReward is an integer value that is added to the players science total.
    • bodyFound is a reference to the CelestialBody just found.
    • withParent indicates if the parent body has also been found and if true:-
    • parentbody must be set to the parent CelestialBody that has also been found.
  • bool Research(CelestialBody body, int researchToAdd) - Use to increase the research percentage of a found body. body is the reference to the CelestialBody and resarchToAdd is the percentage of research to add.
  • bool LaunchResearchPlan(CelestialBody cb) - Start a ResearchPlan for a CelestialBody.
  • bool StopResearchPlan(CelestialBody cb) - Stop a ResearchPlan for a CelestialBody.

CelestialBodyInfo Class.

The following fields are part of this class:

  • string body - The name of the Celestial Body.
  • bool isResearched - True if the Celestial Body has been found.
  • int researchState - Percentage state of the research program. 0% - just found, 100% fully researched.
  • bool ignore - True if this Celestial Body is found by default at the start of a game.
  • int priority - Research Priority - Future field - not currently in use.
  • string discoveryMessage - Message displayed to the user when this celestial body is initially found.
  • bool KOPbarycenter - True if this Celestial Body has a Kopernicus barycenter defined.
  • CelestialBody KOPrelbarycenterBody - Set to the celestial body of the Kopernicus barycenter (if one is defined).

Clone this wiki locally