Options
All
  • Public
  • Public/Protected
  • All
Menu

Class TimeManager

Hierarchy

  • TimeManager

Index

Constructors

constructor

  • Parameters

    • turns: number

    Returns TimeManager

Properties

dayLength

dayLength: number = 3200

dayPercent

dayPercent: number = 0.625

Optional frozenTime

frozenTime: undefined | number

Accessors

day

  • get day(): number
  • Returns which day it is. Starts at 1.

    Returns number

dayStart

  • get dayStart(): number
  • Returns number

ticks

  • get ticks(): number
  • The total number of ticks passed.

    Returns number

Methods

clone

  • Returns a copy of this TimeManager as a new object

    Returns TimeManager

getBrightness

  • getBrightness(time?: number): number
  • Returns how bright it is at the given time.

    Parameters

    • Default value time: number = this.getTime()

      The time to use, defaulting to the current time.

    Returns number

getDayQuarter

  • Returns the DayQuarter of the given time.

    Parameters

    • Default value time: number = this.getTime()

      The time to use, defaulting to the current time.

    Returns DayQuarter

getHour

  • getHour(time?: number, format?: TimeFormat): number
  • Returns the hour of the given time.

    Parameters

    • Default value time: number = this.getTime()

      The time to use, defaulting to the current time.

      Internally calls getHourMinute

    • Default value format: TimeFormat = TimeFormat.TwelveHour

    Returns number

getHoursAndMinutes

  • getHoursAndMinutes(time?: number): { hour: number; minute: number }
  • Returns the hours and minutes of the given time.

    Parameters

    • Default value time: number = this.getTime()

      The time to use, defaulting to the current time.

    Returns { hour: number; minute: number }

    • hour: number
    • minute: number

getMinute

  • getMinute(time?: number): number
  • Returns the minute of the given time.

    Parameters

    • Default value time: number = this.getTime()

      The time to use, defaulting to the current time.

      Internally calls getHourMinute

    Returns number

getPartOfDay

  • Returns the PartOfDay of the given time.

    Parameters

    • Default value time: number = this.getTime()

      The time to use, defaulting to the current time.

    Returns PartOfDay

getTime

  • getTime(tickOffset?: number): number
  • Returns a decimal representation of the current time. 0 is the start of the day, and 1 is the end.

    Parameters

    • Default value tickOffset: number = 0

    Returns number

getTranslation

  • Returns a string representation of the given time.

    Parameters

    • Default value time: number = this.getTime()

      The time to use, defaulting to the current time.

    • Default value format: TimeFormat = TimeFormat.TwelveHour

      The format to use, defaulting to TimeFormat.TwelveHour

    Returns Translation

isBefore

  • isBefore(checkTime: string, time?: number): undefined | false | true
  • Checks if the given time is before a formatted time.

    Parameters

    • checkTime: string

      A formatted time.

    • Default value time: number = this.getTime()

      The time to check, defaulting to the current time.

    Returns undefined | false | true

isBetween

  • isBetween(checkPast: string, checkBefore: string, currentTime?: number): undefined | false | true
  • Returns if the given time is between two formatted times.

    Parameters

    • checkPast: string

      A formatted time to check if the given time is after.

    • checkBefore: string

      A formatted time to check if the given time is before.

    • Default value currentTime: number = this.getTime()

    Returns undefined | false | true

isDay

  • isDay(time?: number): boolean
  • Returns if the given time is at day.

    Parameters

    • Default value time: number = this.getTime()

      The time to check, defaulting to the current time.

    Returns boolean

isFrozen

  • isFrozen(): boolean
  • Returns whether time is frozen.

    Returns boolean

isNight

  • isNight(time?: number): boolean
  • Returns if the given time is at night.

    Parameters

    • Default value time: number = this.getTime()

      The time to check, defaulting to the current time.

    Returns boolean

isPast

  • isPast(checkTime: string, time?: number): undefined | false | true
  • Checks if the given time is after a formatted time.

    Parameters

    • checkTime: string

      A formatted time.

    • Default value time: number = this.getTime()

      The time to check, defaulting to the current time.

    Returns undefined | false | true

nextTick

  • nextTick(): void
  • Increments ticks.

    Returns void

restoreFromDayNight

  • restoreFromDayNight(dayNight: number, dayNightSwitch: 0 | 1): void
  • Sets the current time from a dayNight number and a boolean flag of whether it's day or night.

    Used exclusively for save conversion.

    Parameters

    • dayNight: number
    • dayNightSwitch: 0 | 1

    Returns void

setTime

  • setTime(time: number): this
  • Sets the time.

    Parameters

    • time: number

      A number between 0 and 1, where 0 is the start of the day and 1 is the end.

      Setting the time with the result of getTime will likely not set to the same value. This method is provided for save conversion and utility, and should rarely be used.

    Returns this

Generated using TypeDoc