Table of Contents

Struct GameTime

Namespace
Core.Systems
Assembly
Core.dll

Represents a point in game time (deterministic calendar). Supports real Earth calendar (365 days, variable month lengths). All operations are deterministic for multiplayer compatibility.

[Serializable]
public struct GameTime

Fields

Day

public int Day

Field Value

int

Hour

public int Hour

Field Value

int

Month

public int Month

Field Value

int

Year

public int Year

Field Value

int

Methods

AddDays(int)

Add days (negative to subtract). Returns normalized GameTime.

public GameTime AddDays(int days)

Parameters

days int

Returns

GameTime

AddHours(int)

Add hours (negative to subtract). Returns normalized GameTime.

public GameTime AddHours(int hours)

Parameters

hours int

Returns

GameTime

AddMonths(int)

Add months (negative to subtract). Day is clamped if necessary.

public GameTime AddMonths(int months)

Parameters

months int

Returns

GameTime

AddYears(int)

Add years (negative to subtract).

public GameTime AddYears(int years)

Parameters

years int

Returns

GameTime

CompareTo(GameTime)

public int CompareTo(GameTime other)

Parameters

other GameTime

Returns

int

Create(int, int, int, int)

Create a GameTime with specified components.

public static GameTime Create(int year, int month, int day, int hour = 0)

Parameters

year int
month int
day int
hour int

Returns

GameTime

DaysBetween(GameTime)

Calculate days between this and another GameTime (signed, rounded down).

public int DaysBetween(GameTime other)

Parameters

other GameTime

Returns

int

Equals(GameTime)

public bool Equals(GameTime other)

Parameters

other GameTime

Returns

bool

Equals(object)

public override bool Equals(object obj)

Parameters

obj object

Returns

bool

FromTotalHours(long)

Create GameTime from total hours since year 0. Inverse of ToTotalHours().

public static GameTime FromTotalHours(long totalHours)

Parameters

totalHours long

Returns

GameTime

GetHashCode()

public override int GetHashCode()

Returns

int

HoursBetween(GameTime)

Calculate hours between this and another GameTime (signed). Positive if other is later, negative if other is earlier.

public long HoursBetween(GameTime other)

Parameters

other GameTime

Returns

long

ToCompactString(ICalendar)

Format compact using specified calendar.

public string ToCompactString(ICalendar calendar)

Parameters

calendar ICalendar

Returns

string

ToString()

public override string ToString()

Returns

string

ToString(ICalendar)

Format using specified calendar.

public string ToString(ICalendar calendar)

Parameters

calendar ICalendar

Returns

string

ToTotalHours()

Convert to total hours since year 0. Uses real month lengths (365-day year).

public long ToTotalHours()

Returns

long

Operators

operator ==(GameTime, GameTime)

public static bool operator ==(GameTime a, GameTime b)

Parameters

a GameTime
b GameTime

Returns

bool

operator >(GameTime, GameTime)

public static bool operator >(GameTime a, GameTime b)

Parameters

a GameTime
b GameTime

Returns

bool

operator >=(GameTime, GameTime)

public static bool operator >=(GameTime a, GameTime b)

Parameters

a GameTime
b GameTime

Returns

bool

operator !=(GameTime, GameTime)

public static bool operator !=(GameTime a, GameTime b)

Parameters

a GameTime
b GameTime

Returns

bool

operator <(GameTime, GameTime)

public static bool operator <(GameTime a, GameTime b)

Parameters

a GameTime
b GameTime

Returns

bool

operator <=(GameTime, GameTime)

public static bool operator <=(GameTime a, GameTime b)

Parameters

a GameTime
b GameTime

Returns

bool