KSP-KOS / KOS

Fully programmable autopilot mod for KSP. Originally By Nivekk
Other
690 stars 228 forks source link

Expose fuel line target to users #1974

Open burgled opened 7 years ago

burgled commented 7 years ago

Users can't walk through fuel lines because there is no visibility of what part a fuel line is targeting. This limits how much analysis one can do of the staging and performance of an arbitrary ship.

Dunbaratu commented 7 years ago

I'm going to move this out of the v1.1.0 milestone because it's a bit more complex than it looked on the surface and we need to trim the v1.1.0 list so we can get something out before KSP 1.1.3 drops on us.

But as I do so, I wanted to record here what I've discovered so far so I don't forget it a few months from now:

1 - Fuel lines are parts which contain a PartModule called CModuleLinkedMesh and another one called CModuleFuelLine. CModuleLinkedMesh is also the module used by struts, and I suspect it handles the logic of how both struts and fuel lines violate the parts tree structure. (i.e. they might contain the target of the link, instead of the target being a Child in the tree like how parts usually work).

2 - But, both CModuleLinkedMesh and CModuleFuelLine don't seem to be exposed publicly to anything the IDE can discover. I suspect the may be implemented externally to the DLL in some other code? But at any rate, it's impossible to discover what's inside them to call their members.

3 - There does seem to be another way to let scripts get the same information that we might be able to expose. If you want to do the parts walk in the opposite direction, every Part in KSP does have a fuelLookupTargets property, which is the list of all parts it's allowed to suck fuel from that are attached to it. So it may be possible to start from the target and discover its source fuel line, rather than the other way around. But it's going to take some investigation to testing to verify that this information is correct and that we're using it properly. (For example, does it include parts you could potentially suck fuel from if the crossfeed patterns were different, or does it only include parts you can currently suck fuel from, given the crossfeed settings you have now? Does it inlcude only the adjacent "one hop away" parts you can suck fuel from, or does it contain all the parts multiple hops away?) These questions require a lot of trial and error playing around (none of this stuff is documented by Squad - modders have to learn how the API works largely by trial and error).

Because of all that this will take more than just a couple of hours to implement, so I'm moving it out of v1.1.0.