OCESS / orbitx

Rewrite of OrbitV, maintained by Patrick, Gavin, and contributors
MIT License
10 stars 18 forks source link

Move craft capabilities into PhysicsState #101

Open pmelanson opened 4 years ago

pmelanson commented 4 years ago

This issue is probably medium difficulty but is a good intro to the dark heart of the physics engine

Currently, the habitat engine's maximum thrust is defined in common.craft_capabilities. This is a bit hacky, because there is no clean way to transmit this info over the network as there is for every other piece of data in a PhysicsState (e.g. fuel is easily sent, but not the hab's max thrust).

Usually it doesn't matter because the hab's max thrust doesn't change, but when the compat client is running, the state of OrbitV engineering will change the habitat's max thrust. Currently, only the physics_server will know about this change in max thrust, but we also want to easily let the hab_flight client know about the change.

To do this, we should add something like hab_max_thrust and ayse_max_thrust to orbitx/orbitx.proto. Then, update all uses of craft_capabilities to use the PhysicsState. Probably also have to set default values of max_thrust somewhere, which will probably have to happen somewhere in the savefile loading code. Definitely we'll also have to change some stuff in physics/engine.py, for example using self._last_physical_state.hab_max_thrust. Also in data_structures.py, to expose hab_max_thrust.

If you want to take this issue on to get a better understanding of the physics engine, I foresee many questions and debugging, so don't hesitate to ask.