Home Reference Source
import {EntityManager} from 'shapez.io/js/game/entity_manager.js'
public class | source

EntityManager

Extends:

BasicSerializableObject → EntityManager

Static Method Summary

Static Public Methods
public static
public static

getSchema(): {"nextUid": *}

Constructor Summary

Public Constructor
public

Member Summary

Public Members
public
public
public
public
public

Method Summary

Public Methods
public

attachDynamicComponent(entity: Entity, component: Component)

Call to attach a new component after the creation of the entity

public

Queues an entity for destruction

public

findByUid(uid: number, errorWhenNotFound: boolean=): Entity

Finds an entity buy its uid, kinda slow since it loops over all entities

public

Generates a new uid

public

getAllWithComponent(componentHandle: typeof Component): Array<Entity>

Returns all entities having the given component

public

Returns a map which gives a mapping from UID to Entity.

public
public
public

registerEntity(entity: Entity, uid: number=)

Registers a new entity

public

removeDynamicComponent(entity: Entity, component: typeof Component)

Call to remove a component after the creation of the entity

public

Unregisters all components of an entity from the component to entity mapping

public

update()

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(): {"nextUid": *} source

Should return the serialization schema

Override:

BasicSerializableObject#getSchema

Return:

{"nextUid": *}

Public Constructors

public constructor() source

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

Override:

BasicSerializableObject#constructor

Public Members

public componentToEntity: Object<string, Array<Entity>> source

public destroyList: Array<Entity> source

public entities: Array<Entity> source

public nextUid: number source

public root: GameRoot source

Public Methods

public attachDynamicComponent(entity: Entity, component: Component) source

Call to attach a new component after the creation of the entity

Params:

NameTypeAttributeDescription
entity Entity
component Component

public destroyEntity(entity: Entity) source

Queues an entity for destruction

Params:

NameTypeAttributeDescription
entity Entity

public findByUid(uid: number, errorWhenNotFound: boolean=): Entity source

Finds an entity buy its uid, kinda slow since it loops over all entities

Params:

NameTypeAttributeDescription
uid number
errorWhenNotFound boolean=

Return:

Entity

public generateUid(): number source

Generates a new uid

Return:

number

public getAllWithComponent(componentHandle: typeof Component): Array<Entity> source

Returns all entities having the given component

Params:

NameTypeAttributeDescription
componentHandle typeof Component

Return:

Array<Entity>

entities

public getFrozenUidSearchMap(): Map<number, Entity> source

Returns a map which gives a mapping from UID to Entity. This map is not updated.

Return:

Map<number, Entity>

public getStatsText(): * source

Return:

*

public processDestroyList() source

public registerEntity(entity: Entity, uid: number=) source

Registers a new entity

Params:

NameTypeAttributeDescription
entity Entity
uid number=

Optional predefined uid

public removeDynamicComponent(entity: Entity, component: typeof Component) source

Call to remove a component after the creation of the entity

Params:

NameTypeAttributeDescription
entity Entity
component typeof Component

public unregisterEntityComponents(entity: Entity) source

Unregisters all components of an entity from the component to entity mapping

Params:

NameTypeAttributeDescription
entity Entity

public update() source