當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。