Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Game

Hierarchy

Implements

Index

Properties

Accessors

Methods

Properties

absoluteTime

absoluteTime: number

autoSaveLastSave

autoSaveLastSave: number

autoSaveTimer

autoSaveTimer: number

Optional challengeCollection

challengeCollection: ChallengeModifiersCollection

currentIslandId

currentIslandId: string

customMilestoneModifiersAllowed

customMilestoneModifiersAllowed: boolean

debugRenderer

debugRenderer: ITextureDebugRenderer

difficulty

difficulty: GameMode

Readonly event

event: IEventEmitter<this, IGameEvents> = new EventEmitter<this, E>(this)

fadeInAmount

fadeInAmount: number | undefined

flowFieldSyncCount

flowFieldSyncCount: number

glContext

glContext: WebGL2RenderingContext | undefined

glVersion

glVersion: number | undefined

Readonly interval

interval: 16.6666 = INTERVAL

isLoadingSave

isLoadingSave: boolean

islands

islands: Map<string, Island>

Readonly itemStylesheetHandler

itemStylesheetHandler: ItemStylesheetHandler = new ItemStylesheetHandler()

lastBuildTime

lastBuildTime: number = 0

lastSaveVersion

lastSaveVersion: IVersionInfo

lastTickTime

lastTickTime: number | undefined

mapSize

mapSize: number

mapSizeSq

mapSizeSq: number

Readonly milestonesCollection

milestonesCollection: GameplayModifiersCollection<Milestone, MilestoneModifier> = MilestoneModifiersManager.createCollection()

nextTickTime

nextTickTime: number | undefined

notifier

notifier: INotifier | undefined

originalPlayOptions

originalPlayOptions: Partial<IPlayOptions>

particle

particle: IParticle

paused

paused: boolean

playing

playing: boolean

previousSaveVersion

previousSaveVersion: IVersionInfo | undefined

references

references: ReferenceManager = new ReferenceManager()

replay

replay: ReplayManager | undefined

saveClear

saveClear: boolean

Optional saveSize

saveSize: undefined | string

saveVersion

saveVersion: string | undefined

shouldUpdateTablesAndWeight

shouldUpdateTablesAndWeight: boolean

slot

slot: number | undefined

spawnCoords

spawnCoords: IVector3

spriteTexture

spriteTexture: WebGLTexture

spriteTextureSizeInversed

spriteTextureSizeInversed: Vector2

tickSpeed

tickSpeed: number

tile

tileDecorations

tileDecorations: Uint16Array

tileTexture

tileTexture: WebGLTexture

tileTextureSizeInversed

tileTextureSizeInversed: Vector2

time

travelingToIsland

travelingToIsland: ITravelingToIslandInfo | undefined

turnMode

turnMode: TurnMode

upgrades

upgrades: string[] = []

version

version: string = gameVersion

visible

visible: boolean = true

Readonly voting

voting: VotingManager = new VotingManager()

worldId

worldId: string

Accessors

isChallenge

  • get isChallenge(): boolean
  • Returns boolean

isTravelingToIsland

  • get isTravelingToIsland(): boolean
  • Returns boolean

Methods

addZoomLevel

  • addZoomLevel(amount: number): void
  • Parameters

    • amount: number

    Returns void

calculateAmbientLightLevel

  • calculateAmbientLightLevel(player: Player | undefined, z: number): number
  • Parameters

    • player: Player | undefined
    • z: number

    Returns number

calculateTileLightLevel

  • calculateTileLightLevel(tile: ITile, x: number, y: number, z: number): number
  • Calculates the light level of a tile.

    Parameters

    • tile: ITile
    • x: number
    • y: number
    • z: number

    Returns number

    32bit number representing RED GREEN BLUE ALPHA

