Jump to content

Documentation for the KSP API


Recommended Posts

One of the hurdles to getting started writing plugins for KSP is the lack of any documentation for the functions that are available. You can open up Assembly-CSharp.dll in Visual Studio's Object Browser and see a bunch of classes, but there's nothing that tells you what each one does. As a community we have figured a bunch of it out, though, and assembled some documentation.

Web Documentation.

You can also download the following documentation file:

Assembly-CSharp.xml

Place this file in the directory <your KSP folder>/KSP_Data/Managed right next to Assembly-CSharp.dll. Visual Studio or MonoDevelop will automatically find it and use it to display documentation for some methods in the Object Browser and through IntelliSense. You'll have to restart VS before the documentation will show up.

A number of people have contributed to making this documentation. If you want to contribute, read the instructions at the Github project.

--------

You can also get in-IDE documentation for some Unity features by downloading this XML file and putting it in the same place:

UnityEngine.xml

This Unity documentation is quite old and incomplete, and I don't remember where it comes from. Someday I am going to finish a project I have to scrape the Unity web docs and process them into XML documentation, which will generate something more complete and up-to-date.

Edited by The_Duck
Link to comment
Share on other sites

Just made ~1200 .txt files for the 0.20 API database [i'm very new to rec (nothing really able to be put up; personal use only)


GameEvents

**** EVENTS ****


**** PROPERTIES ****


**** FIELDS ****
<<<GameEvents>>>
Boolean debugEvents PS
EventData`1[EventReport] onJointBreak PS
EventData`1[EventReport] onCrash PS
EventData`1[EventReport] onCrashSplashdown PS
EventData`1[EventReport] onCollision PS
EventData`1[EventReport] onOverheat PS
EventData`1[EventReport] onStageSeparation PS
EventData`1[EventReport] onCrewOnEva PS
EventData`1[EventReport] onCrewKilled PS
EventData`1[EventReport] onCrewBoardVessel PS
EventData`1[EventReport] onLaunch PS
EventData`1[EventReport] onUndock PS
EventData`1[EventReport] onSplashDamage PS
EventData`1[Vessel] onVesselCreate PS
EventData`1[Vessel] onVesselDestroy PS
EventData`1[Vessel] onVesselChange PS
EventData`1[GameEvents+HostedFromToAction`2[Vessel,Vessel+Situations]] onVesselSituationChange PS
EventData`1[GameEvents+FromToAction`2[String,String]] onVesselRename PS
EventData`1[Vessel] onVesselGoOnRails PS
EventData`1[Vessel] onVesselGoOffRails PS
EventData`1[Vessel] onVesselLoaded PS
EventData`1[Vessel] onVesselWasModified PS
EventData`1[Int32] onStageActivate PS
EventData`1[GameEvents+FromToAction`2[CelestialBody,CelestialBody]] onDominantBodyChange PS
EventVoid onGamePause PS
EventVoid onGameUnpause PS
EventVoid onFlightReady PS
EventVoid onTimeWarpRateChanged PS
EventData`1[GameScenes] onGameSceneLoadRequested PS
EventData`1[MapObject] onPlanetariumTargetChanged PS
EventData`1[Game] onGameStateSaved PS
EventData`1[Game] onGameStateCreated PS
EventData`1[GameEvents+ExplosionReaction] onPartDestroy PS
EventData`1[Part] onPartUndock PS
EventData`1[GameEvents+FromToAction`2[Part,Part]] onPartCouple PS
EventData`1[GameEvents+HostTargetAction`2[Part,Part]] onPartAttach PS
EventData`1[GameEvents+HostTargetAction`2[Part,Part]] onPartRemove PS
EventData`1[String] onFlagSelect PS
EventData`1[String] onMissionFlagSelect PS


**** CONSTRUCTORS ****
<<<GameEvents>>>
void .cctor HS ()


