I continued yesterday's work refactoring item charges, so that items could drain power over time or per use, as needed. By the end of the day, I was able to get the nightvision goggles installed with their own, charged battery:
The plan is for there to be several battery types, and each has a different capacity for energy. Energy items can be moved around like water, except it cannot exist anywhere but inside batteries. So it's possible to transfer energy around freely (which is admittedly unrealistic), but not to hoard it on the ground, or put it in a pocket. It must go into another vessel.
Energy items are 1x1 items, and stack 20 high per space. For now, my rough approximation is that a single unit of energy in the game corresponds to about 1kJ of real-life energy. For reference, a AA battery is about 15kJ (1.5V * 2.7Amp_Hours * 3600 seconds/hour) of total stored energy, and a car battery would be ~2000kJ (12V * 50Amp_Hours * 3600 seconds/hour = 2000kJ). That means a AA battery would have room for about 1 stack of 20 energy units, while a car battery would have room for about 100 (a 10x10 grid).
I'm also assuming that a laser rifle emits about 30kJ per shot at high power setting, so roughly 30 energy units in-game. From what I've read, this is the minimum threshold the military considers to be a "high energy laser." It's about 30% of the power currently used in experimental warship lasers used to down incoming missiles and drones.
These are just data points I'm using for reference, to help model consistent values across items.
There are still some kinks to work out, however. For one thing, the goggles are still operational without charge in them right now. I need to look into that next. They should check if they're charged before imparting their bonus.
I also need to make sure the weapons have survived the refactor. They now use similar charge-tracking code to the goggles (except with bullets instead of energy). In theory, if one works, the other should. But you know theories...
Finally, I'll have to make sure things are discharging correctly when used, or as time/distance passes.
So far, I'm thinking the system will serve my purposes well. It seems like it should cover electronic tools both used and equipped, weapons, and vehicles. And once tested and fully working, I can start adding more electronics to the game like flashlights, iSlab apps, and maybe even a gas-powered test vehicle. Should be pretty interesting!
Hope everyone has a good weekend!