You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importCorefrom'tnt-ecs';importSystemfrom'tnt-ecs';importEntityfrom'tnt-ecs';importComponentfrom'tnt-ecs';classPositionextendsComponent{getName(){return'position';}getDefaults(){return{x: 0,y: 0};}}classColorextendsComponent{getName(){return'color';}getDefaults(){return{r: 255,g: 255,b: 255};}}classRenderingextendsSystem{test(entity){returnentity.components.position&&entity.components.color;}update(entity){console.log(entity.components.position.x,entity.components.position.x);console.log(entity.components.color.r,entity.components.color.g,entity.components.color.b);}preUpdate(){console.log('Before all entities are being updated');}postUpdate(){console.log('After all entities are being updated');}enter(entity){console.log('Enter system',entity);}exit(entity){console.log('Exit system',entity);}}constecs=newCore();constrendering=newRendering();ecs.addSystem(rendering);// Start/stop the update loopecs.stop();ecs.start();// Start/stop the systemrendering.stop();rendering.start();// Add entitiesecs.addEntity(newEntity([newPosition(),newColor()]));ecs.addEntity(newEntity([newPosition({x: 50}),newColor({b: 20})]));ecs.addEntity(newEntity([newPosition({x: 50}),newColor({r: 0,g: 0,b: 0})]));constcamera=newEntity([newPosition({x: 50})]);// Removing / adding componentscamera.addComponent(newColor());camera.removeComponent('color');camera.removeComponents(['position','color']);if(camera.hasComponent('position')){console.log('This entity has the position component');}// Taggingcamera.tag('camera');camera.removeTag('camera');if(camera.hasTag('camera')){console.log('This entity has the camera tag');}