ShipSections lets you divide your ships into different sections like "Lifter", "Interplanetary", "Lander", "Explodey Piece", etc. Through ShipSections, other mods can analyze just the parts within that section. Note: This is currently a VAB/SPH only experience. ShipSections does not currently have full support for craft in flight. It works when nothing blows up and nothing is docked, but I don't make any promises.
The ShipSections window is on the App Launcher. Click it, and you'll see a window with all of the current sections and a button to highlight each of them. To create a section, right click on any decoupler or non-shielded docking port and click "Create Section". That will make this part and all of its children within the current section parts of a new section. You can rename the section using the window mentioned before.
- Reference the ShipSections.dll.
- Derive your class from
SectionData<Your Class>
- Implement the Merge method. This method takes in another instance of your data class. Your job is to merge the data from that instance into your instance. This happens upon initial loading (merge current data into defaults), and whenever sections are merged.
- Optional: Create a config file with default values.
- Use the events and methods on the
ShipSections.API
class to interface with your section data.
Here is an example config:
SECTIONDATADEF
{
name = MySectionData
isPayload = 1
}
public class MySectionData : SectionData<MySectionData>
{
[Persistent]
public int isPayload = 0;
protected override void Merge(MySectionData data)
{
isPayload = data.isPayload;
}
}
The following method can be used to get data:
T API.GetSectionDataForMod<T>(string sectionName)
Pass in the name of a section and the type of section data that you want, and this method will return it to you for you to use. Generally, you should only have to use the API class and the SectionData<T>
class.
If you find a bug or want a new feature, contact me either on the KSP Forums, on GitHub, or on the KSP or KSP Mod Dev subreddits, or by private message on any of these platforms.
Extensive Engineer Report v0.5+