Skip to content

Oxygen System

Manav edited this page Oct 16, 2023 · 11 revisions

Description

The functionality of the oxygen level of the planet on which the game takes place.

The planet's atmospheric oxygen percentage is to be displayed in a similar fashion to the GameTimeDisplay, with a small, constant display present. The functionality of the oxygen system includes the following:

Oxygen can be added/produced and removed/consumed from the planet. This can be performable by any entity, such as mobs, tractors or potentially other 'combustion related' future items like campfires. The addition/removal of oxygen is available through two configurations: singular and continuous, with continuous being an hourly addition/consumption rate. (The idea is for entities like animals or a running tractor using up a constant rate of oxygen.)

An OxygenLevel interface to be implemented by this singleton class as well as any other future oxygen-storing items, a potential example being a player's personal tank in their spacesuit.

Implements:

OxygenLevel interface

An interface of the primary methods for an oxygen-holding object, initially just the planet. It is used to generalise an oxygen component for an in game feature, and it is implemented in the PlanetOxygenService.

PlanetOxygenService

A singleton class used to log and report on oxygen production and consumption on the planet. It does this by keeping track of every entity in the game through the EntityService's array of entities, seeing how much they oxygen they contribute or consume, and summing those together as a 'delta'. Each hour of game time that passes, the planet oxygen amount increases or decreases by that delta. The oxygen production/consumption rates of entity types are stored in the EntityType enum class as integer value oxygenValue, with a positive value adding oxygen, and a negative value removing it.

OxygenDisplay

The display is done in a similar manner to the GameTimeDisplay, which creates an array of all possible combinations of labels that could be used and displays them depending on the oxygen percent. It also displays an outline of a progress bar, and scales the inside of it to match the oxygen percent. The oxygen level updates itself every hour that passes. Normally the bar is a light blue colour, but when it reaches 25% or less it becomes red. A transition effect is also provided to allow the bar to slide to the next percentage rather than being instantly set.

image

image

OxygenDisplay (Revamped)

Minimalistic design to prevent the UI from being cluttered, while also staying consistent with the style of the other UI elements

oxg

UML Diagram

The classes for displaying the oxygen bar and the logic behind it are modularised and separate, since OxygenDisplay uses listeners to keep track of the oxygen updates hourly. This is possible by connecting PlanetOxygenService to an event handler. image

Clone this wiki locally