Home Reference Source
import {GameTime} from 'shapez.io/js/game/time/game_time.js'
public class | source

GameTime

Extends:

BasicSerializableObject → GameTime

Static Method Summary

Static Public Methods
public static
public static

getSchema(): {"timeSeconds": *, "speed": *, "realtimeSeconds": *}

Constructor Summary

Public Constructor
public

Member Summary

Public Members
public
public
public
public

root: *

public
public

Method Summary

Public Methods
public

deserialize(data: *): *

public
public

Returns if we are currently in the grace period

public

Returns how many seconds we are in the grace period

public

getSpeed(): *

public

getTimeMs(): *

Returns the ingame time in milliseconds

public

Internal method to generate new logic time budget

public

now(): number

Returns ingame time in seconds

public

performTicks(deltaMs: number, updateMethod: function(): boolean)

Performs update ticks based on the queued logic budget

public

Returns "real" time in seconds

public

setSpeed(speed: *)

public

Returns "real" time in seconds

public

Fetches the new "real" time, called from the core once per frame, since performance now() is kinda slow

Inherited Summary

From class BasicSerializableObject
public static
public static

getId()

public static

Should return the serialization schema

public static

verify(data: *): string | void

public

deserialize(data: any, root: import("./savegame_serializer").GameRoot): string | void

public

Static Public Methods

public static getId(): string source

Override:

BasicSerializableObject#getId

Return:

string

public static getSchema(): {"timeSeconds": *, "speed": *, "realtimeSeconds": *} source

Should return the serialization schema

Override:

BasicSerializableObject#getSchema

Return:

{"timeSeconds": *, "speed": *, "realtimeSeconds": *}

Public Constructors

public constructor(root: GameRoot) source

Fixes typeof DerivedComponent is not assignable to typeof Component, compiled out in non-dev builds

Override:

BasicSerializableObject#constructor

Params:

NameTypeAttributeDescription
root GameRoot

Public Members

public logicTimeBudget: number source

public realtimeAdjust: number source

public realtimeSeconds: number source

public root: * source

public speed: BaseGameSpeed source

public timeSeconds: number source

Public Methods

public deserialize(data: *): * source

Override:

BasicSerializableObject#deserialize

Params:

NameTypeAttributeDescription
data *

Return:

*

public getIsPaused(): * source

Return:

*

public getIsWithinGracePeriod(): boolean source

Returns if we are currently in the grace period

Return:

boolean

public getRemainingGracePeriodSeconds(): number source

Returns how many seconds we are in the grace period

Return:

number

public getSpeed(): * source

Return:

*

public getTimeMs(): * source

Returns the ingame time in milliseconds

Return:

*

public internalAddDeltaToBudget(deltaMs: number) source

Internal method to generate new logic time budget

Params:

NameTypeAttributeDescription
deltaMs number

public now(): number source

Returns ingame time in seconds

Return:

number

seconds

public performTicks(deltaMs: number, updateMethod: function(): boolean) source

Performs update ticks based on the queued logic budget

Params:

NameTypeAttributeDescription
deltaMs number
updateMethod function(): boolean

public realtimeNow(): number source

Returns "real" time in seconds

Return:

number

seconds

public setSpeed(speed: *) source

Params:

NameTypeAttributeDescription
speed *

public systemNow(): number source

Returns "real" time in seconds

Return:

number

seconds

public updateRealtimeNow() source

Fetches the new "real" time, called from the core once per frame, since performance now() is kinda slow