I’ve implemented a first pass at a new feature: fuel. Internally it is not really new, I’ve always had a fuel property available but have not used it for a long time. I decided to reintroduce it now to prepare for another new feature that will be coming soon: shields!
So the idea is that the ship has some internal fuel source that an onboard power plant uses to convert to energy. This energy is stored in an onboard capacitor of limited capacity. Once the capacitor is full the power plant stops producing energy until the capacitor falls below maximum capacity again.
As of right now I’m assuming that the actual fuel source, yet to be identified, is infinite. However, all of the ships components draw power from the capacitor. So the player must now be carful not to draw energy from the capacitor faster than it can be charged. If they do, components will no longer function until enough energy is built back up.
As of right now I have it set so that the ship’s power plant can product 0.25 units of energy per game tick (15 units of energy per second). That means that the capacitor receive 15 units of energy per second until it has reached 100% capacity. The current capacity is set to 100. So, as of right now, if the ship’s capacity is at 0 it would take about 6.5 seconds to completely refill the capacitor.
The rate at which components consume energy from the capacitor is currently: each missile uses 10 energy per shot, main thruster uses 10, rotational thrusters use 5, and brakes use 10.
Right now, it is actually pretty hard to run out of energy based on the current components and capacitor characteristics. However, I’m planning to have shields use a lot of energy which will require much greater care to how energy is managed.
Ultimately, when ships become customizable, each component will have various characteristics that effect the energy system in the game. For example, power plants that can fill the capacitor more quickly and / or more efficiently. Thrusters that require less energy, etc…
I’m also planning to have a damage system that will effect those characteristics also. So, for example, a ship may have a damaged power plant that still works but converts fuel to energy must slower.