Struct GameTime
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
daysint
Returns
AddHours(int)
Add hours (negative to subtract). Returns normalized GameTime.
public GameTime AddHours(int hours)
Parameters
hoursint
Returns
AddMonths(int)
Add months (negative to subtract). Day is clamped if necessary.
public GameTime AddMonths(int months)
Parameters
monthsint
Returns
AddYears(int)
Add years (negative to subtract).
public GameTime AddYears(int years)
Parameters
yearsint
Returns
CompareTo(GameTime)
public int CompareTo(GameTime other)
Parameters
otherGameTime
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
yearintmonthintdayinthourint
Returns
DaysBetween(GameTime)
Calculate days between this and another GameTime (signed, rounded down).
public int DaysBetween(GameTime other)
Parameters
otherGameTime
Returns
- int
Equals(GameTime)
public bool Equals(GameTime other)
Parameters
otherGameTime
Returns
- bool
Equals(object)
public override bool Equals(object obj)
Parameters
objobject
Returns
- bool
FromTotalHours(long)
Create GameTime from total hours since year 0. Inverse of ToTotalHours().
public static GameTime FromTotalHours(long totalHours)
Parameters
totalHourslong
Returns
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
otherGameTime
Returns
- long
ToCompactString(ICalendar)
Format compact using specified calendar.
public string ToCompactString(ICalendar calendar)
Parameters
calendarICalendar
Returns
- string
ToString()
public override string ToString()
Returns
- string
ToString(ICalendar)
Format using specified calendar.
public string ToString(ICalendar calendar)
Parameters
calendarICalendar
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
Returns
- bool
operator >(GameTime, GameTime)
public static bool operator >(GameTime a, GameTime b)
Parameters
Returns
- bool
operator >=(GameTime, GameTime)
public static bool operator >=(GameTime a, GameTime b)
Parameters
Returns
- bool
operator !=(GameTime, GameTime)
public static bool operator !=(GameTime a, GameTime b)
Parameters
Returns
- bool
operator <(GameTime, GameTime)
public static bool operator <(GameTime a, GameTime b)
Parameters
Returns
- bool
operator <=(GameTime, GameTime)
public static bool operator <=(GameTime a, GameTime b)
Parameters
Returns
- bool