本文整理汇总了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 } });
});