Reactor Charging...

Hey Folks! I think I finally got the batteries behaving, and I'm back on the reactor again.

I decided to bite the bullet and just write code to handle power distribution on the ship. Puzzling out the Rube Goldberg machine of conditions and triggers to do what is basically a heartbeat function was getting to be both too much of a headache and too unreliable. So now, all my powered items just update on the same heartbeat as other conditions, and the nitty-gritty power use/storage/transmission stuff is all handled in code.

And wow, was it much easier to understand this way. Note to self for future systems. Hack it out in code first, and only bother with data-driven everything later (if ever). Especially while prototyping.

So now, my powered items draw power from all connected batteries in parallel (like Rimworld), and switch off when the needed power isn't available.

Once that was running, I resumed work on getting a working reactor into the ship. Initially, this seemed pretty simple. Just add some stats to the reactor data to control how much it generates, and generate that amount each heartbeat. Any attached items can draw from that generated power, and at the beginning of each heartbeat, I can bleed off any leftover energy to start the next cycle.

I even added a recharging function, which is basically the reverse of the power consumption code, to recharge all attached batteries in parallel.

And one last thing: change the power stat from a single precision to double precision variable, since the difference between the reactor's power level and a light bulb is so vast, a single precision might not notice the tiny difference.

All was pretty straightforward, but then I hit a snag when I fired it up: the json data reader doesn't like double precision! For some reason, it thinks it is a single, and cannot convert it.

It's a really weird bug, in fact. That sort of type casting is supposed to be easy in C#, but I'm using some third party json reader that I had to hack to get working with +/- infinity values. So maybe I broke it, or maybe it wasn't setup for single/double correctly.

However, I notice that Unity has a json reader/writer now. Maybe it was always there? Maybe it's new since the last time I was writing this code (over a year ago!). In any case, I have a date with json tomorrow!

Tags: Ostranauts


Asthepanda2iscool2's picture

Bit off topic for this post, but I'm really looking forward to seeing how radiation will play out in this.
Will the crew get cancer? Can it be easily treated? How could it be effectively removed? Will nuclear power sources leak radiation sometimes as part of random events?
So many questions...

Rar! Rar rar rar! Thanks for reading :)

dcfedor's picture

Not off topic at all! As you could probably tell from NEO Scavenger, I like gritty, punishing details like this :)

I was thinking of doing something like a tile-based radiation shielding test when the ship layout is finished (or altered). I.e. bombard the ship with radiation from various directions, and record which tiles get radiation exposure.

Then, when an actual radiation source is encountered, I can apply reasonable radiation to any crew in the area.

Possible radiation sources would certainly include the reactor, cosmic/solar background radiation, and any nearby sources, such as Jupiter, weapons discharges, and fusion torch wakes.

Ship design can minimize exposure, depending on the thickness, placement, and materials used in shielding. There may also be room for active radiation shielding (like an artificial magnetosphere).

As for treatment, it depends.

There will likely be advanced medical tech in space, as compared to the DMC. Space civilization was affected differently by the collapse than Earth, and is actually still fairly robust. But economic disparity is still a major issue, and not everyone will have access to the best tech.

I'll have to do some more research to get specific, but a lot of the current treatments we know of only apply to fission radiation (heavy elements like Cs, Pu), while the radiation types I mention above are comparatively light (He, proton, EM waves). Basically, the treatments we use to pull radioactive plutonium from the body won't work on absorbed high-energy helium atoms.

Dan Fedor - Founder, Blue Bottle Games