**** METHODS ****
<<<System.Object>>>
String ToString PV ()
Boolean Equals PV (Object obj)
Boolean InternalEquals Sa (Object objA, Object objB)
Boolean Equals PS (Object objA, Object objB)
Boolean ReferenceEquals PS (Object objA, Object objB)
Int32 GetHashCode PV ()
Int32 InternalGetHashCode Sa (Object obj)
Type GetType P ()
Void Finalize V ()
Object MemberwiseClone ()


**** NESTED ****
<<<GameEvents>>>
GameEvents+ExplosionReaction sv

This looks important. (PS = Public Static)


ProceduralAsteroid

**** EVENTS ****


**** PROPERTIES ****
<<<UnityEngine.MonoBehaviour>>>
Boolean useGUILayout RW
get_useGUILayout P ()
set_useGUILayout P (Boolean value)

<<<UnityEngine.Behaviour>>>
Boolean enabled RW
get_enabled P ()
set_enabled P (Boolean value)

<<<UnityEngine.Component>>>
UnityEngine.Transform transform R
get_transform P ()

UnityEngine.Rigidbody rigidbody R
get_rigidbody P ()

UnityEngine.Camera camera R
get_camera P ()

UnityEngine.Light light R
get_light P ()

UnityEngine.Animation animation R
get_animation P ()

UnityEngine.ConstantForce constantForce R
get_constantForce P ()

UnityEngine.Renderer renderer R
get_renderer P ()

UnityEngine.AudioSource audio R
get_audio P ()

UnityEngine.GUIText guiText R
get_guiText P ()

UnityEngine.NetworkView networkView R
get_networkView P ()

UnityEngine.GUIElement guiElement R
get_guiElement P ()

UnityEngine.GUITexture guiTexture R
get_guiTexture P ()

UnityEngine.Collider collider R
get_collider P ()

UnityEngine.HingeJoint hingeJoint R
get_hingeJoint P ()

UnityEngine.ParticleEmitter particleEmitter R
get_particleEmitter P ()

UnityEngine.ParticleSystem particleSystem R
get_particleSystem P ()

UnityEngine.GameObject gameObject R
get_gameObject P ()

Boolean active RW
get_active P ()
set_active P (Boolean value)

String tag RW
get_tag P ()
set_tag P (String value)

<<<UnityEngine.Object>>>
String name RW
get_name P ()
set_name P (String value)

UnityEngine.HideFlags hideFlags RW
get_hideFlags P ()
set_hideFlags P (UnityEngine.HideFlags value)



**** FIELDS ****
<<<ProceduralAsteroid>>>
Int32 seed P
Int32 number P
UnityEngine.Vector3 range P
Single minRadius P
Single maxRadius P
ProceduralAsteroid+ModWrapper[] mods P
LinkedMeshSO linkedMesh P
UnityEngine.Material material P


**** CONSTRUCTORS ****
<<<ProceduralAsteroid>>>
void .ctor P ()


