Kerbal Inventory System (KIS)

Kerbal Inventory System (KIS)

1M Downloads

Public API for ModuleKISInventory.

allista opened this issue ยท 7 comments

commented

Hi.
I'm the developer of the Hangar mod, and I plan to extend its functionality with the ability to disassemble stored vessel into parts, then reassemble new vessels from stored parts. And I was hoping I could use KIS as a backed for part inventory, so that parts could be accessed via it for other uses.
I've skimmed through the code and, if I'm not mistaken, there's no API to access the inventory from another plugin without linking against KIS.
So i want to ask your advice on how to approach this.

@pellinor0, you could be interested to know this with respect to offloaded parts stats issue.

Thanks in advance!

commented

Are you aware that @magico13 is/was working on similar problems? KCT (kerbal construction time) also has a part inventory to track reuse of recovered parts. He was recently working on an overhaul of that inventory code, but I do not know what the state of that project is (he seems busy with other things at the moment).

commented

Yeah, I've definitely been away from KSP for a while. I've been trying to force myself to get back into it without a whole lot of luck. Regarding the part inventory I was working on, the code for it is here: https://github.com/magico13/ScrapYard. There's no UI and I want to add a way to track individual part reuse, so I really just need to spend a weekend on it and finalize some things.

If KIS provides that functionality then I can try to adapt KCT to use it instead (no sense duplicating work).

commented

I was aware of KCT part inventory, but was under the impression that it has entirely different mechanics than KIS, being global and linked to the editor, while what I need is individual per-container inventories with means to transfer/transport parts: the exact thing that KIS provides.

I didn't know about the overhaul, though. @magico13, could you describe its functionality in a few words? I unfortunately don't have the means to properly read the code - only the phone at hand now(

@ihsoft, I'm sorry, I wasn't clear enough. The vessel spawning part is long since covered; the Hangar does exactly this: despawns and respawns vessels. What I'm after is vessel disassembly into parts. All I want from KIS is to act like part storage and tracking system accessible through API. People use KIS a lot, so if I were to implement my own part inventory, the first request I would get is "make it compatible with KIS!" :)

If part message API is not available for the time, I can fall back to linking against KIS dll; if the modules themselves have public control interfaces, of course.

commented

@allista If you need spawning vessels then KIS is unlikely your friend. Main idea of KIS is creating a single part and adding it to the existing vessel. It results in a whole bunch of issues that KIS tries to mitigate (e.g. fighting with physics). On the other hand, spawning a vessel is a pretty easy task: you create a vessel CFG and then just do Game.AddVessel(vesselNode). As an example look at Contracts.Templates.RecoverAsset.GenerateLandrecovery().

As for KIS API it's in long term plans. I'm going to finish with KAS 1.0 and its API first.

commented

@allista, you're right about KCT's inventory being a global thing. The new one could possibly be used on a per vessel basis, but that's not much different than rolling your own in terms of compatibility with other mods. If you're talking about on-site storage, I agree that KIS sounds more correct. Especially if you want to limit by size or mass.

Also, Reflection is a powerful friend for allowing you to interact with other mods without hard dependencies. If an API is a ways out, you could always use reflection in the meantime, though with something like KIS it might be a bit trickier than the things I've interacted with in the past where I just need access to a few methods or properties.

commented

If part message API is not available for the time, I can fall back to linking against KIS dll; if the modules themselves have public control interfaces, of course.

Given the mod versions issue is now fixed you can do it this way. As far as I understand your mod won't work without KIS anyways, so adding a hard dependency on KIS doesn't seem to be a big issue.

commented

Thanks for the discussion and explanations! I think I close the issue and start to work on it.
And if some problems arise in the process will reopen.