# Class ECSEntity

ECS实体对象

#### Hierarchy

- ECSEntity

- Defined in assets/libs/ecs/ECSEntity.ts:61

#####
Index

### Constructors

constructor

### Properties

_children
_parent
compTid2Ctor
compTid2Obj
eid
mask
name

### Accessors

children
parent

### Methods

_remove
add
addChild
addComponents
destroy
get
has
remove
removeChild

## Constructors

### constructor

- new ECSEntity(): ECSEntity

- #### Returns ECSEntity

## Properties

### `Private` _children

_children: null | Map<number, ECSEntity > = null

- Defined in assets/libs/ecs/ECSEntity.ts:79

### `Private` _parent

_parent: null | ECSEntity = null

- Defined in assets/libs/ecs/ECSEntity.ts:73

### `Private` compTid2Ctor

compTid2Ctor: Map<number, CompType< IComp >> = ...

当前实体身上附加的组件构造函数

- Defined in assets/libs/ecs/ECSEntity.ts:69

### `Private` compTid2Obj

compTid2Obj: Map<number, IComp > = ...

配合 entity.remove(Comp, false)， 记录组件实例上的缓存数据，在添加时恢复原数据

- Defined in assets/libs/ecs/ECSEntity.ts:71

### eid

eid: number = -1

实体唯一标识，不要手动修改

- Defined in assets/libs/ecs/ECSEntity.ts:63

### `Private` mask

mask: ECSMask = ...

组件过滤数据

- Defined in assets/libs/ecs/ECSEntity.ts:67

### name

name: string = ""

实体对象名

- Defined in assets/libs/ecs/ECSEntity.ts:65

## Accessors

### children

- get children(): Map<number, ECSEntity >

- 子实体集合

  #### Returns Map<number, ECSEntity >

  - Defined in assets/libs/ecs/ECSEntity.ts:81

### parent

- get parent(): null | ECSEntity

- 父实体

  #### Returns null | ECSEntity

  - Defined in assets/libs/ecs/ECSEntity.ts:75

## Methods

### `Private` _remove

- _remove(comp: CompType< IComp >): void

- #### Parameters

  - ##### comp: CompType< IComp >

  #### Returns void

  - Defined in assets/libs/ecs/ECSEntity.ts:262

### add

- add<T>(obj: T): ECSEntity

- 根据组件类动态创建组件，并通知关心的系统。如果实体存在了这个组件，那么会先删除之前的组件然后添加新的

  注意：不要直接new Component，new来的Component不会从Component的缓存池拿缓存的数据

  #### Type Parameters

  - #### T extends IComp

  #### Parameters

  - ##### obj: T

  #### Returns ECSEntity

  - Defined in assets/libs/ecs/ECSEntity.ts:119
- add(ctor: number, isReAdd?: boolean): ECSEntity

- #### Parameters

  - ##### ctor: number

  - ##### `Optional` isReAdd: boolean

  #### Returns ECSEntity

  - Defined in assets/libs/ecs/ECSEntity.ts:120
- add<T>(ctor: CompCtor<T>, isReAdd?: boolean): T

- #### Type Parameters

  - #### T extends IComp

  #### Parameters

  - ##### ctor: CompCtor<T>

  - ##### `Optional` isReAdd: boolean

  #### Returns T

  - Defined in assets/libs/ecs/ECSEntity.ts:121
- add<T>(ctor: CompType<T>, isReAdd?: boolean): T

- #### Type Parameters

  - #### T extends IComp

  #### Parameters

  - ##### ctor: CompType<T>

  - ##### `Optional` isReAdd: boolean

  #### Returns T

  - Defined in assets/libs/ecs/ECSEntity.ts:122

### addChild

- addChild(entity: ECSEntity ): void

- 添加子实体

  #### Parameters

  - ##### entity: ECSEntity

    被添加的实体对象

  #### Returns void

  - Defined in assets/libs/ecs/ECSEntity.ts:92

### addComponents

- addComponents<T>(...ctors: CompType<T>[]): ECSEntity

- 批量添加组件

  ### Returns

  #### Type Parameters

  - #### T extends IComp

  #### Parameters

  - ##### `Rest` ...ctors: CompType<T>[]

    组件类

  #### Returns ECSEntity

  - Defined in assets/libs/ecs/ECSEntity.ts:192

### destroy

- destroy(): void

- 销毁实体，实体会被回收到实体缓存池中

  #### Returns void

  - Defined in assets/libs/ecs/ECSEntity.ts:267

### get

- get(ctor: number): number

- 获取一个组件实例

  #### Parameters

  - ##### ctor: number

    组件类

  #### Returns number

  - Defined in assets/libs/ecs/ECSEntity.ts:203
- get<T>(ctor: CompCtor<T>): T

- #### Type Parameters

  - #### T extends IComp

  #### Parameters

  - ##### ctor: CompCtor<T>

  #### Returns T

  - Defined in assets/libs/ecs/ECSEntity.ts:204

### has

- has(ctor: CompType< IComp >): boolean

- 组件是否在实体存在内

  #### Parameters

  - ##### ctor: CompType< IComp >

    组件类

  #### Returns boolean

  - Defined in assets/libs/ecs/ECSEntity.ts:214

### remove

- remove(ctor: CompType< IComp >, isRecycle?: boolean): void

- 从实体上删除指定组件

  #### Parameters

  - ##### ctor: CompType< IComp >

    组件构造函数或者组件Tag

  - ##### isRecycle: boolean = true

    是否回收该组件对象。对于有些组件上有大量数据，当要描述移除组件但是不想清除组件上的数据是可以 设置该参数为false，这样该组件对象会缓存在实体身上，下次重新添加组件时会将该组件对象添加回来，不会重新从组件缓存 池中拿一个组件来用。

  #### Returns void

  - Defined in assets/libs/ecs/ECSEntity.ts:230

### removeChild

- removeChild(entity: ECSEntity ): void

- 移除子实体

  ### Returns

  #### Parameters

  - ##### entity: ECSEntity

    被移除的实体对象

  #### Returns void

  - Defined in assets/libs/ecs/ECSEntity.ts:102

Generated using TypeDoc