Simulator::cTimeOfDay class

Class used to manage day duration and current time of day in planets.

The current time of day is not stored directly in this class, but this class can be used to change it.

This is a singleton class, so use TimeOfDay to access it. For example, TimeOfDay.SetDayDuration(3600).

Base classes

class cGonzagoSimulator

Public static variables

static const uint32_t TYPE

Public static functions

static auto Get() -> cTimeOfDay*
Returns the only cTimeOfDay instance; this function also creates that instance the first time it is called.

Public functions

auto SetSpeedMultiplier(float multiplier) -> void
Makes the day go faster (for values greater than 1) or slower (for values lower than 1).
auto SetDayDuration(float seconds) -> void
Sets how many seconds it takes to make a whole day, in seconds.
auto SetTimeOfDay(float timeOfDay, const Math::Vector3& position) -> void
Sets the time at a specific position in the planet, as a number between 0.0 and 1.0.
auto ConvertEarthTime(float hours, float minutes) -> float
Converts hours and minutes to a fraction of a day, from 0.0 to 1.0, as required by SetTimeOfDay (in Earth time, so a day is 24 hours and an hour 60 minutes).

Public variables

eastl::vector<float> field_10
float mDayDuration
How many seconds it takes to make a day, in seconds. Default value is 86400.0 (24 hours)

Function documentation

void Simulator::cTimeOfDay::SetSpeedMultiplier(float multiplier)

Makes the day go faster (for values greater than 1) or slower (for values lower than 1).

Parameters
multiplier

For example, SetSpeedMultiplier(2.0) makes the day be twice as short as specified in SetDayDuration().

void Simulator::cTimeOfDay::SetDayDuration(float seconds)

Sets how many seconds it takes to make a whole day, in seconds.

Parameters
seconds

void Simulator::cTimeOfDay::SetTimeOfDay(float timeOfDay, const Math::Vector3& position)

Sets the time at a specific position in the planet, as a number between 0.0 and 1.0.

Parameters
timeOfDay A number between 0.0 and 1.0
position The position in the planet where it will be the specified time of day.

The number represents the fraction of a day, with 0.0 being equivalent to 00:00 and 1.0 equivalent to 24:00 (which means it's the same time as 0.0). You can use the ConvertEarthTime() method to convert from hours:minutes to the time units required by this function.

float Simulator::cTimeOfDay::ConvertEarthTime(float hours, float minutes)

Converts hours and minutes to a fraction of a day, from 0.0 to 1.0, as required by SetTimeOfDay (in Earth time, so a day is 24 hours and an hour 60 minutes).

Parameters
hours
minutes

For example, ConvertEarthTime(12.0f, 0.0f) returns 0.5.