canASeeB

  • canASeeB(type: CanASeeBType, sourceEntity: Entity | undefined, aX: number, aY: number, aZ: number, bX: number, bY: number, bZ: number): boolean
  • Parameters

    • type: CanASeeBType
    • sourceEntity: Entity | undefined
    • aX: number
    • aY: number
    • aZ: number
    • bX: number
    • bY: number
    • bZ: number

    Returns boolean

cancelAnimationFrame

  • cancelAnimationFrame(): void
  • Returns void

changeTile

  • changeTile(newTileInfo: TerrainType | ITileData, x: number, y: number, z: number, stackTiles: boolean, dropTiles?: undefined | false | true, skipCaveDirt?: undefined | false | true): void
  • Parameters

    • newTileInfo: TerrainType | ITileData
    • x: number
    • y: number
    • z: number
    • stackTiles: boolean
    • Optional dropTiles: undefined | false | true
    • Optional skipCaveDirt: undefined | false | true

    Returns void

checkForHiddenMob

  • checkForHiddenMob(human: Human, x: number, y: number, z: number): void
  • Parameters

    • human: Human
    • x: number
    • y: number
    • z: number

    Returns void

checkTileState

  • checkTileState(): void
  • Checks if island.tileData is synced with ITile.data

    Returns void

checkWaterFill

  • checkWaterFill(x: number, y: number, z: number, needed: number, waterType: WaterType, waterFill?: IWaterFill): number
  • Check the amount of water tiles there is connected to a supplied x/y area

    Parameters

    • x: number
    • y: number
    • z: number
    • needed: number
    • waterType: WaterType
    • Default value waterFill: IWaterFill = { count: 0, tiles: {} }

    Returns number

clearRenderFlag

  • Parameters

    Returns void

consumeWaterTile

  • consumeWaterTile(x: number, y: number, z: number): void
  • Parameters

    • x: number
    • y: number
    • z: number

    Returns void

contaminateFreshWater

  • contaminateFreshWater(point: IVector3): void
  • Converts shallow single bodies of fresh water into seawater.

    Parameters

    • point: IVector3

      x/y/z of the tile to check against.

    Returns void

contaminateWater

  • contaminateWater(point: IVector3): void
  • Contaminate water sources when new ones are created based on the surrounding water.

    Parameters

    • point: IVector3

      x/y/z of the water tile created.

    Returns void

coolFires

  • Parameters

    Returns void

