本文整理匯總了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);
});
示例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);
});
示例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);
});
示例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);
});
示例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 } });
});