amaschas / delta-v

Delta V Scripts
1 stars 0 forks source link

Module queue messaging #3

Open amaschas opened 11 years ago

amaschas commented 11 years ago

Implement a new messaging system to handle running the actions. Events may not be best for this. The key is to avoid relying on polling. Perhaps use a delegate. Basically the active module needs to be able to send a message the ship when it is done with the current action, so the ship can update the queue and move to the next action. Currently this is handled with polling and boolean triggers.

Can a while loop substitute for Update()?

amaschas commented 11 years ago

Idea: the module queue procedure only needs to change slight. Continue using the single fixedupdate trigger in ShipController, but trigger the next module in the queue and the end of the queue using an event.

The ShipController can subscribe to all module handlers, rather than having the modules subscribe the ship to themselves. This may not even need to be a literal event. A callback, maybe using a delegate, might be sufficient.

The trigger to start the queues should be the unfreezing of all game objects.

So once time is unfrozen, the queues all start running. The ship FixedUpdate functions start running, triggering the first module. Once the module has completed its run, it fires the event, letting the queue move onto the next action. Some modules, like orientation or engine, call routines on the ship controller that alter the ship state.

amaschas commented 11 years ago

Maybe do the game freezing with timescale?