├── .gitignore ├── Assembly-CSharp.xml ├── Doxyfile ├── LICENSE.txt ├── README.md ├── UnityEngine.xml └── src ├── ApplicationLauncher.cs ├── AtmosphericEngine.cs ├── AttachNode.cs ├── AvailablePart.cs ├── BaseAction.cs ├── BaseActionList.cs ├── BinaryReader.cs ├── BinaryWriter.cs ├── CelestialBody.cs ├── ConfigNode.cs ├── ControlTypes.cs ├── Decoupler.cs ├── DecouplerGUI.cs ├── DiscoverableObjectUtil.cs ├── DiscoveryInfo.cs ├── DiscoveryLevels.cs ├── DockingPort.cs ├── EditorLogic.cs ├── EventDataT.cs ├── EventDataTU.cs ├── EventDataTUV.cs ├── EventReport.cs ├── EventVoid.cs ├── File.cs ├── FileInfo.cs ├── FlightCamera.cs ├── FlightCtrlState.cs ├── FlightGlobals.cs ├── FlightInputHandler.cs ├── FloatCurve.cs ├── FuelLine.cs ├── FuelTank.cs ├── FuelTankGUI.cs ├── GameEvents.cs ├── GamePersistence.cs ├── GameScenes.cs ├── HighLogic.cs ├── IDiscoverable.cs ├── IOException.cs ├── IOUtils.cs ├── IScienceDataContainer.cs ├── InputLockManager.cs ├── KFSMEvent.cs ├── KFSMState.cs ├── KSPAction.cs ├── KSPAddon.cs ├── KSPAssembly.cs ├── KSPAssemblyDependency.cs ├── KSPEvent.cs ├── KSPField.cs ├── KSPScenario.cs ├── KerbalEVA.cs ├── KerbalFSM.cs ├── KerbalInstructor.cs ├── Krakensbane.cs ├── ManeuverNode.cs ├── MapView.cs ├── MemoryStream.cs ├── ModuleAsteroid.cs ├── ModuleEngines.cs ├── ModuleScienceExperiment.cs ├── Orbit.cs ├── PAsteroid.cs ├── PSystem.cs ├── PSystemManager.cs ├── Part.cs ├── PartModule.cs ├── PartResource.cs ├── PartResourceDefinition.cs ├── PartResourceLibrary.cs ├── PatchedConicSolver.cs ├── Planetarium.cs ├── PlanetariumCamera.cs ├── PluginConfigNode.cs ├── PluginConfiguration.cs ├── ProceduralAsteroid.cs ├── RDArchivesController.cs ├── ResourceFlowMode.cs ├── ScaledSpace.cs ├── ScenarioCreationOptions.cs ├── ScenarioDiscoverableObjects.cs ├── ScienceData.cs ├── ScienceExperiment.cs ├── ScienceSubject.cs ├── ScreenMessage.cs ├── ScreenMessages.cs ├── SeekOrigin.cs ├── ShipConstruct.cs ├── SpaceCenter.cs ├── Sun.cs ├── TextReader.cs ├── TextWriter.cs ├── TimeWarp.cs ├── TutorialScenario.cs ├── UntrackedObjectClass.cs ├── Vector3d.cs ├── Vessel.cs └── main.md /.gitignore: -------------------------------------------------------------------------------- 1 | us.stackdump 2 | src/Part2.cs 3 | src/Vessel2.cs 4 | html/* -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | You can find me on #kspmodders or the KSP forums as **The_Duck**. 2 | 3 | Web documentation 4 | ----------------- 5 | 6 | This project is used to build the **[web documentation](http://anatid.github.io/XML-Documentation-for-the-KSP-API/index.html)** using Doxygen. 7 | 8 | IDE integration 9 | --------------- 10 | 11 | To get documentation in tooltips and the object browser in Visual Studio or MonoDevelop: 12 | 13 | 1. Download **[Assembly-CSharp.xml](https://raw.githubusercontent.com/Anatid/XML-Documentation-for-the-KSP-API/master/Assembly-CSharp.xml)** and **[UnityEngine.xml](https://raw.githubusercontent.com/Anatid/XML-Documentation-for-the-KSP-API/master/UnityEngine.xml)** 14 | 2. Place Assembly-CSharp.xml and UnityEngine.xml in the same place as the Assembly-CSharp.dll and UnityEngine.dll that you link to when building your KSP plugin (the KSP_Data/Managed folder). 15 | 3. Restart your IDE. 16 | 17 | Now when you use the object browser to examine the contents of Assembly-CSharp.dll you will find helpful comments for some classes. These comments will also show up through IntelliSense when writing code. 18 | 19 | 20 | How to contribute to this documentation 21 | --------------------------------------- 22 | 23 | This documentation is only as good as the effort that the community puts into it! You can help. 24 | 25 | To add new info on a class that already has some documentation: 26 | 27 | 1. Fork this project 28 | 2. Add your comments in the appropriate .cs file. 29 | 3. Send me a pull request. 30 | 31 | To add info on a new class: 32 | 33 | 1. Highlight the class in the source code of your KSP plugin. 34 | 2. Press F12. Visual Studio will create a fake source file for the class. 35 | 3. Copy Visual Studio's uneditable source file into a new file you can edit. 36 | 4. Add your comments to the fake source file. 37 | 5. Fork this project. 38 | 6. Add your new fake source file to your version of the project. 39 | 7. Send me a pull request. 40 | -------------------------------------------------------------------------------- /src/AtmosphericEngine.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | /// 7 | /// The old, deprecated class that implemented jet engine parts before PartModules. 8 | /// Use an appropriately configured ModuleEngines instead of this class. 9 | /// 10 | class AtmosphericEngine : Part 11 | { 12 | } 13 | 14 | -------------------------------------------------------------------------------- /src/AttachNode.cs: -------------------------------------------------------------------------------- 1 | #region Assembly Assembly-CSharp.dll, v2.0.50727 2 | // C:\greg\games\KSP 0.18.2\KSP_Data\Managed\Assembly-CSharp.dll 3 | #endregion 4 | 5 | using System; 6 | using UnityEngine; 7 | 8 | /// 9 | /// An AttachNode represents the physical connection between a Part and its parent Part. 10 | /// 11 | [Serializable] 12 | public class AttachNode 13 | { 14 | /// 15 | /// The part attached to this node. Null if no part is attached. 16 | /// 17 | public Part attachedPart; 18 | public string attachedPartId; 19 | public AttachNodeMethod attachMethod; 20 | public float breakingForce; 21 | public float breakingTorque; 22 | public GameObject icon; 23 | public string id; 24 | /// 25 | /// Whether this node is a surface-attach node, a stack node, or a docking node. 26 | /// 27 | public AttachNode.NodeType nodeType; 28 | public Vector3 offset; 29 | public Vector3 orientation; 30 | public Vector3 originalOrientation; 31 | public Vector3 originalPosition; 32 | public Vector3 position; 33 | public float radius; 34 | public bool requestGate; 35 | /// 36 | /// Wether or not resource cross feed can pass through this node. 37 | /// 38 | public bool ResourceXFeed; 39 | public int size; 40 | 41 | public extern AttachNode(); 42 | 43 | public extern void FindAttachedPart(); 44 | 45 | public enum NodeType 46 | { 47 | /// 48 | /// A stack node, like the connections between stacked fuel tanks 49 | /// 50 | Stack = 0, 51 | /// 52 | /// A surface node, like the connection between a radial decoupler and its parent. 53 | /// 54 | Surface = 1, 55 | /// 56 | /// The type of node that connects two docking ports? 57 | /// 58 | Dock = 2, 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/AvailablePart.cs: -------------------------------------------------------------------------------- 1 | #region Assembly Assembly-CSharp.dll, v2.0.50727 2 | // C:\greg\games\KSP 0.18.2\KSP_Data\Managed\Assembly-CSharp.dll 3 | #endregion 4 | 5 | using System; 6 | using UnityEngine; 7 | 8 | /// 9 | /// An AvailablePart object contains the summary information about a single type of part 10 | /// which is shown in the editor. 11 | /// 12 | [Serializable] 13 | public class AvailablePart 14 | { 15 | public int amountAvailable; 16 | [Persistent] 17 | public string author; 18 | /// 19 | /// Which tab this part shows up in in the editor. 20 | /// 21 | public PartCategories category; 22 | /// 23 | /// The cost of this part, as displayed in the editor. 24 | /// 25 | public int cost; 26 | /// 27 | /// The description of this part, as displayed in the editor? 28 | /// Does this include the GetInfo() of the part's PartModules? 29 | /// 30 | public string description; 31 | public Vector3 iconOffset; 32 | public GameObject iconPrefab; 33 | public Vector3 iconScale; 34 | public string iconUrl; 35 | public ConfigNode internalConfig; 36 | public string manufacturer; 37 | public string moduleInfo; 38 | /// 39 | /// The name of this kind of part, as specified in the "name =" line of its part.cfg. 40 | /// 41 | public string name; 42 | /// 43 | /// The object that gets cloned when you create a new instance of this part in the editor? 44 | /// 45 | public Part partPrefab; 46 | public string partUrl; 47 | public string resourceInfo; 48 | public string title; 49 | public string typeDescription; 50 | 51 | public extern AvailablePart(string path); 52 | 53 | public extern string partPath { get; } 54 | } 55 | -------------------------------------------------------------------------------- /src/BaseAction.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | /// 5 | /// A BaseAction object is the basic action object. 6 | /// There is one of these automatically created for each 'KSPAction' field in a partModule 7 | /// 8 | [Serializable] 9 | public class BaseAction 10 | { 11 | /// 12 | /// Unconfirmed: The action groups this action is currently assigned to. 13 | /// 14 | public KSPActionGroup actionGroup; 15 | /// 16 | /// Is this action available? Setting this false disables the action so it will not show in the available actions list. 17 | /// 18 | public bool active; 19 | /// 20 | ///Unconfirmed: Assign this action to action groups upon creation ('Gear' group for landing legs) 21 | /// 22 | public KSPActionGroup defaultActionGroup; 23 | /// 24 | /// Name shown in editor action groups panel 25 | /// 26 | public string guiName; 27 | /// 28 | /// Information about what the action is attached to. 29 | /// listParent.module = partModule this action is a memeber of 30 | /// listParent.part = part this action is a member of 31 | /// 32 | public BaseActionList listParent; 33 | /// 34 | /// Name of the action group as seen in code where the KSPAction field exists 35 | /// 36 | public string name; 37 | 38 | public extern BaseAction(BaseActionList listParent, string name, BaseActionDelegate onEvent, KSPAction actionAttr); 39 | 40 | public static extern int ActionGroupsLength { get; } 41 | protected extern BaseActionDelegate onEvent { get; } 42 | 43 | public static extern bool ContainsNonDefaultActions(Part p); 44 | public static extern List CreateActionList(List parts, KSPActionGroup group, bool include); 45 | public static extern List CreateActionList(Part p, KSPActionGroup group, bool include); 46 | public static extern List CreateGroupList(List parts); 47 | public static extern List CreateGroupList(Part p); 48 | public static extern void FireAction(List parts, KSPActionGroup group, KSPActionType type); 49 | public static extern int GetGroupIndex(KSPActionGroup group); 50 | /// 51 | /// Activate this action. Note that there is no toggle activation, you must check state yourself in code 52 | /// and activate or deactivate as appropriate 53 | /// 54 | /// **Example code start to activate an action: KSP version 0.24.2** 55 | /// 56 | /// 57 | /// KSPActionParam actParam = new KSPActionParam(KSPActionGroup.None, KSPActionType.Activate); //okay to create this new just before invoking 58 | /// exampleAction.Invoke(actParam); //action defined as a KSPAction in a partModule 59 | /// 60 | /// 61 | /// **Example code start to deactivate an action: KSP version 0.24.2** 62 | /// 63 | /// 64 | /// KSPActionParam actParam = new KSPActionParam(KSPActionGroup.None, KSPActionType.Deactivate); //okay to create this new just before invoking 65 | /// exampleAction.Invoke(actParam); //action defined as a KSPAction in a partModule 66 | /// 67 | /// 68 | public extern void Invoke(KSPActionParam param); 69 | public extern void OnLoad(ConfigNode node); 70 | public extern void OnSave(ConfigNode node); 71 | } 72 | -------------------------------------------------------------------------------- /src/BaseActionList.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Reflection; 4 | 5 | /// 6 | /// A BaseActionList is an object to manipulate actions. 7 | /// 8 | [Serializable] 9 | public class BaseActionList : List 10 | { 11 | /// 12 | /// The partModule this list of actions belongs to 13 | /// 14 | public PartModule module; 15 | /// 16 | /// The Part this list of actions belongs to 17 | /// 18 | public Part part; 19 | 20 | public extern BaseActionList(Part part, PartModule module); 21 | 22 | public extern BaseAction this[string name] { get; } 23 | 24 | public extern bool Contains(KSPActionGroup group); 25 | public extern void OnLoad(ConfigNode node); 26 | public extern void OnSave(ConfigNode node); 27 | } 28 | -------------------------------------------------------------------------------- /src/BinaryReader.cs: -------------------------------------------------------------------------------- 1 | #region Assembly Assembly-CSharp.dll, v2.0.50727 2 | // C:\greg\games\KSP 0.18.2\KSP_Data\Managed\Assembly-CSharp.dll 3 | #endregion 4 | 5 | using System; 6 | using System.IO; 7 | 8 | namespace KSP.IO 9 | { 10 | /// 11 | /// Identical to System.IO.BinaryReader, but with added IDisposable methods (for use in using structures), and a factory method instead of constructors. 12 | /// 13 | public class BinaryReader : IDisposable 14 | { 15 | public extern Stream BaseStream { get; } 16 | 17 | public extern void Close(); 18 | /// 19 | /// Create a binary reader with the desired filename. 20 | /// 21 | /// 22 | /// 23 | /// 24 | /// 25 | public extern static BinaryReader CreateForType(string filename, Vessel flight = null); 26 | /// 27 | /// Close the stream and any resources (e.g. files) it has open. 28 | /// 29 | public extern void Dispose(); 30 | public extern int PeekChar(); 31 | public extern int Read(); 32 | /// 33 | /// Read a block of bytes from the stream. 34 | /// 35 | /// 36 | /// 37 | /// 38 | /// 39 | public extern int Read(byte[] buffer, int index, int count); 40 | /// 41 | /// Read a block of chars from the stream. 42 | /// 43 | /// 44 | /// 45 | /// 46 | /// 47 | public extern int Read(char[] buffer, int index, int count); 48 | public extern bool ReadBoolean(); 49 | public extern byte ReadByte(); 50 | public extern byte[] ReadBytes(int count); 51 | public extern char ReadChar(); 52 | public extern char[] ReadChars(int count); 53 | public extern decimal ReadDecimal(); 54 | public extern double ReadDouble(); 55 | public extern short ReadInt16(); 56 | public extern int ReadInt32(); 57 | public extern long ReadInt64(); 58 | public extern sbyte ReadSByte(); 59 | public extern float ReadSingle(); 60 | public extern string ReadString(); 61 | public extern ushort ReadUInt16(); 62 | public extern uint ReadUInt32(); 63 | public extern ulong ReadUInt64(); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/BinaryWriter.cs: -------------------------------------------------------------------------------- 1 | #region Assembly Assembly-CSharp.dll, v2.0.50727 2 | // C:\greg\games\KSP 0.18.2\KSP_Data\Managed\Assembly-CSharp.dll 3 | #endregion 4 | 5 | using System; 6 | using System.IO; 7 | 8 | namespace KSP.IO 9 | { 10 | /// 11 | /// Identical to System.IO.BinaryWriter, but with added IDisposable methods (for use in using structures), and a factory method instead of constructors. 12 | /// 13 | public class BinaryWriter : IDisposable 14 | { 15 | public extern Stream BaseStream { get; } 16 | 17 | public extern void Close(); 18 | /// 19 | /// Create a binary file writer. 20 | /// 21 | /// 22 | /// 23 | /// 24 | /// 25 | public extern static BinaryWriter CreateForType(string filename, Vessel flight = null); 26 | public extern void Dispose(); 27 | public extern void Flush(); 28 | public extern long Seek(int offset, SeekOrigin origin); 29 | public extern void Write(bool value); 30 | public extern void Write(byte value); 31 | public extern void Write(byte[] buffer); 32 | public extern void Write(char ch); 33 | public extern void Write(char[] chars); 34 | public extern void Write(decimal value); 35 | public extern void Write(double value); 36 | public extern void Write(float value); 37 | public extern void Write(int value); 38 | public extern void Write(long value); 39 | public extern void Write(sbyte value); 40 | public extern void Write(short value); 41 | public extern void Write(string value); 42 | public extern void Write(uint value); 43 | public extern void Write(ulong value); 44 | public extern void Write(ushort value); 45 | public extern void Write(byte[] buffer, int index, int count); 46 | public extern void Write(char[] chars, int index, int count); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/Decoupler.cs: -------------------------------------------------------------------------------- 1 | #region Assembly Assembly-CSharp.dll, v2.0.50727 2 | // C:\greg\games\KSP 0.18.2\KSP_Data\Managed\Assembly-CSharp.dll 3 | #endregion 4 | 5 | using System; 6 | 7 | /// 8 | /// The old, deprecated class that used to be used to implement decouplers before PartModules. 9 | /// Use ModuleDecouple or ModuleAnchoredDecoupler instead. 10 | /// 11 | public class Decoupler : Part 12 | { 13 | public float ejectionForce; 14 | 15 | public extern Decoupler(); 16 | 17 | public extern override void OnDrawStats(); 18 | protected extern override bool onPartActivate(); 19 | protected extern override void onPartStart(); 20 | } 21 | -------------------------------------------------------------------------------- /src/DecouplerGUI.cs: -------------------------------------------------------------------------------- 1 | #region Assembly Assembly-CSharp.dll, v2.0.50727 2 | // C:\greg\games\KSP 0.18.2\KSP_Data\Managed\Assembly-CSharp.dll 3 | #endregion 4 | 5 | using System; 6 | 7 | /// 8 | /// An old, deprecated class that used to be used to implement decouplers before PartModules. 9 | /// Use ModuleDecouple or ModuleAnchoredDecoupler instead. 10 | /// 11 | public class DecouplerGUI : Part 12 | { 13 | public float ejectionForce; 14 | 15 | public extern DecouplerGUI(); 16 | 17 | [KSPAction("Decouple")] 18 | public extern void DecoupleAction(KSPActionParam param); 19 | [KSPEvent(guiName = "Decouple", guiActive = true)] 20 | public extern void GUIDecouple(); 21 | public extern override void OnDrawStats(); 22 | protected extern override bool onPartActivate(); 23 | protected extern override void onPartStart(); 24 | } 25 | -------------------------------------------------------------------------------- /src/DiscoverableObjectUtil.cs: -------------------------------------------------------------------------------- 1 | /// Static methods used by asteroids 2 | public static class DiscoverableObjectsUtil 3 | { 4 | /// Generates an suitably science-y asteroid name 5 | /// 6 | /// A random string of the form "XXX-###". 7 | /// 8 | public static extern string GenerateAsteroidName(); 9 | } 10 | -------------------------------------------------------------------------------- /src/DiscoveryInfo.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Anatid/XML-Documentation-for-the-KSP-API/338e0fe797ccced9814c3c1d2712dc2362d3afe5/src/DiscoveryInfo.cs -------------------------------------------------------------------------------- /src/DiscoveryLevels.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | /// Describes an IDiscoverable object's state regarding tracking and exploration 4 | [Flags] public enum DiscoveryLevels { 5 | None, 6 | /// Object has been detected in tracking station 7 | Presence = 1, 8 | /// Object has been tracked 9 | Name = 4, 10 | /// Object is currently tracked 11 | StateVectors = 8, 12 | /// Unlocks mass and type fields; intended for discoverable CelestialBodies? 13 | Appearance = 16, 14 | /// Alias for "all flags" 15 | /// 16 | /// Set for docked asteroids and all normal ship parts. 17 | Owned 18 | } -------------------------------------------------------------------------------- /src/DockingPort.cs: -------------------------------------------------------------------------------- 1 | #region Assembly Assembly-CSharp.dll, v2.0.50727 2 | // C:\greg\games\KSP 0.18.2\KSP_Data\Managed\Assembly-CSharp.dll 3 | #endregion 4 | 5 | using System; 6 | using UnityEngine; 7 | 8 | /// 9 | /// An unused class; use ModuleDockingNode instead. 10 | /// 11 | public class DockingPort : Part 12 | { 13 | public Vector3 dockingNodeOrientation; 14 | public Vector3 dockingNodePosition; 15 | public float ejectionForce; 16 | 17 | public extern DockingPort(); 18 | 19 | [KSPEvent(guiName = "AutoDock", guiActive = true)] 20 | public extern void ActivateAutoDock(); 21 | public extern override void OnDrawStats(); 22 | protected extern override void onFlightStart(); 23 | protected extern override bool onPartActivate(); 24 | protected extern override void onPartStart(); 25 | [KSPEvent(guiName = "Undock", guiActive = true)] 26 | public extern void Undock(); 27 | } 28 | -------------------------------------------------------------------------------- /src/EditorLogic.cs: -------------------------------------------------------------------------------- 1 | #region Assembly Assembly-CSharp.dll, v2.0.50727 2 | // C:\greg\games\KSP 0.18.2\KSP_Data\Managed\Assembly-CSharp.dll 3 | #endregion 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | using UnityEngine; 8 | 9 | /// 10 | /// This class has information about what is going on in the editor. In particular see SortedShipList. 11 | /// 12 | public class EditorLogic : MonoBehaviour 13 | { 14 | public UIButton actionPanelBtn; 15 | public bool allowNodeAttachment; 16 | public bool allowSrfAttachment; 17 | public UIButton angleSnapButton; 18 | public PackedSprite angleSnapSprite; 19 | public AudioClip attachClip; 20 | public GameObject attachNodePrefab; 21 | public bool debugFlight; 22 | public AudioClip deletePartClip; 23 | public Vector3 dragPlaneCenter; 24 | public float dragSharpness; 25 | public Camera editorCamera; 26 | public static bool editorLocked; 27 | public EditorLogic.EditorScreen editorScreen; 28 | public EditorLogic.EditorMode editorType; 29 | public UIButton exitBtn; 30 | public static EditorLogic fetch; 31 | public Vector3 initialPodPosition; 32 | public Vector3 initialPodRotation; 33 | public UIButton launchBtn; 34 | public string launchSiteName; 35 | public UIButton loadBtn; 36 | public float maxHeight; 37 | public PackedSprite mirrorSprite; 38 | public GameObject[] modalAreas; 39 | public bool mouseGrab; 40 | public UIButton newBtn; 41 | public AudioClip partGrabClip; 42 | public UIButton partPanelBtn; 43 | public AudioClip partReleaseClip; 44 | public Quaternion partRotation; 45 | public UIButton saveBtn; 46 | public int sceneToLoad; 47 | public Vector3 selPartGrabOffset; 48 | /// 49 | /// EditorLogic.fetch.ship.parts is a list of the parts in the ship currently under construction, 50 | /// ordered by the order in which they were added to the ship. 51 | /// 52 | public ShipConstruct ship; 53 | public GUISkin shipBrowserSkin; 54 | public Texture2D shipFileImage; 55 | public UITextField shipNameField; 56 | public static bool softLock; 57 | public float srfAttachAngleSnap; 58 | public static Part startPod; 59 | public string startPodId; 60 | public EditorLogic.EditorState state; 61 | public UIButton symmetryButton; 62 | public int symmetryMode; 63 | public PackedSprite symmetrySprite; 64 | 65 | public extern EditorLogic(); 66 | 67 | public extern static int LayerMask { get; } 68 | public extern bool mouseOverGUI { get; } 69 | public extern static Quaternion PartRotation { get; } 70 | public extern Part PartSelected { get; set; } 71 | public extern static Part SelectedPart { get; } 72 | public extern static Texture2D ShipFileImage { get; } 73 | /// 74 | /// A list of all parts in the vessel that is being edited. 75 | /// 76 | public extern static List SortedShipList { get; } 77 | public extern EditorLogic.EditorState State { get; set; } 78 | public extern static Quaternion VesselRotation { get; } 79 | 80 | public extern bool AreAllPartsConnected(); 81 | public extern int CountAllSceneParts(bool includeSelected); 82 | public extern static void DeletePart(Part part); 83 | public extern void DestroySelectedPart(); 84 | public extern void editText(); 85 | public extern static T GetComponentUpwards(GameObject obj) where T : Component; 86 | public extern static Component GetComponentUpwards(string type, GameObject obj); 87 | public extern List getSortedShipList(); 88 | public extern static void LoadShipFromFile(string path); 89 | public extern void Lock(bool lockLoad, bool lockExit, bool lockSave); 90 | public extern void OnPodSelect(AvailablePart pod); 91 | public extern void SelectPanelActions(); 92 | public extern void SelectPanelParts(); 93 | public extern void SetBackup(); 94 | public extern void SetHighlightRecursive(bool recursive, List parts); 95 | public extern void SetHighlightRecursive(bool recursive, Part p); 96 | public extern void SetHighlightRecursive(bool recursive, ShipConstruct parts); 97 | public extern static void SetLayerRecursive(GameObject part, int layer, int ignoreLayersMask = 0); 98 | public extern static void SetSoftLock(bool lockState); 99 | public extern void snapButton(); 100 | public extern void SpawnPart(AvailablePart part); 101 | public extern void symButton(); 102 | public extern bool UndoRedo(); 103 | public extern void Unlock(); 104 | 105 | public enum EditorMode 106 | { 107 | VAB = 0, 108 | SPH = 1, 109 | } 110 | 111 | public enum EditorScreen 112 | { 113 | Parts = 0, 114 | Actions = 1, 115 | Staging = 2, 116 | } 117 | 118 | public enum EditorState 119 | { 120 | GUI_UNSELECTED = 0, 121 | GUI_SELECTED = 1, 122 | PAD_UNSELECTED = 2, 123 | PAD_SELECTED = 3, 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /src/EventDataT.cs: -------------------------------------------------------------------------------- 1 |  2 | using System; 3 | using System.Collections.Generic; 4 | using UnityEngine; 5 | 6 | /// 7 | /// A type used to generate GameEvents 8 | /// 9 | /// Use this type with one accompanying type; 10 | /// GameEvents.FromToAction, 11 | /// GameEvents.HostedFromToAction, 12 | /// GameEvents.HostTargetAction 13 | /// are commonly used 14 | /// 15 | /// See EventVoid for events that require no parameters 16 | /// or EventReport for a different style 17 | /// 18 | /// The type to be passed through on EventData.Fire() 19 | public class EventData 20 | { 21 | /// 22 | /// Generate debug logs if true 23 | /// 24 | public bool debugEvent; 25 | 26 | /// 27 | /// The constructor used to create a new EventData 28 | /// 29 | /// EventData<Vessel> myNewEvent = new EventData<Vessel>("myNewEvent"); 30 | /// 31 | /// Give the event a string name, 32 | /// generally the same as the declared name 33 | public extern EventData(string eventName); 34 | 35 | /// 36 | /// Add a method to be run when the EventData is fired. 37 | /// 38 | /// This is generally done in an object's Start or Awake method, or a class' constructor. 39 | /// 40 | /// Can be setup like: 41 | /// 42 | /// GameEvents.someEventDataEvent.Add(yourMethod); 43 | /// 44 | /// or 45 | /// 46 | /// GameEvents.someEventDataEvent.Add(new EventVoid.OnEvent(yourMethod)); 47 | /// 48 | /// The method you want to add; must contain a single parameter 49 | /// of the type matching that in the host EventData 50 | public extern void Add(EventData.OnEvent evt); 51 | public extern static bool AddEventScene(string eventName, EventData.OnEvent evt, bool addToAll); 52 | public extern static bool AddEventUpwards(Transform transform, string eventName, EventData.OnEvent evt, bool addToAll); 53 | public extern static EventData FindEventScene(string eventName); 54 | public extern static List> FindEventsScene(string eventName); 55 | public extern static List> FindEventsUpwards(Transform transform, string eventName); 56 | public extern static EventData FindEventUpwards(Transform transform, string eventName); 57 | /// 58 | /// Triggers the EventData 59 | /// 60 | /// All of the methods added using Add are run after this. 61 | /// 62 | /// Single parameter matching the type of the host EventData 63 | /// Use this to give information relevant to the event 64 | public extern void Fire(T data); 65 | /// 66 | /// Remove a method from the list of methods to be run when the EventData is fired. 67 | /// 68 | /// This is generally done in an object's OnDestroy method. 69 | /// 70 | /// The method you want to remove; must contain a single parameter 71 | /// of a type matching that in the host EventData 72 | public extern void Remove(EventData.OnEvent evt); 73 | public extern static bool RemoveEventScene(string eventName, EventData.OnEvent evt, bool removeFromAll); 74 | public extern static bool RemoveEventUpwards(Transform transform, string eventName, EventData.OnEvent evt, bool removeFromAll); 75 | 76 | /// 77 | /// Any methods added to the event must match the delegate's parameters; 78 | /// one parameter of the given type in this case. 79 | /// 80 | /// 81 | public delegate void OnEvent(T data); 82 | } 83 | -------------------------------------------------------------------------------- /src/EventDataTU.cs: -------------------------------------------------------------------------------- 1 |  2 | using System; 3 | using System.Collections.Generic; 4 | using UnityEngine; 5 | 6 | /// 7 | /// A type used to generate GameEvents 8 | /// 9 | /// Use this type with two accompanying parameters 10 | /// 11 | /// The first type to be passed through on EventData.Fire() 12 | /// The second type to be passed through on EventData.Fire() 13 | public class EventData 14 | { 15 | /// 16 | /// Generate debug logs if true 17 | /// 18 | public bool debugEvent; 19 | 20 | /// 21 | /// The constructor used to create a new EventData 22 | /// 23 | /// EventData<Vessel, CelestialBody> myNewEvent = new EventData<Vessel, CelestialBody>("myNewEvent"); 24 | /// 25 | /// Give the event a string name, 26 | /// generally the same as the declared name 27 | public extern EventData(string eventName); 28 | 29 | /// 30 | /// Add a method to be run when the EventData is fired. 31 | /// 32 | /// This is generally done in an object's Start or Awake method, or a class' constructor. 33 | /// 34 | /// Can be setup like: 35 | /// 36 | /// GameEvents.someEventDataEvent.Add(yourMethod); 37 | /// 38 | /// or 39 | /// 40 | /// GameEvents.someEventDataEvent.Add(new EventVoid.OnEvent(yourMethod)); 41 | /// 42 | /// The method you want to add; must contain two parameters 43 | /// of types matching those in the host EventData 44 | public extern void Add(EventData.OnEvent evt); 45 | public extern static bool AddEventScene(string eventName, EventData.OnEvent evt, bool addToAll); 46 | public extern static bool AddEventUpwards(Transform transform, string eventName, EventData.OnEvent evt, bool addToAll); 47 | public extern static EventData FindEventScene(string eventName); 48 | public extern static List> FindEventsScene(string eventName); 49 | public extern static List> FindEventsUpwards(Transform transform, string eventName); 50 | public extern static EventData FindEventUpwards(Transform transform, string eventName); 51 | /// 52 | /// Triggers the EventData 53 | /// 54 | /// All of the methods added using Add are run after this. 55 | /// 56 | /// A parameter matching the first type of the host EventData 57 | /// Use this to give information relevant to the event 58 | /// The second type of the host EventData 59 | public extern void Fire(T data0, U data1); 60 | /// 61 | /// Remove a method from the list of methods to be run when the EventData is fired. 62 | /// 63 | /// This is generally done in an object's OnDestroy method. 64 | /// 65 | /// The method you want to remove; must contain two parameters 66 | /// of types matching those in the host EventData 67 | public extern void Remove(EventData.OnEvent evt); 68 | public extern static bool RemoveEventScene(string eventName, EventData.OnEvent evt, bool removeFromAll); 69 | public extern static bool RemoveEventUpwards(Transform transform, string eventName, EventData.OnEvent evt, bool removeFromAll); 70 | 71 | /// 72 | /// Any methods added to the event must match the delegate's parameters; 73 | /// two parameters of the given types in this case. 74 | /// 75 | /// 76 | /// 77 | public delegate void OnEvent(T data0, U data1); 78 | } 79 | -------------------------------------------------------------------------------- /src/EventDataTUV.cs: -------------------------------------------------------------------------------- 1 |  2 | using System; 3 | using System.Collections.Generic; 4 | using UnityEngine; 5 | 6 | /// 7 | /// A type used to generate GameEvents 8 | /// 9 | /// Use this type with three accompanying parameters 10 | /// 11 | /// The first type to be passed through on EventData.Fire() 12 | /// The second type to be passed through on EventData.Fire() 13 | /// The third type to be passed through on EventData.Fire() 14 | public class EventData 15 | { 16 | /// 17 | /// Generate debug logs if true 18 | /// 19 | public bool debugEvent; 20 | 21 | /// 22 | /// The constructor used to create a new EventData 23 | /// 24 | /// EventData<Vessel, CelestialBody, String> myNewEvent = new EventData<Vessel, CelestialBody, String>("myNewEvent"); 25 | /// 26 | /// Give the event a string name, 27 | /// generally the same as the declared name 28 | public extern EventData(string eventName); 29 | 30 | /// 31 | /// Add a method to be run when the EventData is fired. 32 | /// 33 | /// This is generally done in an object's Start or Awake method, or a class' constructor. 34 | /// 35 | /// Can be setup like: 36 | /// 37 | /// GameEvents.someEventDataEvent.Add(yourMethod); 38 | /// 39 | /// or 40 | /// 41 | /// GameEvents.someEventDataEvent.Add(new EventVoid.OnEvent(yourMethod)); 42 | /// 43 | /// The method you want to add; must contain three parameters 44 | /// matching the types of in the host EventData 45 | public extern void Add(EventData.OnEvent evt); 46 | public extern static bool AddEventScene(string eventName, EventData.OnEvent evt, bool addToAll); 47 | public extern static bool AddEventUpwards(Transform transform, string eventName, EventData.OnEvent evt, bool addToAll); 48 | public extern static EventData FindEventScene(string eventName); 49 | public extern static List> FindEventsScene(string eventName); 50 | public extern static List> FindEventsUpwards(Transform transform, string eventName); 51 | public extern static EventData FindEventUpwards(Transform transform, string eventName); 52 | /// 53 | /// Triggers the EventData 54 | /// 55 | /// All of the methods added using Add are run after this. 56 | /// 57 | /// A parameter matching the first type of the host EventData 58 | /// Use this to give information relevant to the event 59 | /// The second type of the host EventData 60 | /// The third type of the host EventData 61 | public extern void Fire(T data0, U data1, V data2); 62 | /// 63 | /// Remove a method from the list of methods to be run when the EventData is fired. 64 | /// 65 | /// This is generally done in an object's OnDestroy method. 66 | /// 67 | /// The method you want to remove; must contain three parameters 68 | /// matching the types of in the host EventData 69 | public extern void Remove(EventData.OnEvent evt); 70 | public extern static bool RemoveEventScene(string eventName, EventData.OnEvent evt, bool removeFromAll); 71 | public extern static bool RemoveEventUpwards(Transform transform, string eventName, EventData.OnEvent evt, bool removeFromAll); 72 | 73 | /// 74 | /// Any methods added to the event must match the delegate's parameters; 75 | /// three parameters of the given types in this case. 76 | /// 77 | /// 78 | /// 79 | /// 80 | public delegate void OnEvent(T data0, U data1, V data2); 81 | } 82 | -------------------------------------------------------------------------------- /src/EventReport.cs: -------------------------------------------------------------------------------- 1 |  2 | using System; 3 | 4 | /// 5 | /// A type frequently used as a parameter in GameEvents 6 | /// 7 | public class EventReport 8 | { 9 | /// 10 | /// An enum used to specify the type of EventReport; 11 | /// see FlightEvents for the available types 12 | /// 13 | public FlightEvents eventType; 14 | /// 15 | /// A string message that can accompany the EventReport 16 | /// 17 | public string msg; 18 | /// 19 | /// The Part responsible for generating the EventReport 20 | /// 21 | public Part origin; 22 | /// 23 | /// Usually the originating part name 24 | /// 25 | public string other; 26 | /// 27 | /// The target of the event; 28 | /// another part's name, the surface, blank, etc... 29 | /// 30 | public string sender; 31 | /// 32 | /// The active stage number when the EventReport is generated; 33 | /// can be set to any integer; 0 by default 34 | /// 35 | public int stage; 36 | 37 | /// 38 | /// The EventReport constructor, generally used when firing an EventData event 39 | /// that calls for an EventReport parameter 40 | /// 41 | /// someEvent.Fire(new EventReport(...)); 42 | /// 43 | /// 44 | /// 45 | /// 46 | /// 47 | /// 48 | /// 49 | public extern EventReport(FlightEvents type, Part eventCreator, string name = "an unidentified object", string otherName = "an unidentified object", int stageNumber = 0, string customMsg = ""); 50 | } 51 | -------------------------------------------------------------------------------- /src/EventVoid.cs: -------------------------------------------------------------------------------- 1 |  2 | using System; 3 | using System.Collections.Generic; 4 | using UnityEngine; 5 | 6 | /// 7 | /// A type used to generate GameEvents 8 | /// 9 | /// Use this type when there is no need to accompany the event with any parameters, 10 | /// ie relevant Part, Vessel, CelestialBody, etc... 11 | /// 12 | /// See EventData for events that require such extra information 13 | /// 14 | public class EventVoid 15 | { 16 | /// 17 | /// Generate debug logs if true 18 | /// 19 | public bool debugEvent; 20 | 21 | /// 22 | /// The constructor used to create a new EventVoid 23 | /// 24 | /// EventVoid myNewEvent = new EventVoid("myNewEvent"); 25 | /// 26 | /// Give the event a string name, 27 | /// generally the same as the declared name 28 | public extern EventVoid(string eventName); 29 | 30 | /// 31 | /// Add a method to be run when the EventVoid is fired. 32 | /// 33 | /// This is generally done in an object's Start or Awake method, or a class' constructor. 34 | /// 35 | /// Can be setup like: 36 | /// 37 | /// GameEvents.someEventVoidEvent.Add(yourMethod); 38 | /// 39 | /// or 40 | /// 41 | /// GameEvents.someEventVoidEvent.Add(new EventVoid.OnEvent(yourMethod)); 42 | /// 43 | /// The method you want to add, should contain no parameters 44 | public extern void Add(EventVoid.OnEvent evt); 45 | public extern static bool AddEventScene(string eventName, EventVoid.OnEvent evt, bool addToAll); 46 | public extern static bool AddEventUpwards(Transform transform, string eventName, EventVoid.OnEvent evt, bool addToAll); 47 | public extern static EventVoid FindEventScene(string eventName); 48 | public extern static List FindEventsScene(string eventName); 49 | public extern static List FindEventsUpwards(Transform transform, string eventName); 50 | public extern static EventVoid FindEventUpwards(Transform transform, string eventName); 51 | /// 52 | /// Triggers the EventVoid 53 | /// 54 | /// All of the methods added using Add are run after this. 55 | /// 56 | public extern void Fire(); 57 | /// 58 | /// Remove a method from the list of methods to be run when the EventVoid is fired. 59 | /// 60 | /// This is generally done in an object's OnDestroy method. 61 | /// 62 | /// The method you want to remove, should contain no parameters 63 | public extern void Remove(EventVoid.OnEvent evt); 64 | public extern static bool RemoveEventScene(string eventName, EventVoid.OnEvent evt, bool removeFromAll); 65 | public extern static bool RemoveEventUpwards(Transform transform, string eventName, EventVoid.OnEvent evt, bool removeFromAll); 66 | 67 | /// 68 | /// Any methods added to the event must match the delegate's parameters; none in this case 69 | /// 70 | public delegate void OnEvent(); 71 | } 72 | -------------------------------------------------------------------------------- /src/File.cs: -------------------------------------------------------------------------------- 1 | #region Assembly Assembly-CSharp.dll, v2.0.50727 2 | // C:\greg\games\KSP 0.18.2\KSP_Data\Managed\Assembly-CSharp.dll 3 | #endregion 4 | 5 | using System; 6 | 7 | namespace KSP.IO 8 | { 9 | public class File 10 | { 11 | public extern File(); 12 | 13 | /// 14 | /// Append a string to a file, or creates it if it doesn't exist. 15 | /// 16 | /// 17 | /// 18 | /// 19 | /// 20 | public extern static void AppendAllText(string data, string filename, Vessel flight = null); 21 | /// 22 | /// Open a stream that appends to a file. 23 | /// 24 | /// 25 | /// 26 | /// 27 | /// 28 | public extern static TextWriter AppendText(string filename, Vessel flight = null); 29 | /// 30 | /// Open a stream that creates a file. 31 | /// 32 | /// 33 | /// 34 | /// 35 | /// 36 | public extern static FileStream Create(string filename, Vessel flight = null); 37 | /// 38 | /// Open a stream that creates a file. 39 | /// 40 | /// 41 | /// 42 | /// 43 | /// 44 | public extern static TextWriter CreateText(string filename, Vessel flight = null); 45 | /// 46 | /// Delete a file in your IO sandbox. 47 | /// 48 | /// 49 | /// 50 | /// 51 | public extern static void Delete(string filename, Vessel flight = null); 52 | /// 53 | /// Find out if a file in your IO sandbox exists. 54 | /// 55 | /// 56 | /// 57 | /// 58 | /// 59 | public extern static bool Exists(string filename, Vessel flight = null); 60 | /// 61 | /// Open a stream that operates on a file. 62 | /// 63 | /// 64 | /// 65 | /// 66 | /// 67 | /// 68 | public extern static FileStream Open(string filename, FileMode mode, Vessel flight = null); 69 | /// 70 | /// Open a stream that operates on a file. 71 | /// 72 | /// 73 | /// 74 | /// 75 | /// 76 | public extern static TextReader OpenText(string filename, Vessel flight = null); 77 | /// 78 | /// Open a stream that writes to a file. 79 | /// 80 | /// 81 | /// 82 | /// 83 | /// 84 | public extern static FileStream OpenWrite(string filename, Vessel flight = null); 85 | /// 86 | /// Read all the bytes from a file in your IO sandbox. 87 | /// 88 | /// 89 | /// 90 | /// 91 | public extern static byte[] ReadAllBytes(string filename, Vessel flight = null); 92 | /// 93 | /// Read all lines from a file in your IO sandbox. 94 | /// 95 | /// 96 | /// 97 | /// 98 | /// 99 | public extern static string[] ReadAllLines(string filename, Vessel flight = null); 100 | /// 101 | /// Read all the text from a file in your IO sandbox. 102 | /// 103 | /// 104 | /// 105 | /// 106 | /// 107 | public extern static string ReadAllText(string filename, Vessel flight = null); 108 | /// 109 | /// Write a bunch of bytes to a file on disk 110 | /// 111 | /// 112 | /// 113 | /// 114 | /// 115 | public extern static void WriteAllBytes(byte[] data, string filename, Vessel flight = null); 116 | /// 117 | /// Write an array of strings to a file, with each string becoming a line. 118 | /// 119 | /// 120 | /// 121 | /// 122 | /// 123 | public extern static void WriteAllLines(string[] data, string filename, Vessel flight = null); 124 | /// 125 | /// Write a string to a file. 126 | /// 127 | /// 128 | /// 129 | /// 130 | /// 131 | public extern static void WriteAllText(string data, string filename, Vessel flight = null); 132 | } 133 | } 134 | -------------------------------------------------------------------------------- /src/FileInfo.cs: -------------------------------------------------------------------------------- 1 | #region Assembly Assembly-CSharp.dll, v2.0.50727 2 | // C:\greg\games\KSP 0.18.2\KSP_Data\Managed\Assembly-CSharp.dll 3 | #endregion 4 | 5 | using System; 6 | 7 | namespace KSP.IO 8 | { 9 | /// 10 | /// A surrogate for System.IO.FileInfo. 11 | /// 12 | public class FileInfo 13 | { 14 | /// 15 | /// Gets a string representing the directory's full path. 16 | /// 17 | public extern string DirectoryName { get; } 18 | /// 19 | /// Gets a value indicating whether a file exists. 20 | /// 21 | public extern bool Exists { get; } 22 | /// 23 | /// Gets or sets a value that determines if the current file is read only. 24 | /// 25 | public extern bool IsReadOnly { get; set; } 26 | /// 27 | /// Gets the size, in bytes, of the current file. 28 | /// 29 | public extern long Length { get; } 30 | /// 31 | /// Gets the name of the file. 32 | /// 33 | public extern string Name { get; } 34 | 35 | /// 36 | /// Creates a System.IO.StreamWriter that appends text to the file represented by this instance of the System.IO.FileInfo. 37 | /// 38 | /// 39 | public extern TextWriter AppendText(); 40 | /// 41 | /// Copies an existing file to a new file, disallowing the overwriting of an existing file. 42 | /// 43 | /// 44 | /// 45 | public extern FileInfo CopyTo(string destFileName); 46 | /// 47 | /// Copies an existing file to a new file, allowing the overwriting of an existing file. 48 | /// 49 | /// 50 | /// 51 | /// 52 | public extern FileInfo CopyTo(string destFileName, bool overwrite); 53 | /// 54 | /// Creates a file. 55 | /// 56 | /// 57 | public extern FileStream Create(); 58 | /// 59 | /// Create a text reader stream. 60 | /// 61 | /// 62 | /// 63 | /// 64 | /// 65 | public extern static FileInfo CreateForType(string filename, Vessel flight = null); 66 | /// 67 | /// Creates a KSP.IO.TextWriter that writes a new text file. 68 | /// 69 | /// 70 | public extern TextWriter CreateText(); 71 | /// 72 | /// Decrypts a file that was encrypted by the current account using the System.IO.FileInfo.Encrypt() method. 73 | /// 74 | public extern void Decrypt(); 75 | /// 76 | /// Permanently deletes a file. 77 | /// 78 | public extern void Delete(); 79 | /// 80 | /// Encrypts a file so that only the account used to encrypt the file can decrypt it. 81 | /// 82 | public extern void Encrypt(); 83 | /// 84 | /// Moves a specified file to a new location, providing the option to specify a new file name. 85 | /// 86 | /// 87 | public extern void MoveTo(string destFileName); 88 | /// 89 | /// Opens a file in the specified mode. 90 | /// 91 | /// 92 | /// 93 | public extern FileStream Open(FileMode mode); 94 | /// 95 | /// Opens a file in the specified mode with read, write, or read/write access. 96 | /// 97 | /// 98 | /// 99 | /// 100 | public extern FileStream Open(FileMode mode, FileAccess access); 101 | /// 102 | /// Opens a file in the specified mode with read, write, or read/write access and the specified sharing option. 103 | /// 104 | /// 105 | /// 106 | /// 107 | /// 108 | public extern FileStream Open(FileMode mode, FileAccess access, FileShare share); 109 | /// 110 | /// Creates a read-only System.IO.FileStream. 111 | /// 112 | /// 113 | public extern FileStream OpenRead(); 114 | /// 115 | /// Creates a System.IO.StreamReader with UTF8 encoding that reads from an existing text file. 116 | /// 117 | /// 118 | public extern TextReader OpenText(); 119 | /// 120 | /// Creates a write-only System.IO.FileStream. 121 | /// 122 | /// 123 | public extern FileStream OpenWrite(); 124 | /// 125 | /// Replaces the contents of a specified file with the file described by the current System.IO.FileInfo object, deleting the original file, and creating a backup of the replaced file. 126 | /// 127 | /// 128 | /// 129 | /// 130 | public extern FileInfo Replace(string destinationFileName, string destinationBackupFileName); 131 | /// 132 | /// Replaces the contents of a specified file with the file described by the current System.IO.FileInfo object, deleting the original file, and creating a backup of the replaced file. Also specifies whether to ignore merge errors. 133 | /// 134 | /// 135 | /// 136 | /// 137 | /// 138 | public extern FileInfo Replace(string destinationFileName, string destinationBackupFileName, bool ignoreMetadataErrors); 139 | /// 140 | /// Returns the path as a string. 141 | /// 142 | /// 143 | public extern string ToString(); 144 | } 145 | } 146 | -------------------------------------------------------------------------------- /src/FlightCamera.cs: -------------------------------------------------------------------------------- 1 | #region Assembly Assembly-CSharp.dll, v2.0.50727 2 | // C:\greg\games\KSP 0.18.2\KSP_Data\Managed\Assembly-CSharp.dll 3 | #endregion 4 | 5 | using System; 6 | using UnityEngine; 7 | 8 | /// 9 | /// This class is related to control of the main camera used in the flight scene. Its transform is the 10 | /// parent of the actual Camera objects. 11 | /// 12 | public class FlightCamera : MonoBehaviour 13 | { 14 | public FlightCamera.Modes autoMode; 15 | public Camera[] cameras; 16 | public float cameraWobbleSensitivity; 17 | public float camHdg; 18 | public float camPitch; 19 | public Vector3 endDirection; 20 | /// 21 | /// Returns the singleton FlightCamera object. 22 | /// 23 | public static FlightCamera fetch; 24 | public FoRModes FoRMode; 25 | public float fovDefault; 26 | public float maxDistance; 27 | public float maxPitch; 28 | public float minDistance; 29 | public float minHeight; 30 | public float minHeightAtMaxDist; 31 | public float minHeightAtMinDist; 32 | public float minPitch; 33 | public FlightCamera.Modes mode; 34 | public GUIStyle modeReadoutStyle; 35 | public float orbitSensitivity; 36 | public float orientationSharpness; 37 | public float pivotTranslateSharpness; 38 | public float sharpness; 39 | public float startDistance; 40 | public Vector3 targetDirection; 41 | public bool updateActive; 42 | public float zoomScaleFactor; 43 | 44 | public extern FlightCamera(); 45 | 46 | /// 47 | /// You can set this to change the look direction of the in-flight camera (value is in radians). 48 | /// 49 | public extern static float CamHdg { get; set; } 50 | public extern static int CamMode { get; } 51 | /// 52 | /// You can set this to change the look direction of the in-flight camera (value is in radians). 53 | /// 54 | public extern static float CamPitch { get; set; } 55 | public extern float Distance { get; } 56 | public extern static FoRModes FrameOfReferenceMode { get; } 57 | public extern Quaternion pivotRotation { get; } 58 | 59 | /// 60 | /// Enables mouse control of the camera. 61 | /// 62 | public extern void ActivateUpdate(); 63 | /// 64 | /// Disables mouse control of the camera. 65 | /// 66 | public extern void DeactivateUpdate(); 67 | public extern void DisableCamera(); 68 | public extern void EnableCamera(); 69 | public extern void ResetFoV(); 70 | public extern void SetDistance(float dist); 71 | public extern void SetDistanceImmediate(float dist); 72 | public extern void SetFoV(); 73 | public extern void SetFoV(float fov); 74 | public extern void setMode(FlightCamera.Modes m); 75 | public extern static void SetMode(FlightCamera.Modes m); 76 | public extern void setModeImmediate(FlightCamera.Modes m); 77 | public extern static void SetModeImmediate(FlightCamera.Modes m); 78 | public extern void SetNextMode(); 79 | public extern void setTarget(Transform tgt); 80 | public extern static void SetTarget(Transform tgt); 81 | 82 | public enum Modes 83 | { 84 | AUTO = 0, 85 | FREE = 1, 86 | ORBITAL = 2, 87 | CHASE = 3, 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /src/FlightCtrlState.cs: -------------------------------------------------------------------------------- 1 | #region Assembly Assembly-CSharp.dll, v2.0.50727 2 | // C:\greg\games\KSP 0.18.2\KSP_Data\Managed\Assembly-CSharp.dll 3 | #endregion 4 | 5 | using System; 6 | 7 | /// 8 | /// A FlightCtrlState is a snapshot of the state of all control inputs to a vessel at a given instant in time. 9 | /// See FlightInputHandler.state and Vessel.OnFlyByWire. 10 | /// 11 | public class FlightCtrlState 12 | { 13 | /// 14 | /// Unused? 15 | /// 16 | public float fastThrottle; 17 | /// 18 | /// Unused? Landing gear are lowered by sending an Event. 19 | /// 20 | public bool gearDown; 21 | /// 22 | /// Unused? Landing gear are raised by sending an Event. 23 | /// 24 | public bool gearUp; 25 | /// 26 | /// Presumably, whether the EVA headlight is turned on. 27 | /// 28 | public bool headlight; 29 | /// 30 | /// Whether SAS is turned on. 31 | /// 32 | public bool killRot; 33 | /// 34 | /// The throttle setting; this must be between 0 and 1. 35 | /// 36 | public float mainThrottle; 37 | /// 38 | /// The pitch control input; this must be between -1 and 1. 39 | /// 40 | public float pitch; 41 | /// 42 | /// Presumably, the pitch trim setting, i.e., the pitch input that will 43 | /// be given if no other input is given. 44 | /// 45 | public float pitchTrim; 46 | /// 47 | /// The roll control input; this must be between -1 and 1. 48 | /// 49 | public float roll; 50 | /// 51 | /// Presumably, the roll trim setting, i.e., the roll input that will 52 | /// be given if no other input is given. 53 | /// 54 | public float rollTrim; 55 | /// 56 | /// The RCS x-axis control input. 57 | /// 58 | public float X; 59 | /// 60 | /// The RCS y-axis control input. 61 | /// 62 | public float Y; 63 | /// 64 | /// The yaw control input; this must be between -1 and 1. 65 | /// 66 | public float yaw; 67 | /// 68 | /// Presumably, the yaw trim input; i.e., the yaw input that will be 69 | /// given if no other input is given. 70 | /// 71 | public float yawTrim; 72 | /// 73 | /// The RCS z-axis control input. 74 | /// 75 | public float Z; 76 | 77 | public extern FlightCtrlState(); 78 | 79 | /// 80 | /// Presumably, whether this flight control represents "neutral" controls, i.e., no input and zero throttle. 81 | /// 82 | public extern bool isNeutral { get; } 83 | 84 | /// 85 | /// Presumably, copies the state of the FlightCtrlState st into this FlightCtrlState object. 86 | /// 87 | /// 88 | public extern void CopyFrom(FlightCtrlState st); 89 | } 90 | -------------------------------------------------------------------------------- /src/FlightInputHandler.cs: -------------------------------------------------------------------------------- 1 | #region Assembly Assembly-CSharp.dll, v2.0.50727 2 | // C:\greg\games\KSP 0.18.2\KSP_Data\Managed\Assembly-CSharp.dll 3 | #endregion 4 | 5 | using System; 6 | using UnityEngine; 7 | 8 | /// 9 | /// FlightInputHandler stores some global information about the control of the current active vessel. 10 | /// 11 | public class FlightInputHandler : MonoBehaviour 12 | { 13 | public static int currentTarget; 14 | /// 15 | /// Use this FlightInputHandler instance to access non-static members of the class. 16 | /// 17 | public static FlightInputHandler fetch; 18 | public bool hasFocus; 19 | public Renderer[] inputGaugeRenderers; 20 | [Obsolete("Use vessel.OnFlyByWire instead.")] 21 | public static FlightInputCallback OnFlyByWire; 22 | /// 23 | /// Presumably, whether precision mode is engaged. 24 | /// 25 | public bool precisionMode; 26 | public float rcsDeadZone; 27 | /// 28 | /// Whether RCS is enabled. 29 | /// 30 | public bool rcslock; 31 | /// 32 | /// Presumably, whether staging has been locked via Alt-L. 33 | /// 34 | public bool stageLock; 35 | /// 36 | /// The FlightCtrlState that represents player input. You can change the on-screen throttle 37 | /// by setting FlightCtrlState.state.mainThrottle. 38 | /// 39 | public static FlightCtrlState state; 40 | public float throttleResponsiveness; 41 | 42 | public extern FlightInputHandler(); 43 | 44 | /// 45 | /// Whether RCS is enabled. 46 | /// 47 | public extern static bool RCSLock { get; } 48 | 49 | public extern void OnDestroy(); 50 | /// 51 | /// Call this to set neutral controls; in particular this wil turn off the throttle. 52 | /// 53 | public extern static void SetNeutralControls(); 54 | } 55 | -------------------------------------------------------------------------------- /src/FloatCurve.cs: -------------------------------------------------------------------------------- 1 | #region Assembly Assembly-CSharp.dll, v2.0.50727 2 | // C:\greg\games\KSP 0.18.2\KSP_Data\Managed\Assembly-CSharp.dll 3 | #endregion 4 | 5 | using System; 6 | 7 | /// 8 | /// Represents a function of one variable. The function is interpolated from a given set of points, 9 | /// and optionally the tangents at those points can be specified. 10 | /// 11 | [Serializable] 12 | public class FloatCurve /* : IConfigNode */ 13 | { 14 | public extern FloatCurve(); 15 | 16 | public extern float maxTime { get; } 17 | public extern float minTime { get; } 18 | 19 | public extern void Add(float time, float value); 20 | public extern void Add(float time, float value, float inTangent, float outTangent); 21 | /// 22 | /// Evaluate the function at a given value of the input parameter. 23 | /// 24 | /// The input parameter (not necessarily a time). 25 | /// The value of the function. 26 | public extern float Evaluate(float time); 27 | public void Load(ConfigNode node) { } 28 | public void Save(ConfigNode node) { } 29 | } 30 | -------------------------------------------------------------------------------- /src/FuelLine.cs: -------------------------------------------------------------------------------- 1 | #region Assembly Assembly-CSharp.dll, v2.0.50727 2 | // C:\greg\games\KSP 0.18.2\KSP_Data\Managed\Assembly-CSharp.dll 3 | #endregion 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | using UnityEngine; 8 | 9 | /// 10 | /// Stock fuel lines are not yet PartModules, but are implemented through this class. 11 | /// 12 | public class FuelLine : Part 13 | { 14 | public Vector3 direction; 15 | public Transform endCap; 16 | public FuelLine.FuelFlowDirection flowDirection; 17 | public bool fuelLineOpen; 18 | public Part fuelLookupTarget; 19 | public Transform line; 20 | public float maxLength; 21 | public Transform startCap; 22 | /// 23 | /// The part that can draw fuel through this fuel line. This fuel line in turn draws fuel from its parent. 24 | /// 25 | public Part target; 26 | public Transform targetAnchor; 27 | public Vector3 targetPosition; 28 | 29 | public extern FuelLine(); 30 | 31 | public extern void BreakLine(); 32 | public extern void CloseFuelLine(); 33 | public extern override bool FindFuel(Part source, List fuelSources, uint reqId); 34 | public extern override void onBackup(); 35 | protected extern override void onCopy(Part original, bool asSymCPart); 36 | public extern override void OnDrawStats(); 37 | protected extern override void onEditorUpdate(); 38 | protected extern override void onFlightStart(); 39 | protected extern override void onPartAttach(Part parent); 40 | protected extern override void onPartDestroy(); 41 | protected extern override void onPartDetach(); 42 | protected extern override void onPartFixedUpdate(); 43 | protected extern override void onPartLoad(); 44 | protected extern override void onPartStart(); 45 | public extern bool raycastTarget(); 46 | public extern bool raycastTarget(Vector3 dir); 47 | public extern override bool RequestFuel(Part requester, float amount, uint reqId); 48 | public extern void SetFuelSource(Part requester); 49 | 50 | public enum FuelFlowDirection 51 | { 52 | AUTO = 0, 53 | TO_PARENT = 1, 54 | TO_TARGET = 2, 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/FuelTank.cs: -------------------------------------------------------------------------------- 1 | #region Assembly Assembly-CSharp.dll, v2.0.50727 2 | // C:\greg\games\KSP 0.18.2\KSP_Data\Managed\Assembly-CSharp.dll 3 | #endregion 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | 8 | /// 9 | /// The old, deprecated class that implemented fuel tanks before the resource system. 10 | /// Don't use this class: to allow a part to store a resource add a RESOURCE block to the part.cfg. 11 | /// 12 | public class FuelTank : Part 13 | { 14 | [KSPField] 15 | public bool allowFlow; 16 | [KSPField(guiName = "Flow Rate", guiUnits = "L/sec", guiFormat = "0.0", isPersistant = false, guiActive = true)] 17 | public float drainRate; 18 | public float dryMass; 19 | public float emptyExplosionPotential; 20 | [KSPField(guiName = "Fuel", guiUnits = "L", guiFormat = "F1", isPersistant = false, guiActive = true)] 21 | public float fuel; 22 | public float fullExplosionPotential; 23 | 24 | public extern FuelTank(); 25 | 26 | public extern override bool DrainFuel(float amount); 27 | public extern override bool FindFuel(Part source, List fuelSources, uint reqId); 28 | protected extern override void onDecouple(float breakForce); 29 | public extern override void OnDrawStats(); 30 | protected extern override void onFlightStart(); 31 | public extern override void onFlightStateLoad(Dictionary parsedData); 32 | public extern override void onFlightStateSave(Dictionary partDataCollection); 33 | protected extern override bool onPartActivate(); 34 | protected extern override void onPartAwake(); 35 | protected extern override void onPartFixedUpdate(); 36 | protected extern override void onPartStart(); 37 | public extern override bool RequestFuel(Part source, float amount, uint reqId); 38 | } 39 | -------------------------------------------------------------------------------- /src/FuelTankGUI.cs: -------------------------------------------------------------------------------- 1 | #region Assembly Assembly-CSharp.dll, v2.0.50727 2 | // C:\greg\games\KSP 0.18.2\KSP_Data\Managed\Assembly-CSharp.dll 3 | #endregion 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | 8 | /// 9 | /// An unused class. 10 | /// 11 | public class FuelTankGUI : Part 12 | { 13 | [KSPField(guiName = "Flow", guiActive = true)] 14 | public bool allowFlow; 15 | public float drainRate; 16 | public float dryMass; 17 | public float ejectionForce; 18 | public float emptyExplosionPotential; 19 | [KSPField(guiName = "Fuel", guiUnits = "L", guiActive = true)] 20 | public float fuel; 21 | public float fullExplosionPotential; 22 | 23 | public extern FuelTankGUI(); 24 | 25 | protected extern override void onDecouple(float breakForce); 26 | public extern override void OnDrawStats(); 27 | protected extern override void onFlightStart(); 28 | public extern override void onFlightStateLoad(Dictionary parsedData); 29 | public extern override void onFlightStateSave(Dictionary partDataCollection); 30 | protected extern override bool onPartActivate(); 31 | protected extern override void onPartAwake(); 32 | protected extern override void onPartStart(); 33 | public extern override bool RequestFuel(Part source, float amount, uint reqId); 34 | } 35 | -------------------------------------------------------------------------------- /src/GamePersistence.cs: -------------------------------------------------------------------------------- 1 | #region Assembly Assembly-CSharp.dll, v2.0.50727 2 | // C:\greg\games\KSP 0.18.2\KSP_Data\Managed\Assembly-CSharp.dll 3 | #endregion 4 | 5 | using System; 6 | using UnityEngine; 7 | 8 | /// 9 | /// Contains some functions you can call to save the game state to a persistence file, or load the game state from a persistence file. 10 | /// 11 | public class GamePersistence : MonoBehaviour 12 | { 13 | public extern GamePersistence(); 14 | 15 | public extern static FlightState LoadFlightState(string filename, string saveFolder, bool haltIfIncompatible, bool suppressErrorMessage); 16 | public extern static Game LoadGame(string filename, string saveFolder, bool haltIfIncompatible, bool suppressErrorMessage); 17 | public extern static string SaveFlightState(string saveFileName, string saveFolder, SaveMode saveMode); 18 | public extern static string SaveFlightState(FlightState st, string saveFileName, string saveFolder, SaveMode saveMode); 19 | /// 20 | /// Creates a persistence file containing the current game state. Probably persistent.sfs and quicksave.sfs are 21 | /// generated by calls to this function. 22 | /// 23 | /// The name of the persistence file to create (".sfs" will be appended to the file name). 24 | /// The folder in which to create the save file. Try using HighLogic.SaveFolder. 25 | /// Whether to overwrite, append, or abort if the given file already exists. 26 | /// Returns the filename on success. Returns an empty string when the file already exists and SaveMode.ABORT is used. 27 | public extern static string SaveGame(string saveFileName, string saveFolder, SaveMode saveMode); 28 | public extern static string SaveGame(Game game, string saveFileName, string saveFolder, SaveMode saveMode); 29 | } 30 | -------------------------------------------------------------------------------- /src/GameScenes.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | /// 4 | /// An enum corresponding to the different Unity scenes in KSP 5 | /// 6 | public enum GameScenes 7 | { 8 | LOADING = 0, 9 | LOADINGBUFFER = 1, 10 | MAINMENU = 2, 11 | SETTINGS = 3, 12 | CREDITS = 4, 13 | SPACECENTER = 5, 14 | EDITOR = 6, 15 | FLIGHT = 7, 16 | TRACKSTATION = 8, 17 | SPH = 9, 18 | PSYSTEM = 10, 19 | } 20 | -------------------------------------------------------------------------------- /src/HighLogic.cs: -------------------------------------------------------------------------------- 1 | #region Assembly Assembly-CSharp.dll, v2.0.50727 2 | // C:\greg\games\KSP 0.18.2\KSP_Data\Managed\Assembly-CSharp.dll 3 | #endregion 4 | 5 | using System; 6 | using UnityEngine; 7 | 8 | 9 | /// 10 | /// This class stores some very high-level information about the current game state. 11 | /// 12 | public class HighLogic : MonoBehaviour 13 | { 14 | public Game currentGame; 15 | public static bool FastEditorLoading; 16 | /// 17 | /// Use this instance to access non-static members of this class. 18 | /// 19 | public static HighLogic fetch; 20 | public string GameSaveFolder; 21 | public static GameScenes LoadedScene; 22 | public static bool LoadedSceneHasPlanetarium; 23 | /// 24 | /// Whether the game is currently in the VAB or SPH scenes. 25 | /// 26 | public static bool LoadedSceneIsEditor; 27 | /// 28 | /// Whether the game is currently in the flight scene. 29 | /// 30 | public static bool LoadedSceneIsFlight; 31 | public int maxLines; 32 | public bool showConsole; 33 | public bool showConsoleOnError; 34 | public GUISkin skin; 35 | 36 | public extern HighLogic(); 37 | 38 | public extern static Game CurrentGame { get; set; } 39 | public extern static string SaveFolder { get; set; } 40 | /// 41 | /// The GUISkin used by the game. Set GUI.skin = HighLogic.Skin at the start of your GUI function to use it yourself. 42 | /// 43 | public extern static GUISkin Skin { get; } 44 | 45 | public extern static void LoadScene(GameScenes scene); 46 | [ContextMenu("Debug Current Game")] 47 | public extern void printCurrentGame(); 48 | 49 | public enum VK 50 | { 51 | BACK = 8, 52 | TAB = 9, 53 | RETURN = 13, 54 | SHIFT = 16, 55 | CONTROL = 17, 56 | MENU = 18, 57 | ESCAPE = 27, 58 | PRIOR = 33, 59 | NEXT = 34, 60 | END = 35, 61 | HOME = 36, 62 | LEFT = 37, 63 | UP = 38, 64 | RIGHT = 39, 65 | DOWN = 40, 66 | SELECT = 41, 67 | PRINT = 42, 68 | EXECUTE = 43, 69 | SNAPSHOT = 44, 70 | INSERT = 45, 71 | DELETE = 46, 72 | HELP = 47, 73 | LWIN = 91, 74 | RWIN = 92, 75 | NUMPAD0 = 96, 76 | NUMPAD1 = 97, 77 | NUMPAD2 = 98, 78 | NUMPAD3 = 99, 79 | NUMPAD4 = 100, 80 | NUMPAD5 = 101, 81 | NUMPAD6 = 102, 82 | NUMPAD7 = 103, 83 | NUMPAD8 = 104, 84 | NUMPAD9 = 105, 85 | MULTIPLY = 106, 86 | ADD = 107, 87 | SEPARATOR = 108, 88 | SUBTRACT = 109, 89 | DECIMAL = 110, 90 | DIVIDE = 111, 91 | F1 = 112, 92 | F2 = 113, 93 | F3 = 114, 94 | F4 = 115, 95 | F5 = 116, 96 | F6 = 117, 97 | F7 = 118, 98 | F8 = 119, 99 | F9 = 120, 100 | F10 = 121, 101 | F11 = 122, 102 | F12 = 123, 103 | MEDIA_NEXT_TRACK = 176, 104 | MEDIA_PREV_TRACK = 177, 105 | MEDIA_STOP = 178, 106 | MEDIA_PLAY_PAUSE = 179, 107 | OEM_1 = 186, 108 | OEM_PLUS = 187, 109 | OEM_COMMA = 188, 110 | OEM_MINUS = 189, 111 | OEM_PERIOD = 190, 112 | OEM_2 = 191, 113 | OEM_3 = 192, 114 | } 115 | 116 | public class LogEntry 117 | { 118 | public string condition; 119 | public bool expanded; 120 | public LogType logType; 121 | public string stackTrace; 122 | 123 | public extern LogEntry(string condition, string stackTrace, LogType type); 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /src/IDiscoverable.cs: -------------------------------------------------------------------------------- 1 | /// Methods allowing information for celestial bodies or ships to be hidden at game start 2 | /// 3 | /// 4 | /// These methods appear to be used in the tracking station. 5 | /// 6 | /// Implemented by CelestialBody 7 | /// Implemented by Vessel 8 | /// 9 | public interface IDiscoverable 10 | { 11 | /// Describes to what extent this object has been explored 12 | DiscoveryInfo DiscoveryInfo { 13 | get; 14 | } 15 | 16 | /// Returns the object's altitude 17 | /// 18 | /// The height above the reference sphere of the Celestial Body in 19 | /// whose sphere of influence the object lies, in meters. 20 | /// 21 | double RevealAltitude (); 22 | 23 | /// Returns the object's mass 24 | /// 25 | /// Units are implementation-dependent. 26 | float RevealMass (); 27 | 28 | /// Returns the object's tracking station name 29 | /// 30 | /// The string to display in the tracking station 31 | /// 32 | string RevealName (); 33 | 34 | /// Describes the state of the object 35 | /// 36 | /// A string containing the sphere of influence and trajectory of the object 37 | /// 38 | /// "Orbiting the Sun" 39 | /// 40 | string RevealSituationString (); 41 | 42 | /// Returns the speed of the object 43 | /// 44 | /// The inertial speed relative to the Celestial Body in whose sphere of influence 45 | /// the object lies, in meters per second. 46 | /// 47 | double RevealSpeed (); 48 | 49 | /// Gives the type of object used 50 | /// 51 | /// Meaning is implementation-dependent. 52 | string RevealType (); 53 | } 54 | -------------------------------------------------------------------------------- /src/IOException.cs: -------------------------------------------------------------------------------- 1 | #region Assembly Assembly-CSharp.dll, v2.0.50727 2 | // C:\greg\games\KSP 0.18.2\KSP_Data\Managed\Assembly-CSharp.dll 3 | #endregion 4 | 5 | using System; 6 | 7 | namespace KSP.IO 8 | { 9 | /// 10 | /// A surrogate for System.IO.IOException. 11 | /// 12 | public class IOException : Exception 13 | { 14 | protected string message; 15 | protected string source; 16 | protected string stack; 17 | 18 | public extern IOException(string message, string source, string stack); 19 | 20 | public extern override string Message { get; } 21 | public extern override string Source { get; } 22 | public extern override string StackTrace { get; } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/IOUtils.cs: -------------------------------------------------------------------------------- 1 | #region Assembly Assembly-CSharp.dll, v2.0.50727 2 | // C:\greg\games\KSP 0.18.2\KSP_Data\Managed\Assembly-CSharp.dll 3 | #endregion 4 | 5 | using System; 6 | 7 | namespace KSP.IO 8 | { 9 | /// 10 | /// Has some useful little tools and utilities. 11 | /// 12 | public class IOUtils 13 | { 14 | public extern IOUtils(); 15 | 16 | /// 17 | /// Deserialize a binary serialized object 18 | /// 19 | /// 20 | /// 21 | public extern static object DeserializeFromBinary(byte[] input); 22 | /// 23 | /// Return the full path for a given filename, provided a class from the plugin. 24 | /// PluginData/[.flights/FLIGHT_UUID/]assemblyname/file 25 | /// 26 | /// 27 | /// 28 | /// 29 | /// 30 | public extern static string GetFilePathFor(Type T, string file, Vessel flight = null); 31 | /// 32 | /// Serialize an object (same as using a BinaryFormatter). 33 | /// 34 | /// 35 | /// 36 | public extern static byte[] SerializeToBinary(object something); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/IScienceDataContainer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | /// 4 | /// Interface used by ModuleScienceExperiment and ModuleScienceContainer. Used for storing, transfering and transmitting Science Data. 5 | /// 6 | public interface IScienceDataContainer 7 | { 8 | /// 9 | /// Removes science data from the part, called after transmission or EVA data collection. 10 | /// 11 | /// 12 | void DumpData(ScienceData data); 13 | /// 14 | /// Returns an array of all Science Data stored in the module. 15 | /// 16 | /// 17 | ScienceData[] GetData(); 18 | /// 19 | /// Returns a count of Science Data reports stored in the module. 20 | /// 21 | /// 22 | int GetScienceCount(); 23 | /// 24 | /// Can the experiment be run more than once? 25 | /// 26 | /// 27 | bool IsRerunnable(); 28 | /// 29 | /// Opens the experimental results dialog page, displays stored Science Data. 30 | /// 31 | void ReviewData(); 32 | /// 33 | /// Opens the experimental results dialog page, displays stored Science Data. 34 | /// 35 | /// 36 | void ReviewDataItem(ScienceData data); 37 | } 38 | -------------------------------------------------------------------------------- /src/InputLockManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | /// 5 | /// This class lets you lock the player out of certain controls. It's 6 | /// probably what KSP uses internally to lock controls during time warp, 7 | /// or when out of electric charge. 8 | /// 9 | /// 10 | /// You can view the current set of locks in-game with the Alt-F12 debug menu. 11 | /// 12 | public static class InputLockManager 13 | { 14 | public static ulong lockMask; 15 | /// 16 | /// The set of locks currently in place? 17 | /// 18 | public static Dictionary lockStack; 19 | 20 | /// 21 | /// If ControlTypes.X & LockMask != 0 then ControlTypes.X is locked? 22 | /// 23 | public static extern ulong LockMask { get; } 24 | 25 | public static extern void ClearControlLocks(); 26 | public static extern ControlTypes GetControlLock(string lockID); 27 | public static extern bool IsLocked(ControlTypes controlType); 28 | public static extern bool IsLocked(ControlTypes controlType, ControlTypes refMask); 29 | public static extern bool IsUnlocked(ControlTypes controlType); 30 | public static extern bool IsUnlocked(ControlTypes controlType, ControlTypes refMask); 31 | public static extern string PrintLockStack(); 32 | /// 33 | /// Unlock a set of controls that were earlier locked with SetControlLock. 34 | /// 35 | /// The string ID passed to SetControlLock. 36 | public static extern void RemoveControlLock(string lockID); 37 | public static extern ControlTypes SetControlLock(string lockID); 38 | /// 39 | /// Locks a set of controls. 40 | /// 41 | /// Which controls to lock. You can OR several ControlTypes together to lock several types of controls at once. 42 | /// A unique string ID that you will pass to RemoveControlLock to unlock these controls. 43 | /// ? 44 | public static extern ControlTypes SetControlLock(ControlTypes locks, string lockID); 45 | } 46 | -------------------------------------------------------------------------------- /src/KFSMEvent.cs: -------------------------------------------------------------------------------- 1 | #region Assembly Assembly-CSharp.dll, v2.0.50727 2 | // C:\greg\games\KSP 0.18.2\KSP_Data\Managed\Assembly-CSharp.dll 3 | #endregion 4 | 5 | using System; 6 | 7 | /// 8 | /// A KFSMEvent represents a possible transition between two KFSMStates in a KerbalFSM 9 | /// finite state machine. 10 | /// 11 | public class KFSMEvent 12 | { 13 | /// 14 | /// Which state to transition to when this event is triggered. 15 | /// 16 | public KFSMState GoToStateOnEvent; 17 | /// 18 | /// The name of the event. 19 | /// 20 | public string name; 21 | /// 22 | /// You can assign to this field a delegate that takes a KFSMState (the current state) 23 | /// and returns a bool. The function will be called each frame and if it returns true, 24 | /// the event is triggered. 25 | /// 26 | public KFSMEventCondition OnCheckCondition; 27 | /// 28 | /// You can assign a delegate to this field, and the delegate will be run when the event is triggered. 29 | /// 30 | public KFSMCallback OnEvent; 31 | /// 32 | /// Specifies when OnCheckCondition should be checked? 33 | /// 34 | public KFSMUpdateMode updateMode; 35 | 36 | /// 37 | /// Creates a new KFSMEvent 38 | /// 39 | /// The name of the event. 40 | public extern KFSMEvent(string name); 41 | 42 | /// 43 | /// Whether this event can be triggered when the state machine is in the given state. 44 | /// Events must be added to states through KerbalFSM.AddEvent before they can be triggered, 45 | /// and they can only be triggered when the machine is in one of the states to which they 46 | /// have been added. 47 | /// 48 | /// The state to check. 49 | /// Whether the event can be triggered from the given state. 50 | public extern bool IsValid(KFSMState state); 51 | } 52 | -------------------------------------------------------------------------------- /src/KFSMState.cs: -------------------------------------------------------------------------------- 1 | #region Assembly Assembly-CSharp.dll, v2.0.50727 2 | // C:\greg\games\KSP 0.18.2\KSP_Data\Managed\Assembly-CSharp.dll 3 | #endregion 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | 8 | /// 9 | /// Represents a state in a KerbalFSM finite state machine. 10 | /// 11 | public class KFSMState 12 | { 13 | public int FrameCountAtStateEnter; 14 | /// 15 | /// The name of this state. 16 | /// 17 | public string name; 18 | /// 19 | /// You can assign to this field a delegate that takes a KFSMState (which will be this state). 20 | /// The delegate will be called when the state machine enters this state. 21 | /// 22 | public KFSMStateChange OnEnter; 23 | /// 24 | /// You can assign a delegate to this field, and the delegate will be called during each FixedUpdate 25 | /// while the state machine is in this state. 26 | /// 27 | public KFSMCallback OnFixedUpdate; 28 | /// 29 | /// You can assign a delegate to this field, and the delegate will be called during each LateUpdate 30 | /// while the state machine is in this state. 31 | /// 32 | public KFSMCallback OnLateUpdate; 33 | /// 34 | /// You can assign to this field a delegate that takes a KFSMState. The delegate will be called 35 | /// when the state machine leaves this state, and the argument passed to the delegate will be 36 | /// the new state that the machine is transitioning to. 37 | /// 38 | public KFSMStateChange OnLeave; 39 | /// 40 | /// You can assign a delegate to this field, and the delegate will be call during each Update while 41 | /// the state machine is in this state. 42 | /// 43 | public KFSMCallback OnUpdate; 44 | protected List stateEvents; 45 | public double TimeAtStateEnter; 46 | public KFSMUpdateMode updateMode; 47 | 48 | /// 49 | /// Create a new KFSMState with a given name. 50 | /// 51 | /// The name of the new state. 52 | public extern KFSMState(string name); 53 | 54 | /// 55 | /// The set of events that are valid for this state (i.e., the possible transitions from this state). 56 | /// 57 | public extern List StateEvents { get; } 58 | 59 | /// 60 | /// Add an event (possible transition) to this state. 61 | /// 62 | /// The event to add. 63 | public extern void AddEvent(KFSMEvent ev); 64 | /// 65 | /// Whether the given event can be triggered from this state. An event must be added to a state before 66 | /// it can be triggered from that state. 67 | /// 68 | /// The event to check. 69 | /// Whether the event can be triggered from this state. 70 | public extern bool IsValid(KFSMEvent ev); 71 | public extern override string ToString(); 72 | } 73 | -------------------------------------------------------------------------------- /src/KSPAction.cs: -------------------------------------------------------------------------------- 1 | #region Assembly Assembly-CSharp.dll, v2.0.50727 2 | // C:\greg\games\KSP 0.18.2\KSP_Data\Managed\Assembly-CSharp.dll 3 | #endregion 4 | 5 | using System; 6 | 7 | /// 8 | /// Apply this attribute to a function to allow it to be called via action groups. 9 | /// 10 | [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)] 11 | public class KSPAction : Attribute 12 | { 13 | /// 14 | /// Which action groups this action is currently a part of? Probably you can test 15 | /// whether this action is part of a given action group (say, the Abort group) with 16 | /// 17 | /// if((actionGroup & KSPActionGroup.Abort) != 0) 18 | /// 19 | public KSPActionGroup actionGroup; 20 | /// 21 | /// The name of this action as it appears in the action group editor. 22 | /// 23 | public string guiName; 24 | 25 | public extern KSPAction(string guiName); 26 | public extern KSPAction(string guiName, KSPActionGroup actionGroup); 27 | } 28 | -------------------------------------------------------------------------------- /src/KSPAddon.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | /// 4 | /// Apply this attribute to a class that derives from MonoBehaviour to have KSP automatically start up 5 | /// your addon at a specified time. 6 | /// 7 | /// 8 | /// At the time specified by the "startup" argument KSP will create 9 | /// a new GameObject and attach your MonoBehaviour to it. You can then implement the Unity event functions 10 | /// like Start(), Update(), etc. 11 | /// 12 | [AttributeUsage(AttributeTargets.Class)] 13 | public class KSPAddon : Attribute 14 | { 15 | /// 16 | /// Whether KSP should start up your addon just once per game session, or every time 17 | /// the startup time is reached. If you want your addon to persist forever, even through 18 | /// scene changes, after being started once, set once to true. call DontDestroyOnLoad(this) in your 19 | /// Start() function. 20 | /// 21 | public bool once; 22 | /// 23 | /// When this addon should be started. 24 | /// 25 | public KSPAddon.Startup startup; 26 | 27 | /// 28 | /// Constructor. 29 | /// 30 | /// When this addon should be started 31 | /// Whether KSP should start up your addon just once per game session, or every time 32 | /// the startup time is reached. If you want your addon to persist forever, even through 33 | /// scene changes, after being started once, set once to true. call DontDestroyOnLoad(this) in your 34 | /// Start() function. 35 | public extern KSPAddon(KSPAddon.Startup startup, bool once); 36 | 37 | /// 38 | /// Possible values for when your addon can be started up. 39 | /// 40 | public enum Startup 41 | { 42 | /// 43 | /// Presumably, start on entering either the VAB or the SPH. 44 | /// 45 | EditorAny = -3, 46 | /// 47 | /// Presumably, start soon as possible after loading your assembly? 48 | /// 49 | Instantly = -2, 50 | /// 51 | /// Start up on any scene transition? 52 | /// 53 | EveryScene = -1, 54 | /// 55 | /// Start on entering the main KSP menu. 56 | /// 57 | MainMenu = 2, 58 | /// 59 | /// Start on entering the KSP settings menu. 60 | /// 61 | Settings = 3, 62 | /// 63 | /// Start on entering the KSP credits scene. 64 | /// 65 | Credits = 4, 66 | /// 67 | /// Start on entering the space centre scene. 68 | /// 69 | SpaceCentre = 5, 70 | /// 71 | /// Start on entering the VAB scene. 72 | /// 73 | EditorVAB = 6, 74 | /// 75 | /// Start on entering the flight scene. 76 | /// 77 | Flight = 7, 78 | /// 79 | /// Start on entering the tracking station scene. 80 | /// 81 | TrackingStation = 8, 82 | /// 83 | /// Start on entering the SPH scene. 84 | /// 85 | EditorSPH = 9, 86 | /// 87 | /// Start just before KSP creates the solar system? This seems to be the right hook to 88 | /// use for addons that modify the solar system. See the PSystemManager class and related 89 | /// classes. 90 | /// 91 | PSystemSpawn = 10, 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /src/KSPAssembly.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | /// 4 | /// This attribute and the KSPAssemblyDependency attribute can be used to ensure that plugin assemblies are loaded in the right order. 5 | /// 6 | /// 7 | /// Suppose Mod A depends on mod B, which is currently at version 2.6. 8 | /// Mod B should add the following line to the end of Properties/AssemblyInfo.cs: 9 | /// 10 | /// 11 | /// [assembly: KSPAssembly("ModBName", 2, 6)] 12 | /// 13 | /// 14 | /// where "ModBName" is the name of Mod B (Mod B's .dll?). Replace 2 and 6 with the major and minor version of 15 | /// Mod B. 16 | /// 17 | /// Then Mod A should add the following line to the end of Properties/AssemblyInfo.cs: 18 | /// 19 | /// 20 | /// [assembly: KSPAssemblyDependency("ModBName", 2, 6)] 21 | /// 22 | /// 23 | /// This will tell KSP that Mod A depends on version 2.6 of Mod B, and ensure the the assemblies get loaded in 24 | /// the proper order. 25 | /// 26 | /// 27 | [AttributeUsage(AttributeTargets.Assembly)] 28 | public class KSPAssembly : Attribute 29 | { 30 | public string name; 31 | public int versionMajor; 32 | public int versionMinor; 33 | 34 | public extern KSPAssembly(string name, int versionMajor, int versionMinor); 35 | } -------------------------------------------------------------------------------- /src/KSPAssemblyDependency.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | /// 4 | /// This attribute and the KSPAssembly attribute can be used to ensure that plugin assemblies are loaded in the right order. 5 | /// 6 | /// 7 | /// Suppose Mod A depends on mod B, which is currently at version 2.6. 8 | /// Mod B should add the following line to the end of Properties/AssemblyInfo.cs: 9 | /// 10 | /// 11 | /// [assembly: KSPAssembly("ModBName", 2, 6)] 12 | /// 13 | /// 14 | /// where "ModBName" is the name of Mod B (Mod B's .dll?). Replace 2 and 6 with the major and minor version of 15 | /// Mod B. 16 | /// 17 | /// Then Mod A should add the following line to the end of Properties/AssemblyInfo.cs: 18 | /// 19 | /// 20 | /// [assembly: KSPAssemblyDependency("ModBName", 2, 6)] 21 | /// 22 | /// 23 | /// This will tell KSP that Mod A depends on version 2.6 of Mod B, and ensure the the assemblies get loaded in 24 | /// the proper order. 25 | /// 26 | /// 27 | [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] 28 | public class KSPAssemblyDependency : Attribute 29 | { 30 | public string name; 31 | public int versionMajor; 32 | public int versionMinor; 33 | 34 | public extern KSPAssemblyDependency(string name, int versionMajor, int versionMinor); 35 | } 36 | -------------------------------------------------------------------------------- /src/KSPEvent.cs: -------------------------------------------------------------------------------- 1 | #region Assembly Assembly-CSharp.dll, v2.0.50727 2 | // C:\greg\games\KSP 0.18.2\KSP_Data\Managed\Assembly-CSharp.dll 3 | #endregion 4 | 5 | using System; 6 | 7 | /// 8 | /// Apply this attribute to a function in a PartModule to make it callable by the player via 9 | /// the right click menu of the part, or from other plugin code via Part.SendEvent. 10 | /// 11 | /// 12 | /// It seems like this attribute is NOT refreshed on parts already in flight when you rebuild 13 | /// your module DLL! You need to launch a new ship with your part. 14 | /// 15 | [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)] 16 | public class KSPEvent : Attribute 17 | { 18 | /// 19 | /// Whether this event can be triggered through Part.SendEvent. 20 | /// 21 | public bool active; 22 | public string category; 23 | /// 24 | /// Whether the event is only available when out on EVA. 25 | /// 26 | public bool externalToEVAOnly; 27 | /// 28 | /// Whether the event is shown as available in the right click menu (active must also be true). 29 | /// 30 | public bool guiActive; 31 | /// 32 | /// Whether the event is shown as available in the right click menu even when 33 | /// the part is on a ship not currently being controlled by the player (but 34 | /// close enough to right click). 35 | /// 36 | public bool guiActiveUnfocused; 37 | public string guiIcon; 38 | /// 39 | /// The name shown for the event in the right click menu. 40 | /// 41 | public string guiName; 42 | public bool isDefault; 43 | /// 44 | /// The name of the event, which can be used to trigger the event using from plugin code using Part.SendEvent. 45 | /// 46 | public string name; 47 | /// 48 | /// When the part is on a ship not being controlled by the player, 49 | /// how close the player needs to be (in meters) in order for the event to appear in the right click menu. 50 | /// 51 | public float unfocusedRange; 52 | 53 | public extern KSPEvent(); 54 | } 55 | -------------------------------------------------------------------------------- /src/KSPField.cs: -------------------------------------------------------------------------------- 1 | #region Assembly Assembly-CSharp.dll, v2.0.50727 2 | // C:\greg\games\KSP 0.18.2\KSP_Data\Managed\Assembly-CSharp.dll 3 | #endregion 4 | 5 | using System; 6 | 7 | /// 8 | /// Apply this attribute to a field in a PartModule or ScenarioModule to make the field 9 | /// get automatically initialized from the cfg file, and optionally persistent. See 10 | /// 11 | /// http://forum.kerbalspaceprogram.com/showthread.php/10296-0-15-code-update-PartModule-KSPField-KSPEvent-ConfigNode-and-PartResource 12 | /// 13 | [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)] 14 | public class KSPField : Attribute 15 | { 16 | public string category; 17 | /// 18 | /// Whether to show the value of this field in the right click menu of the part. 19 | /// 20 | public bool guiActive; 21 | /// 22 | /// The format string that will be passed to ToString when displaying the value of your field 23 | /// in the right click menu of the part? 24 | /// E.g. "F3" for a floating point number with 3 digits past the decimal point. 25 | /// 26 | public string guiFormat; 27 | /// 28 | /// The name that will be shown for this field in the right click menu of the part. 29 | /// 30 | public string guiName; 31 | /// 32 | /// The units that will be shown for this field in the right click menu of the part. 33 | /// 34 | public string guiUnits; 35 | /// 36 | /// Whether to store the value of this field in persistent.sfs when the game state is saved, and 37 | /// reload it from persistent.sfs when the game state is loaded. 38 | /// 39 | public bool isPersistant; 40 | 41 | public extern KSPField(); 42 | } 43 | -------------------------------------------------------------------------------- /src/KSPScenario.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | /// 4 | /// Like KSPAddon, but for ScenarioModules. Apply this attribute to your subclass 5 | /// of ScenarioModule and KSP will add it to the game at the right time. 6 | /// 7 | [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] 8 | public sealed class KSPScenario : Attribute 9 | { 10 | public ScenarioCreationOptions createOptions; 11 | public GameScenes[] tgtScenes; 12 | 13 | /// 14 | /// Constructor. 15 | /// 16 | /// Directions about which games the scenario should be added to. Different options 17 | /// can be combined with the | operator. 18 | /// A list of the game scenes to which the scenario should be added 19 | public extern KSPScenario(ScenarioCreationOptions createOptions, params GameScenes[] tgtScenes); 20 | 21 | public extern GameScenes[] TargetScenes { get; } 22 | 23 | public extern bool HasCreateOption(ScenarioCreationOptions option); 24 | } 25 | -------------------------------------------------------------------------------- /src/KerbalEVA.cs: -------------------------------------------------------------------------------- 1 | #region Assembly Assembly-CSharp.dll, v2.0.50727 2 | // C:\greg\games\KSP 0.18.2\KSP_Data\Managed\Assembly-CSharp.dll 3 | #endregion 4 | 5 | using System; 6 | using UnityEngine; 7 | 8 | /// 9 | /// Kerbals on EVA are represented as vessels with a single part. That part contains a KerbalEVA PartModule. 10 | /// 11 | public class KerbalEVA : PartModule 12 | { 13 | public KerbalAnimationManager Animations; 14 | public float boundAttack; 15 | public float boundFallThreshold; 16 | public float boundForce; 17 | public float boundFrequency; 18 | public float boundRelease; 19 | public float boundSharpness; 20 | public float boundSpeed; 21 | public float boundThreshold; 22 | public bool canRecover; 23 | public Collider[] characterColliders; 24 | public bool CharacterFrameMode; 25 | public bool CharacterFrameModeToggle; 26 | public Vector3 fFwd; 27 | public Transform footPivot; 28 | public Vector3 fRgt; 29 | public KerbalFSM fsm; 30 | [KSPField(guiName = "Pack Fuel", guiUnits = "%", guiFormat = "0.0", isPersistant = true, guiActive = true)] 31 | public float Fuel; 32 | public float FuelCapacity; 33 | public float FuelConsumption; 34 | public Vector3 fUp; 35 | public GameObject headLamp; 36 | public float hopThreshold; 37 | public float initialMass; 38 | public bool isRagdoll; 39 | public bool JetpackDeployed; 40 | public float Kd; 41 | public float Ki; 42 | public float Kp; 43 | public float ladderClimbSpeed; 44 | public Transform ladderPivot; 45 | public float ladderPushoffForce; 46 | public bool lampOn; 47 | public float linPower; 48 | public float massMultiplier; 49 | public float maxJumpForce; 50 | public float minRunningGee; 51 | public float minWalkingGee; 52 | public Collider[] otherRagdollColliders; 53 | public KerbalRagdollNode[] ragdollNodes; 54 | public float recoverThreshold; 55 | public float recoverTime; 56 | public float rotPower; 57 | public float runSpeed; 58 | public bool splatEnabled; 59 | public GameObject splatPrefab; 60 | public float splatSpeed; 61 | public float splatThreshold; 62 | public float strafeSpeed; 63 | public float stumbleThreshold; 64 | public float swimSpeed; 65 | public float turnRate; 66 | public Transform upperTorso; 67 | public float walkSpeed; 68 | 69 | public extern KerbalEVA(); 70 | 71 | /// 72 | /// Whether the kerbal is currently hanging on to a ladder. 73 | /// 74 | public extern bool OnALadder { get; } 75 | public extern bool Ready { get; } 76 | public extern bool VesselUnderControl { get; } 77 | 78 | public extern void BoardPart(Part p); 79 | public extern int CompareContactsByNormalToSurface(ContactPoint c1, ContactPoint c2); 80 | public extern void OnCollisionEnter(Collision c); 81 | public extern void OnCollisionExit(Collision c); 82 | public extern void OnCollisionStay(Collision c); 83 | public extern override void OnLoad(ConfigNode node); 84 | public extern void OnPartDie(); 85 | public extern override void OnSave(ConfigNode node); 86 | public extern override void OnStart(PartModule.StartState state); 87 | public extern void OnVesselPack(); 88 | public extern void OnVesselUnpack(); 89 | [ContextMenu("Reconfigure Animations")] 90 | public extern void SetupAnimations(); 91 | public extern void SetWaypoint(Vector3 tgtPos); 92 | } 93 | -------------------------------------------------------------------------------- /src/KerbalFSM.cs: -------------------------------------------------------------------------------- 1 | #region Assembly Assembly-CSharp.dll, v2.0.50727 2 | // C:\greg\games\KSP 0.18.2\KSP_Data\Managed\Assembly-CSharp.dll 3 | #endregion 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | 8 | /// 9 | /// A finite state machine. States are represented by KFSMState objects, and 10 | /// "events" (transitions between states) are represented by KFSMEvent objects. 11 | /// 12 | [Serializable] 13 | public class KerbalFSM 14 | { 15 | protected KFSMState currentState; 16 | /// 17 | /// The name of the state the machine is currently in. 18 | /// 19 | public string currentStateName; 20 | public bool DebugBreakOnStateChange; 21 | protected bool fsmStarted; 22 | protected KFSMEvent lastEvent; 23 | /// 24 | /// The name of the last event that occurred. 25 | /// 26 | public string lastEventName; 27 | protected KFSMState lastState; 28 | protected List States; 29 | 30 | public extern KerbalFSM(); 31 | 32 | /// 33 | /// The state the machine is currently in. 34 | /// 35 | public extern KFSMState CurrentState { get; } 36 | /// 37 | /// How many frames the machine has been in this state. 38 | /// 39 | public extern int FramesInCurrentState { get; } 40 | /// 41 | /// The last event that occurred. 42 | /// 43 | public extern KFSMEvent LastEvent { get; } 44 | /// 45 | /// The state the machine was in before this state. 46 | /// 47 | public extern KFSMState LastState { get; } 48 | /// 49 | /// Whether the state machine has been started. 50 | /// 51 | public extern bool Started { get; } 52 | /// 53 | /// How long the machine has been in the current state, in seconds. 54 | /// 55 | public extern double TimeAtCurrentState { get; } 56 | 57 | /// 58 | /// Add a new event (possible transition) to the finite state machine. 59 | /// 60 | /// The event to add. 61 | /// The states to add the event to. The event can only be triggered when 62 | /// the machine is in one of these states. 63 | public extern void AddEvent(KFSMEvent ev, params KFSMState[] toStates); 64 | /// 65 | /// Add a new event (possible transition) to the finite state machine. 66 | /// 67 | /// The event to add. 68 | /// A list of states *not* to add the event to. The event can only be triggered 69 | /// when the machine is *not* in one of these states. 70 | public extern void AddEventExcluding(KFSMEvent ev, params KFSMState[] excStates); 71 | /// 72 | /// Add a new possible state to the machine. 73 | /// 74 | /// The state to add. 75 | public extern void AddState(KFSMState st); 76 | public extern void FixedUpdateFSM(); 77 | public extern void LateUpdateFSM(); 78 | /// 79 | /// Cause the machine to execute the transition specified by evt. 80 | /// 81 | /// The event to execute. 82 | public extern void RunEvent(KFSMEvent evt); 83 | /// 84 | /// Start the state machine in a given initial state. 85 | /// 86 | /// The state to start in. 87 | public extern void StartFSM(KFSMState initialState); 88 | /// 89 | /// Start the state machine in a given initial state. 90 | /// 91 | /// The name of the state to start in 92 | public extern void StartFSM(string initialStateName); 93 | public extern void UpdateFSM(); 94 | protected extern void updateFSM(KFSMUpdateMode mode); 95 | } 96 | -------------------------------------------------------------------------------- /src/KerbalInstructor.cs: -------------------------------------------------------------------------------- 1 | #region Assembly Assembly-CSharp.dll, v2.0.50727 2 | // C:\greg\games\KSP 0.18.2\KSP_Data\Managed\Assembly-CSharp.dll 3 | #endregion 4 | 5 | using System; 6 | using UnityEngine; 7 | 8 | /// 9 | /// A KerbalInstructor object controls the animated image of a kerbal instructor 10 | /// in a TutorialScenario. KerbalInstructors come with a stock emote animations 11 | /// that you can trigger by calling the appropriate functions. 12 | /// 13 | public class KerbalInstructor : MonoBehaviour 14 | { 15 | public Animation anim; 16 | public CharacterAnimationState anim_false_disagreeA; 17 | public CharacterAnimationState anim_false_disagreeB; 18 | public CharacterAnimationState anim_false_disagreeC; 19 | public CharacterAnimationState anim_false_disappointed; 20 | public CharacterAnimationState anim_false_sadA; 21 | public CharacterAnimationState anim_idle; 22 | public CharacterAnimationState anim_idle_lookAround; 23 | public CharacterAnimationState anim_idle_sigh; 24 | public CharacterAnimationState anim_idle_wonder; 25 | public CharacterAnimationState anim_true_nodA; 26 | public CharacterAnimationState anim_true_nodB; 27 | public CharacterAnimationState anim_true_smileA; 28 | public CharacterAnimationState anim_true_smileB; 29 | public CharacterAnimationState anim_true_thumbsUp; 30 | public CharacterAnimationState anim_true_thumbUp; 31 | public Transform AnimationRoot; 32 | public string CharacterName; 33 | public bool DrawDebugPanel; 34 | public Camera instructorCamera; 35 | public Material PortraitRenderMaterial; 36 | 37 | public extern KerbalInstructor(); 38 | 39 | /// 40 | /// Presumably, makes the instructor execute a given animation. 41 | /// 42 | /// The animation to execute. 43 | public extern void PlayEmote(CharacterAnimationState st); 44 | /// 45 | /// Presumably, makes the instructor execute a given animation repeatedly. 46 | /// 47 | /// The animation to exectue. 48 | /// How often to repeat the animation, in seconds? 49 | public extern void PlayEmoteRepeating(CharacterAnimationState st, float repeatInterval); 50 | [ContextMenu("Reset Animations")] 51 | public extern void SetupAnimations(); 52 | /// 53 | /// Presumably, makes the instructor stop repeating whatever animation 54 | /// you last told it to repeat. 55 | /// 56 | public extern void StopRepeatingEmote(); 57 | } 58 | -------------------------------------------------------------------------------- /src/Krakensbane.cs: -------------------------------------------------------------------------------- 1 | #region Assembly Assembly-CSharp.dll, v2.0.50727 2 | // C:\greg\games\KSP 0.18.2\KSP_Data\Managed\Assembly-CSharp.dll 3 | #endregion 4 | 5 | using System; 6 | using UnityEngine; 7 | 8 | /// 9 | /// The physics simulation has problems if vessels move too fast relative to 10 | /// the underlying reference frame used by the simulation, or get too far from 11 | /// the origin of the coordinate system. Krakensbane shifts the reference frame 12 | /// origin and velocity so that the active vessel is always near the origin of, 13 | /// and moving slowly with respect to, the underlying coordinate system used by the 14 | /// physics simulation. 15 | /// 16 | public class Krakensbane : MonoBehaviour 17 | { 18 | public Vector3d excessV; 19 | public Vector3d FrameVel; 20 | public Vector3d lastCorrection; 21 | public float MaxV; 22 | public Vector3d RBVel; 23 | public Vector3d totalVel; 24 | 25 | public extern Krakensbane(); 26 | 27 | /// 28 | /// Returns the velocity of the Krakensbane velocity frame. 29 | /// 30 | /// 31 | public extern static Vector3d GetFrameVelocity(); 32 | /// 33 | /// Returns the velocity of the Krakensbane velocity frame as a single-precision vector. 34 | /// 35 | /// 36 | public extern static Vector3 GetFrameVelocityV3f(); 37 | /// 38 | /// Returns the last velocity correction performed. 39 | /// 40 | /// 41 | public extern static Vector3d GetLastCorrection(); 42 | /// 43 | /// sets the frame velocity back to 0m/s. Use this if setting the worldspace velocity of vessels directly. 44 | /// 45 | public extern static void ResetVelocityFrame(); 46 | /// 47 | /// Moves all vessels not on rails by the given position offset. This will usually only affect the active vessel, 48 | /// unless there are other vessels nearby. The offset can be very large and the vessels 49 | /// will not break, unlike for Vessel.SetPosition. 50 | /// 51 | /// 52 | public extern void setOffset(Vector3d offset); 53 | } 54 | -------------------------------------------------------------------------------- /src/ManeuverNode.cs: -------------------------------------------------------------------------------- 1 | #region Assembly Assembly-CSharp.dll, v2.0.50727 2 | // C:\greg\games\KSP 0.18.2\KSP_Data\Managed\Assembly-CSharp.dll 3 | #endregion 4 | 5 | using System; 6 | using UnityEngine; 7 | 8 | 9 | /// 10 | /// Represents a maneuver node. 11 | /// 12 | [Serializable] 13 | public class ManeuverNode 14 | { 15 | public ManeuverGizmo attachedGizmo; 16 | /// 17 | /// The delta-V of the burn represented by this maneuver node, in m/s. NOTE: maneuver nodes use a special coordinate system for delta-V. 18 | /// The x-component of DeltaV represents the delta-V in the radial-plus direction. The y-component of DeltaV 19 | /// represents the delta-V in the normal-minus direction. The z-component of DeltaV represents the delta-V in the 20 | /// prograde direction. 21 | /// 22 | public Vector3d DeltaV; 23 | /// 24 | /// The orbit patch that starts at this maneuver node. 25 | /// 26 | public Orbit nextPatch; 27 | public Quaternion nodeRotation; 28 | /// 29 | /// The orbit patch that ends at this maneuver node? 30 | /// 31 | public Orbit patch; 32 | public Transform scaledSpaceTarget; 33 | public PatchedConicSolver solver; 34 | /// 35 | /// The universal time of the burn represented by this maneuver node. 36 | /// 37 | public double UT; 38 | 39 | public extern ManeuverNode(); 40 | 41 | public extern void AttachGizmo(GameObject gizmoPrefab, PatchedConicRenderer renderer, PatchRendering pr); 42 | public extern void DetachGizmo(); 43 | /// 44 | /// Perhaps this translates the DeltaV vector into a world-space vector? 45 | /// 46 | /// 47 | /// 48 | public extern Vector3d GetBurnVector(Orbit currentOrbit); 49 | /// 50 | /// You can call this function to change the delta-V and time of a maneuver node. 51 | /// 52 | /// The new delta-V. See the DeltaV for notes about the coordinate system used. 53 | /// The new universal time. 54 | public extern void OnGizmoUpdated(Vector3d dV, double ut); 55 | public extern void RemoveSelf(); 56 | } 57 | -------------------------------------------------------------------------------- /src/MapView.cs: -------------------------------------------------------------------------------- 1 | #region Assembly Assembly-CSharp.dll, v2.0.50727 2 | // C:\greg\games\KSP 0.18.2\KSP_Data\Managed\Assembly-CSharp.dll 3 | #endregion 4 | 5 | using System; 6 | using UnityEngine; 7 | 8 | /// 9 | /// This class stores some global information related to the map view. 10 | /// 11 | public class MapView : MonoBehaviour 12 | { 13 | public float camDistance; 14 | public int camFocusTarget; 15 | public float camHdg; 16 | public float camPitch; 17 | public bool ConstantMode; 18 | public static int culledCaptions; 19 | public Material dottedLineMaterial; 20 | public bool draw3Dlines; 21 | public static MapView fetch; 22 | public FlightCamera mainCamera; 23 | public Camera[] mainCameras; 24 | public bool maneuverModeActive; 25 | public ScreenSafeUIButton maneuverModeToggle; 26 | public GameObject maneuverNodePrefab; 27 | public PlanetariumCamera mapCamera; 28 | public ScreenSafeUISlideTab MapCollapse_navBall; 29 | public static float MapIconTextOverlap; 30 | /// 31 | /// Whether the game is currently in map view or not. 32 | /// 33 | public static bool MapIsEnabled; 34 | public float masterOrbitOpacity; 35 | public float max3DlineDrawDist; 36 | public static Callback OnEnterMapView; 37 | public static Callback OnExitMapView; 38 | public ScreenSafeUIStateButton orbitDrawModeBtn; 39 | public Texture2D orbitIconsMap; 40 | public Material orbitIconsMaterial; 41 | public GUISkin orbitIconsTextSkin; 42 | public Material orbitLinesMaterial; 43 | public Color[] patchColors; 44 | public MonoBehaviour[] scriptsToDisable; 45 | public Transform spaceCameraHome; 46 | public static int totalCaptions; 47 | public float transitionDuration; 48 | public Camera[] uiCameras; 49 | public Camera vectorCam; 50 | 51 | public extern MapView(); 52 | 53 | public extern static Material DottedLinesMaterial { get; } 54 | public extern static bool Draw3DLines { get; } 55 | public extern static bool ManeuverModeActive { get; } 56 | public extern static GameObject ManeuverNodePrefab { get; } 57 | public extern static PlanetariumCamera MapCamera { get; } 58 | public extern static int OrbitDrawMode { get; } 59 | public extern static Texture2D OrbitIconsMap { get; } 60 | public extern static Material OrbitIconsMaterial { get; } 61 | public extern static GUISkin OrbitIconsTextSkin { get; } 62 | public extern static Material OrbitLinesMaterial { get; } 63 | public extern static Color[] PatchColors { get; } 64 | 65 | /// 66 | /// Calling this function will cause the game to switch to map view from the flight view. 67 | /// 68 | public extern static void EnterMapView(); 69 | /// 70 | /// Calling this function will cause the game to switch to flight view from the map view. 71 | /// 72 | public extern static void ExitMapView(); 73 | } 74 | -------------------------------------------------------------------------------- /src/MemoryStream.cs: -------------------------------------------------------------------------------- 1 | #region Assembly Assembly-CSharp.dll, v2.0.50727 2 | // C:\greg\games\KSP 0.18.2\KSP_Data\Managed\Assembly-CSharp.dll 3 | #endregion 4 | 5 | using System; 6 | 7 | namespace KSP.IO 8 | { 9 | /// 10 | /// Useful for manipulating bytes in memory. 11 | /// 12 | public class MemoryStream 13 | { 14 | public extern MemoryStream(); 15 | public extern MemoryStream(byte[] buffer); 16 | 17 | public extern bool CanRead { get; } 18 | public extern bool CanSeek { get; } 19 | public extern bool CanWrite { get; } 20 | public extern int Capacity { get; set; } 21 | public extern long Length { get; } 22 | public extern long Position { get; set; } 23 | 24 | public extern void Flush(); 25 | public extern byte[] GetBuffer(); 26 | public extern int Read(byte[] buffer, int offset, int count); 27 | public extern int ReadByte(); 28 | public extern long Seek(long offset, SeekOrigin loc); 29 | public extern void SetLength(long value); 30 | public extern byte[] ToArray(); 31 | public extern void Write(byte[] buffer, int offset, int count); 32 | public extern void WriteByte(byte value); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/ModuleAsteroid.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Diagnostics; 3 | 4 | /// Key module in PART[PotatoRoid] 5 | /// 6 | /// 7 | /// Although this module is included in the PotatoRoid config file, it is not saved 8 | /// in the VESSEL trees of unvisited asteroids. The module is initialized when an asteroid 9 | /// first enters physics range 10 | /// 11 | public class ModuleAsteroid : PartModule, IVesselAutoRename 12 | { 13 | /// Density of asteroid, in tons/m^3. Used to calculate part mass. 14 | [KSPField] public float density = 0.03f; 15 | 16 | /// Largest allowed radius relative to nominal radius for that asteroid class 17 | [KSPField] public float maxRadiusMultiplier = 1.25f; 18 | 19 | /// The fraction of science recovered by transmitting back to Kerbin. 20 | [KSPField] public float sampleExperimentXmitScalar = 0.3f; 21 | 22 | /// The science experiment triggered by sampling this asteroid. 23 | [KSPField] public string sampleExperimentId = "asteroidSample"; 24 | 25 | /// Smallest allowed radius relative to nominal radius for that asteroid class 26 | [KSPField] public float minRadiusMultiplier = 0.75f; 27 | 28 | /// Stores the original name of the asteroid, before any ships docked with it 29 | [KSPField (isPersistant = true)] public string AsteroidName; 30 | 31 | /// Used to generate asteroid mesh 32 | [KSPField (isPersistant = true)] public int seed; 33 | 34 | /// Stores some kind of resource. 35 | /// 36 | /// "Procedural/PA_C" 37 | [KSPField (isPersistant = true)] public string prefabBaseURL; 38 | 39 | //---------------------------------------------------------------------- 40 | 41 | /// Returns asteroid name 42 | /// 43 | /// The original asteroid name, not that of any docked ships 44 | /// 45 | /// Implements IVesselAutoRename 46 | public extern string GetVesselName(); 47 | 48 | /// Returns the ship class 49 | /// 50 | /// Returns VesselType.SpaceObject 51 | /// 52 | /// Implements IVesselAutoRename 53 | public extern VesselType GetVesselType(); 54 | 55 | /// Called when the player selects the asteroid's center of mass as their target 56 | [KSPEvent] 57 | public extern void MakeTarget(); 58 | 59 | /// Initializes the asteroid 60 | public extern override void OnStart(PartModule.StartState state); 61 | 62 | [DebuggerHidden] 63 | public extern IEnumerator PostInit(); 64 | 65 | /// Called when the player manually renames the asteroid 66 | [KSPEvent] 67 | public extern void RenameAsteroidEvent(); 68 | 69 | /// Called when the player takes a surface sample 70 | [KSPEvent] 71 | public extern void TakeSampleEVAEvent (); 72 | } 73 | -------------------------------------------------------------------------------- /src/ModuleEngines.cs: -------------------------------------------------------------------------------- 1 | #region Assembly Assembly-CSharp.dll, v2.0.50727 2 | // C:\greg\games\KSP 0.18.2\KSP_Data\Managed\Assembly-CSharp.dll 3 | #endregion 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | using UnityEngine; 8 | 9 | /// 10 | /// A PartModule that can be configured to behave like many different kinds of engines. All stock 11 | /// propulsion systems except for RCS are implemented through ModuleEngines. 12 | /// 13 | public class ModuleEngines : PartModule 14 | { 15 | [KSPField] 16 | public bool allowRestart; 17 | [KSPField] 18 | public bool allowShutdown; 19 | /// 20 | /// Represents the specific impulse (Isp) of the engine as a function of altitude. To get 21 | /// the Isp at a certain height h (in meters), use atmosphereCurve.Evaluate(h). 22 | /// 23 | [KSPField] 24 | public FloatCurve atmosphereCurve; 25 | [KSPField] 26 | public bool autoPositionFX; 27 | /// 28 | /// The current *internal* throttle of the engine, which may be different from the current 29 | /// throttle set by the player if useEngineResponseTime is true. 30 | /// 31 | [KSPField(isPersistant = true)] 32 | public float currentThrottle; 33 | /// 34 | /// How quickly the engine spools up when the user-set throttle is higher than 35 | /// currentThrottle. 36 | /// 37 | /// 38 | /// Each frame, if the user throttle is higher than 39 | /// the engine's currentThrottle, currentThrottle 40 | /// is updated according to the formula 41 | /// 42 | /// currentThrottle += (user throttle - currentThrottle) * engineAccelerationSpeed * dt 43 | /// 44 | /// engineAccelerationSpeed has units of inverse seconds. 45 | /// 46 | [KSPField] 47 | public float engineAccelerationSpeed; 48 | /// 49 | /// How quickly the engine spools down when the user-set throttle is higher than 50 | /// currentThrottle. 51 | /// 52 | /// 53 | /// Each frame, if the user throttle is lower than 54 | /// the engine's currentThrottle, currentThrottle 55 | /// is updated according to the formula 56 | /// 57 | /// currentThrottle += (user throttle - currentThrottle) * engineDecelerationSpeed * dt 58 | /// 59 | /// engineDecelerationSpeed has units of inverse seconds. 60 | /// 61 | [KSPField] 62 | public float engineDecelerationSpeed; 63 | /// 64 | /// Whether the engine has ever been turned on? 65 | /// 66 | [KSPField(isPersistant = true)] 67 | public bool EngineIgnited; 68 | [KSPField(isPersistant = true)] 69 | public bool engineShutdown; 70 | /// 71 | /// Whether the engine's exhaust will damage parts that it hits. A ray is cast back 72 | /// along the engine's thrust vector and if that ray hits a part then that part gets heated 73 | /// up, and may explode if it exceeds its maximum temperature. 74 | /// 75 | [KSPField] 76 | public bool exhaustDamage; 77 | [KSPField(guiName = "Thrust", guiUnits = "kN", guiFormat = "F1", guiActive = true)] 78 | public float finalThrust; 79 | [KSPField(isPersistant = true)] 80 | public bool flameout; 81 | [KSPField(guiName = "Fuel Flow", guiUnits = "U", guiFormat = "F5", guiActive = true)] 82 | public float fuelFlowGui; 83 | [KSPField] 84 | public string fxGroupPrefix; 85 | [KSPField] 86 | public Vector3 fxOffset; 87 | public float G; 88 | [KSPField] 89 | public float heatProduction; 90 | [KSPField] 91 | public float ignitionThreshold; 92 | /// 93 | /// The thrust this engine produces at maximum throttle. 94 | /// 95 | [KSPField] 96 | public float maxThrust; 97 | /// 98 | /// The thrust this engine produces at minimum throttle. 99 | /// 100 | [KSPField] 101 | public float minThrust; 102 | public float mixtureDensity; 103 | /// 104 | /// The resources used by this engine, and their relative ratios. 105 | /// 106 | public List propellants; 107 | /// 108 | /// The current specific impulse of this engine, in seconds. 109 | /// 110 | [KSPField(guiName = "Specific Impulse", guiUnits = "s", guiFormat = "F1", guiActive = true)] 111 | public float realIsp; 112 | public float requestedThrottle; 113 | public float requestedThrust; 114 | [KSPField(isPersistant = true)] 115 | public bool staged; 116 | [KSPField(guiName = "Status", guiActive = true)] 117 | public string status; 118 | [KSPField(guiName = " ", guiActive = true)] 119 | public string statusL2; 120 | /// 121 | /// Whether this engine always produces maximum thrust once activated (like solid rocket boosters). 122 | /// 123 | [KSPField] 124 | public bool throttleLocked; 125 | /// 126 | /// These transforms store the locations and directions at which the thrust this engine generates is applied to the part. 127 | /// Which component of the transform rotation gives the thrust vector? 128 | /// 129 | public List thrustTransforms; 130 | [KSPField] 131 | public string thrustVectorTransformName; 132 | /// 133 | /// Whether the engine has a nonzero spool-up and spool-down time. 134 | /// 135 | /// 136 | /// If useEngineResponseTime is true, then the engine does not 137 | /// spool up or down instantly when the throttle changes, but uses the 138 | /// engineAccelerationSpeed and engineDecelerationSpeed 139 | /// variables. 140 | /// 141 | [KSPField] 142 | public bool useEngineResponseTime; 143 | /// 144 | /// Whether this engine's thrust varies with airspeed? 145 | /// 146 | [KSPField] 147 | public bool useVelocityCurve; 148 | /// 149 | /// How this engine's thrust varies with airspeed? 150 | /// 151 | [KSPField] 152 | public FloatCurve velocityCurve; 153 | 154 | public extern ModuleEngines(); 155 | 156 | /// 157 | /// If this is true, the engine is not producing thrust because it can't get enough resources. 158 | /// 159 | public extern bool getFlameoutState { get; } 160 | public extern bool getIgnitionState { get; } 161 | public extern float normalizedThrustOutput { get; } 162 | 163 | public extern void AutoPlaceFXGroup(FXGroup group, Transform thruster); 164 | public extern void BurstFlameoutGroups(); 165 | public extern float CalculateThrust(); 166 | public extern void EngineExhaustDamage(); 167 | public extern void FixedUpdate(); 168 | public extern override string GetInfo(); 169 | public extern override void OnActive(); 170 | public extern override void OnAwake(); 171 | public extern void OnCenterOfThrustQuery(CenterOfThrustQuery qry); 172 | public extern override void OnLoad(ConfigNode node); 173 | public extern override void OnSave(ConfigNode node); 174 | public extern override void OnStart(PartModule.StartState state); 175 | public extern double RequestPropellant(double mass); 176 | public extern void SetPowerGroupsActive(bool active); 177 | public extern void SetRunningGroupsActive(bool active); 178 | public extern void SetupFXGroups(); 179 | public extern void SetupPropellant(); 180 | public extern void UpdateThrottle(); 181 | 182 | /// 183 | /// A class that represents the resource requirements of an engine. 184 | /// 185 | [Serializable] 186 | public class Propellant 187 | { 188 | public double currentAmount; 189 | public double currentRequirement; 190 | public bool drawStackGauge; 191 | /// 192 | /// The integer ID of the resource consumed. 193 | /// 194 | public int id; 195 | public bool isDeprived; 196 | /// 197 | /// The string name of the resource consumed, e.g. "LiquidFuel" 198 | /// 199 | public string name; 200 | /// 201 | /// How much of this resource is consumed by the engine, in proportion to other resources. For example if the 202 | /// engine consumes three resources (A, B, C) with A.ratio = 3, B.ratio = 2, C.ratio = 1, then 3 units of every 203 | /// will be consumed for every 2 units of B and 1 unit of C. 204 | /// 205 | public float ratio; 206 | 207 | public extern Propellant(); 208 | 209 | public extern void Load(ConfigNode node); 210 | public extern void Save(ConfigNode node); 211 | } 212 | } 213 | -------------------------------------------------------------------------------- /src/ModuleScienceExperiment.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | /// 4 | /// Part module for initiating and describing science experiments. 5 | /// 6 | public class ModuleScienceExperiment : PartModule, IScienceDataContainer 7 | { 8 | /// 9 | /// Name for the right-click option to collect science data from the part while on EVA. 10 | /// 11 | [KSPField] 12 | public string collectActionName; 13 | /// 14 | /// Text for warning pop-up while collecting science data from a non-repeatable experiment while on EVA. 15 | /// 16 | [KSPField] 17 | public string collectWarningText; 18 | /// 19 | /// Is EVA science data collection available? 20 | /// 21 | [KSPField] 22 | public bool dataIsCollectable; 23 | [KSPField(isPersistant = true)] 24 | public bool Deployed; 25 | /// 26 | /// The relevant experiment based on experimentID and info from ScienceDefs file. 27 | /// 28 | public ScienceExperiment experiment; 29 | /// 30 | /// Right-click and action group name for initiating experiment. 31 | /// 32 | [KSPField] 33 | public string experimentActionName; 34 | /// 35 | /// Must match applicable ID field in the ScienceDefs.cfg file. 36 | /// 37 | [KSPField] 38 | public string experimentID; 39 | /// 40 | /// Set to 1 to trigger animation in ModuleAnimateGeneric on activation. 41 | /// 42 | public int[] fxModuleIndices; 43 | /// 44 | /// Hide right-click experiment button when experiment cannot be performed. 45 | /// 46 | [KSPField] 47 | public bool hideUIwhenUnavailable; 48 | /// 49 | /// Can the experiment be performed? Only relevant for non-rerunnable experiments. 50 | /// 51 | [KSPField(isPersistant = true)] 52 | public bool Inoperable; 53 | /// 54 | /// EVA interaction range for data collection or experiment reset. 55 | /// 56 | [KSPField] 57 | public float interactionRange; 58 | /// 59 | /// Can the experiment be run more than once before requiring Science Lab reset? 60 | /// 61 | [KSPField] 62 | public bool rerunnable; 63 | /// 64 | /// Right-click, action group, and EVA button name to reset the experiment, science data will be lost. 65 | /// 66 | [KSPField] 67 | public string resetActionName; 68 | [KSPField] 69 | public bool resettable; 70 | /// 71 | /// Can the experiment be reset on EVA? Science data will be lost. 72 | /// 73 | [KSPField] 74 | public bool resettableOnEVA; 75 | /// 76 | /// Cost for cleaning the experiment at the science lab. Units * dataScale * baseValue? 77 | /// 78 | [KSPField] 79 | public float resourceResetCost; 80 | /// 81 | /// Resource to be used for cleaning the experiment at the science lab. 82 | /// 83 | [KSPField] 84 | public string resourceToReset; 85 | /// 86 | /// Right-click and action group name for reviewing collected science data. 87 | /// 88 | [KSPField] 89 | public string reviewActionName; 90 | /// 91 | /// Warning displayed before transmitting data from a non-rerunnable experiment. 92 | /// 93 | [KSPField] 94 | public string transmitWarningText; 95 | /// 96 | /// Allow action groups to be set for the experiment, rather than right-click buttons only. 97 | /// 98 | [KSPField] 99 | public bool useActionGroups; 100 | [KSPField] 101 | public bool useStaging; 102 | /// 103 | /// Percentage of data allowed to be transmitted, 1 equals the amount gained from returning the sample to Kerbin. 104 | /// 105 | [KSPField] 106 | public float xmitDataScalar; 107 | 108 | public extern ModuleScienceExperiment(); 109 | 110 | /// 111 | /// Transfers data from the part to an EVA Kerbal. 112 | /// 113 | [KSPEvent(active = true, guiActiveUnfocused = true, externalToEVAOnly = true, guiActive = false, unfocusedRange = 1.5f)] 114 | public extern void CollectDataExternalEvent(); 115 | /// 116 | /// Initiates the experiment from an action group. 117 | /// 118 | /// 119 | [KSPAction("Deploy")] 120 | public extern void DeployAction(KSPActionParam actParams); 121 | /// 122 | /// Initiates the experiment from a right-click button. 123 | /// 124 | [KSPEvent(guiName = "Deploy", active = true, guiActive = true)] 125 | public extern void DeployExperiment(); 126 | /// 127 | /// Removes science data from the part, called after transmission. Implements IScienceDataContainer. 128 | /// 129 | /// The Science Data to be removed 130 | public extern void DumpData(ScienceData data); 131 | /// 132 | /// Returns all Science Data stored in the module. Implements IScienceDataContainer. 133 | /// 134 | /// 135 | public extern ScienceData[] GetData(); 136 | /// 137 | /// A count of how many Science Data reports are stored in the module. Implements IScienceDataContainer. 138 | /// 139 | /// 140 | public extern int GetScienceCount(); 141 | /// 142 | /// Is the experiment rerunnable? Refers to rerunnable field. Implements IScienceDataContainer. 143 | /// 144 | /// 145 | public extern bool IsRerunnable(); 146 | public extern override void OnActive(); 147 | public extern override void OnAwake(); 148 | public extern void OnDestroy(); 149 | /// 150 | /// Stores any Science Data in the persistent file. 151 | /// 152 | /// 153 | public extern override void OnLoad(ConfigNode node); 154 | /// 155 | /// Loads any Science Data stored in the persistent file. 156 | /// 157 | /// 158 | public extern override void OnSave(ConfigNode node); 159 | public extern override void OnStart(PartModule.StartState state); 160 | public extern void OnVesselSituationChange(GameEvents.HostedFromToAction vcs); 161 | /// 162 | /// Resets the experiment from an action group. Science Data is lost. Experiment can be re-run. 163 | /// 164 | /// 165 | [KSPAction("Reset")] 166 | public extern void ResetAction(KSPActionParam actParams); 167 | /// 168 | /// Resets the experiment from a right-click button. Science Data is lost. Experiment can be re-run. 169 | /// 170 | [KSPEvent(guiName = "Reset", active = true, guiActive = true)] 171 | public extern void ResetExperiment(); 172 | /// 173 | /// Resets the experiment from an EVA right-click button. Science Data is lost. Experiment can be re-run. 174 | /// 175 | [KSPEvent(guiName = "Reset", active = true, guiActiveUnfocused = true, externalToEVAOnly = true, guiActive = false)] 176 | public extern void ResetExperimentExternal(); 177 | /// 178 | /// Opens experimental results dialog. Implements IScienceDataContainer. 179 | /// 180 | public extern void ReviewData(); 181 | /// 182 | /// Review stored Science Data from a right-click button. 183 | /// 184 | [KSPEvent(guiName = "Review Data", active = true, guiActive = true)] 185 | public extern void ReviewDataEvent(); 186 | /// 187 | /// Review individual Science Data reports? Implements IScienceDataContainer. 188 | /// 189 | /// 190 | public extern void ReviewDataItem(ScienceData data); 191 | /// 192 | /// Sets the Inoperable bool, determines whether experiment can be performed again. 193 | /// 194 | public extern void SetInoperable(); 195 | } 196 | -------------------------------------------------------------------------------- /src/PAsteroid.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | /// Stores information on an asteroid's shape 4 | /// 5 | /// for a 6 | /// factory method creating PAsteroids 7 | public class PAsteroid : MonoBehaviour 8 | { 9 | /// The largest distance of any vertex to the mesh center 10 | public float highestPoint; 11 | 12 | /// The (approximate?) volume of the asteroid mesh 13 | public float volume; 14 | 15 | //---------------------------------------------------------------------- 16 | 17 | /// Combines premade elements into visual, collider, and convex meshes. 18 | public extern void Setup (Mesh visualMesh, Material visualMaterial, string visualLayer, string visualTag, 19 | Mesh colliderMesh, PhysicMaterial colliderMaterial, string colliderLayer, string colliderTag, 20 | Mesh convexMesh, PhysicMaterial convexMaterial, string convexLayer, string convexTag); 21 | } 22 | -------------------------------------------------------------------------------- /src/PSystem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | [AddComponentMenu("KSP/SolarSystem/PSystem")] 5 | public class PSystem : MonoBehaviour 6 | { 7 | [HideInInspector] 8 | public int mainToolbarSelected; 9 | public PSystemBody rootBody; 10 | public string systemName; 11 | public double systemScale; 12 | public double systemTimeScale; 13 | 14 | public extern PSystem(); 15 | 16 | public extern PSystemBody AddBody(PSystemBody parent); 17 | [ContextMenu("Load Celestial Bodies Database")] 18 | public extern void LoadDatabase(); 19 | public extern void Reset(); 20 | [ContextMenu("Save Celestial Bodies Database")] 21 | public extern void SaveDatabase(); 22 | } 23 | -------------------------------------------------------------------------------- /src/PSystemManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | 6 | /// 7 | /// A class for managing planetary systems. Ask the Kopernicus guys/look at their code for details. 8 | /// 9 | [AddComponentMenu("KSP/SolarSystem/PSystemManager")] 10 | public class PSystemManager : MonoBehaviour 11 | { 12 | public string localSpaceName; 13 | public PlanetariumCamera scaledSpaceCamera; 14 | public float scaledSpaceFactor; 15 | public string scaledSpaceName; 16 | public Sun sun; 17 | public PSystem systemPrefab; 18 | 19 | public extern PSystemManager(); 20 | 21 | public extern static PSystemManager Instance { get; } 22 | public extern List localBodies { get; } 23 | public extern EventVoid OnPSystemReady { get; } 24 | public extern List scaledBodies { get; } 25 | } 26 | -------------------------------------------------------------------------------- /src/PartModule.cs: -------------------------------------------------------------------------------- 1 | #region Assembly Assembly-CSharp.dll, v2.0.50727 2 | // C:\greg\games\KSP 0.18.2\KSP_Data\Managed\Assembly-CSharp.dll 3 | #endregion 4 | 5 | using System; 6 | using UnityEngine; 7 | 8 | /// 9 | /// Extending PartModule lets you add new functionality to parts. The main class of many plugins 10 | /// will be a subclass of PartModule. See this forum thread for the official instructions on 11 | /// using PartModule: 12 | /// 13 | /// http://forum.kerbalspaceprogram.com/showthread.php/10296-0-15-code-update-PartModule-KSPField-KSPEvent-ConfigNode-and-PartResource 14 | /// 15 | public class PartModule : MonoBehaviour 16 | { 17 | public bool isEnabled; 18 | public string moduleName; 19 | public ProtoPartModuleSnapshot snapshot; 20 | 21 | public extern PartModule(); 22 | 23 | /// 24 | /// A list of KSPActions which can be added to action groups. 25 | /// 26 | public extern BaseActionList Actions { get; } 27 | /// 28 | /// A hash of ClassName? 29 | /// 30 | public extern int ClassID { get; } 31 | /// 32 | /// In any subclass of PartModule, ClassName will be the name of the subclass. 33 | /// It gets set by the PartModule loading process. 34 | /// 35 | public extern string ClassName { get; } 36 | /// 37 | /// A list of KSPEvents, which can be triggered by code or by the user through the part's right-click menu. 38 | /// 39 | public extern BaseEventList Events { get; } 40 | /// 41 | /// A list of the KSPFields which the module loads from the part.cfg file. 42 | /// 43 | public extern BaseFieldList Fields { get; } 44 | public extern string GUIName { get; } 45 | /// 46 | /// The Part to which this PartModule is attached. Use this to reference the part from your module code. 47 | /// 48 | public extern Part part { get; set; } 49 | /// 50 | /// The Vessel of the Part to which this PartModule is attached. 51 | /// 52 | public extern Vessel vessel { get; } 53 | 54 | /// 55 | /// The return value of this function appears in the part's description in the editor. 56 | /// 57 | /// Editor info for the part 58 | public extern virtual string GetInfo(); 59 | public extern void Load(ConfigNode node); 60 | /// 61 | /// This function is called once when the part gets activated. 62 | /// 63 | public extern virtual void OnActive(); 64 | /// 65 | /// This function gets called only once, during the KSP loading screen. See the Unity documentation on Awake for more information. 66 | /// 67 | public extern virtual void OnAwake(); 68 | /// 69 | /// This function gets called once every Unity FixedUpdate cycle (once per physics frame) once the part has been activated. 70 | /// If you want to be called even if the part has not been activated, define a function called void FixedUpdate() instead 71 | /// of overriding OnFixedUpdate 72 | /// 73 | /// 74 | /// See the Unity documentation on FixedUpdate for more information. You can get the time between FixedUpdates from 75 | /// TimeWarp.fixedDeltaTime. Do any physics stuff in OnFixedUpdate, not OnUpdate. 76 | /// 77 | public extern virtual void OnFixedUpdate(); 78 | /// 79 | /// When does this get called? 80 | /// 81 | public extern virtual void OnInactive(); 82 | /// 83 | /// This function is called to initialize the part. The ConfigNode contains the parameters of the module 84 | /// as specified in the part.cfg file, or as you last saved them in OnSave. 85 | /// 86 | /// A ConfigNode containing the module's parameters from part.cfg or persistent.sfs 87 | public extern virtual void OnLoad(ConfigNode node); 88 | /// 89 | /// This function is called when the game is saved to let the part save persistent data. Add any data you want 90 | /// to persist to the ConfigNode. The ConfigNode will then be saved as part of persistent.sfs. 91 | /// When the game is resumed, you can then read this data back out in OnLoad. 92 | /// 93 | /// 94 | public extern virtual void OnSave(ConfigNode node); 95 | /// 96 | /// Called when the flight starts, or when the part is created in the editor. OnStart will be called 97 | /// before OnUpdate or OnFixedUpdate are ever called. 98 | /// 99 | /// Some information about what situation the vessel is starting in. 100 | public extern virtual void OnStart(PartModule.StartState state); 101 | /// 102 | /// Called once per Unity Update cycle once the part has been activated. 103 | /// If you want to be called even if the part has not been activated, define a function called void Update() instead 104 | /// of overriding OnFixedUpdate. 105 | /// 106 | /// 107 | /// See the 108 | /// Unity documentation on Update for more information. Poll for user input in OnUpdate, not OnFixedUpdate. 109 | /// 110 | public extern virtual void OnUpdate(); 111 | public extern void Save(ConfigNode node); 112 | 113 | /// 114 | /// A StartState is passed on OnStart in order to provide the PartModule with some information 115 | /// about where it is starting up. 116 | /// 117 | [Flags] 118 | public enum StartState 119 | { 120 | None = 0, 121 | Editor = 1, 122 | PreLaunch = 2, 123 | Landed = 4, 124 | Docked = 8, 125 | Flying = 16, 126 | Splashed = 32, 127 | SubOrbital = 64, 128 | Orbital = 128, 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /src/PartResource.cs: -------------------------------------------------------------------------------- 1 | #region Assembly Assembly-CSharp.dll, v2.0.50727 2 | // C:\greg\games\KSP 0.18.2\KSP_Data\Managed\Assembly-CSharp.dll 3 | #endregion 4 | 5 | using System; 6 | using UnityEngine; 7 | 8 | /// 9 | /// A PartResource object represents the store of a single type of resource within a Part. 10 | /// 11 | public class PartResource : MonoBehaviour 12 | { 13 | /// 14 | /// How much of the resource is in this part, in whatever units the resource uses. 15 | /// 16 | public double amount; 17 | public PartResource.FlowMode flowMode; 18 | public bool flowState; 19 | /// 20 | /// The definition of this type of resource, which contains all information about this resource type. 21 | /// 22 | public PartResourceDefinition info; 23 | /// 24 | /// The maximum amount of this resource that this part can hold. 25 | /// 26 | public double maxAmount; 27 | /// 28 | /// The part whose stored resource this object represents 29 | /// 30 | public Part part; 31 | /// 32 | /// The name of this resource, as a string, e.g. "ElectricCharge" 33 | /// 34 | public string resourceName; 35 | 36 | public extern PartResource(); 37 | 38 | public extern string GetInfo(); 39 | public extern void Load(ConfigNode node); 40 | public extern void Save(ConfigNode node); 41 | public extern void SetInfo(PartResourceDefinition info); 42 | 43 | public enum FlowMode 44 | { 45 | Both = 0, 46 | Out = 1, 47 | In = 2, 48 | None = 3, 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/PartResourceDefinition.cs: -------------------------------------------------------------------------------- 1 | #region Assembly Assembly-CSharp.dll, v2.0.50727 2 | // C:\greg\games\KSP 0.18.2\KSP_Data\Managed\Assembly-CSharp.dll 3 | #endregion 4 | 5 | using System; 6 | 7 | /// 8 | /// A PartResourceDefinition contains the basic information defining a type of resource. 9 | /// 10 | [Serializable] 11 | public class PartResourceDefinition 12 | { 13 | public extern PartResourceDefinition(); 14 | 15 | /// 16 | /// The mass of this resource, per unit. This is not necessarily per unit volume, as resources 17 | /// don't have defined volumes. Instead resource "density" is the mass of one units of the resourc.e 18 | /// 19 | public extern float density { get; } 20 | /// 21 | /// The integer ID of this resource type. 22 | /// 23 | public extern int id { get; } 24 | /// 25 | /// The string ID of this resource type 26 | /// 27 | public extern string name { get; } 28 | /// 29 | /// How this resource does or does not flow between parts on a ship in response 30 | /// to resource requests by engines and the like. 31 | /// 32 | public extern ResourceFlowMode resourceFlowMode { get; } 33 | /// 34 | /// How this resource does or does not flow when using the resource transfer function? 35 | /// 36 | public extern ResourceTransferMode resourceTransferMode { get; } 37 | 38 | public extern void Load(ConfigNode node); 39 | public extern void Save(ConfigNode node); 40 | } 41 | -------------------------------------------------------------------------------- /src/PartResourceLibrary.cs: -------------------------------------------------------------------------------- 1 | #region Assembly Assembly-CSharp.dll, v2.0.50727 2 | // C:\greg\games\KSP 0.18.2\KSP_Data\Managed\Assembly-CSharp.dll 3 | #endregion 4 | 5 | using System; 6 | using UnityEngine; 7 | 8 | /// 9 | /// The PartResourceLibrary lets you retrieve information about a resource type, given its name or integer id. 10 | /// 11 | public class PartResourceLibrary : MonoBehaviour 12 | { 13 | [SerializeField] 14 | public PartResourceDefinitionList resourceDefinitions; 15 | public string resourceExtension; 16 | public string resourcePath; 17 | 18 | public extern PartResourceLibrary(); 19 | 20 | /// 21 | /// Use this instance to access the methods of this class 22 | /// 23 | public extern static PartResourceLibrary Instance { get; } 24 | 25 | /// 26 | /// Gets information about a resource, specified by its integer ID. 27 | /// 28 | /// The integer ID of the resource 29 | /// A PartResourceDefinition, which contains all the information about the resource 30 | public extern PartResourceDefinition GetDefinition(int id); 31 | /// 32 | /// Gets information about a resource, specified by its name as a string. 33 | /// 34 | /// The name of the resource, e.g. "ElectricCharge" 35 | /// A PartResourceDefinition, which contains all the information about the resource 36 | public extern PartResourceDefinition GetDefinition(string name); 37 | } 38 | -------------------------------------------------------------------------------- /src/PatchedConicSolver.cs: -------------------------------------------------------------------------------- 1 | #region Assembly Assembly-CSharp.dll, v2.0.50727 2 | // C:\greg\games\KSP 0.18.2\KSP_Data\Managed\Assembly-CSharp.dll 3 | #endregion 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | using UnityEngine; 8 | 9 | /// 10 | /// Each vessel has a PatchedConicSolver, which stores the predicted patched conics trajectory and 11 | /// any maneuver nodes that currently exist. 12 | /// 13 | [RequireComponent(typeof(OrbitDriver))] 14 | public class PatchedConicSolver : MonoBehaviour 15 | { 16 | public bool debug_disableEscapeCheck; 17 | public List flightPlan; 18 | public int GeoSolverIterations; 19 | /// 20 | /// A list of the maneuver nodes that are currently planned for this vessel. 21 | /// 22 | public List maneuverNodes; 23 | public int maxGeometrySolverIterations; 24 | public int maxTimeSolverIterations; 25 | public int maxTotalPatches; 26 | public bool MorePatchesAhead; 27 | public OrbitDriver obtDriver; 28 | public double outerReaches; 29 | public List patches; 30 | public int patchesAhead; 31 | public CelestialBody targetBody; 32 | public int TimeSolverIterations1; 33 | public int TimeSolverIterations2; 34 | 35 | public extern PatchedConicSolver(); 36 | 37 | public extern Orbit LastActivePatch { get; } 38 | public extern Orbit orbit { get; } 39 | 40 | /// 41 | /// Add a maneuver node to the flight plan. 42 | /// 43 | /// The universal time of the maneuver node. 44 | /// A reference to the maneuver node 45 | public extern ManeuverNode AddManeuverNode(double UT); 46 | [ContextMenu("Decrease Patch Limit")] 47 | public extern void DecreasePatchLimit(); 48 | [ContextMenu("Increase Patch Limit")] 49 | public extern void IncreasePatchLimit(); 50 | /// 51 | /// Remove a maneuver node from the flight plane. 52 | /// 53 | /// The maneuver node to be removed. 54 | public extern void RemoveManeuverNode(ManeuverNode node); 55 | public extern void Update(); 56 | public extern void UpdateFlightPlan(); 57 | } 58 | -------------------------------------------------------------------------------- /src/Planetarium.cs: -------------------------------------------------------------------------------- 1 | #region Assembly Assembly-CSharp.dll, v2.0.50727 2 | // C:\greg\games\KSP 0.18.2\KSP_Data\Managed\Assembly-CSharp.dll 3 | #endregion 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | using UnityEngine; 8 | 9 | /// 10 | /// Probably the most useful function here is Planetarium.GetUniversalTime(). 11 | /// 12 | public class Planetarium : MonoBehaviour 13 | { 14 | /// 15 | /// Presumably, the main body of the active vessel? 16 | /// 17 | public CelestialBody CurrentMainBody; 18 | /// 19 | /// Use this instance to access non-static fields. 20 | /// 21 | public static Planetarium fetch; 22 | public double fixedDeltaTime; 23 | public double inverseRotAngle; 24 | public List orbits; 25 | public bool pause; 26 | public QuaternionD rotation; 27 | /// 28 | /// The CelestialBody representing the Sun. 29 | /// 30 | public CelestialBody Sun; 31 | public double time; 32 | public double timeScale; 33 | public static Planetarium.ZupVectors Zup; 34 | public QuaternionD zUpRotation; 35 | 36 | public extern Planetarium(); 37 | 38 | /// 39 | /// Along with "up" and "right," one of the three vectors defining the fixed celestial 40 | /// reference frame. 41 | /// 42 | public extern static Vector3d forward { get; } 43 | public extern static double InverseRotAngle { get; set; } 44 | public extern static List Orbits { get; } 45 | public extern static bool Pause { get; } 46 | /// 47 | /// Along with "up" and "forward," one of the three vectors defining the fixed celestial 48 | /// reference frame. The LAN (longitude of the ascending node) of every orbit is defined 49 | /// in reference to Planetarium.right. Specifically, the LAN is the angle between 50 | /// Planetarium.right and the orbit's ascending node, as viewed along Planetarium.up. 51 | /// 52 | public extern static Vector3d right { get; } 53 | public extern static QuaternionD Rotation { get; set; } 54 | public extern static double TimeScale { get; set; } 55 | /// 56 | /// Along with "right" and "forward," one of the three vectors defining the fixed celestial 57 | /// reference frame. As of 0.23.5, all planet rotation axes are aligned with Planetarium.up. 58 | /// 59 | public extern static Vector3d up { get; } 60 | public extern static QuaternionD ZupRotation { get; set; } 61 | 62 | /// 63 | /// Presumably, whether the game is currently using a rotating 64 | /// frame for physics (as opposed to an unrotating inertial frame). 65 | /// Below a certain altitude (CelestialBody.inverseRot 66 | /// 67 | /// 68 | public extern static bool FrameIsRotating(); 69 | /// 70 | /// The simulation time, in seconds, since this save was started. 71 | /// 72 | /// Universal time, in seconds 73 | public extern static double GetUniversalTime(); 74 | public extern static void SetUniversalTime(double t); 75 | 76 | /* 77 | * Can't get this to compile --The_Duck 78 | public struct ZupVectors 79 | { 80 | 81 | public Vector3d X { get; } 82 | public Vector3d Y { get; } 83 | public Vector3d Z { get; } 84 | }*/ 85 | public struct ZupVectors { } 86 | } 87 | 88 | -------------------------------------------------------------------------------- /src/PlanetariumCamera.cs: -------------------------------------------------------------------------------- 1 | #region Assembly Assembly-CSharp.dll, v2.0.50727 2 | // C:\greg\games\KSP 0.18.2\KSP_Data\Managed\Assembly-CSharp.dll 3 | #endregion 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | using UnityEngine; 8 | 9 | /// 10 | /// A class related to the map view camera. 11 | /// 12 | public class PlanetariumCamera : MonoBehaviour 13 | { 14 | public float cameraWobbleSensitivity; 15 | public float camHdg; 16 | public float camPitch; 17 | public float endHeading; 18 | /// 19 | /// Use this instance to access non-static members of this class. 20 | /// 21 | public static PlanetariumCamera fetch; 22 | public float maxDistance; 23 | public float maxPitch; 24 | public float minDistance; 25 | public float minHeight; 26 | public float minHeightAtMaxDist; 27 | public float minHeightAtMinDist; 28 | public float minPitch; 29 | public PlanetariumCamera.Modes mode; 30 | public float orbitSensitivity; 31 | public float pivotTranslateSharpness; 32 | public float sharpness; 33 | public float startDistance; 34 | public GUIStyle style; 35 | public bool TabSwitchTargets; 36 | public Transform target; 37 | public float targetHeading; 38 | public List targets; 39 | public float zoomScaleFactor; 40 | 41 | public extern PlanetariumCamera(); 42 | 43 | /// 44 | /// This is the Camera that looks at the planetarium scene. See the Unity documentation on Camera 45 | /// to see what you can do with this object. 46 | /// 47 | public extern static Camera Camera { get; } 48 | public extern float Distance { get; } 49 | public extern Quaternion pivotRotation { get; } 50 | 51 | public extern void AddTarget(Transform tgt); 52 | public extern Transform findNearestTarget(); 53 | public extern void RemoveTarget(Transform tgt); 54 | public extern void SetDistance(float dist); 55 | public extern void setTarget(int tgtIdx); 56 | public extern void setTarget(Transform tgt); 57 | 58 | public enum Modes 59 | { 60 | FREE = 0, 61 | CHASE = 1, 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/PluginConfigNode.cs: -------------------------------------------------------------------------------- 1 | #region Assembly Assembly-CSharp.dll, v2.0.50727 2 | // C:\greg\games\KSP 0.18.2\KSP_Data\Managed\Assembly-CSharp.dll 3 | #endregion 4 | 5 | using System; 6 | using System.Reflection; 7 | 8 | namespace KSP.IO 9 | { 10 | /// 11 | /// A node full of configuration values. 12 | /// 13 | public class PluginConfigNode 14 | { 15 | public extern PluginConfigNode(); 16 | public extern PluginConfigNode(PluginConfigNode parent); 17 | 18 | /// 19 | /// Get or set the value of a configuration key 20 | /// 21 | /// 22 | /// 23 | public extern object this[string key] { get; set; } 24 | 25 | /// 26 | /// Gets the parent of this node. 27 | /// 28 | /// 29 | public extern PluginConfigNode GetParent(); 30 | /// 31 | /// Get the value of a configuration key. 32 | /// 33 | /// 34 | /// 35 | /// 36 | public extern T GetValue(string key); 37 | /// 38 | /// Get the value of a configuration key. 39 | /// 40 | /// 41 | /// 42 | /// 43 | /// 44 | public extern T GetValue(string key, T _default); 45 | /// 46 | /// Set the value of a configuration key 47 | /// 48 | /// 49 | /// 50 | public extern void SetValue(string key, object value); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/PluginConfiguration.cs: -------------------------------------------------------------------------------- 1 | #region Assembly Assembly-CSharp.dll, v2.0.50727 2 | // C:\greg\games\KSP 0.18.2\KSP_Data\Managed\Assembly-CSharp.dll 3 | #endregion 4 | 5 | using System; 6 | using System.Reflection; 7 | 8 | namespace KSP.IO 9 | { 10 | /// 11 | /// From N3X15: PluginConfiguration was something I threw together a while ago to try and improve settings serialization. The INI files we were using just couldn't cope with newlines and had all sorts of horrible workarounds. Instead of INI files, it writes structured XML files that look like this: 12 | /// 13 | /// 14 | /// <config> 15 | /// <int name="int"\>4</int> 16 | /// <long name="long">45</long> 17 | /// <short name="short">4</short> 18 | /// <byte name="byte">255</byte> 19 | /// <bool name="bool">1</bool> 20 | /// <vector3 name="vector3"> 21 | /// <x>0</x> 22 | /// <y>1</y> 23 | /// <z>2</z> 24 | /// </vector3> 25 | /// <vector3d name="vector3d"> 26 | /// <x>0</x> 27 | /// <y>1</y> 28 | /// <z>2.05</z> 29 | /// </vector3d> 30 | /// <string name="string">string</string> 31 | /// </config> 32 | /// 33 | /// 34 | /// Despite looking a bit messy, it's actually a lot easier to use and doesn't have as many drawbacks as INI files. Newlines are preserved, and most importantly, types are also preserved. Oh, and it's UTF-8 encoded, so internationalization won't be as much as a problem, theoretically. Here's how to use it: 35 | /// 36 | /// PluginConfiguration cfg = PluginConfiguration.CreateForType<MyCoolModule>(); 37 | /// cfg["a string"] = "I love KSP!"; 38 | /// cfg["another setting"] = new Vector3d(0,1,2); 39 | /// cfg.save(); 40 | /// // Later... 41 | /// cfg.load(); 42 | /// settingAString = cfg.GetValue<string>("a string"); 43 | /// settingAVector = cfg.GetValue<Vector3d>("another setting"); 44 | /// 45 | /// 46 | public class PluginConfiguration 47 | { 48 | protected extern PluginConfiguration(string pathToFile); 49 | 50 | /// 51 | /// Return configuration key from the root node 52 | /// 53 | /// 54 | /// 55 | public extern object this[string key] { get; set; } 56 | 57 | /// 58 | /// Initialize the configuration object 59 | /// 60 | /// 61 | /// 62 | /// 63 | public extern static PluginConfiguration CreateForType(Vessel flight = null); 64 | /// 65 | /// Get a typed value from the root node. 66 | /// 67 | /// 68 | /// 69 | /// 70 | public extern T GetValue(string key); 71 | /// 72 | /// Get a typed value from the root node, and set to a default if it doesn't exist. 73 | /// 74 | /// 75 | /// 76 | /// 77 | /// 78 | public extern T GetValue(string key, T _default); 79 | /// 80 | /// Load from disk 81 | /// 82 | public extern void load(); 83 | /// 84 | /// Commit changes to disk 85 | /// 86 | public extern void save(); 87 | /// 88 | /// Set a configuration key's value 89 | /// 90 | /// 91 | /// 92 | public extern void SetValue(string key, object value); 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /src/ProceduralAsteroid.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System; 3 | 4 | /// Generates an asteroid shape 5 | public class ProceduralAsteroid : MonoBehaviour 6 | { 7 | /// The desired reference surface of the asteroid mesh 8 | [SerializeField] public float radius; 9 | 10 | //---------------------------------------------------------------------- 11 | 12 | /// Initializes a randomly generated asteroid shape 13 | /// 14 | /// 15 | /// Used to randomize the mesh 16 | /// The desired reference surface of the asteroid mesh 17 | /// The reference frame in which the asteroid is to be oriented 18 | /// 19 | /// Note: may not be null, even though UnityEngine.Transforms 20 | /// are usually allowed to have null parents. 21 | /// 22 | /// An object containing all relevant meshes and key statistics 23 | /// 24 | public extern PAsteroid Generate (int seed, float radius, Transform parent); 25 | 26 | //---------------------------------------------------------------------- 27 | 28 | [Serializable] public class ModValue { 29 | public string name; 30 | 31 | /// Smallest mesh height that can be randomly chosen, in units of the asteroid radius 32 | public float minValue; 33 | 34 | /// Largest mesh height that can be randomly chosen, in units of the asteroid radius 35 | public float maxValue; 36 | 37 | /// Size multiplier in addition to ProceduralAsteroid.radius 38 | public float radiusFactor; 39 | } 40 | 41 | [Serializable] public class ModWrapper { 42 | public string name = ""; 43 | 44 | public ProceduralAsteroid.ModValue[] values; 45 | 46 | public PQSMod mod { 47 | get; 48 | set; 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/RDArchivesController.cs: -------------------------------------------------------------------------------- 1 | #region Assembly Assembly-CSharp.dll, v1.0.0.0 2 | // C:\Users\boone\KSP_Lite\KSP_Data\Managed\Assembly-CSharp.dll 3 | #endregion 4 | 5 | using System; 6 | using UnityEngine; 7 | 8 | public class RDArchivesController : MonoBehaviour 9 | { 10 | public BTButton btnExpand; 11 | public BTButton btnReset; 12 | public RDDropDownListContainer dropdownListContainer; 13 | public UIButton instructorComponent; 14 | public int instructorPortraitSize; 15 | public GameObject instructorPrefab; 16 | public SpriteTextRich instructorText; 17 | public RenderTexture instructorTexture; 18 | public UIScrollList planetList; 19 | public GameObject planetListItemPrefab; 20 | public RDScrollbar planetListScrollbar; 21 | public GameObject reportItemContainer; 22 | public RomfarerScrollList reportList; 23 | public ScrollListResizer reportListResizer; 24 | public RomfarerSlider reportListScrollbar; 25 | public int reportListSizeMax; 26 | public SpriteText reportsFoundLabel; 27 | public UIStateToggleBtn reportSortData; 28 | public UIStateToggleBtn reportSortName; 29 | public UIStateToggleBtn reportSortScience; 30 | public UIStateToggleBtn reportSortValue; 31 | public PSystem systemPrefab; 32 | 33 | public extern RDArchivesController(); 34 | 35 | public extern static Func And(params Func[] predicates); 36 | 37 | public struct Filter 38 | { 39 | public string key; 40 | public string value; 41 | 42 | public extern Filter(string key, string value); 43 | } 44 | 45 | public struct ReportData 46 | { 47 | public float data; 48 | public string description; 49 | public string id; 50 | public float science; 51 | public float value; 52 | 53 | public extern ReportData(string id, string description, float data, float value, float science); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/ResourceFlowMode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | /// 4 | /// An enumeration of the different behaviors resources can have with respect to fuel flow. 5 | /// 6 | public enum ResourceFlowMode 7 | { 8 | /// 9 | /// This resource cannot flow between parts (like SolidFuel). 10 | /// 11 | NO_FLOW = 0, 12 | /// 13 | /// The flow scheme used by the stock ElectricCharge and IntakeAir resources. 14 | /// 15 | ALL_VESSEL = 1, 16 | /// 17 | /// Unused? 18 | /// 19 | EVEN_FLOW = 2, 20 | /// 21 | /// The flow scheme used by the stock MonoPropellant and XenonGas resources. 22 | /// Resource can be draw from any container by any consumer, but it tries to 23 | /// prioritize drawing from continers in earlier stages. 24 | /// 25 | STAGE_PRIORITY_FLOW = 2, 26 | /// 27 | /// This resource behaves like LiquidFuel or Oxidizer, and can only flow 28 | /// through crossfeed-enabled parts and fuel lines. 29 | /// 30 | STACK_PRIORITY_SEARCH = 3, 31 | } 32 | -------------------------------------------------------------------------------- /src/ScaledSpace.cs: -------------------------------------------------------------------------------- 1 | #region Assembly Assembly-CSharp.dll, v2.0.50727 2 | // C:\greg\games\KSP 0.18.2\KSP_Data\Managed\Assembly-CSharp.dll 3 | #endregion 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | using UnityEngine; 8 | 9 | /// 10 | /// A class that handles the transformations between the scaled-down coordinate system used by the map view and the 11 | /// regular coordinate system used by the main flight view and the physics. 12 | /// 13 | public class ScaledSpace : MonoBehaviour 14 | { 15 | public Transform originTarget; 16 | public List scaledSpaceTransforms; 17 | public float scaleFactor; 18 | 19 | public extern ScaledSpace(); 20 | 21 | public extern static float InverseScaleFactor { get; } 22 | /// 23 | /// "Scaled space" is the coordinate system used by the planetarium view. It's the same coordinate system as 24 | /// the world coordinates used by the physics, except scaled down by this scale factor. 25 | /// 26 | public extern static float ScaleFactor { get; } 27 | public extern static Transform SceneTransform { get; } 28 | 29 | public extern static void AddScaledSpaceTransform(Transform t); 30 | /// 31 | /// Convert a position in world coordinates into a position in planetarium coordinates. 32 | /// 33 | /// A position in world coordinates 34 | /// The corresponding position in planetarium coordinates 35 | public extern static Vector3d LocalToScaledSpace(Vector3d localSpacePoint); 36 | public extern static void RemoveScaledSpaceTransform(Transform t); 37 | /// 38 | /// Convert a position in planetarium coordinates into a position in world coordinates. 39 | /// 40 | /// A position in planetarium coordinates. 41 | /// The corresponding position in world coordinates. 42 | public extern static Vector3d ScaledToLocalSpace(Vector3d scaledSpacePoint); 43 | } 44 | -------------------------------------------------------------------------------- /src/ScenarioCreationOptions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | /// 4 | /// A list of options for use with the KSPScenario attribute. 5 | /// 6 | public enum ScenarioCreationOptions 7 | { 8 | None = 0, 9 | AddToNewSandboxGames = 2, 10 | AddToExistingSandboxGames = 4, 11 | AddToNewScienceSandboxGames = 8, 12 | AddToExistingScienceSandboxGames = 16, 13 | AddToNewCareerGames = 32, 14 | AddToNewGames = 42, 15 | AddToExistingCareerGames = 64, 16 | AddToExistingGames = 84, 17 | AddToAllGames = 126, 18 | RemoveFromSandboxGames = 128, 19 | RemoveFromScienceSandboxGames = 256, 20 | RemoveFromCareerGames = 512, 21 | RemoveFromAllGames = 896, 22 | } 23 | -------------------------------------------------------------------------------- /src/ScenarioDiscoverableObjects.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | /// Stores information on asteroid spawning 4 | /// 5 | /// 6 | /// Executed while in Flight, Tracking Station, and Space Center scenes 7 | /// 8 | /// The module schedules periodic "spawn checks" while the game clock is running, at an interval 9 | /// set by spawnInterval. At each spawn check, any asteroids that have gone untracked for too long 10 | /// are removed from the game. 11 | /// 12 | /// To add an element of randomness, only a fraction of checks (controlled by spawnOddsAgainst) 13 | /// have a chance to produce asteroids. No asteroids are produced if the number of untracked 14 | /// asteroids already in the game exceeds spawnGroupMaxLimit. Because spawn checks happen 15 | /// very frequently, the number of detected asteroids in a game where the player never 16 | /// tracks an asteroid will almost always be close to spawnGroupMaxLimit. 17 | /// 18 | /// The timing of spawn checks appears to be independent of the warp rate, but at high time warp 19 | /// multiple asteroids may be spawned per check. (Needs confirmation) 20 | /// 21 | public class ScenarioDiscoverableObjects : ScenarioModule 22 | { 23 | /// Number of untracked asteroids at which spawn rate begins to slow 24 | public int spawnGroupMinLimit = 3; 25 | 26 | /// Number of untracked asteroids at which spawn rate stops completely 27 | public int spawnGroupMaxLimit = 8; 28 | 29 | /// Sets size distribution for asteroids 30 | /// 31 | /// The output range of [0, 1) is divided equally among the classes. So [0, 0.2) is class A, 32 | /// [0.2, 0.4) is class B, ..., [0.8, 1) is class E. 33 | /// 34 | /// Default curve translates to 35 | /// 12% class A, 13% class B, 49% class C, 13% class D, and 12% class E 36 | /// 37 | /// 38 | [KSPField (isPersistant = true)] public FloatCurve sizeCurve /* = new FloatCurve 39 | { 40 | {0 , 0 , 1.5 , 1.5 }, 41 | {0.3, 0.45, 0.875, 0.875}, 42 | {0.7, 0.55, 0.875, 0.875}, 43 | {1 , 1 , 1.5 , 1.5 } 44 | }*/; 45 | 46 | /// Controls the fraction of spawn checks in which new asteroids are generated 47 | /// 48 | /// The probability of spawning an asteroid is 1 / (1 + spawnOddsAgainst) 49 | /// 50 | public int spawnOddsAgainst = 2; 51 | 52 | /// Number of seconds between asteroid checks 53 | /// 54 | /// 55 | /// These are seconds of time spent playing KSP, regardless of the time warp rate. The faster 56 | /// your time warp, the longer the in-game interval between asteroid detections. 57 | /// 58 | /// Since asteroids are removed during spawn checks, spawnInterval also controls the 59 | /// asteroid removal rate. 60 | /// 61 | public float spawnInterval = 15.0f; 62 | 63 | /// Longest time an asteroid can go untracked before disappearing, in Earth days 64 | /// 65 | public float maxUntrackedLifetime = 20.0f; 66 | 67 | /// Shortest time an asteroid can go untracked before disappearing, in Earth days 68 | /// 69 | public float minUntrackedLifetime = 1.0f; 70 | 71 | //---------------------------------------------------------------------- 72 | 73 | /// Returns a description of the current spawn interval and spawn odds 74 | /// 75 | /// 76 | /// 77 | /*[ContextMenu ()]*/ public extern void debugSpawnProbability(); 78 | 79 | public extern /*override*/ void OnAwake(); 80 | public extern /*override*/ void OnLoad(ConfigNode node); 81 | public extern /*override*/ void OnSave(ConfigNode node); 82 | 83 | /// Creates a random asteroid and Kerbin-intercepting orbit 84 | /*[ContextMenu()]*/ 85 | public extern void SpawnAsteroid(); 86 | 87 | /// Creates a random asteroid and Kerbin-intercepting orbit. 88 | /// 89 | /// 90 | /// Asteroid is identical to the last 91 | /// call of SpawnAsteroid() 92 | /// 93 | /// Intended for debugging? 94 | /// 95 | /*[ContextMenu ()]*/ public extern void SpawnLastAsteroid (); 96 | 97 | public extern void Start (); 98 | } -------------------------------------------------------------------------------- /src/ScienceData.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | /// 4 | /// Class containing information on science reports, stored in the persistent file in modules using IScienceDataContainer. 5 | /// 6 | public class ScienceData /*: IConfigNode*/ 7 | { 8 | /// 9 | /// Amount of data, in mits, to be transmitted or recovered. Affects transmission time and energy usage. 10 | /// 11 | public float dataAmount; 12 | /// 13 | /// Level of science lab boost, less than 1 is un-boosted, 1.5 is the standard lab boosted value, higher levels don't appear to be used. 14 | /// 15 | public float labBoost; 16 | /// 17 | /// ID of science data in Experimentname@CelestialbodynameExperimentalsituationBiome format, matches Science Subject id. 18 | /// 19 | public string subjectID; 20 | /// 21 | /// Science data title, displayed on experimental results dialog page and recovery summary. 22 | /// 23 | public string title; 24 | /// 25 | /// Percentage of science value that can be transmitted. 1 is equal to the amount gained by returning to Kerbin. 26 | /// 27 | public float transmitValue; 28 | 29 | public extern ScienceData(ConfigNode node); 30 | /// 31 | /// Generate Science Data based on Science Subject values. 32 | /// 33 | /// Amount of data, it mits. 34 | /// Transmission value 35 | /// Current state of science lab boost 36 | /// Matches Science Subject ID 37 | /// Title of science data 38 | public extern ScienceData(float amount, float xmitValue, float labBoost, string id, string dataName); 39 | 40 | public extern static ScienceData CopyOf(ScienceData src); 41 | public extern void Load(ConfigNode node); 42 | public extern void Save(ConfigNode node); 43 | } 44 | -------------------------------------------------------------------------------- /src/ScienceExperiment.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | /// 5 | /// Class containing information from the experiment stored in the ScienceDefs file. 6 | /// 7 | [Serializable] 8 | public class ScienceExperiment 9 | { 10 | /// 11 | /// Base science value from ScienceDefs file. 12 | /// 13 | public float baseValue; 14 | /// 15 | /// Bitmask to determine when biomes are relevant. 16 | /// 17 | public uint biomeMask; 18 | /// 19 | /// Multiplier to increase data amount in mits. 20 | /// 21 | public float dataScale; 22 | /// 23 | /// Title to be displayed for experimental results dialog and science archives. 24 | /// 25 | public string experimentTitle; 26 | /// 27 | /// Matches ID from ModuleScienceExperiment field. 28 | /// 29 | public string id; 30 | /// 31 | /// Can the experiment only be performed on planets with an atmosphere? 32 | /// 33 | public bool requireAtmosphere; 34 | /// 35 | /// Maximum science value available for each experimental result. 36 | /// 37 | public float scienceCap; 38 | /// 39 | /// Bitmask to determine which Experiment Situations the experiment can be performed in. 40 | /// 41 | public uint situationMask; 42 | 43 | public extern ScienceExperiment(); 44 | 45 | extern Dictionary Results { get; } 46 | 47 | /// 48 | /// Checks if the biome is relevent to the experiment given the biomeMask specified in the ScienceDefs file. 49 | /// 50 | /// Current Experiment Situation 51 | /// 52 | public extern bool BiomeIsRelevantWhile(ExperimentSituations situation); 53 | /// 54 | /// Determines if the experiment is available given the situationMask and requireAtmosphere values specified in the ScienceDefs file. 55 | /// 56 | /// Current Experiment Situation 57 | /// Current Celestial Body 58 | /// 59 | public extern bool IsAvailableWhile(ExperimentSituations situation, CelestialBody body); 60 | public extern void Load(ConfigNode node); 61 | public extern void Save(ConfigNode node); 62 | } 63 | -------------------------------------------------------------------------------- /src/ScienceSubject.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | /// 4 | /// Class containing information on a specific science result, data stored in the persistent file under the R&D node. 5 | /// 6 | [Serializable] 7 | public class ScienceSubject /*: IConfigNode*/ 8 | { 9 | /// 10 | /// Multiply science value by this dataScale value to determine data amount in mits. 11 | /// 12 | public float dataScale; 13 | /// 14 | /// Subject ID in Experimentname@CelestialbodyExperimentalsituationBiome format 15 | /// 16 | public string id; 17 | /// 18 | /// Amount of science already earned from this subject, not updated until after transmission/recovery. 19 | /// 20 | public float science; 21 | /// 22 | /// Total science allowable for this subject, based on subjectValue. 23 | /// 24 | public float scienceCap; 25 | /// 26 | /// Diminishing value multiplier for decreasing the science value returned from repeated experiments. 27 | /// 28 | public float scientificValue; 29 | /// 30 | /// Multiplier for specific Celestial Body/Experiment Situation combination. 31 | /// 32 | public float subjectValue; 33 | /// 34 | /// Title of science subject, displayed in science archives. 35 | /// 36 | public string title; 37 | 38 | /// 39 | /// Return a Science Subject from Research and Development node in the persistent file. 40 | /// 41 | /// 42 | public extern ScienceSubject(ConfigNode node); 43 | /// 44 | /// Generate new Science Subject. 45 | /// 46 | /// Science Experiment from ScienceDefs file and ModuleScienceExperiment 47 | /// Current experimantal situation, based on VesselSituation 48 | /// Current Celestial Body 49 | /// Current biome if applicable, empty string if not 50 | public extern ScienceSubject(ScienceExperiment exp, ExperimentSituations sit, CelestialBody body, string biome = ""); 51 | public extern ScienceSubject(string id, string title, float dataScale, float subjectValue, float scienceCap); 52 | public extern ScienceSubject(ScienceExperiment exp, ExperimentSituations sit, string sourceUid, string sourceTitle, CelestialBody body, string biome = ""); 53 | 54 | public extern void Load(ConfigNode node); 55 | public extern void Save(ConfigNode node); 56 | } 57 | -------------------------------------------------------------------------------- /src/ScreenMessage.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | /// 5 | /// A class representing temporary messages posted to the screen. Don't use this class, use the static methods in ScreenMessages instead. 6 | /// 7 | public class ScreenMessage 8 | { 9 | public float duration; 10 | public GUIStyle guiStyleOverride; 11 | public string message; 12 | public bool persistAcrossScenes; 13 | public float startTime; 14 | public ScreenMessageStyle style; 15 | 16 | public extern ScreenMessage(string msg, float dur, ScreenMessageStyle s); 17 | public extern ScreenMessage(string msg, float dur, bool persistAcrossScenes, ScreenMessageStyle s); 18 | public extern ScreenMessage(string msg, float dur, ScreenMessageStyle s, GUIStyle guiStyle); 19 | public extern ScreenMessage(string msg, float dur, bool persistAcrossScenes, ScreenMessageStyle s, GUIStyle guiStyle); 20 | } 21 | -------------------------------------------------------------------------------- /src/ScreenMessages.cs: -------------------------------------------------------------------------------- 1 | #region Assembly Assembly-CSharp.dll, v2.0.50727 2 | // C:\greg\games\KSP 0.18.2\KSP_Data\Managed\Assembly-CSharp.dll 3 | #endregion 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | using UnityEngine; 8 | 9 | /// 10 | /// A class that lets you post temporary messages to the screen. If you use this class your messages will 11 | /// automatically have the same style as regular in-game messages. 12 | /// 13 | public class ScreenMessages : MonoBehaviour 14 | { 15 | /// 16 | /// The set of currently active screen messages. This is a non-static member, but you can get a 17 | /// reference to the ScreenMessages instance via 18 | /// ScreenMessages sm = (ScreenMessages)GameObject.FindObjectOfType(typeof(ScreenMessages)); 19 | /// 20 | public List activeMessages; 21 | public GUIStyle[] textStyles; 22 | public bool useRenderQueue; 23 | 24 | public extern ScreenMessages(); 25 | 26 | /// 27 | /// Post a temporary message to the screen. Examples of screen messages are the "Warp = {number}x" message 28 | /// and the "Quicksaving..." message. 29 | /// 30 | /// The message to post 31 | public extern static void PostScreenMessage(ScreenMessage msg); 32 | /// 33 | /// Post a temporary message to the screen. Examples of screen messages are the "Warp = {number}x" message 34 | /// and the "Quicksaving..." message. 35 | /// 36 | /// The message to post. 37 | /// A reference to the posted message 38 | public extern static ScreenMessage PostScreenMessage(string message); 39 | /// 40 | /// Post a temporary message to the screen. Examples of screen messages are the "Warp = {number}x" message 41 | /// and the "Quicksaving..." message. 42 | /// 43 | /// The message to post 44 | /// How long the message should remain on the screen, in seconds. 45 | /// A reference to the posted message 46 | public extern static ScreenMessage PostScreenMessage(string message, float duration); 47 | /// 48 | /// Post a temporary message to the screen. Examples of screen messages are the "Warp = {number}x" message 49 | /// and the "Quicksaving..." message. 50 | /// 51 | /// The message to post 52 | /// How long the message should remain on the screen, in seconds. 53 | /// Which style of screen message to post--for instance, should it by like the warp message, the quicksaving message, etc. 54 | /// A reference to the posted message 55 | public extern static ScreenMessage PostScreenMessage(string message, float duration, ScreenMessageStyle style); 56 | /// 57 | /// Remove a currently active message from the screen. 58 | /// 59 | /// The message to remove 60 | public extern static void RemoveMessage(ScreenMessage msg); 61 | } 62 | 63 | /// 64 | /// An enumeration of the different styles of message you can display. 65 | /// 66 | public enum ScreenMessageStyle 67 | { 68 | /// 69 | /// This results in a message in the same font and position as the "Warp = {number}x" message. 70 | /// 71 | UPPER_CENTER = 0, 72 | /// 73 | /// What sort of message style does this produce? 74 | /// 75 | UPPER_LEFT = 1, 76 | /// 77 | /// This results in a message in the same font and position as the "Quicksaving..." message. 78 | /// 79 | UPPER_RIGHT = 2, 80 | /// 81 | /// What sort of message style does this produce? 82 | /// 83 | LOWER_CENTER = 3, 84 | } 85 | -------------------------------------------------------------------------------- /src/SeekOrigin.cs: -------------------------------------------------------------------------------- 1 | #region Assembly Assembly-CSharp.dll, v2.0.50727 2 | // C:\greg\games\KSP 0.18.2\KSP_Data\Managed\Assembly-CSharp.dll 3 | #endregion 4 | 5 | using System; 6 | 7 | namespace KSP.IO 8 | { 9 | /// 10 | /// This enum is a replacement for its System.IO equivalent. It's used to determine from where one wishes to seek in a file stream. 11 | /// 12 | public enum SeekOrigin 13 | { 14 | /// 15 | /// Seek from the beginning of the stream. 16 | /// 17 | Begin = 0, 18 | /// 19 | /// Seek from the current position in the stream. 20 | /// 21 | Current = 1, 22 | /// 23 | /// Seek from the end of the stream. 24 | /// 25 | End = 2, 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/ShipConstruct.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using System.Reflection; 5 | 6 | [Serializable] 7 | public class ShipConstruct /*: IEnumerable, IShipconstruct, IEnumerable*/ 8 | { 9 | public static int lastCompatibleMajor; 10 | public static int lastCompatibleMinor; 11 | public static int lastCompatibleRev; 12 | /// 13 | /// A list of all the parts in the ShipConstruct. 14 | /// The parts are listed in the same order in which they were added to the ship in the editor. 15 | /// 16 | public List parts; 17 | public string shipDescription; 18 | public string shipName; 19 | public bool shipPartsUnlocked; 20 | public int shipType; 21 | 22 | public extern ShipConstruct(); 23 | public extern ShipConstruct(int shipType); 24 | public extern ShipConstruct(string shipName, int shipType, List parts); 25 | public extern ShipConstruct(string shipName, string shipDescription, Part rootPart); 26 | 27 | public extern int Count { get; } 28 | public extern List Parts { get; } 29 | 30 | public extern Part this[int index] { get; set; } 31 | 32 | public extern void Add(Part p); 33 | public extern bool AreAllPartsConnected(); 34 | public extern void Clear(); 35 | public extern bool Contains(Part p); 36 | public extern IEnumerator GetEnumerator(); 37 | public extern float GetShipCosts(out float dryCost, out float fuelCost); 38 | public extern bool isControllable(); 39 | public extern bool LoadShip(ConfigNode root); 40 | public extern void Remove(Part p); 41 | public extern ConfigNode SaveShip(); 42 | } 43 | -------------------------------------------------------------------------------- /src/SpaceCenter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | public class SpaceCenter : MonoBehaviour 5 | { 6 | public double AreaRadius; 7 | public CelestialBody cb; 8 | public static SpaceCenter Instance; 9 | public Collider spaceCenterAreaTrigger; 10 | 11 | public extern SpaceCenter(); 12 | 13 | public extern double Latitude { get; } 14 | public extern double Longitude { get; } 15 | public extern Transform SpaceCenterTransform { get; set; } 16 | public extern Vector3d SrfNVector { get; } 17 | 18 | public extern double GreatCircleDistance(Vector3d fromSrfNrm); 19 | } 20 | -------------------------------------------------------------------------------- /src/Sun.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | public class Sun : MonoBehaviour 5 | { 6 | public double AU; 7 | public AnimationCurve brightnessCurve; 8 | public float fadeEnd; 9 | public float fadeStart; 10 | public static Sun Instance; 11 | public float localTime; 12 | public CelestialBody sun; 13 | public Vector3d sunDirection; 14 | public LensFlare sunFlare; 15 | public Transform target; 16 | public bool useLocalSpaceSunLight; 17 | 18 | public extern Sun(); 19 | 20 | public extern float GetLocalTimeAtPosition(Vector3d wPos, CelestialBody cb); 21 | public extern void SunlightEnabled(bool state); 22 | } 23 | -------------------------------------------------------------------------------- /src/TextReader.cs: -------------------------------------------------------------------------------- 1 | #region Assembly Assembly-CSharp.dll, v2.0.50727 2 | // C:\greg\games\KSP 0.18.2\KSP_Data\Managed\Assembly-CSharp.dll 3 | #endregion 4 | 5 | using System; 6 | using System.IO; 7 | using System.Text; 8 | 9 | namespace KSP.IO 10 | { 11 | /// 12 | /// Identical to System.IO.TextReader, but with added IDisposable methods (for use in using() statements), and a factory method instead of constructors. 13 | /// 14 | public class TextReader : IDisposable 15 | { 16 | public extern Stream BaseStream { get; } 17 | public extern Encoding CurrentEncoding { get; } 18 | public extern bool EndOfStream { get; } 19 | 20 | public extern void Close(); 21 | /// 22 | /// Create a text reader stream. 23 | /// 24 | /// 25 | /// 26 | /// 27 | /// 28 | public extern static TextReader CreateForType(string filename, Vessel flight = null); 29 | public extern void DiscardBufferedData(); 30 | public extern void Dispose(); 31 | public extern int Peek(); 32 | public extern int Read(); 33 | public extern int Read(char[] buffer, int index, int count); 34 | public extern string ReadLine(); 35 | public extern string ReadToEnd(); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/TextWriter.cs: -------------------------------------------------------------------------------- 1 | #region Assembly Assembly-CSharp.dll, v2.0.50727 2 | // C:\greg\games\KSP 0.18.2\KSP_Data\Managed\Assembly-CSharp.dll 3 | #endregion 4 | 5 | using System; 6 | using System.Text; 7 | 8 | namespace KSP.IO 9 | { 10 | /// 11 | /// Identical to System.IO.TextWriter, but with added IDisposable methods (for use in using() statements), and a factory method instead of constructors. 12 | /// 13 | public class TextWriter : IDisposable 14 | { 15 | public extern Encoding Encoding { get; } 16 | public extern IFormatProvider FormatProvider { get; } 17 | public extern string NewLine { get; set; } 18 | 19 | public extern void Close(); 20 | /// 21 | /// Create a text writing stream 22 | /// 23 | /// 24 | /// 25 | /// 26 | /// 27 | public extern static TextWriter CreateForType(string filename, Vessel flight = null); 28 | public extern void Dispose(); 29 | public extern void Flush(); 30 | public extern void Write(bool value); 31 | public extern void Write(char value); 32 | public extern void Write(char[] buffer); 33 | public extern void Write(decimal value); 34 | public extern void Write(double value); 35 | public extern void Write(float value); 36 | public extern void Write(int value); 37 | public extern void Write(long value); 38 | public extern void Write(object value); 39 | public extern void Write(string value); 40 | public extern void Write(uint value); 41 | public extern void Write(ulong value); 42 | public extern void Write(string format, object arg0); 43 | public extern void Write(string format, params object[] arg); 44 | public extern void Write(char[] buffer, int index, int count); 45 | public extern void Write(string format, object arg0, object arg1); 46 | public extern void Write(string format, object arg0, object arg1, object arg2); 47 | public extern void WriteLine(); 48 | public extern void WriteLine(bool value); 49 | public extern void WriteLine(char value); 50 | public extern void WriteLine(char[] buffer); 51 | public extern void WriteLine(decimal value); 52 | public extern void WriteLine(double value); 53 | public extern void WriteLine(float value); 54 | public extern void WriteLine(int value); 55 | public extern void WriteLine(long value); 56 | public extern void WriteLine(object value); 57 | public extern void WriteLine(string value); 58 | public extern void WriteLine(uint value); 59 | public extern void WriteLine(ulong value); 60 | public extern void WriteLine(string format, object arg0); 61 | public extern void WriteLine(string format, params object[] arg); 62 | public extern void WriteLine(char[] buffer, int index, int count); 63 | public extern void WriteLine(string format, object arg0, object arg1); 64 | public extern void WriteLine(string format, object arg0, object arg1, object arg2); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/TimeWarp.cs: -------------------------------------------------------------------------------- 1 | #region Assembly Assembly-CSharp.dll, v2.0.50727 2 | // C:\greg\games\KSP 0.18.2\KSP_Data\Managed\Assembly-CSharp.dll 3 | #endregion 4 | 5 | using System; 6 | using UnityEngine; 7 | 8 | /// 9 | /// The class that handles time warp. 10 | /// 11 | public class TimeWarp : MonoBehaviour 12 | { 13 | /// 14 | /// Unused? CelestialBodies have their own sets of altitude limits. 15 | /// 16 | public float[] altitudeLimits; 17 | public int current_rate_index; 18 | /// 19 | /// Use this TimeWarp instance to access non-static members. 20 | /// 21 | public static TimeWarp fetch; 22 | public int maxModeSwitchRate_index; 23 | public int maxPhysicsRate_index; 24 | public TimeWarp.Modes Mode; 25 | /// 26 | /// The available physics warp rates. In 0.18.2 these are {1, 2, 3, 4} by default. You can modify the 27 | /// available rates by modifying this array. 28 | /// 29 | public float[] physicsWarpRates; 30 | public GUIStyle screenTextStyle; 31 | public float textDuration; 32 | public ScreenSafeUISlideTab timeQuadrantTab; 33 | public ScreenSafeUISliderButton warpHighButton; 34 | public ScreenSafeUISliderButton warpLowButton; 35 | /// 36 | /// The available regular warp rates. In 0.18.2 these are {1, 5, 10, 50, 100, 1000, 10000, 100000} by default. 37 | /// You can modify the available rates by modifying this array. 38 | /// 39 | public float[] warpRates; 40 | 41 | public extern TimeWarp(); 42 | 43 | /// 44 | /// The current warp rate, e.g. 50 if the current warp rate is 50x. This number 45 | /// may not be equal to one of the entries in warpRates, because KSP will smoothly 46 | /// interpolate between two warp rates over a period of time when you increase 47 | /// or decrease the warp. 48 | /// 49 | public extern static float CurrentRate { get; } 50 | /// 51 | /// The index of the current current warp rate in either warpRates or physicsWarpRates, depending 52 | /// on whether WarpMode is HIGH or LOW. Note that CurrentRate may not equal the warp rate indexed 53 | /// by CurrentRateIndex if KSP has not finished interpolating the last warp change. 54 | /// 55 | public extern static int CurrentRateIndex { get; } 56 | public extern static float deltaTime { get; } 57 | /// 58 | /// The time between FixedUpdate cycles (i.e., the time between physics steps). See the Unity FixedUpdate 59 | /// documentation for more details. 60 | /// 61 | public extern static float fixedDeltaTime { get; } 62 | public extern static float MaxPhysicsRate { get; } 63 | /// 64 | /// Whether we are in regular warp mode or physics warp mode 65 | /// 66 | public extern static TimeWarp.Modes WarpMode { get; } 67 | 68 | /// 69 | /// Presumably, gets the minimum altitude in meters above the sea level of the given body at which the 70 | /// given warp rate index is allowed. 71 | /// 72 | /// A warp rate index 73 | /// The body in question 74 | /// The minimum altitude in meters at which that warp rate index is allowed 75 | public extern double GetAltitudeLimit(int i, CelestialBody body); 76 | /// 77 | /// Changes the warp rate to either warpRates[rateIndex] or physicsWarpRates[rate_index], depending 78 | /// on whether WarpMode is HIGH or LOW. 79 | /// 80 | /// The index of the desired new warp rate 81 | /// If false, KSP will gradually smoothly adjust the warp rate up or down until it reaches the target. 82 | /// If true, the warp rate will change instantly. 83 | public extern static void SetRate(int rate_index, bool instant); 84 | 85 | public enum Modes 86 | { 87 | /// 88 | /// Reguar time warp mode 89 | /// 90 | HIGH = 0, 91 | /// 92 | /// Physics warp mode 93 | /// 94 | LOW = 1, 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /src/TutorialScenario.cs: -------------------------------------------------------------------------------- 1 | #region Assembly Assembly-CSharp.dll, v2.0.50727 2 | // C:\greg\games\KSP 0.18.2\KSP_Data\Managed\Assembly-CSharp.dll 3 | #endregion 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | using UnityEngine; 8 | 9 | /// 10 | /// A TutorialScenario is a ScenarioModule with some added features that 11 | /// are useful for building tutorials or similar kinds of scenarios. A TutorialScenario 12 | /// comes with a builtin in finite state machine for running the scenario and 13 | /// displays "tutorial pages" in a GUI window alongside a picture of a friendly Kerbal instructor. 14 | /// You can take advantage of all these features by making your ScenarioModule a subclass of 15 | /// TutorialScenario. 16 | /// 17 | /// See HarvesteR's example code in his forum article: 18 | /// 19 | /// http://forum.kerbalspaceprogram.com/content.php/121-Writing-Tutorials-A-Demo-%28and-some-source-code%29 20 | /// 21 | public class TutorialScenario : ScenarioModule 22 | { 23 | protected GameObject arrowPrefab; 24 | protected List arrows; 25 | protected TutorialScenario.TutorialPage currentPage; 26 | public string guiSkinName; 27 | /// 28 | /// Controls the animated image of the kerbal instructor. This object lets you make the instructor run 29 | /// various animations . 30 | /// 31 | public KerbalInstructor instructor; 32 | public int instructorPortraitSize; 33 | /// 34 | /// Set this string in OnAssetSetup to specify which instructor kerbal will appear 35 | /// in the tutorial window. The value "Instructor_Gene" gives Gene Kerman as the 36 | /// instructor. The default if you do not specify anything is Werner von Kerman. 37 | /// 38 | public string instructorPrefabName; 39 | public RenderTexture instructorTexture; 40 | public int textureBorderRadius; 41 | /// 42 | /// The finite state machine that controls the progression of the tutorial. 43 | /// 44 | protected TutorialScenario.TutorialFSM Tutorial; 45 | public string tutorialArrowPrefabName; 46 | 47 | public extern TutorialScenario(); 48 | 49 | protected extern void ClearArrows(); 50 | protected extern TutorialArrow CreateArrow(); 51 | protected extern void DeleteArrow(TutorialArrow arrow); 52 | protected extern void Destroy(global::UnityEngine.Object obj); 53 | /// 54 | /// Override this function to run some initialization code? 55 | /// 56 | protected extern virtual void OnAssetSetup(); 57 | /// 58 | /// Override this function to run some code as the tutorial 59 | /// is being set up. 60 | /// 61 | protected extern virtual void OnTutorialSetup(); 62 | /// 63 | /// Sets the location of the GUI window of the tutorial. 64 | /// 65 | /// 66 | protected extern void SetDialogRect(Rect r); 67 | 68 | /// 69 | /// The TutorialFSM provides a convient interface for implementing the meat of 70 | /// your scenario logic through a finite state machine. The states of the state 71 | /// machine are "pages." 72 | /// 73 | [Serializable] 74 | public class TutorialFSM : KerbalFSM 75 | { 76 | /// 77 | /// The page that the tutorial was on before this one. 78 | /// 79 | public TutorialScenario.TutorialPage lastPage; 80 | /// 81 | /// The list of all pages in the tutorial. 82 | /// 83 | public List pages; 84 | 85 | public extern TutorialFSM(); 86 | 87 | /// 88 | /// Add a page (a new possible state) to the tutorial. 89 | /// 90 | /// The page to add. 91 | public extern void AddPage(TutorialScenario.TutorialPage st); 92 | /// 93 | /// Add a page (a new possible state) to the tutorial, but outside 94 | /// the default page sequence that will be used by GoToLastPage and 95 | /// GoToNextPage. 96 | /// 97 | /// The page to add. 98 | public extern void AddState(TutorialScenario.TutorialPage st); 99 | /// 100 | /// Transition the tutorial to the page before the current one in the default page sequence. 101 | /// 102 | public extern void GoToLastPage(); 103 | /// 104 | /// Transition the tutorial to the page after current one in the default page sequence. 105 | /// 106 | public extern void GoToNextPage(); 107 | /// 108 | /// Start the finite state machine on the page with the given name. 109 | /// 110 | /// The name of the page to start on. 111 | public extern void StartTutorial(string initialPageName); 112 | /// 113 | /// Start the finite state machine on the given page. 114 | /// 115 | /// The page to start one. 116 | public extern void StartTutorial(TutorialScenario.TutorialPage initialPage); 117 | } 118 | 119 | /// 120 | /// TutorialPages are the states in the TutorialFSM finite state machine. 121 | /// They extend the KFSMState class, which represents a class in a more general 122 | /// finite state machine, to add tutorial-related features like a Callback in which 123 | /// you draw the GUI of the tutorial page. 124 | /// 125 | /// 126 | /// 127 | public class TutorialPage : KFSMState 128 | { 129 | /// 130 | /// Presumably, this KFSMEvent will be triggered when the function you passed to SetAdvanceCondition 131 | /// returns true. This should give you the opportunity to go to a page besides the default next 132 | /// page when the advance condition is met. 133 | /// 134 | public KFSMEvent onAdvanceConditionMet; 135 | /// 136 | /// Assign this Callback to a function that uses GUILayout to draw the GUI of this tutorial page. 137 | /// Whatever you do here gets draw inside the tutorial window, next to the picture of the 138 | /// Kerbal instructor. 139 | /// 140 | public Callback OnDrawContent; 141 | /// 142 | /// Is this event triggered when GoToLastPage is called? Perhaps it gives you a chance to 143 | /// go to a page besides the default previous page? 144 | /// 145 | public KFSMEvent onStepBack; 146 | /// 147 | /// The title displayed for this page. 148 | /// 149 | public string windowTitle; 150 | 151 | /// 152 | /// Create a new tutorial page with a given name. Note that the name of the page 153 | /// is distinct from its title. 154 | /// 155 | /// The name of the new page. 156 | public extern TutorialPage(string name); 157 | 158 | /// 159 | /// You can call this function and pass to it a function that takes a KFSMState 160 | /// and returns a boolean. That function will be called every update cycle while 161 | /// this tutorial page is active. If the function ever returns true, the tutorial 162 | /// will automatically advance to the next page. 163 | /// 164 | /// 165 | public extern void SetAdvanceCondition(KFSMEventCondition condition); 166 | } 167 | } 168 | -------------------------------------------------------------------------------- /src/UntrackedObjectClass.cs: -------------------------------------------------------------------------------- 1 | /// Describes an asteroid's size 2 | public enum UntrackedObjectClass 3 | { 4 | /// Standard radius = ??? 5 | A, 6 | /// Standard radius = 5.5 m? 7 | B, 8 | /// Standard radius = 8.5 m? 9 | C, 10 | /// Standard radius = 15 m? 11 | D, 12 | /// Standard radius = 25 m? 13 | E 14 | } 15 | -------------------------------------------------------------------------------- /src/Vector3d.cs: -------------------------------------------------------------------------------- 1 | #region Assembly Assembly-CSharp.dll, v2.0.50727 2 | // C:\greg\games\KSP 0.18.2\KSP_Data\Managed\Assembly-CSharp.dll 3 | #endregion 4 | 5 | using System; 6 | using System.Reflection; 7 | using UnityEngine; 8 | 9 | /// 10 | /// A Vector3d in 3D space. 11 | /// Vector3d is just like Unity's Vector3 class, except it uses doubles instead of floats, 12 | /// so refer to the Unity documentation on Vector3. 13 | /// Vector3d also adds a few functions. 14 | /// 15 | public struct Vector3d 16 | { 17 | public const float kEpsilon = 1e-005f; 18 | 19 | public double x; 20 | public double y; 21 | public double z; 22 | 23 | public extern Vector3d(double x, double y); 24 | public extern Vector3d(double x, double y, double z); 25 | 26 | public extern static Vector3d operator -(Vector3d a); 27 | public extern static Vector3d operator -(Vector3 a, Vector3d b); 28 | public extern static Vector3d operator -(Vector3d a, Vector3 b); 29 | public extern static Vector3d operator -(Vector3d a, Vector3d b); 30 | public extern static bool operator !=(Vector3d lhs, Vector3d rhs); 31 | public extern static Vector3d operator *(double d, Vector3d a); 32 | public extern static Vector3d operator *(Vector3d a, double d); 33 | public extern static Vector3d operator /(Vector3d a, double d); 34 | public extern static Vector3d operator +(Vector3 a, Vector3d b); 35 | public extern static Vector3d operator +(Vector3d a, Vector3 b); 36 | public extern static Vector3d operator +(Vector3d a, Vector3d b); 37 | public extern static bool operator ==(Vector3d lhs, Vector3d rhs); 38 | public extern static implicit operator Vector3d(Vector3 v); 39 | public extern static implicit operator Vector3(Vector3d v); 40 | 41 | /// 42 | /// Minus forward 43 | /// 44 | public static Vector3d back { get { return Vector3d.zero; } } 45 | /// 46 | /// Minus up 47 | /// 48 | public static Vector3d down { get { return Vector3d.zero; } } 49 | public static Vector3d forward { get { return Vector3d.zero; } } 50 | [Obsolete("Use Vector3.forward instead.")] 51 | public static Vector3d fwd { get { return Vector3d.zero; } } 52 | /// 53 | /// Minus right. 54 | /// 55 | public static Vector3d left { get { return Vector3d.zero; } } 56 | public double magnitude { get { return 0; } } 57 | public Vector3d normalized { get { return Vector3d.zero; } } 58 | public static Vector3d one { get { return Vector3d.zero; } } 59 | public static Vector3d right { get { return Vector3d.zero; } } 60 | public double sqrMagnitude { get { return 0; } } 61 | public static Vector3d up { get { return Vector3d.zero; } } 62 | /// 63 | /// Returs a new Vector3d with the y and z coordinates swapped? 64 | /// 65 | public Vector3d xzy { get { return Vector3d.zero; } } 66 | public static Vector3d zero { get { return Vector3d.zero; } } 67 | 68 | public double this[int index] { get { return 0; } set { } } 69 | 70 | public extern static double Angle(Vector3d from, Vector3d to); 71 | [Obsolete("Use Vector3.Angle instead. AngleBetween uses radians instead of degrees and was deprecated for this reason")] 72 | public extern static double AngleBetween(Vector3d from, Vector3d to); 73 | public extern static Vector3d Cross(Vector3d lhs, Vector3d rhs); 74 | public extern static double Distance(Vector3d a, Vector3d b); 75 | public extern static double Dot(Vector3d lhs, Vector3d rhs); 76 | public extern override bool Equals(object other); 77 | /// 78 | /// Returns fromThat - Vector3d.Project(fromThat, excludeThis). That is, it removes 79 | /// the component of fromThat that is parallel to excludeThis and returns the remainder, which will 80 | /// be perpendicular to excludeThis. 81 | /// 82 | /// The direction to exclude from the result. 83 | /// The starting vector 84 | /// A vector perpendicular to excludeThis and pointing in the same general direction as fromThat. 85 | public extern static Vector3d Exclude(Vector3d excludeThis, Vector3d fromThat); 86 | public extern override int GetHashCode(); 87 | public extern static Vector3d Lerp(Vector3d from, Vector3d to, float t); 88 | public extern static double Magnitude(Vector3d a); 89 | public extern static Vector3d Max(Vector3d lhs, Vector3d rhs); 90 | public extern static Vector3d Min(Vector3d lhs, Vector3d rhs); 91 | public extern void Normalize(); 92 | public extern static Vector3d Normalize(Vector3d value); 93 | public extern static void OrthoNormalize(ref Vector3d normal, ref Vector3d tangent); 94 | public extern static void OrthoNormalize(ref Vector3d normal, ref Vector3d tangent, ref Vector3d binormal); 95 | public extern static Vector3d Project(Vector3d vector, Vector3d onNormal); 96 | public extern static Vector3d Reflect(Vector3d inDirection, Vector3d inNormal); 97 | public extern static Vector3d RotateTowards(Vector3d from, Vector3d to, float maxRadiansDelta, float maxMagnitudeDelta); 98 | public extern void Scale(Vector3d scale); 99 | public extern static Vector3d Scale(Vector3d a, Vector3d b); 100 | public extern static Vector3d Slerp(Vector3d from, Vector3d to, float t); 101 | public extern static double SqrMagnitude(Vector3d a); 102 | public extern override string ToString(); 103 | } 104 | -------------------------------------------------------------------------------- /src/main.md: -------------------------------------------------------------------------------- 1 | ### About this project 2 | 3 | This is community-generated documentation for the KSP API. It has been 4 | assembled through the efforts of 5 | [a number of people](https://github.com/Anatid/XML-Documentation-for-the-KSP-API/graphs/contributors). 6 | If you want to contribute, read the instructions at 7 | [the Github project](https://github.com/Anatid/XML-Documentation-for-the-KSP-API#how-to-contribute-to-this-documentation). 8 | 9 | ### Where to start 10 | 11 | Probably the best place to start browsing this documentation is the 12 | [class list](http://anatid.github.io/XML-Documentation-for-the-KSP-API/annotated.html). 13 | 14 | ### Documentation in your IDE 15 | 16 | You can download an XML documentation file that will integrate this documentation 17 | with Visual Studio or MonoDevelop. Download 18 | [Assembly-CSharp.xml](https://raw.githubusercontent.com/Anatid/XML-Documentation-for-the-KSP-API/master/Assembly-CSharp.xml) 19 | and place it next to Assembly-CSharp.dll in the KSP_Data/Managed folder. Now 20 | VS or MonoDevelop will show the documentation in tooltips and in the object browser. 21 | 22 | ### What to do when the documentation is incomplete 23 | 24 | 1. Look at the source code of a mod that does something similar to what you are trying to do. 25 | 26 | 2. Look through Assembly-CSharp.xml in the object browser and see if you can find any classes 27 | with likely-sounding names. Then try them out. This is how this documentation was put together in 28 | the first place. 29 | 30 | 3. Once you learn how to use a class or member that's not documented here, you should 31 | contribute your new-found knowledge to make the documentation better. See the instructions 32 | for how to to help [here](https://github.com/Anatid/XML-Documentation-for-the-KSP-API#how-to-contribute-to-this-documentation). 33 | 34 | ### Resources for beginning plugin coders 35 | 36 | * Tutorials on setting up 37 | [Visual Studio](http://wiki.kerbalspaceprogram.com/wiki/Setting_up_Visual_Studio) 38 | or 39 | [MonoDevelop](http://wiki.kerbalspaceprogram.com/wiki/Setting_up_MonoDevelop) 40 | and 41 | [creating your first plugin](http://wiki.kerbalspaceprogram.com/wiki/Tutorial:Creating_your_first_module). 42 | 43 | * The 44 | [Plugin Development Help](http://forum.kerbalspaceprogram.com/forums/30-Plugin-Development-Help-and-Support) 45 | section of the official KSP forum. 46 | 47 | * [Example plugin projects to help you get started](http://forum.kerbalspaceprogram.com/threads/56053-Example-plugin-projects-to-help-you-get-started). 48 | 49 | * The source code of the many plugins on the 50 | [Add-On Releases](http://forum.kerbalspaceprogram.com/forums/35-Add-on-Releases) 51 | section of the official KSP forum. 52 | 53 | --------------------------------------------------------------------------------