**** METHODS ****
<<<ProceduralAsteroid>>>
Void Reset H ()
Void Awake H ()
Void GenerateAsteroids H ()
UnityEngine.GameObject GenerateAsteroid H (Int32 index, Single radius, OnDefaultDelegate onSetup, OnVertexBuildDelegate onBuildVert)
<<<UnityEngine.MonoBehaviour>>>
Void Invoke P (String methodName, Single time)
Void InvokeRepeating P (String methodName, Single time, Single repeatRate)
Void CancelInvoke P ()
Void CancelInvoke P (String methodName)
Boolean IsInvoking P (String methodName)
Boolean IsInvoking P ()
UnityEngine.Coroutine StartCoroutine P (Collections.IEnumerator routine)
UnityEngine.Coroutine StartCoroutine_Auto P (Collections.IEnumerator routine)
UnityEngine.Coroutine StartCoroutine P (String methodName, Object value)
UnityEngine.Coroutine StartCoroutine P (String methodName)
Void StopCoroutine P (String methodName)
Void StopAllCoroutines P ()
Void print PS (Object message)
<<<UnityEngine.Behaviour>>>
<<<UnityEngine.Component>>>
UnityEngine.Transform InternalGetTransform a ()
UnityEngine.GameObject InternalGetGameObject a ()
UnityEngine.Component GetComponent P (Type type)
T GetComponent P ()
UnityEngine.Component GetComponent P (String type)
UnityEngine.Component GetComponentInChildren P (Type t)
T GetComponentInChildren P ()
UnityEngine.Component[] GetComponentsInChildren P (Type t)
UnityEngine.Component[] GetComponentsInChildren P (Type t, Boolean includeInactive)
T[] GetComponentsInChildren P (Boolean includeInactive)
T[] GetComponentsInChildren P ()
UnityEngine.Component[] GetComponents P (Type type)
T[] GetComponents P ()
Boolean CompareTag P (String tag)
Void SendMessageUpwards P (String methodName, Object value, UnityEngine.SendMessageOptions options)
Void SendMessageUpwards P (String methodName, Object value)
Void SendMessageUpwards P (String methodName)
Void SendMessageUpwards P (String methodName, UnityEngine.SendMessageOptions options)
Void SendMessage P (String methodName, Object value, UnityEngine.SendMessageOptions options)
Void SendMessage P (String methodName, Object value)
Void SendMessage P (String methodName)
Void SendMessage P (String methodName, UnityEngine.SendMessageOptions options)
Void BroadcastMessage P (String methodName, Object parameter, UnityEngine.SendMessageOptions options)
Void BroadcastMessage P (String methodName, Object parameter)
Void BroadcastMessage P (String methodName)
Void BroadcastMessage P (String methodName, UnityEngine.SendMessageOptions options)
<<<UnityEngine.Object>>>
Boolean Equals PV (Object o)
Int32 GetHashCode PV ()
Int32 GetInstanceID P ()
UnityEngine.Object Instantiate PS (UnityEngine.Object original, UnityEngine.Vector3 position, UnityEngine.Quaternion rotation)
UnityEngine.Object Instantiate PS (UnityEngine.Object original)
Void Destroy PS (UnityEngine.Object obj, Single t)
Void Destroy PS (UnityEngine.Object obj)
Void DestroyImmediate PS (UnityEngine.Object obj, Boolean allowDestroyingAssets)
Void DestroyImmediate PS (UnityEngine.Object obj)
UnityEngine.Object[] FindObjectsOfType PS (Type type)
UnityEngine.Object FindObjectOfType PS (Type type)
Void DontDestroyOnLoad PS (UnityEngine.Object target)
Void DestroyObject PS (UnityEngine.Object obj, Single t)
Void DestroyObject PS (UnityEngine.Object obj)
UnityEngine.Object[] FindSceneObjectsOfType PS (Type type)
UnityEngine.Object[] FindObjectsOfTypeIncludingAssets PS (Type type)
UnityEngine.Object[] FindObjectsOfTypeAll PS (Type type)
String ToString PV ()
Boolean op_Implicit PS (UnityEngine.Object exists)
Boolean op_Equality PS (UnityEngine.Object x, UnityEngine.Object y)
Boolean op_Inequality PS (UnityEngine.Object x, UnityEngine.Object y)
<<<System.Object>>>
Boolean InternalEquals Sa (Object objA, Object objB)
Boolean Equals PS (Object objA, Object objB)
Boolean ReferenceEquals PS (Object objA, Object objB)
Int32 InternalGetHashCode Sa (Object obj)
Type GetType P ()
Void Finalize V ()
Object MemberwiseClone ()


**** NESTED ****
<<<ProceduralAsteroid>>>
ProceduralAsteroid+ModValue C
ProceduralAsteroid+ModWrapper C

And this looks fun :P

