Home Reference Source
public class | source

Component

Component - entity way to express it's behaviour.

Static Member Summary

Static Public Members
public static get

Static Method Summary

Static Public Methods
public static

Component factory.

Constructor Summary

Public Constructor
public

Constructor.

Member Summary

Public Members
public

[name]: *

public get

Method Summary

Public Methods
public

deserialize(json: *)

Deserialize JSON properties into this component.

public

Destructor (dispose internal resources and detach from entity).

public

onAction(name: string, args: *)

Called when action arrived.

public

onAlterActionArguments(name: string, args: *): array | undefined

Called when asked to alter arrived action parameters.

public

Called after attached to entity.

public

Called before detached from entity.

public

onPropertySerialize(name: string, value: *): *

Called when property is serialized.

public

onPropertySetup(name: string, value: *)

Called when given property is deserialized.

public

serialize(): *

Serialize component into JSON data.

Static Public Members

public static get propsTypes: * source

Static Public Methods

public static factory(): Component source

Component factory.

Return:

Component

New component instance.

Public Constructors

public constructor() source

Constructor.

Public Members

public [name]: * source

public get entity: Entity | null source

Public Methods

public deserialize(json: *) source

Deserialize JSON properties into this component.

Params:

NameTypeAttributeDescription
json *

Serialized JSON data.

Example:

component.deserialize({ hello: 'world' });
component.hello === 'world';

public dispose() source

Destructor (dispose internal resources and detach from entity).

Example:

component.parent = system.root;
component.dispose();
component.parent === null;

public onAction(name: string, args: *) source

Called when action arrived.

Params:

NameTypeAttributeDescription
name string

Action name.

args *

Action parameters.

public onAlterActionArguments(name: string, args: *): array | undefined source

Called when asked to alter arrived action parameters.

Params:

NameTypeAttributeDescription
name string

Action name.

args *

Action parameters.

Return:

array | undefined

New action parameters or undefined if they're not change.

public onAttach() source

Called after attached to entity.

public onDetach() source

Called before detached from entity.

public onPropertySerialize(name: string, value: *): * source

Called when property is serialized.

Params:

NameTypeAttributeDescription
name string

Property name.

value *

Property value.

Return:

*

Serializable proeprty JSON value.

public onPropertySetup(name: string, value: *) source

Called when given property is deserialized.

Params:

NameTypeAttributeDescription
name string

Property name.

value *

Property value.

public serialize(): * source

Serialize component into JSON data.

Return:

*

Serialized JSON data.

Example:

component.hello = 'world';
const json = component.serialize();
json.hello === 'world';