Jump to content

Resource handling for unloaded vessels


Recommended Posts

Hi everyone, 

I saw some guys talking about how stock KSP handles mining, isru etc for a vessel, which was unloaded for a while and then becomes active. Especially in the @RoverDude USI-LS thread, regarding supply and EC consumption. Things like 6 hour segments are processed as a catch up mechanic.

My question: are there any (Un)official resources or Wikis on how to work with that mechanic plugin-wise? I would like to implement that functionality to my RealBattery mod. Thanks!

Link to comment
Share on other sites

  • 2 weeks later...

There are two ways to do it.

One is the so-called 'catch-up simulation'. It is very simple: you just keep track of time elapsed since the module was active the last time, and when it become active again, you 'catch up' with the missing time. You practically do one (or more) simulation steps when the module is loaded, using the unloaded-time (or a fraction of it) you tracked in place of the usual elapsed time of a simulation step. You can understand how that's not going to work unless the set of producers, consumers and storage is trivially simple. But its advantage is simplicity.

Then there is the 'full blown background simulation'. In essence, you need to 'emulate' the module in question when the vessel is not loaded. This mean you will have to emulate its behaviour using only data available in the part prototype (for non-persistent data) and in the serialized structure of the module (for persistent data). You can even change the latter during the simulation if required.

Now, some modules are not 'self-contained': eg: they may interact with other systems. Some of these systems may not be available for unloaded vessels. So you'll have to 'roll your own' replacement for these systems. The most frequently used is obviously the 'KSP resource system'. So in emulating a module that consume/produce resources, you will also need to emulate the KSP resource system. And so on and so forth to all systems used by the module.

Link to comment
Share on other sites

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

Join the conversation

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

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

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

×   Your previous content has been restored.   Clear editor

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

×
×
  • Create New...