@vaguevoid/fiasco / game / Game
Class: Game
Defined in: src/game.ts:46
The Game class is an extension of EcsModule. Designed to work best with the fiasco generated code. Usually defined as the default export for the main game.
improt { Resource } from '@vaguevoid/fiasco'
function system1() {}
function system2() {}
class Foo extends Resource {}
export const systems = [system1, system2]
export const resources = [new Foo()]
export default new Game({ systems, resources })
Extends
Constructors
Constructor
new Game(
options
):Game
Defined in: src/game.ts:49
Parameters
options
GameOptions
= {}
Returns
Game
Overrides
Properties
afterSystem
afterSystem:
Signal
<[number
]>
Defined in: src/ecs/module.ts:64
Inherited from
beforeSystem
beforeSystem:
Signal
<[number
]>
Defined in: src/ecs/module.ts:63
Inherited from
componentKeys
protected
componentKeys:string
[]
Defined in: src/ecs/module.ts:56
Inherited from
components
protected
components:Record
<string
>
Defined in: src/ecs/module.ts:57
Inherited from
debugLogs
debugLogs:
boolean
Defined in: src/game.ts:47
name
protected
name:string
="JS_ECS_Module"
Defined in: src/ecs/module.ts:61
Inherited from
onComponentIdSet
protected
onComponentIdSet:undefined
| (stringId
,componentId
) =>void
Defined in: src/ecs/module.ts:59
Inherited from
onEngineSet
protected
onEngineSet:undefined
| (engine
) =>void
Defined in: src/ecs/module.ts:58
Inherited from
resourceIds
protected
resourceIds:Set
<string
>
Defined in: src/ecs/module.ts:55
Inherited from
systemDefinitions
protected
systemDefinitions:SystemDef
[]
Defined in: src/ecs/module.ts:53
Inherited from
systemFunctions
protected
systemFunctions:SystemFunc
[]
Defined in: src/ecs/module.ts:54
Inherited from
voidTargetVersionOverride
protected
voidTargetVersionOverride:undefined
|number
Defined in: src/ecs/module.ts:60
Inherited from
EcsModule
.voidTargetVersionOverride
Methods
componentAlign()
componentAlign(
stringId
):number
Defined in: src/ecs/module.ts:176
Returns the component alignment in bytes, for each component returned by componentStringId
. Called for both components and resources.
Parameters
stringId
string
Returns
number
Inherited from
componentDeserializeJson()
componentDeserializeJson(
stringId
,ptr
,json
):number
Defined in: src/ecs/module.ts:103
When deserializing scene json, the engine will pass a pointer for the module to deserialize the component from the jsonString parameter
Parameters
stringId
string
ptr
[___brand]
typeof FiascoPointerBrand
json
string
Returns
number
Inherited from
EcsModule
.componentDeserializeJson
componentSize()
componentSize(
stringId
):number
Defined in: src/ecs/module.ts:170
Returns the component size in bytes, for each component returned by componentStringId
. Called for both components and resources.
Parameters
stringId
string
Returns
number
Inherited from
componentStringId()
componentStringId(
index
):undefined
|string
Defined in: src/ecs/module.ts:151
Called infinitly until undefined
is returned. For every index provided, return an associated string id.
Parameters
index
number
The component index
Returns
undefined
| string
Inherited from
componentType()
componentType(
stringId
):EcsType
Defined in: src/ecs/module.ts:181
Returns the EcsType
for this string id, for each component returned by componentStringId
.
Parameters
stringId
string
Returns
EcsType
Inherited from
deinit()
deinit():
void
Defined in: src/ecs/module.ts:98
Called once right before this module is unloaded
Returns
void
Inherited from
init()
init():
void
Defined in: src/ecs/module.ts:96
Called once during module startup.
Returns
void
Inherited from
moduleName()
moduleName():
string
Defined in: src/ecs/module.ts:92
The name of this ecs module.
Returns
string
Inherited from
resourceDeserialize()
resourceDeserialize(
stringId
,_ptr
,serialized
):number
Defined in: src/ecs/module.ts:127
When restoring a state snapshot, for each resource which this module defines, the engine will pass a pointer to the resource for the module to deserialize the resource state into, from a previously serialized buffer.
The binary buffer will typically be a JSON representation of the resource.
Parameters
stringId
string
_ptr
[___brand]
typeof FiascoPointerBrand
serialized
ArrayBuffer
Returns
number
Inherited from
resourceInit()
resourceInit(
stringId
,ptr
):number
Defined in: src/ecs/module.ts:163
For each resource which this module defines, the engine will allocate the requested size and pass a pointer to that memory, for the module to initialize the resource at startup.
Parameters
stringId
string
ptr
[___brand]
typeof FiascoPointerBrand
Returns
number
Inherited from
resourceSerialize()
resourceSerialize(
stringId
,_ptr
):ArrayBuffer
Defined in: src/ecs/module.ts:133
When taking a state snapshot, for each resource which this module defines, the engine will pass a pointer to the resource for the module to serialize the resource state from, into a binary buffer.
The binary buffer will typically be a JSON representation of the resource, but not limited to that.
Parameters
stringId
string
_ptr
[___brand]
typeof FiascoPointerBrand
Returns
ArrayBuffer
Inherited from
setComponentId()
setComponentId(
stringId
,componentId
):void
Defined in: src/ecs/module.ts:156
Tells the module which numerical component id has been assigned to each component.
Parameters
stringId
string
componentId
number
Returns
void
Inherited from
setEngine()
setEngine(
engine
):void
Defined in: src/ecs/module.ts:139
Called with the internal engine instance.
Parameters
engine
Engine
Returns
void
Inherited from
systemArgComponent()
systemArgComponent(
systemIndex
,argIndex
):string
Defined in: src/ecs/module.ts:225
Returns the resource string id for any resource system inputs.
Parameters
systemIndex
number
argIndex
number
Returns
string
Inherited from
systemArgEvent()
systemArgEvent(
systemIndex
,argIndex
):string
Defined in: src/ecs/module.ts:251
Returns the event string id for any ArgType.EventReader
/ArgType.EventWriter
system inputs.
Parameters
systemIndex
number
argIndex
number
Returns
string
Inherited from
systemArgsLen()
systemArgsLen(
systemIndex
):number
Defined in: src/ecs/module.ts:215
Returns the number of inputs for each system.
Parameters
systemIndex
number
Returns
number
Inherited from
systemArgType()
systemArgType(
systemIndex
,argIndex
):number
Defined in: src/ecs/module.ts:220
Returns the type of input of a given system argument.
Parameters
systemIndex
number
argIndex
number
Returns
number
Inherited from
systemFunction()
systemFunction(
systemIndex
): (ptr
) =>number
Defined in: src/ecs/module.ts:205
Returns the function for each system.
System functions take a ptr
parameter, which is a double pointer to system inputs. System functions return zero on success, non-zero on error.
Parameters
systemIndex
number
Returns
(
ptr
):number
Parameters
ptr
[___brand]
typeof FiascoPointerBrand
Returns
number
Inherited from
systemIsOnce()
systemIsOnce(
systemIndex
):boolean
Defined in: src/ecs/module.ts:197
Returns whether a system is a "once" system, i.e. it runs only once at startup. Most systems are not, and should run once per frame.
Parameters
systemIndex
number
Returns
boolean
Inherited from
systemName()
systemName(
systemIndex
):string
Defined in: src/ecs/module.ts:191
Returns the name of a system.
Parameters
systemIndex
number
Returns
string
Inherited from
systemQueryArgComponent()
systemQueryArgComponent(
systemIndex
,argIndex
,queryArgIndex
):string
Defined in: src/ecs/module.ts:246
Returns the component string id each Query
input.
Parameters
systemIndex
number
argIndex
number
queryArgIndex
number
Returns
string
Inherited from
EcsModule
.systemQueryArgComponent
systemQueryArgsLen()
systemQueryArgsLen(
systemIndex
,argIndex
):number
Defined in: src/ecs/module.ts:230
Returns the number of inputs to each Query
.
Parameters
systemIndex
number
argIndex
number
Returns
number
Inherited from
systemQueryArgType()
systemQueryArgType(
systemIndex
,argIndex
,queryArgIndex
):number
Defined in: src/ecs/module.ts:235
Returns the type of input for each Query
input.
Parameters
systemIndex
number
argIndex
number
queryArgIndex
number
Returns
number
Inherited from
systemsLen()
systemsLen():
number
Defined in: src/ecs/module.ts:186
Returns the number of systems in this module.
Returns
number
Inherited from
voidTargetVersion()
voidTargetVersion():
number
Defined in: src/ecs/module.ts:88
The version of the engine that this module is compatible with.
Returns
number