From the looks of things, Resources are actually VERY far along [and I can see why they pushed them back, they were going for the 100% not the 20%]. (Not much difference with the old API's, and the new ones (KerbalSeat / FlagSite) are a bit restrictive. **Fun note, resources also have a "colour" now XD

Edited by Fel
Link to comment
Share on other sites

  • 2 weeks later...
  • 1 month later...

Are these summaries the same that can go into the Wiki API Documentation? I'm looking for an easy way to copy over information without having to do any extra work, but I'm seeing some methods and properties that aren't in the XML documentation. Why is this? I'm not familiar with the XML documentation use at all, I just want to grab the information from it for wiki tables.

Thanks!

Link to comment
Share on other sites

  • 9 months later...

Is there a simpler method for getting to an editable version of a class file from the Assembly-CSharp.dll?

Go to definition (F12) always takes me to the locked, metadata-as-source window with the source code. I can get at it by right clicking on the tab, selecting 'open containing folder', then opening the .cs file in another VS window. I guess it's simple enough, but if anyone was wondering how to get at the .cs file it might not be obvious.

Link to comment
Share on other sites

Is there a simpler method for getting to an editable version of a class file from the Assembly-CSharp.dll?

Go to definition (F12) always takes me to the locked, metadata-as-source window with the source code. I can get at it by right clicking on the tab, selecting 'open containing folder', then opening the .cs file in another VS window. I guess it's simple enough, but if anyone was wondering how to get at the .cs file it might not be obvious.

I just copy the whole thing into a new file and edit that. (Ctrl-A Ctrl-C Ctrl-N Ctrl-V -- simple enough? :P)

Link to comment
Share on other sites

  • 2 months later...

@stephm: Great! I've updated the OP to say that the XML docs work in MonoDevelop too.

----

I've added a bit more information to the docs as I learned it, for example Romfarer's ApplicationLauncher interface.

We could really use some good documentation of all the GameEvents callbacks. If you want to contribute your knowledge on this or any other subject, follow the link in the OP to the Github repository, which has instructions for contributing.

Edited by The_Duck
Link to comment
Share on other sites

hello !

I 'm embarrassed :blush: I have no knowledge about plugin, for now I have just learned how to display

some info by module, because they are some tuto about that ...

But I'm looking very often in monodevelopp and how module are , I'm looking too in community plugin (like Github)

(I have a little background with Java , my level is simple Brick-Breaker game :D)

and thank for the update, I replace the xml with the updated version, right now .

@+

Edited by stephm
Link to comment
Share on other sites

  • 4 weeks later...
  • 2 weeks later...
So... How is this (awesome) effort aligns with the EULA explicitly forbidding reverse engineering?

This documentation is based on experience and trial and error using the public interfaces available in the KSP assemblies, not decompilation.

Link to comment
Share on other sites

Look, what do you think the point of the EULA is? It's not to prevent modders from learning how to write plugins. The EULA clause you are referring to is to protect the private *implementation* of KSP itself. KSP is a game intended to be modded. It's not an accident that KSP loads any assembly you put in the GameData folder; it's a feature that was added so that people could write plugins. Squad originally had some intention of publishing some documentation for the KSP public interface, but never got around to doing so (understandably: it would be a big task and it would take a ton of time away from working on the actual game). In the meantime we are writing the documentation for ourselves.

Link to comment
Share on other sites

"trial and error" is still reverse engineering... decompilation is one tool for RE, poking things until they make sense is another.

So says you.

If poking around to find out how things worked were considered a violation of the EULA then basically all addons would be in violation. This thread would certainly not be stickied along with the other thread dedicated primarily to explaining what Squad's code actually does. So it seems reasonable to assume that users telling other users how the code works is considered acceptable.

Link to comment
Share on other sites

  • 3 months later...

Does anybody think that Squad could just release the actual code for interfacing with the classes? (eg. just release KSPFields.class or somesuch?)

I don't know about anybody else, but it seems to me that it would be a lot easier for modders if we could just what all they've already implemented, rather than trying to figure it, duplicate it, get it wrong, or do something massively more resource intensive (doubling code will do that, you know)

I'm looking at you: moduleDockingNode

Link to comment
Share on other sites

Does anybody think that Squad could just release the actual code for interfacing with the classes? (eg. just release KSPFields.class or somesuch?)

Of course they could; All the information is easy to access and filter out of the compiled binaries, any self-respecting IDE is displaying it, and many tools allow for easy exporting of API documentation. Hack, I could do it, if it weren't for the pesky EULA.

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...