diff --git a/src/foundation/core/Component.ts b/src/foundation/core/Component.ts index e02912ffa..6772b1162 100644 --- a/src/foundation/core/Component.ts +++ b/src/foundation/core/Component.ts @@ -6,10 +6,8 @@ import { BufferUseEnum } from '../definitions/BufferUse'; import { ComponentTypeEnum } from '../../foundation/definitions/ComponentType'; import { CompositionTypeEnum } from '../../foundation/definitions/CompositionType'; import { ProcessStage, ProcessStageEnum } from '../definitions/ProcessStage'; -import { ProcessApproachEnum } from '../definitions/ProcessApproach'; import { ComponentRepository } from './ComponentRepository'; import { Config } from './Config'; -import { WebGLStrategy } from '../../webgl/WebGLStrategy'; import { RenderPass } from '../renderer/RenderPass'; import { RnObject } from './RnObject'; import { EntityUID, ComponentSID, TypedArray, Count, Byte } from '../../types/CommonTypes'; @@ -32,7 +30,6 @@ type MemberInfo = { */ export class Component extends RnObject { private _component_sid: number; - static readonly invalidComponentSID = -1; _isAlive = true; protected __currentProcessStage: ProcessStageEnum = ProcessStage.Load; private static __bufferViews: Map> = new Map(); @@ -497,7 +494,7 @@ export class Component extends RnObject { * @returns the entity which has this component */ get entity(): IEntity { - return EntityRepository.getEntity(this.__entityUid); + return this.__entityRepository.getEntity(this.__entityUid); } /** @@ -570,18 +567,18 @@ export class Component extends RnObject { * @param memberName the member of component in string * @returns bytes information */ - static getDataByteInfoByEntityUID( - componentType: typeof Component, - entityUID: EntityUID, - memberName: string - ) { - const component = EntityRepository.getComponentOfEntity(entityUID, componentType); - if (component) { - return Component.getDataByteInfoInner(component, memberName); - } + // static getDataByteInfoByEntityUID( + // componentType: typeof Component, + // entityUID: EntityUID, + // memberName: string + // ) { + // const component = EntityRepository.getComponentOfEntity(entityUID, componentType); + // if (component) { + // return Component.getDataByteInfoInner(component, memberName); + // } - return void 0; - } + // return void 0; + // } /** * get the Pixel Location Offset in the Buffer of the Member diff --git a/src/foundation/core/ComponentRepository.ts b/src/foundation/core/ComponentRepository.ts index b77786e16..3a526dcf6 100644 --- a/src/foundation/core/ComponentRepository.ts +++ b/src/foundation/core/ComponentRepository.ts @@ -1,4 +1,4 @@ -import { Component } from './Component'; +import type { Component } from './Component'; import { Is } from '../misc/Is'; import { EntityRepository } from './EntityRepository'; import { Config } from './Config'; @@ -14,6 +14,7 @@ export class ComponentRepository { static __componentClasses: Map = new Map(); private static __componentTIDs: Array = []; private static __renderingComponentTIDs: Array = []; + static readonly invalidComponentSID = -1; constructor() {} /** @@ -60,7 +61,7 @@ export class ComponentRepository { let component_sid_count = this.__component_sid_count_map.get(componentTid); if (Is.not.exist(component_sid_count)) { this.__component_sid_count_map.set(componentTid, 0); - component_sid_count = Component.invalidComponentSID; + component_sid_count = ComponentRepository.invalidComponentSID; } // check __components array whether it has undefined element diff --git a/src/foundation/core/EntityRepository.ts b/src/foundation/core/EntityRepository.ts index f7146bb94..2a459cfa6 100644 --- a/src/foundation/core/EntityRepository.ts +++ b/src/foundation/core/EntityRepository.ts @@ -277,6 +277,13 @@ export class EntityRepository { return this.__entities[entityUid]; } + /** + * Gets the entity corresponding to the entityUID. + * @param entityUid The entityUID of the entity. + */ + public getEntity(entityUid: EntityUID): IEntity { + return EntityRepository.__entities[entityUid]; + } /** * Gets the specified component from the entity. * @param entityUid The entity to get the component from.