createPuddles

  • Create puddles around a point and limit them (so they can't expand infinitely).

    Parameters

    • point: IVector3

      x/y/z of the splash/puddle source.

    Returns void

damage

  • Parameters

    Returns number | undefined

directionToMovement

emitTileUpdate

  • emitTileUpdate(tile: ITile, x: number, y: number, z: number, tileUpdateType: TileUpdateType, updatedRenderer?: undefined | false | true): void
  • Parameters

    • tile: ITile
    • x: number
    • y: number
    • z: number
    • tileUpdateType: TileUpdateType
    • Optional updatedRenderer: undefined | false | true

    Returns void

enableFlowFieldDebug

  • enableFlowFieldDebug(): void
  • Returns void

ensureValidPoint

  • ensureValidPoint<T>(point?: T): T | undefined
  • Type parameters

    Parameters

    • Optional point: T

    Returns T | undefined

fireBreath

  • fireBreath(x: number, y: number, z: number, facingDirection: Direction, itemName?: Translation, player?: undefined | false | true): void
  • Parameters

    • x: number
    • y: number
    • z: number
    • facingDirection: Direction
    • Optional itemName: Translation
    • Optional player: undefined | false | true

    Returns void

gameLogicLoop

  • gameLogicLoop(): void
  • Returns void

gameRenderLoop

  • gameRenderLoop(timeStamp: number): void
  • Game render loop Not executed for the host in dedicated servers

    Parameters

    • timeStamp: number

    Returns void

getAmbientLightLevel

  • getAmbientLightLevel(z: number): number
  • Note: Don't inject here. This gets called ten million times. If you want to override this functionality, use calculateAmbientLightLevel

    Parameters

    • z: number

    Returns number

getAnimationProgress

  • getAnimationProgress(timeStamp: number, finishTime: number | undefined, delay: Delay | number): number
  • Parameters

    • timeStamp: number
    • finishTime: number | undefined
    • delay: Delay | number

    Returns number

getBenignity

  • getBenignity(): number
  • Returns number

getBlackness

  • getBlackness(): number
  • Returns number

getCameraPosition

  • Returns IVector2

getDailyChallengeSeed

  • getDailyChallengeSeed(): number
  • Returns number

getDefaultTerrainType

  • getDefaultTerrainType(tile: ITile): TerrainType
  • Gets the default terrain type that should be under a tile (in the case of melting or removing it in some way).

    Parameters

    • tile: ITile

      ITile that we are getting the default terrain type for.

    Returns TerrainType

    The default terrain type with a fallback to dirt (which shouldn't happen without mods or bugs).

getExactCameraPosition

  • getExactCameraPosition(): Vector2
  • Returns Vector2

getGameMode

  • Returns GameMode

getGameOptions

getGameOptionsBeforeModifiers

getGreatestWeaknesses

  • Gets the largest damage type weaknesses of a human or creature based on a type and damage value

    Parameters

    • defense: Defense

      Defense of the human or creature

    • damageTypes: DamageType

      Measures the weaknesses compared to damage types passed

    • damage: number

      The damage value given to the human or creature

    Returns DamageType[]

    returns DamageType array or undefined if there are no weaknesses

getHeight

  • getHeight(z0: number, z1: number, d: number): number
  • Parameters

    • z0: number
    • z1: number
    • d: number

    Returns number

getLightSourceAt

  • getLightSourceAt(x: number, y: number, z: number): number
  • Parameters

    • x: number
    • y: number
    • z: number

    Returns number

getMalignity

  • getMalignity(): number
  • Returns number

getMaxHealth

  • getMaxHealth(): number
  • Returns number

getMaxWeight

  • getMaxWeight(): number
  • Returns number

getMovementFinishTime

  • getMovementFinishTime(delay?: Delay | number): number
  • Parameters

    • Default value delay: Delay | number = Delay.Movement

    Returns number

getMovementProgress

  • getMovementProgress(timeStamp: number, finishTime: number | undefined, delay?: Delay | number): any
  • Parameters

    • timeStamp: number
    • finishTime: number | undefined
    • Default value delay: Delay | number = Delay.Movement

    Returns any

getNearestPlayer

  • getNearestPlayer(x: number, y: number, z?: undefined | number, canSee?: undefined | false | true, includeConnecting?: undefined | false | true): { distance?: undefined | number; player?: Player }
  • Gets the nearest player based on x/y/z coordinates.

    Parameters

    • x: number

      The x coord to get the closest player.

    • y: number

      The y coord to get the closest player.

    • Optional z: undefined | number

      The z coord to get the closest player.

    • Optional canSee: undefined | false | true

      If set to true, check if the player can see the x/y/z coords. Defaults to false.

    • Optional includeConnecting: undefined | false | true

    Returns { distance?: undefined | number; player?: Player }

    • Optional distance?: undefined | number
    • Optional player?: Player

getOrCreateTile

  • getOrCreateTile(index: number): ITile
  • Parameters

    • index: number

    Returns ITile

getOrCreateTileData

  • getOrCreateTileData(x: number, y: number, z: number): ITileData[]
  • Parameters

    • x: number
    • y: number
    • z: number

    Returns ITileData[]

getPlayerAverage

  • getPlayerAverage(calc: (player: Player) => number | undefined, round?: undefined | false | true): number
  • Parameters

    • calc: (player: Player) => number | undefined
        • (player: Player): number | undefined
        • Parameters

          Returns number | undefined

    • Optional round: undefined | false | true

    Returns number

getPlayerByIdentifier

  • getPlayerByIdentifier(identifier: string, includeAbsent?: boolean): Player | undefined
  • Parameters

    • identifier: string
    • Default value includeAbsent: boolean = true

    Returns Player | undefined

getPlayerByName

  • getPlayerByName(name: string): Player | undefined
  • Parameters

    • name: string

    Returns Player | undefined

getPlayerByPid

  • getPlayerByPid(pid: number): Player | undefined
  • Parameters

    • pid: number

    Returns Player | undefined

getPlayers

  • getPlayers(includeGhosts?: undefined | false | true, includeConnecting?: undefined | false | true): Player[]
  • Parameters

    • Optional includeGhosts: undefined | false | true
    • Optional includeConnecting: undefined | false | true

    Returns Player[]

getPlayersAtPosition

  • getPlayersAtPosition(position: IVector3, includeGhosts?: undefined | false | true, includeConnecting?: undefined | false | true): Player[]
  • getPlayersAtPosition(x: number, y: number, z: number, includeGhosts?: undefined | false | true, includeConnecting?: undefined | false | true): Player[]
  • Parameters

    • position: IVector3
    • Optional includeGhosts: undefined | false | true
    • Optional includeConnecting: undefined | false | true

    Returns Player[]

  • Parameters

    • x: number
    • y: number
    • z: number
    • Optional includeGhosts: undefined | false | true
    • Optional includeConnecting: undefined | false | true

    Returns Player[]

getPlayersAtTile

  • getPlayersAtTile(tile: ITile, includeGhosts?: undefined | false | true, includeConnecting?: undefined | false | true): Player[]
  • Parameters

    • tile: ITile
    • Optional includeGhosts: undefined | false | true
    • Optional includeConnecting: undefined | false | true

    Returns Player[]

getPlayersThatSeePosition

  • getPlayersThatSeePosition(x: number, y: number, z: number): Player[]
  • Parameters

    • x: number
    • y: number
    • z: number

    Returns Player[]

getQualityDurabilityBonus

  • getQualityDurabilityBonus(quality: Quality, itemDurability: number, getMax?: undefined | false | true): number
  • Parameters

    • quality: Quality
    • itemDurability: number
    • Optional getMax: undefined | false | true

    Returns number

getRandomQuality

getReputation

  • getReputation(): number
  • Returns number

getSkillPercent

  • Parameters

    Returns number

getTactics

  • getTactics(): number
  • Returns number

getTickSpeed

  • getTickSpeed(): number
  • Returns number

getTile

  • getTile(x: number, y: number, z: number): ITile
  • Parameters

    • x: number
    • y: number
    • z: number

    Returns ITile

getTileData

  • getTileData(x: number, y: number, z: number): ITileData[] | undefined
  • Parameters

    • x: number
    • y: number
    • z: number

    Returns ITileData[] | undefined

getTileFromPoint

  • Parameters

    Returns ITile

getTurnMode

  • Returns TurnMode

getValidPlayerName

  • getValidPlayerName(name: string | undefined): string
  • Parameters

    • name: string | undefined

    Returns string

globalSlotReady

  • globalSlotReady(): void
  • Returns void

hasRenderFlag

  • Parameters

    Returns boolean

initGl

  • initGl(forceWebGlVersion?: undefined | number): Promise<void>
  • Initializes WebGl

    Parameters

    • Optional forceWebGlVersion: undefined | number

      Set to force a specific webgl version

    Returns Promise<void>

initialize

  • initialize(): void
  • Returns void

isFlammable

  • isFlammable(x: number, y: number, z: number): boolean
  • Parameters

    • x: number
    • y: number
    • z: number

    Returns boolean

isMapEdge

  • isMapEdge(x: number, y: number): boolean
  • Parameters

    • x: number
    • y: number

    Returns boolean

isOnFire

  • Parameters

    Returns FireType

isPlayerAtPosition

  • isPlayerAtPosition(x: number, y: number, z: number, includeGhosts?: undefined | false | true, includeConnecting?: undefined | false | true): boolean
  • Parameters

    • x: number
    • y: number
    • z: number
    • Optional includeGhosts: undefined | false | true
    • Optional includeConnecting: undefined | false | true

    Returns boolean

isPlayerAtTile

  • isPlayerAtTile(tile: ITile, includeGhosts?: undefined | false | true, includeConnecting?: undefined | false | true): boolean
  • Parameters

    • tile: ITile
    • Optional includeGhosts: undefined | false | true
    • Optional includeConnecting: undefined | false | true

    Returns boolean

isPositionEmpty

  • isPositionEmpty(x: number, y: number, z: number): boolean
  • Parameters

    • x: number
    • y: number
    • z: number

    Returns boolean

isPositionFull

  • isPositionFull(x: number, y: number, z: number): boolean
  • Parameters

    • x: number
    • y: number
    • z: number

    Returns boolean

isSimulatedOrRealTimeMode

  • isSimulatedOrRealTimeMode(): boolean
  • Returns boolean

isTileEmpty

  • isTileEmpty(tile: ITile): boolean
  • Parameters

    Returns boolean

isTileFull

  • isTileFull(tile: ITile): boolean
  • Parameters

    Returns boolean

makeCaveEntrance

  • makeCaveEntrance(human: Human, chance?: number): TerrainType | undefined
  • Parameters

    • human: Human
    • Default value chance: number = 50

    Returns TerrainType | undefined

makeLavaPassage

  • makeLavaPassage(human: Human): TerrainType | undefined
  • Parameters

    Returns TerrainType | undefined

onGlobalSlotReady

  • onGlobalSlotReady(): Promise<void>
  • Returns Promise<void>

Protected onRestEnd

  • onRestEnd(): void
  • Returns void

packGround

  • packGround(x: number, y: number, z: number): void
  • Parameters

    • x: number
    • y: number
    • z: number

    Returns void

passTurn

  • Marks that the player had a turn In manual turn mode, it will tick the players stat timers & the game

    Parameters

    Returns void

play

  • Parameters

    Returns Promise<boolean>

processWaterContamination

  • processWaterContamination(): void
  • Returns void

rangeFinder

  • rangeFinder(weaponRange: number, playerSkillLevel: number, useMaxRange?: boolean): number
  • Parameters

    • weaponRange: number
    • playerSkillLevel: number
    • Default value useMaxRange: boolean = false

    Returns number

    a range value for the weapon being shot based on the weapon range and the players skill with that weapon type. This value then becomes the maximum potential range of the current shot.

removeTopTile

  • removeTopTile(x: number, y: number, z: number, newTileTypeWhenEmpty: TerrainType | ((tile: ITile) => TerrainType)): void
  • Removes the top tiledata (index 0) from the tile If there is no remaining tile data, a new tile data will be added with the newTileTypeWhenEmpty type

    Parameters

    • x: number
    • y: number
    • z: number
    • newTileTypeWhenEmpty: TerrainType | ((tile: ITile) => TerrainType)

    Returns void

requestAnimationFrame

  • Parameters

    Returns void

requestPlay

  • Parameters

    Returns Promise<boolean>

resetGameState

  • resetGameState(saveType?: SaveType | false, isReconnecting?: boolean): Promise<void>
  • Parameters

    • Optional saveType: SaveType | false
    • Default value isReconnecting: boolean = false

    Returns Promise<void>

resetWebGL

  • resetWebGL(): void
  • Returns void

resizeRenderer

  • resizeRenderer(): void
  • Returns void

restartDedicatedServer

  • restartDedicatedServer(): boolean
  • Returns boolean

saveGame

setGlContextSize

  • setGlContextSize(width: number, height: number): void
  • Parameters

    • width: number
    • height: number

    Returns void

setLoaded

  • Parameters

    Returns this

setLoading

  • Parameters

    Returns this

setPaused

  • setPaused(paused: boolean, showChatMessage?: boolean): void
  • Parameters

    • paused: boolean
    • Default value showChatMessage: boolean = false

    Returns void

setTickSpeed

  • setTickSpeed(tickSpeed: number): void
  • Parameters

    • tickSpeed: number

    Returns void

setTile

  • setTile(x: number, y: number, z: number, tile: ITile): ITile
  • Parameters

    • x: number
    • y: number
    • z: number
    • tile: ITile

    Returns ITile

setTurnMode

  • Parameters

    Returns void

setupGl

  • setupGl(restoring: boolean): Promise<void>
  • Compiles webgl programs / shaders and creates renderers

    Parameters

    • restoring: boolean

    Returns Promise<void>

setupSave

  • setupSave(): void
  • Returns void

shouldRender

  • shouldRender(): number
  • Returns number

shouldUpdateWorldRender

  • shouldUpdateWorldRender(timeStamp: number): RenderSource | undefined
  • Parameters

    • timeStamp: number

    Returns RenderSource | undefined

synchronizeFlowFields

  • synchronizeFlowFields(plys: Player[]): void
  • Synchronizes flow field, entity flow, and island temperature Usually calls when a new player joins

    Parameters

    Returns void

tick

  • tick(ticks?: number, realPlayers?: Player[], tickFlag?: TickFlag): void
  • Collection of things to perform on each tick

    Parameters

    • Default value ticks: number = 1
    • Default value realPlayers: Player[] = this.getPlayers(true)
    • Default value tickFlag: TickFlag = TickFlag.All

    Returns void

tickAsync

  • Collection of things to perform on each tick

    Parameters

    • ticks: number
    • Default value realPlayers: Player[] = this.getPlayers(true)
    • Default value tickFlag: TickFlag = TickFlag.All
    • onProgress: (progess: number) => Promise<void>
        • Parameters

          • progess: number

          Returns Promise<void>

    Returns Promise<void>

tickRealtime

  • tickRealtime(): void
  • Returns void

travelToIslandId

travelToIslandPosition

travelTowardsIsland

updateAmbientLightLevel

  • updateAmbientLightLevel(z: number): number
  • Parameters

    • z: number

    Returns number

updateFlowFieldTile

  • updateFlowFieldTile(tile: ITile, x: number, y: number, z: number, tileUpdateType: TileUpdateType, updatedRenderer?: undefined | false | true): void
  • Parameters

    • tile: ITile
    • x: number
    • y: number
    • z: number
    • tileUpdateType: TileUpdateType
    • Optional updatedRenderer: undefined | false | true

    Returns void

updateOption

  • updateOption(player: Player | undefined, id: keyof IOptions, value: boolean | number): void
  • Parameters

    • player: Player | undefined
    • id: keyof IOptions
    • value: boolean | number

    Returns void

updateRender

updateReputation

  • updateReputation(reputation: number): void
  • Parameters

    • reputation: number

    Returns void

updateTablesAndWeight

  • updateTablesAndWeight(deferTableUpdates?: boolean): void
  • AVOID USING THIS. USE updateTablesAndWeightNextTick INSTEAD! For most cases you don't need this

    Parameters

    • Default value deferTableUpdates: boolean = false

    Returns void

updateTablesAndWeightNextTick

  • updateTablesAndWeightNextTick(): void
  • Returns void

updateThumbnail

  • updateThumbnail(): Promise<boolean>
  • Returns Promise<boolean>

updateView

  • updateView(source: RenderSource, updateFov?: boolean): void
  • Parameters

    • source: RenderSource
    • Default value updateFov: boolean = false

    Returns void

updateZoomLevel

  • updateZoomLevel(): void
  • Returns void

Generated using TypeDoc