当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Entity.addComponent函数代码示例

本文整理汇总了TypeScript中shattered-lib/Entity.addComponent函数的典型用法代码示例。如果您正苦于以下问题:TypeScript addComponent函数的具体用法?TypeScript addComponent怎么用?TypeScript addComponent使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了addComponent函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: it

    it(`should set the current tile's architecture to it's entity`, () => {
      const architectureComponent = new ArchitectureComponent();
      const entity = new Entity();
      const currentTile = new Tile();
      entity.addComponent(architectureComponent);

      architectureComponent.onPosition({data: {destination: currentTile}});
      expect(currentTile.architecture).to.equal(entity);
    });
开发者ID:nathantreid,项目名称:shattered-planes,代码行数:9,代码来源:ArchitectureComponent.tests.ts

示例2: it

    it(`should update the entity's tile`, () => {
      const transientsComponent = new TransientComponent();
      const entity = new Entity();
      entity.addComponent(transientsComponent);

      const destination = new Tile();
      destination._architecture = new Entity;

      transientsComponent.onPositionChanged({ data: { destination } });
      entity.tile.should.equal(destination);
    });
开发者ID:nathantreid,项目名称:shattered-planes,代码行数:11,代码来源:TransientComponent.tests.ts

示例3: it

    it(`should calculate the time cost`, () => {
      const movementComponent = new NormalMovementComponent();
      const entity = new Entity();
      entity.addComponent(movementComponent);
      entity.attributes.add('moveSpeed', 1000);

      const destination = {};
      const event = {data:destination};
      movementComponent.onMove(event);
      event.actionTime.should.equal(1000);
    });
开发者ID:nathantreid,项目名称:shattered-planes,代码行数:11,代码来源:NormalMovementComponent.tests.ts

示例4: it

    it(`should move all tile from the fov to the previousFov when the visionRange is 0`, () => {
      const entity = new Entity();
      const visionComponent = new VisionComponent();
      entity.addComponent(visionComponent);
      const tile1 = new Tile();
      const tile2 = new Tile();
      const fov = visionComponent.fov = [tile1, tile2];

      visionComponent.updateFov();

      expect(visionComponent.fov).to.eql([]);
      expect(visionComponent._previousFov).to.equal(fov);
    });
开发者ID:nathantreid,项目名称:shattered-planes,代码行数:13,代码来源:VisionComponent.tests.ts

示例5: it

    it(`should emit a willNotCollide event`, (done) => {
      const collisionComponent = new CollisionComponent();
      const entity = new Entity();
      entity.addComponent(collisionComponent);

      const destination = {
        emit(event) {
          expect(event.data).to.eql({ entity: entity });
          done();
          return event;
        }
      };
      collisionComponent.onPosition({ data: { destination } });
    });
开发者ID:nathantreid,项目名称:shattered-planes,代码行数:14,代码来源:CollisionComponent.tests.ts


注:本文中的shattered-lib/Entity.addComponent函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。