Removed structure top mixins requirement #15

Merged
Mergul merged 3 commits from remove_structure_top_mixin into master 2021-02-27 17:42:50 +01:00
17 changed files with 296 additions and 272 deletions
Showing only changes of commit a6d92cb21b - Show all commits

View file

@ -125,11 +125,11 @@ struct Launcher
foreach(ref system; manager.systems) foreach(ref system; manager.systems)
{ {
if(system.id != CountSystem.system_id && system.id != CleanSystem.system_id)system.disable(); if(system.id != becsID!CountSystem && system.id != becsID!CleanSystem)system.disable();
} }
/*launcher.manager.getSystem(CountSystem.system_id).enable(); /*launcher.manager.getSystem(becsID!CountSystem).enable();
launcher.manager.getSystem(CleanSystem.system_id).enable();//*/ launcher.manager.getSystem(becsID!CleanSystem).enable();//*/
if(callbacks.register)callbacks.register(); if(callbacks.register)callbacks.register();
if(callbacks.initialize)callbacks.initialize(); if(callbacks.initialize)callbacks.initialize();

View file

@ -372,9 +372,9 @@ void brickBreakerStart()
draw_system.default_data.material_id = 0; draw_system.default_data.material_id = 0;
EntityTemplate* brick_tmpl = launcher.manager.allocateTemplate( EntityTemplate* brick_tmpl = launcher.manager.allocateTemplate(
[CLocation.component_id, CScale.component_id, CColor.component_id, [becsID!CLocation, becsID!CScale, becsID!CColor,
CTexCoordsIndex.component_id, CBVH.component_id, CHitPoints.component_id, becsID!CTexCoordsIndex, becsID!CBVH, becsID!CHitPoints,
CAABB.component_id, CStatic.component_id].staticArray becsID!CAABB, becsID!CStatic].staticArray
); );
brick_tmpl.getComponent!CTexCoordsIndex().value = TexCoordsManager.instance.getCoordIndex(vec4(304,40,16,8)*px); brick_tmpl.getComponent!CTexCoordsIndex().value = TexCoordsManager.instance.getCoordIndex(vec4(304,40,16,8)*px);
brick_tmpl.getComponent!CColor().value = 0x80206020; brick_tmpl.getComponent!CColor().value = 0x80206020;
@ -387,10 +387,10 @@ void brickBreakerStart()
big_brick_tmpl.getComponent!CScale().value = vec2(16,16); big_brick_tmpl.getComponent!CScale().value = vec2(16,16);
EntityTemplate* paddle_tmpl = launcher.manager.allocateTemplate( EntityTemplate* paddle_tmpl = launcher.manager.allocateTemplate(
[CLocation.component_id, CScale.component_id, CInput.component_id, [becsID!CLocation, becsID!CScale, becsID!CInput,
CTexCoordsIndex.component_id, CPaddle.component_id, CVelocity.component_id, becsID!CTexCoordsIndex, becsID!CPaddle, becsID!CVelocity,
CDamping.component_id, CVelocityFactor.component_id, CBVH.component_id, becsID!CDamping, becsID!CVelocityFactor, becsID!CBVH,
CAABB.component_id].staticArray becsID!CAABB].staticArray
); );
paddle_tmpl.getComponent!CTexCoordsIndex().value = TexCoordsManager.instance.getCoordIndex(vec4(272,48,64,10)*px); paddle_tmpl.getComponent!CTexCoordsIndex().value = TexCoordsManager.instance.getCoordIndex(vec4(272,48,64,10)*px);
paddle_tmpl.getComponent!CScale().value = vec2(64,10); paddle_tmpl.getComponent!CScale().value = vec2(64,10);
@ -398,8 +398,8 @@ void brickBreakerStart()
paddle_tmpl.getComponent!CVelocityFactor().value = vec2(1,0); paddle_tmpl.getComponent!CVelocityFactor().value = vec2(1,0);
EntityTemplate* ball_tmpl = launcher.manager.allocateTemplate( EntityTemplate* ball_tmpl = launcher.manager.allocateTemplate(
[CLocation.component_id, CScale.component_id, //CDamping.component_id, [becsID!CLocation, becsID!CScale, //becsID!CDamping,
CTexCoordsIndex.component_id, CBall.component_id, CVelocity.component_id].staticArray becsID!CTexCoordsIndex, becsID!CBall, becsID!CVelocity].staticArray
); );
ball_tmpl.getComponent!CTexCoordsIndex().value = TexCoordsManager.instance.getCoordIndex(vec4(304,32,8,8)*px); ball_tmpl.getComponent!CTexCoordsIndex().value = TexCoordsManager.instance.getCoordIndex(vec4(304,32,8,8)*px);
ball_tmpl.getComponent!CScale().value = vec2(8,8); ball_tmpl.getComponent!CScale().value = vec2(8,8);
@ -417,12 +417,12 @@ void brickBreakerStart()
launcher.gui_manager.addComponent(CDamping(), "Damping"); launcher.gui_manager.addComponent(CDamping(), "Damping");
launcher.gui_manager.addComponent(CBall(), "Ball"); launcher.gui_manager.addComponent(CBall(), "Ball");
launcher.gui_manager.addSystem(MoveSystem.system_id, "Move System"); launcher.gui_manager.addSystem(becsID!MoveSystem, "Move System");
launcher.gui_manager.addSystem(EdgeCollisionSystem.system_id, "Edge Collision System"); launcher.gui_manager.addSystem(becsID!EdgeCollisionSystem, "Edge Collision System");
launcher.gui_manager.addSystem(BallCollisionSystem.system_id, "Ball Collision System"); launcher.gui_manager.addSystem(becsID!BallCollisionSystem, "Ball Collision System");
launcher.gui_manager.addSystem(InputMovementSystem.system_id, "Input Movement System"); launcher.gui_manager.addSystem(becsID!InputMovementSystem, "Input Movement System");
launcher.gui_manager.addSystem(DampingSystem.system_id, "Damping System"); launcher.gui_manager.addSystem(becsID!DampingSystem, "Damping System");
launcher.gui_manager.addSystem(DamageSystem.system_id, "Damage System"); launcher.gui_manager.addSystem(becsID!DamageSystem, "Damage System");
launcher.gui_manager.addTemplate(brick_tmpl, "Brick"); launcher.gui_manager.addTemplate(brick_tmpl, "Brick");
launcher.gui_manager.addTemplate(big_brick_tmpl, "Big Brick"); launcher.gui_manager.addTemplate(big_brick_tmpl, "Big Brick");

View file

@ -494,13 +494,13 @@ void particlesStart()
draw_system.default_data.material_id = 2; draw_system.default_data.material_id = 2;
draw_system.default_data.texture = particles_demo.texture; draw_system.default_data.texture = particles_demo.texture;
launcher.gui_manager.addSystem(MoveSystem.system_id,"Move System"); launcher.gui_manager.addSystem(becsID!MoveSystem,"Move System");
launcher.gui_manager.addSystem(DrawSystem.system_id,"Draw System"); launcher.gui_manager.addSystem(becsID!DrawSystem,"Draw System");
launcher.gui_manager.addSystem(PlayAreaSystem.system_id,"Play Area System"); launcher.gui_manager.addSystem(becsID!PlayAreaSystem,"Play Area System");
launcher.gui_manager.addSystem(AttractSystem.system_id,"Attract System"); launcher.gui_manager.addSystem(becsID!AttractSystem,"Attract System");
launcher.gui_manager.addSystem(MouseAttractSystem.system_id,"Mouse Attract System"); launcher.gui_manager.addSystem(becsID!MouseAttractSystem,"Mouse Attract System");
launcher.gui_manager.addSystem(DampingSystem.system_id,"Damping System"); launcher.gui_manager.addSystem(becsID!DampingSystem,"Damping System");
launcher.gui_manager.addSystem(ParticleLifeSystem.system_id,"Particle Life System"); launcher.gui_manager.addSystem(becsID!ParticleLifeSystem,"Particle Life System");
// launcher.gui_manager.addComponent(CColor(),"Color (white)"); // launcher.gui_manager.addComponent(CColor(),"Color (white)");
// launcher.gui_manager.addComponent(CColor(0xFF101540),"Color (red)"); // launcher.gui_manager.addComponent(CColor(0xFF101540),"Color (red)");
@ -516,7 +516,7 @@ void particlesStart()
launcher.gui_manager.addComponent(CGravity(),"Gravity"); launcher.gui_manager.addComponent(CGravity(),"Gravity");
EntityTemplate* tmpl; EntityTemplate* tmpl;
EntityTemplate* base_tmpl = launcher.manager.allocateTemplate([CTexCoords.component_id, CLocation.component_id, CColor.component_id, CVelocity.component_id, CDamping.component_id, CScale.component_id, CMaterialIndex.component_id].staticArray); EntityTemplate* base_tmpl = launcher.manager.allocateTemplate([becsID!CTexCoords, becsID!CLocation, becsID!CColor, becsID!CVelocity, becsID!CDamping, becsID!CScale, becsID!CMaterialIndex].staticArray);
base_tmpl.getComponent!CColor().value = 0xFF251010; base_tmpl.getComponent!CColor().value = 0xFF251010;
base_tmpl.getComponent!CScale().value = vec2(2); base_tmpl.getComponent!CScale().value = vec2(2);
base_tmpl.getComponent!CTexCoords().value = vec4(246,64,2,2)*px; base_tmpl.getComponent!CTexCoords().value = vec4(246,64,2,2)*px;
@ -531,15 +531,15 @@ void particlesStart()
// tmpl = launcher.manager.allocateTemplate(base_tmpl); // tmpl = launcher.manager.allocateTemplate(base_tmpl);
// tmpl.getComponent!CColor().value = 0xFF101540; // tmpl.getComponent!CColor().value = 0xFF101540;
// launcher.gui_manager.addTemplate(tmpl,"Particle (red)"); // launcher.gui_manager.addTemplate(tmpl,"Particle (red)");
// tmpl = launcher.manager.allocateTemplate(tmpl, [CDamping.component_id].staticArray); // tmpl = launcher.manager.allocateTemplate(tmpl, [becsID!CDamping].staticArray);
// launcher.gui_manager.addTemplate(tmpl,"Particle (damping)"); // launcher.gui_manager.addTemplate(tmpl,"Particle (damping)");
// tmpl = launcher.manager.allocateTemplate(tmpl); // tmpl = launcher.manager.allocateTemplate(tmpl);
// tmpl.getComponent!CDamping().power = 4; // tmpl.getComponent!CDamping().power = 4;
// launcher.gui_manager.addTemplate(tmpl,"Particle (damping!)"); // launcher.gui_manager.addTemplate(tmpl,"Particle (damping!)");
tmpl = launcher.manager.allocateTemplate([CAttractor.component_id, CLocation.component_id, CForceRange.component_id, CScale.component_id].staticArray); tmpl = launcher.manager.allocateTemplate([becsID!CAttractor, becsID!CLocation, becsID!CForceRange, becsID!CScale].staticArray);
tmpl.getComponent!CScale().value = vec2(4); tmpl.getComponent!CScale().value = vec2(4);
launcher.gui_manager.addTemplate(tmpl,"Attractor"); launcher.gui_manager.addTemplate(tmpl,"Attractor");
tmpl = launcher.manager.allocateTemplate(tmpl, [CVortex.component_id].staticArray); tmpl = launcher.manager.allocateTemplate(tmpl, [becsID!CVortex].staticArray);
launcher.gui_manager.addTemplate(tmpl,"Vortex"); launcher.gui_manager.addTemplate(tmpl,"Vortex");
// tmpl = launcher.manager.allocateTemplate(tmpl); // tmpl = launcher.manager.allocateTemplate(tmpl);
// tmpl.getComponent!CVortex().strength = -0.6; // tmpl.getComponent!CVortex().strength = -0.6;

View file

@ -2,6 +2,8 @@ module demos.sandbox;
import bindbc.sdl; import bindbc.sdl;
import bubel.ecs.core;
import demos.simple; import demos.simple;
import demos.snake; import demos.snake;
import demos.space_invaders; import demos.space_invaders;
@ -37,8 +39,8 @@ void sandboxStart()
draw_system.default_data.texture = particles_demo.texture; draw_system.default_data.texture = particles_demo.texture;
draw_system.default_data.color = 0x80808080; draw_system.default_data.color = 0x80808080;
launcher.manager.getSystem(MouseAttractSystem.system_id).disable(); launcher.manager.getSystem(becsID!MouseAttractSystem).disable();
launcher.manager.getSystem(demos.simple.MoveSystem.system_id).disable(); launcher.manager.getSystem(becsID!(demos.simple.MoveSystem)).disable();
} }

View file

@ -134,10 +134,10 @@ void simpleStart()
draw_system.default_data.size = vec2(16,16); draw_system.default_data.size = vec2(16,16);
draw_system.default_data.coords = vec4(0,48,16,16)*px;//vec4(0,0,1,1); draw_system.default_data.coords = vec4(0,48,16,16)*px;//vec4(0,0,1,1);
launcher.gui_manager.addSystem(MoveSystem.system_id,"Move Up System"); launcher.gui_manager.addSystem(becsID!MoveSystem,"Move Up System");
launcher.gui_manager.addSystem(DrawSystem.system_id,"Draw System"); launcher.gui_manager.addSystem(becsID!DrawSystem,"Draw System");
simple.tmpl = launcher.manager.allocateTemplate([CLocation.component_id, CDrawDefault.component_id].staticArray); simple.tmpl = launcher.manager.allocateTemplate([becsID!CLocation, becsID!CDrawDefault].staticArray);
//*simple.tmpl.getComponent!CTexCoordsIndex = TexCoordsManager.instance.getCoordIndex(vec4(0,48,16,16)*px); //*simple.tmpl.getComponent!CTexCoordsIndex = TexCoordsManager.instance.getCoordIndex(vec4(0,48,16,16)*px);
//CLocation* loc_comp = simple.tmpl.getComponent!CLocation; //CLocation* loc_comp = simple.tmpl.getComponent!CLocation;
@ -153,8 +153,8 @@ void simpleStart()
void simpleEnd() void simpleEnd()
{ {
launcher.manager.getSystem(MoveSystem.system_id).disable(); launcher.manager.getSystem(becsID!MoveSystem).disable();
launcher.manager.getSystem(DrawSystem.system_id).disable(); launcher.manager.getSystem(becsID!DrawSystem).disable();
simple.texture.destroy(); simple.texture.destroy();

View file

@ -903,26 +903,26 @@ void snakeStart()
//launcher.gui_manager.addComponent(CAnimation(),"Movement"); //launcher.gui_manager.addComponent(CAnimation(),"Movement");
launcher.gui_manager.addComponent(CILocation(),"Int Location"); launcher.gui_manager.addComponent(CILocation(),"Int Location");
launcher.gui_manager.addSystem(MoveSystem.system_id,"Move System"); launcher.gui_manager.addSystem(becsID!MoveSystem,"Move System");
launcher.gui_manager.addSystem(InputSystem.system_id,"Input System"); launcher.gui_manager.addSystem(becsID!InputSystem,"Input System");
launcher.gui_manager.addSystem(FixSnakeDirectionSystem.system_id,"Fix Direction System"); launcher.gui_manager.addSystem(becsID!FixSnakeDirectionSystem,"Fix Direction System");
launcher.gui_manager.addSystem(AnimationRenderSystem.system_id,"Animation Render System"); launcher.gui_manager.addSystem(becsID!AnimationRenderSystem,"Animation Render System");
launcher.gui_manager.addSystem(AnimationSystem.system_id,"Animation System"); launcher.gui_manager.addSystem(becsID!AnimationSystem,"Animation System");
launcher.gui_manager.addSystem(ParticleSystem.system_id,"Particle Life System"); launcher.gui_manager.addSystem(becsID!ParticleSystem,"Particle Life System");
launcher.gui_manager.addSystem(ParticleMovementSystem.system_id,"Particle Movement System"); launcher.gui_manager.addSystem(becsID!ParticleMovementSystem,"Particle Movement System");
launcher.gui_manager.addSystem(DrawAppleSystem.system_id,"Draw Apple System"); launcher.gui_manager.addSystem(becsID!DrawAppleSystem,"Draw Apple System");
launcher.gui_manager.addSystem(DrawSnakeSystem.system_id,"Draw Snake System"); launcher.gui_manager.addSystem(becsID!DrawSnakeSystem,"Draw Snake System");
snake.snake_destroy_particle_frames = Mallocator.makeArray([vec4(64,144,16,16)*px,vec4(80,144,16,16)*px,vec4(96,144,16,16)*px,vec4(112,144,16,16)*px].staticArray); snake.snake_destroy_particle_frames = Mallocator.makeArray([vec4(64,144,16,16)*px,vec4(80,144,16,16)*px,vec4(96,144,16,16)*px,vec4(112,144,16,16)*px].staticArray);
{ {
ushort[5] components = [CILocation.component_id, CSnake.component_id, CMovement.component_id, CInput.component_id, CLocation.component_id]; ushort[5] components = [becsID!CILocation, becsID!CSnake, becsID!CMovement, becsID!CInput, becsID!CLocation];
snake.snake_tmpl = launcher.manager.allocateTemplate(components); snake.snake_tmpl = launcher.manager.allocateTemplate(components);
launcher.manager.addEntity(snake.snake_tmpl,[CILocation(ivec2(2,2)).ref_].staticArray); launcher.manager.addEntity(snake.snake_tmpl,[CILocation(ivec2(2,2)).ref_].staticArray);
} }
{ {
snake.snake_destroy_particle = launcher.manager.allocateTemplate([CLocation.component_id, CParticle.component_id, CParticleVector.component_id, CAnimation.component_id, CLocation.component_id].staticArray); snake.snake_destroy_particle = launcher.manager.allocateTemplate([becsID!CLocation, becsID!CParticle, becsID!CParticleVector, becsID!CAnimation, becsID!CLocation].staticArray);
CAnimation* canim = snake.snake_destroy_particle.getComponent!CAnimation; CAnimation* canim = snake.snake_destroy_particle.getComponent!CAnimation;
canim.frames = snake.snake_destroy_particle_frames; canim.frames = snake.snake_destroy_particle_frames;
CParticle* particle = snake.snake_destroy_particle.getComponent!CParticle; CParticle* particle = snake.snake_destroy_particle.getComponent!CParticle;
@ -930,7 +930,7 @@ void snakeStart()
} }
{ {
ushort[3] components = [CILocation.component_id, CApple.component_id, CLocation.component_id]; ushort[3] components = [becsID!CILocation, becsID!CApple, becsID!CLocation];
snake.apple_tmpl = launcher.manager.allocateTemplate(components); snake.apple_tmpl = launcher.manager.allocateTemplate(components);
snake.addApple(); snake.addApple();
} }

View file

@ -542,8 +542,8 @@ struct ShipWeaponSystem
void create() void create()
{ {
laser1_tmpl = launcher.manager.allocateTemplate([CWeapon.component_id, CLocation.component_id, CShootDirection.component_id, CTargetParent.component_id, CGuild.component_id, CVelocity.component_id].staticArray); laser1_tmpl = launcher.manager.allocateTemplate([becsID!CWeapon, becsID!CLocation, becsID!CShootDirection, becsID!CTargetParent, becsID!CGuild, becsID!CVelocity].staticArray);
main_weapon_tmpl = launcher.manager.allocateTemplate([CLocation.component_id, CShootDirection.component_id, CTargetParent.component_id, CGuild.component_id, CVelocity.component_id].staticArray); main_weapon_tmpl = launcher.manager.allocateTemplate([becsID!CLocation, becsID!CShootDirection, becsID!CTargetParent, becsID!CGuild, becsID!CVelocity].staticArray);
*laser1_tmpl.getComponent!CWeapon = CWeapon(0,CWeapon.Type.laser,3); *laser1_tmpl.getComponent!CWeapon = CWeapon(0,CWeapon.Type.laser,3);
laser1_tmpl.getComponent!CTargetParent().rel_pos = vec2(10,13); laser1_tmpl.getComponent!CTargetParent().rel_pos = vec2(10,13);
main_weapon_tmpl.getComponent!CTargetParent().rel_pos = vec2(0,4); main_weapon_tmpl.getComponent!CTargetParent().rel_pos = vec2(0,4);
@ -585,11 +585,11 @@ struct ShipWeaponSystem
void create() void create()
{ {
weapon_tmpl = launcher.manager.allocateTemplate( weapon_tmpl = launcher.manager.allocateTemplate(
[CWeapon.component_id, CLocation.component_id, CShootDirection.component_id, [becsID!CWeapon, becsID!CLocation, becsID!CShootDirection,
CTargetParent.component_id, CGuild.component_id, CVelocity.component_id, becsID!CTargetParent, becsID!CGuild, becsID!CVelocity,
CAutoShoot.component_id, CTarget.component_id, CTargetPlayerShip.component_id, becsID!CAutoShoot, becsID!CTarget, becsID!CTargetPlayerShip,
CRotation.component_id, CScale.component_id, CTexCoords.component_id, becsID!CRotation, becsID!CScale, becsID!CTexCoords,
CDepth.component_id, CWeaponLocation.component_id].staticArray); becsID!CDepth, becsID!CWeaponLocation].staticArray);
*weapon_tmpl.getComponent!CWeapon = CWeapon(0,CWeapon.Type.laser,3); *weapon_tmpl.getComponent!CWeapon = CWeapon(0,CWeapon.Type.laser,3);
weapon_tmpl.getComponent!CTargetParent().rel_pos = vec2(0,0); weapon_tmpl.getComponent!CTargetParent().rel_pos = vec2(0,0);
weapon_tmpl.getComponent!CGuild().guild = 1; weapon_tmpl.getComponent!CGuild().guild = 1;
@ -601,8 +601,8 @@ struct ShipWeaponSystem
weapon_tmpl.getComponent!CWeaponLocation().rel_pos = vec2(0,12); weapon_tmpl.getComponent!CWeaponLocation().rel_pos = vec2(0,12);
top_tmpl = launcher.manager.allocateTemplate( top_tmpl = launcher.manager.allocateTemplate(
[CLocation.component_id, CTargetParent.component_id, CScale.component_id, [becsID!CLocation, becsID!CTargetParent, becsID!CScale,
CTexCoords.component_id, CDepth.component_id].staticArray); becsID!CTexCoords, becsID!CDepth].staticArray);
top_tmpl.getComponent!CTargetParent().rel_pos = vec2(0,1); top_tmpl.getComponent!CTargetParent().rel_pos = vec2(0,1);
top_tmpl.getComponent!CScale().value = vec2(10,11); top_tmpl.getComponent!CScale().value = vec2(10,11);
top_tmpl.getComponent!CDepth().value = -2; top_tmpl.getComponent!CDepth().value = -2;
@ -645,11 +645,11 @@ struct ShipWeaponSystem
void create() void create()
{ {
tower1_tmpl = launcher.manager.allocateTemplate( tower1_tmpl = launcher.manager.allocateTemplate(
[CColor.component_id, CHitMark.component_id, CHitPoints.component_id, CLocation.component_id, [becsID!CColor, becsID!CHitMark, becsID!CHitPoints, becsID!CLocation,
CTexCoords.component_id, CScale.component_id, CEnemy.component_id, becsID!CTexCoords, becsID!CScale, becsID!CEnemy,
CShootGrid.component_id, CGuild.component_id, CInit.component_id, becsID!CShootGrid, becsID!CGuild, becsID!CInit,
CChildren.component_id, CDepth.component_id, CTargetParent.component_id, becsID!CChildren, becsID!CDepth, becsID!CTargetParent,
CSpawnUponDeath.component_id, CShootWaveUponDeath.component_id, CShootGridMask.component_id].staticArray becsID!CSpawnUponDeath, becsID!CShootWaveUponDeath, becsID!CShootGridMask].staticArray
); );
/*CTexCoords* tex_comp = tower1_tmpl.getComponent!CTexCoords; /*CTexCoords* tex_comp = tower1_tmpl.getComponent!CTexCoords;
@ -696,8 +696,8 @@ struct ShipWeaponSystem
ship.create(); ship.create();
tower.create(); tower.create();
boss.create(); boss.create();
/*ship.laser1_tmpl = launcher.manager.allocateTemplate([CWeapon.component_id, CLocation.component_id, CShootDirection.component_id, CTargetParent.component_id, CGuild.component_id, CVelocity.component_id].staticArray); /*ship.laser1_tmpl = launcher.manager.allocateTemplate([becsID!CWeapon, becsID!CLocation, becsID!CShootDirection, becsID!CTargetParent, becsID!CGuild, becsID!CVelocity].staticArray);
ship.main_weapon_tmpl = launcher.manager.allocateTemplate([CLocation.component_id, CShootDirection.component_id, CTargetParent.component_id, CGuild.component_id, CVelocity.component_id].staticArray); ship.main_weapon_tmpl = launcher.manager.allocateTemplate([becsID!CLocation, becsID!CShootDirection, becsID!CTargetParent, becsID!CGuild, becsID!CVelocity].staticArray);
*ship.laser1_tmpl.getComponent!CWeapon = CWeapon(3,0.0); *ship.laser1_tmpl.getComponent!CWeapon = CWeapon(3,0.0);
ship.laser1_tmpl.getComponent!CTargetParent().rel_pos = vec2(10,13); ship.laser1_tmpl.getComponent!CTargetParent().rel_pos = vec2(10,13);
ship.main_weapon_tmpl.getComponent!CTargetParent().rel_pos = vec2(0,4); ship.main_weapon_tmpl.getComponent!CTargetParent().rel_pos = vec2(0,4);
@ -958,8 +958,8 @@ struct ShootingSystem
void onCreate() void onCreate()
{ {
/*bullet_tmpl[0] = launcher.manager.allocateTemplate( /*bullet_tmpl[0] = launcher.manager.allocateTemplate(
[CLocation.component_id, CTexCoords.component_id, CVelocity.component_id, [becsID!CLocation, becsID!CTexCoords, becsID!CVelocity,
CScale.component_id, CBullet.component_id, CGuild.component_id].staticArray becsID!CScale, becsID!CBullet, becsID!CGuild].staticArray
); );
bullet_tmpl[0].getComponent!CTexCoords().value = vec4(0,24,2,8)*px; bullet_tmpl[0].getComponent!CTexCoords().value = vec4(0,24,2,8)*px;
bullet_tmpl[0].getComponent!CScale().value = vec2(2,8); bullet_tmpl[0].getComponent!CScale().value = vec2(2,8);
@ -977,9 +977,9 @@ struct ShootingSystem
fire_tmpl = launcher.manager.allocateTemplate( fire_tmpl = launcher.manager.allocateTemplate(
[CLocation.component_id, CTexCoords.component_id, CScale.component_id, [becsID!CLocation, becsID!CTexCoords, becsID!CScale,
CAnimation.component_id, CParticle.component_id, CRotation.component_id, becsID!CAnimation, becsID!CParticle, becsID!CRotation,
CVelocity.component_id, CDamping.component_id].staticArray becsID!CVelocity, becsID!CDamping].staticArray
); );
fire_tmpl.getComponent!CTexCoords().value = vec4(96,64,8,16)*px; fire_tmpl.getComponent!CTexCoords().value = vec4(96,64,8,16)*px;
@ -1174,9 +1174,9 @@ struct ParticleEmittingSystem
void onCreate() void onCreate()
{ {
templates[0] = launcher.manager.allocateTemplate( templates[0] = launcher.manager.allocateTemplate(
[CLocation.component_id, CTexCoords.component_id, CScale.component_id, [becsID!CLocation, becsID!CTexCoords, becsID!CScale,
CAnimation.component_id, CParticle.component_id, CRotation.component_id, becsID!CAnimation, becsID!CParticle, becsID!CRotation,
CVelocity.component_id, CDamping.component_id, CDepth.component_id].staticArray); becsID!CVelocity, becsID!CDamping, becsID!CDepth].staticArray);
*templates[0].getComponent!CAnimation() = CAnimation(flashes,0,2); *templates[0].getComponent!CAnimation() = CAnimation(flashes,0,2);
*templates[0].getComponent!CParticle() = CParticle(350); *templates[0].getComponent!CParticle() = CParticle(350);
//*templates[0].getComponent!CDepth() = CDepth(-3); //*templates[0].getComponent!CDepth() = CDepth(-3);
@ -1242,7 +1242,7 @@ struct UpgradeCollisionSystem
if(space_invaders.shoot_grid.test(id, data.location[i], cast(ubyte)(0xFF))) if(space_invaders.shoot_grid.test(id, data.location[i], cast(ubyte)(0xFF)))
{ {
Entity* entity = launcher.manager.getEntity(id); Entity* entity = launcher.manager.getEntity(id);
if(entity && entity.hasComponent(CShip.component_id)) if(entity && entity.hasComponent(becsID!CShip))
{ {
launcher.manager.sendEvent(id, EUpgrade()); launcher.manager.sendEvent(id, EUpgrade());
launcher.manager.removeEntity(data.entity[i].id); launcher.manager.removeEntity(data.entity[i].id);
@ -1471,17 +1471,17 @@ struct HitPointsSystem
void onCreate() void onCreate()
{ {
upgrade_tmpl = launcher.manager.allocateTemplate( upgrade_tmpl = launcher.manager.allocateTemplate(
[CVelocity.component_id, CLocation.component_id, CTexCoords.component_id, [becsID!CVelocity, becsID!CLocation, becsID!CTexCoords,
CScale.component_id, CUpgrade.component_id, CAnimation.component_id, becsID!CScale, becsID!CUpgrade, becsID!CAnimation,
CAnimationLooped.component_id].staticArray); becsID!CAnimationLooped].staticArray);
//tex_comp.tex = space_invaders.texture;//ship_tex; //tex_comp.tex = space_invaders.texture;//ship_tex;
upgrade_tmpl.getComponent!CTexCoords().value = vec4(0*px,32*px,16*px,16*px); upgrade_tmpl.getComponent!CTexCoords().value = vec4(0*px,32*px,16*px,16*px);
*upgrade_tmpl.getComponent!CAnimation = CAnimation(upgrade_laser_frames, 0, 1); *upgrade_tmpl.getComponent!CAnimation = CAnimation(upgrade_laser_frames, 0, 1);
upgrade_tmpl.getComponent!CVelocity().value = vec2(0,-0.05); upgrade_tmpl.getComponent!CVelocity().value = vec2(0,-0.05);
explosion_tmpl = launcher.manager.allocateTemplate( explosion_tmpl = launcher.manager.allocateTemplate(
[CDepth.component_id, CParticle.component_id, CLocation.component_id, [becsID!CDepth, becsID!CParticle, becsID!CLocation,
CTexCoords.component_id, CScale.component_id, CAnimation.component_id].staticArray); becsID!CTexCoords, becsID!CScale, becsID!CAnimation].staticArray);
//explosion_tmpl.getComponent!(CTexCoords).tex = space_invaders.texture; //explosion_tmpl.getComponent!(CTexCoords).tex = space_invaders.texture;
*explosion_tmpl.getComponent!CAnimation = CAnimation(explosion_laser_frames, 0, 1.333); *explosion_tmpl.getComponent!CAnimation = CAnimation(explosion_laser_frames, 0, 1.333);
explosion_tmpl.getComponent!(CParticle).life = 600; explosion_tmpl.getComponent!(CParticle).life = 600;
@ -1627,8 +1627,8 @@ struct PartsDestroySystem
{ {
flashes_emitter = launcher.manager.allocateTemplate( flashes_emitter = launcher.manager.allocateTemplate(
[ [
CVelocity.component_id, CLocation.component_id, CParticleEmitter.component_id, becsID!CVelocity, becsID!CLocation, becsID!CParticleEmitter,
CParticleEmitterTime.component_id, CTargetParent.component_id, CDepth.component_id becsID!CParticleEmitterTime, becsID!CTargetParent, becsID!CDepth
].staticArray); ].staticArray);
*flashes_emitter.getComponent!CParticleEmitter() = CParticleEmitter(vec2(0,0), vec2(800,1600), 0); *flashes_emitter.getComponent!CParticleEmitter() = CParticleEmitter(vec2(0,0), vec2(800,1600), 0);
} }
@ -1992,8 +1992,8 @@ struct CShipIterator
{ {
flashes_emitter = launcher.manager.allocateTemplate( flashes_emitter = launcher.manager.allocateTemplate(
[ [
CVelocity.component_id, CLocation.component_id, CParticleEmitter.component_id, becsID!CVelocity, becsID!CLocation, becsID!CParticleEmitter,
CParticleEmitterTime.component_id, CTargetParent.component_id becsID!CParticleEmitterTime, becsID!CTargetParent
].staticArray); ].staticArray);
*flashes_emitter.getComponent!CParticleEmitter() = CParticleEmitter(vec2(0,0), vec2(400,400), 0); *flashes_emitter.getComponent!CParticleEmitter() = CParticleEmitter(vec2(0,0), vec2(400,400), 0);
} }
@ -2185,43 +2185,43 @@ void spaceInvadersStart()
//launcher.gui_manager.addComponent(CSpawnUponDeath(),"Spawn Upon Death"); //launcher.gui_manager.addComponent(CSpawnUponDeath(),"Spawn Upon Death");
launcher.gui_manager.addComponent(CShootWaveUponDeath(CWeapon.Type.canon),"Wave Upon Death"); launcher.gui_manager.addComponent(CShootWaveUponDeath(CWeapon.Type.canon),"Wave Upon Death");
launcher.gui_manager.addSystem(DrawSystem.system_id,"Draw System"); launcher.gui_manager.addSystem(becsID!DrawSystem,"Draw System");
launcher.gui_manager.addSystem(InputMovementSystem.system_id,"Input Movement"); launcher.gui_manager.addSystem(becsID!InputMovementSystem,"Input Movement");
launcher.gui_manager.addSystem(ShootingSystem.system_id,"Shooting System"); launcher.gui_manager.addSystem(becsID!ShootingSystem,"Shooting System");
//launcher.gui_manager.addSystem(MovementSystem.system_id,"Movement System"); //launcher.gui_manager.addSystem(becsID!MovementSystem,"Movement System");
launcher.gui_manager.addSystem(MoveSystem.system_id,"Move System"); launcher.gui_manager.addSystem(becsID!MoveSystem,"Move System");
launcher.gui_manager.addSystem(ClampPositionSystem.system_id,"Clamp Position System"); launcher.gui_manager.addSystem(becsID!ClampPositionSystem,"Clamp Position System");
launcher.gui_manager.addSystem(ChangeDirectionSystem.system_id,"Change Direction System"); launcher.gui_manager.addSystem(becsID!ChangeDirectionSystem,"Change Direction System");
launcher.gui_manager.addSystem(BulletsCollisionSystem.system_id,"Bullets Collision System"); launcher.gui_manager.addSystem(becsID!BulletsCollisionSystem,"Bullets Collision System");
launcher.gui_manager.addSystem(ShootGridManager.system_id,"Shoot Grid Manager"); launcher.gui_manager.addSystem(becsID!ShootGridManager,"Shoot Grid Manager");
launcher.gui_manager.addSystem(ShootGridCleaner.system_id,"Shoot Grid Cleaner"); launcher.gui_manager.addSystem(becsID!ShootGridCleaner,"Shoot Grid Cleaner");
launcher.gui_manager.addSystem(HitPointsSystem.system_id,"Hit Points System"); launcher.gui_manager.addSystem(becsID!HitPointsSystem,"Hit Points System");
launcher.gui_manager.addSystem(HitMarkingSystem.system_id,"Hit Marking System"); launcher.gui_manager.addSystem(becsID!HitMarkingSystem,"Hit Marking System");
launcher.gui_manager.addSystem(UpgradeCollisionSystem.system_id,"Upgrade Collision System"); launcher.gui_manager.addSystem(becsID!UpgradeCollisionSystem,"Upgrade Collision System");
launcher.gui_manager.addSystem(UpgradeSystem.system_id,"Upgrade System"); launcher.gui_manager.addSystem(becsID!UpgradeSystem,"Upgrade System");
launcher.gui_manager.addSystem(ParticleSystem.system_id,"Particle System"); launcher.gui_manager.addSystem(becsID!ParticleSystem,"Particle System");
launcher.gui_manager.addSystem(AnimationSystem.system_id,"Animation System"); launcher.gui_manager.addSystem(becsID!AnimationSystem,"Animation System");
launcher.gui_manager.addSystem(DampingSystem.system_id,"Damping System"); launcher.gui_manager.addSystem(becsID!DampingSystem,"Damping System");
launcher.gui_manager.addSystem(MoveToParentTargetSystem.system_id,"Move To Target System"); launcher.gui_manager.addSystem(becsID!MoveToParentTargetSystem,"Move To Target System");
launcher.gui_manager.addSystem(ParentOwnerSystem.system_id,"Parent Owner System"); launcher.gui_manager.addSystem(becsID!ParentOwnerSystem,"Parent Owner System");
launcher.gui_manager.addSystem(ShipWeaponSystem.system_id,"Ship Weapon System"); launcher.gui_manager.addSystem(becsID!ShipWeaponSystem,"Ship Weapon System");
launcher.gui_manager.addSystem(ParticleEmittingSystem.system_id,"Particle Emitting System"); launcher.gui_manager.addSystem(becsID!ParticleEmittingSystem,"Particle Emitting System");
launcher.gui_manager.addSystem(RotateToTargetSystem.system_id,"Rotate To Target System"); launcher.gui_manager.addSystem(becsID!RotateToTargetSystem,"Rotate To Target System");
launcher.gui_manager.addSystem(ShipTargetSystem.system_id,"Ship Target System"); launcher.gui_manager.addSystem(becsID!ShipTargetSystem,"Ship Target System");
launcher.gui_manager.addSystem(PartsDestroySystem.system_id,"Parts Destroy System"); launcher.gui_manager.addSystem(becsID!PartsDestroySystem,"Parts Destroy System");
launcher.gui_manager.addSystem(ChildDestroySystem.system_id,"Child Destroy System"); launcher.gui_manager.addSystem(becsID!ChildDestroySystem,"Child Destroy System");
launcher.gui_manager.addSystem(ShootWaveSystem.system_id,"Shoot Wave System"); launcher.gui_manager.addSystem(becsID!ShootWaveSystem,"Shoot Wave System");
//launcher.gui_manager.addSystem(SpawnUponDeathSystem.system_id,"Child Destroy System"); //launcher.gui_manager.addSystem(becsID!SpawnUponDeathSystem,"Child Destroy System");
//launcher.manager.getSystem(CleanSystem.system_id).disable(); //launcher.manager.getSystem(becsID!CleanSystem).disable();
{ {
space_invaders.ship_tmpl = launcher.manager.allocateTemplate( space_invaders.ship_tmpl = launcher.manager.allocateTemplate(
[CVelocity.component_id, CColor.component_id, CHitMark.component_id, CHitPoints.component_id, [becsID!CVelocity, becsID!CColor, becsID!CHitMark, becsID!CHitPoints,
CLocation.component_id, CTexCoords.component_id, CInput.component_id, becsID!CLocation, becsID!CTexCoords, becsID!CInput,
CShip.component_id, CScale.component_id, CColliderScale.component_id, becsID!CShip, becsID!CScale, becsID!CColliderScale,
CShootDirection.component_id, CShootGrid.component_id, CGuild.component_id, becsID!CShootDirection, becsID!CShootGrid, becsID!CGuild,
CDamping.component_id, CChildren.component_id, CInit.component_id, becsID!CDamping, becsID!CChildren, becsID!CInit,
CShootGridMask.component_id, CVelocityFactor.component_id].staticArray becsID!CShootGridMask, becsID!CVelocityFactor].staticArray
); );
space_invaders.ship_tmpl.getComponent!CTexCoords().value = vec4(0,80,48,32)*px; space_invaders.ship_tmpl.getComponent!CTexCoords().value = vec4(0,80,48,32)*px;
space_invaders.ship_tmpl.getComponent!CScale().value = vec2(48,32); space_invaders.ship_tmpl.getComponent!CScale().value = vec2(48,32);
@ -2235,7 +2235,7 @@ void spaceInvadersStart()
} }
{ {
ushort[6] components = [CLocation.component_id, CTexCoords.component_id, CVelocity.component_id, CScale.component_id, CBullet.component_id, CGuild.component_id]; ushort[6] components = [becsID!CLocation, becsID!CTexCoords, becsID!CVelocity, becsID!CScale, becsID!CBullet, becsID!CGuild];
space_invaders.laser_tmpl = launcher.manager.allocateTemplate(components); space_invaders.laser_tmpl = launcher.manager.allocateTemplate(components);
space_invaders.laser_tmpl.getComponent!CTexCoords().value = vec4(0,24,2,8)*px; space_invaders.laser_tmpl.getComponent!CTexCoords().value = vec4(0,24,2,8)*px;
@ -2253,11 +2253,11 @@ void spaceInvadersStart()
{ {
boss_tmpl = launcher.manager.allocateTemplate( boss_tmpl = launcher.manager.allocateTemplate(
[CColor.component_id, CHitMark.component_id, CParts.component_id, CLocation.component_id, [becsID!CColor, becsID!CHitMark, becsID!CParts, becsID!CLocation,
CTexCoords.component_id, CScale.component_id, CEnemy.component_id, becsID!CTexCoords, becsID!CScale, becsID!CEnemy,
CBoss.component_id, CGuild.component_id, CInit.component_id, becsID!CBoss, becsID!CGuild, becsID!CInit,
CChildren.component_id, CSideMove.component_id, CVelocity.component_id, becsID!CChildren, becsID!CSideMove, becsID!CVelocity,
CDepth.component_id].staticArray becsID!CDepth].staticArray
); );
//CTexture* tex_comp = boss_tmpl.getComponent!CTexture; //CTexture* tex_comp = boss_tmpl.getComponent!CTexture;
@ -2276,10 +2276,10 @@ void spaceInvadersStart()
{ {
tower_tmpl = launcher.manager.allocateTemplate( tower_tmpl = launcher.manager.allocateTemplate(
[CColor.component_id, CHitMark.component_id, CHitPoints.component_id, CLocation.component_id, [becsID!CColor, becsID!CHitMark, becsID!CHitPoints, becsID!CLocation,
CTexCoords.component_id, CScale.component_id, CEnemy.component_id, becsID!CTexCoords, becsID!CScale, becsID!CEnemy,
CShootGrid.component_id, CGuild.component_id, CInit.component_id, becsID!CShootGrid, becsID!CGuild, becsID!CInit,
CChildren.component_id, CShootGridMask.component_id].staticArray becsID!CChildren, becsID!CShootGridMask].staticArray
); );
tower_tmpl.getComponent!CTexCoords().value = vec4(96,96,16,16)*px; tower_tmpl.getComponent!CTexCoords().value = vec4(96,96,16,16)*px;
@ -2290,11 +2290,11 @@ void spaceInvadersStart()
{ {
space_invaders.enemy_tmpl = launcher.manager.allocateTemplate( space_invaders.enemy_tmpl = launcher.manager.allocateTemplate(
[CWeaponLocation.component_id, CColor.component_id, CHitMark.component_id, CHitPoints.component_id, [becsID!CWeaponLocation, becsID!CColor, becsID!CHitMark, becsID!CHitPoints,
CVelocity.component_id, CAutoShoot.component_id, CLocation.component_id, becsID!CVelocity, becsID!CAutoShoot, becsID!CLocation,
CTexCoords.component_id, CScale.component_id, CWeapon.component_id, becsID!CTexCoords, becsID!CScale, becsID!CWeapon,
CEnemy.component_id, CShootDirection.component_id, CShootGrid.component_id, becsID!CEnemy, becsID!CShootDirection, becsID!CShootGrid,
CGuild.component_id, CShootGridMask.component_id].staticArray becsID!CGuild, becsID!CShootGridMask].staticArray
); );
space_invaders.enemy_tmpl.getComponent!CTexCoords().value = vec4(32,32,16,16)*px; space_invaders.enemy_tmpl.getComponent!CTexCoords().value = vec4(32,32,16,16)*px;
@ -2329,7 +2329,7 @@ void spaceInvadersStart()
EntityTemplate* upgrade_tmpl; EntityTemplate* upgrade_tmpl;
{ {
upgrade_tmpl = launcher.manager.allocateTemplate([CVelocity.component_id, CLocation.component_id, CTexCoords.component_id, CScale.component_id, CUpgrade.component_id, CAnimationLooped.component_id, CAnimation.component_id].staticArray); upgrade_tmpl = launcher.manager.allocateTemplate([becsID!CVelocity, becsID!CLocation, becsID!CTexCoords, becsID!CScale, becsID!CUpgrade, becsID!CAnimationLooped, becsID!CAnimation].staticArray);
upgrade_tmpl.getComponent!CTexCoords().value = vec4(0,32,16,16)*px; upgrade_tmpl.getComponent!CTexCoords().value = vec4(0,32,16,16)*px;
upgrade_tmpl.getComponent!CVelocity().value = vec2(0,-0.05); upgrade_tmpl.getComponent!CVelocity().value = vec2(0,-0.05);
*upgrade_tmpl.getComponent!CAnimation = CAnimation(HitPointsSystem.upgrade_laser_frames, 0, 0.75); *upgrade_tmpl.getComponent!CAnimation = CAnimation(HitPointsSystem.upgrade_laser_frames, 0, 0.75);
@ -2341,8 +2341,8 @@ void spaceInvadersStart()
grouped_tmpl = launcher.manager.allocateTemplate(grouped_id); grouped_tmpl = launcher.manager.allocateTemplate(grouped_id);
space_invaders.bullet_tmpl[0] = launcher.manager.allocateTemplate( space_invaders.bullet_tmpl[0] = launcher.manager.allocateTemplate(
[CLocation.component_id, CTexCoords.component_id, CVelocity.component_id, [becsID!CLocation, becsID!CTexCoords, becsID!CVelocity,
CScale.component_id, CBullet.component_id, CGuild.component_id].staticArray becsID!CScale, becsID!CBullet, becsID!CGuild].staticArray
); );
space_invaders.bullet_tmpl[0].getComponent!CTexCoords().value = vec4(0,24,2,8)*px; space_invaders.bullet_tmpl[0].getComponent!CTexCoords().value = vec4(0,24,2,8)*px;
space_invaders.bullet_tmpl[0].getComponent!CScale().value = vec2(2,8); space_invaders.bullet_tmpl[0].getComponent!CScale().value = vec2(2,8);
@ -2372,12 +2372,12 @@ void spaceInvadersStart()
void spaceInvadersEnd() void spaceInvadersEnd()
{ {
/*launcher.manager.getSystem(DrawSystem.system_id).disable(); /*launcher.manager.getSystem(becsID!DrawSystem).disable();
launcher.manager.getSystem(InputMovementSystem.system_id).disable(); launcher.manager.getSystem(becsID!InputMovementSystem).disable();
launcher.manager.getSystem(ShootingSystem.system_id).disable(); launcher.manager.getSystem(becsID!ShootingSystem).disable();
launcher.manager.getSystem(MovementSystem.system_id).disable(); launcher.manager.getSystem(becsID!MovementSystem).disable();
launcher.manager.getSystem(ClampPositionSystem.system_id).disable(); launcher.manager.getSystem(becsID!ClampPositionSystem).disable();
launcher.manager.getSystem(ShootGridCleaner.system_id).disable();*/ launcher.manager.getSystem(becsID!ShootGridCleaner).disable();*/
//launcher.manager.freeTemplate(space_invaders.enemy_tmpl); //launcher.manager.freeTemplate(space_invaders.enemy_tmpl);
Mallocator.dispose(space_invaders); Mallocator.dispose(space_invaders);
@ -2401,13 +2401,13 @@ bool spaceInvadersLoop()
{ {
if(igCheckbox("Move system",&simple.move_system)) if(igCheckbox("Move system",&simple.move_system))
{ {
if(simple.move_system)launcher.manager.getSystem(MoveSystem.system_id).enable(); if(simple.move_system)launcher.manager.getSystem(becsID!MoveSystem).enable();
else launcher.manager.getSystem(MoveSystem.system_id).disable(); else launcher.manager.getSystem(becsID!MoveSystem).disable();
} }
if(igCheckbox("Draw system",&simple.draw_system)) if(igCheckbox("Draw system",&simple.draw_system))
{ {
if(simple.draw_system)launcher.manager.getSystem(DrawSystem.system_id).enable(); if(simple.draw_system)launcher.manager.getSystem(becsID!DrawSystem).enable();
else launcher.manager.getSystem(DrawSystem.system_id).disable(); else launcher.manager.getSystem(becsID!DrawSystem).disable();
} }
igPushButtonRepeat(true); igPushButtonRepeat(true);
igColumns(3,null,0); igColumns(3,null,0);
@ -2429,11 +2429,11 @@ bool spaceInvadersLoop()
igColumns(1,null,0); igColumns(1,null,0);
if(igButton("Clear",ImVec2(-1,0))) if(igButton("Clear",ImVec2(-1,0)))
{ {
launcher.manager.getSystem(CleanSystem.system_id).enable(); launcher.manager.getSystem(becsID!CleanSystem).enable();
launcher.manager.begin(); launcher.manager.begin();
launcher.manager.update(); launcher.manager.update();
launcher.manager.end(); launcher.manager.end();
launcher.manager.getSystem(CleanSystem.system_id).disable(); launcher.manager.getSystem(becsID!CleanSystem).disable();
} }
} }
igEnd(); igEnd();

View file

@ -119,26 +119,25 @@ struct GUIManager
// void addComponent(ComponentRef comp, const (char)* name) // void addComponent(ComponentRef comp, const (char)* name)
// { // {
// uint size = EntityManager.instance.components[comp.component_id].size; // uint size = EntityManager.instance.components[becsID(comp)].size;
// void* data = malloc(size); // void* data = malloc(size);
// memcpy(data, comp.ptr, size); // memcpy(data, comp.ptr, size);
// components.add(ComponentGUI(name, data, comp.component_id)); // components.add(ComponentGUI(name, data, becsID(comp)));
// } // }
void addComponent(T)(T comp, const (char)* name) void addComponent(T)(T comp, const (char)* name)
{ {
static assert(hasStaticMember!(T,"component_id")); uint size = EntityManager.instance.components[becsID(comp)].size;
uint size = EntityManager.instance.components[comp.component_id].size;
void* data = malloc(size); void* data = malloc(size);
memcpy(data, &comp, size); memcpy(data, &comp, size);
components.add(ComponentGUI(name, data, comp.component_id)); components.add(ComponentGUI(name, data, becsID(comp)));
if(edit_components.length <= comp.component_id) if(edit_components.length <= becsID(comp))
{ {
edit_components.length = comp.component_id+1;//.extend(comp.component_id + 1); edit_components.length = becsID(comp)+1;//.extend(becsID(comp) + 1);
} }
//edit_components[comp.component_id] = ComponentEditGUI(name); //edit_components[becsID(comp)] = ComponentEditGUI(name);
if(edit_components[comp.component_id].variables)return; if(edit_components[becsID(comp)].variables)return;
ComponentEditGUI comp_edit; ComponentEditGUI comp_edit;
comp_edit.name = T.stringof; comp_edit.name = T.stringof;
//enum fields = __traits(allMembers, T); //enum fields = __traits(allMembers, T);
@ -246,7 +245,7 @@ struct GUIManager
} }
} }
} }
edit_components[comp.component_id] = comp_edit; edit_components[becsID(comp)] = comp_edit;
} }
void gui() void gui()

View file

@ -1,6 +1,6 @@
/************************************************************************************************************************ /************************************************************************************************************************
This module contain main templates for user. This module contain main helper templates for user.
There are three structure templates (mixins) which should be added on top of structure: There are three structure templates (mixins) which can be added on top of structure:
$(LIST $(LIST
* System: make system structure * System: make system structure
* Component: make component structure * Component: make component structure
@ -46,6 +46,26 @@ Struct System1
} }
--- ---
Templates ReadOnlyDependencies nad WritableDependencies are used to create list of dependencies for System.
Writable dependencies are bloking parallel execution of system which has same dependency (as writable or readonly).
This dependencies works same as Component dependencies but can be used for creating external dependencies (e.g. dependency on spatial partitioning tree access).
---
enum ExternalDependency1 = "ExternalDependency1";
Struct System1
{
mixin!ECS.System;
struct EntitiesData
{
... //used components
}
ReadOnlyDependencies!(ExternalDependency1);
}
---
Copyright: Copyright © 2018-2019, Dawid Masiukiewicz, Michał Masiukiewicz Copyright: Copyright © 2018-2019, Dawid Masiukiewicz, Michał Masiukiewicz
License: BSD 3-clause, see LICENSE file in project root folder. License: BSD 3-clause, see LICENSE file in project root folder.
*/ */
@ -53,7 +73,7 @@ module bubel.ecs.core;
public import bubel.ecs.manager; public import bubel.ecs.manager;
public import bubel.ecs.entity; public import bubel.ecs.entity;
public import bubel.ecs.traits : ecsID; public import bubel.ecs.traits : becsID;
/************************************************************************************************************************ /************************************************************************************************************************
Main struct used as namespace for templates. Main struct used as namespace for templates.
@ -65,30 +85,27 @@ static struct ECS
*/ */
mixin template System(uint jobs_count = 32) mixin template System(uint jobs_count = 32)
{ {
// __gshared ushort system_id = ushort.max; __gshared uint __becs_jobs_count = jobs_count;
__gshared uint __ecs_jobs_count = jobs_count;
} }
/************************************************************************************************************************ /************************************************************************************************************************
Mark structure as Component. Should be added on top of structure (before any data). Mark structure as Component
*/ */
mixin template Component() mixin template Component()
{ {
//__gshared ushort component_id = ushort.max;
ComponentRef ref_() @nogc nothrow return ComponentRef ref_() @nogc nothrow return
{ {
return ComponentRef(&this, ecsID!(typeof(this))); return ComponentRef(&this, becsID!(typeof(this)));
} }
} }
/************************************************************************************************************************ /************************************************************************************************************************
Mark structure as Event. Should be added on top of structure (before any data). Mark structure as Event
*/ */
// mixin template Event() mixin template Event()
// { {
// __gshared ushort event_id = ushort.max;
// } }
/************************************************************************************************************************ /************************************************************************************************************************
Make list of excluded components. This template get structure types as argument. Should be added inside System structure. Make list of excluded components. This template get structure types as argument. Should be added inside System structure.

View file

@ -8,7 +8,7 @@ module bubel.ecs.entity;
import bubel.ecs.system; import bubel.ecs.system;
import bubel.ecs.manager; import bubel.ecs.manager;
import bubel.ecs.traits : ecsID; public import bubel.ecs.traits : becsID;
/************************************************************************************************************************ /************************************************************************************************************************
Entity ID structure. Used as reference to Entity. Pointer to entity should be ever used to store entity reference! Entity ID structure. Used as reference to Entity. Pointer to entity should be ever used to store entity reference!
@ -41,7 +41,7 @@ struct Entity
return null; return null;
return cast(T*)(cast(void*)block + info.deltas[T.component_id] + block.entityIndex(&this) * T.sizeof);*/ return cast(T*)(cast(void*)block + info.deltas[T.component_id] + block.entityIndex(&this) * T.sizeof);*/
return cast(T*)getComponent(ecsID!T); return cast(T*)getComponent(becsID!T);
} }
void* getComponent(ushort component_id) const void* getComponent(ushort component_id) const
@ -82,7 +82,7 @@ struct EntityMeta
if (T.component_id >= info.deltas.length || info.deltas[T.component_id] == 0) if (T.component_id >= info.deltas.length || info.deltas[T.component_id] == 0)
return null; return null;
return cast(T*)(cast(void*)block + info.deltas[T.component_id] + index * T.sizeof);*/ return cast(T*)(cast(void*)block + info.deltas[T.component_id] + index * T.sizeof);*/
return cast(T*)getComponent(ecsID!T); return cast(T*)getComponent(becsID!T);
} }
void* getComponent(ushort component_id) const void* getComponent(ushort component_id) const
@ -126,8 +126,8 @@ export struct EntityTemplate
*/ */
T* getComponent(T)() nothrow @nogc T* getComponent(T)() nothrow @nogc
{ {
if(ecsID!T >= info.tmpl_deltas.length || info.tmpl_deltas[ecsID!T] == ushort.max)return null; if(becsID!T >= info.tmpl_deltas.length || info.tmpl_deltas[becsID!T] == ushort.max)return null;
return cast(T*)(entity_data.ptr + info.tmpl_deltas[ecsID!T]); return cast(T*)(entity_data.ptr + info.tmpl_deltas[becsID!T]);
} }
} }

View file

@ -4,7 +4,7 @@ import bubel.ecs.block_allocator;
import bubel.ecs.entity; import bubel.ecs.entity;
import bubel.ecs.manager; import bubel.ecs.manager;
import bubel.ecs.std; import bubel.ecs.std;
import bubel.ecs.traits : ecsID; import bubel.ecs.traits : becsID;
import std.algorithm.comparison : max; import std.algorithm.comparison : max;
@ -33,7 +33,7 @@ package struct EventManager
{ {
uint block_id = current_index + thread_id; uint block_id = current_index + thread_id;
EventData* data = &events[ecsID!Ev]; EventData* data = &events[becsID!Ev];
EventBlock* block = data.blocks[block_id]; EventBlock* block = data.blocks[block_id];
//EntityManager.EventInfo* info = &manager.events[Ev.event_id]; //EntityManager.EventInfo* info = &manager.events[Ev.event_id];
//event.entity_id = id; //event.entity_id = id;

View file

@ -408,7 +408,7 @@ export struct EntityManager
~ "\" due to non existing event \"" ~ EventName ~ "\"."); ~ "\" due to non existing event \"" ~ EventName ~ "\".");
callers[i].callback = cast(void*)&callEventHandler!(EventParamType); callers[i].callback = cast(void*)&callEventHandler!(EventParamType);
callers[i].id = ecsID!EventParamType; callers[i].id = becsID!EventParamType;
i++; i++;
} }
} }
@ -1125,7 +1125,7 @@ export struct EntityManager
system.m_priority = priority; system.m_priority = priority;
//(cast(Sys*) system.m_system_pointer).__ecsInitialize(); //(cast(Sys*) system.m_system_pointer).__ecsInitialize();
//system.jobs = (cast(Sys*) system.m_system_pointer)._ecs_jobs; //system.jobs = (cast(Sys*) system.m_system_pointer)._ecs_jobs;
static if(__traits(hasMember, Sys ,"__ecs_jobs_count"))system.jobs = Mallocator.makeArray!(Job)(Sys.__ecs_jobs_count); static if(__traits(hasMember, Sys ,"__becs_jobs_count"))system.jobs = Mallocator.makeArray!(Job)(Sys.__becs_jobs_count);
else system.jobs = Mallocator.makeArray!(Job)(32); else system.jobs = Mallocator.makeArray!(Job)(32);
static if (OnUpdateOverloadNum != -1) static if (OnUpdateOverloadNum != -1)
@ -1194,7 +1194,7 @@ export struct EntityManager
systems[$ - 1].enable(); systems[$ - 1].enable();
} }
ecsID!Sys = system.id; becsID!Sys = system.id;
} }
/************************************************************************************************************************ /************************************************************************************************************************
@ -1212,9 +1212,9 @@ export struct EntityManager
*/ */
Sys* getSystem(Sys)() nothrow @nogc Sys* getSystem(Sys)() nothrow @nogc
{ {
if (ecsID!Sys >= systems.length) if (becsID!Sys >= systems.length)
return null; return null;
return cast(Sys*) systems[ecsID!Sys].m_system_pointer; return cast(Sys*) systems[becsID!Sys].m_system_pointer;
} }
export ushort registerPass(const(char)[] name) export ushort registerPass(const(char)[] name)
@ -1283,7 +1283,7 @@ export struct EntityManager
ushort comp_id = components_map.get(cast(char[]) ComponentName, ushort.max); ushort comp_id = components_map.get(cast(char[]) ComponentName, ushort.max);
if (comp_id < components.length) if (comp_id < components.length)
{ {
ecsID!Comp = comp_id; becsID!Comp = comp_id;
if (components[comp_id].init_data) if (components[comp_id].init_data)
Mallocator.dispose(components[comp_id].init_data); Mallocator.dispose(components[comp_id].init_data);
components[comp_id] = info; components[comp_id] = info;
@ -1291,7 +1291,7 @@ export struct EntityManager
else else
{ {
components.add(info); components.add(info);
ecsID!Comp = cast(ushort)(components.length - 1); becsID!Comp = cast(ushort)(components.length - 1);
char[] name = Mallocator.makeArray(cast(char[]) ComponentName); char[] name = Mallocator.makeArray(cast(char[]) ComponentName);
components_map.add(name, cast(ushort)(components.length - 1)); components_map.add(name, cast(ushort)(components.length - 1));
} }
@ -1324,12 +1324,12 @@ export struct EntityManager
ushort event_id = events_map.get(fullName!Ev, ushort.max); ushort event_id = events_map.get(fullName!Ev, ushort.max);
if (event_id < events.length) if (event_id < events.length)
{ {
ecsID!Ev = event_id; becsID!Ev = event_id;
} }
else else
{ {
events.add(info); events.add(info);
ecsID!Ev = cast(ushort)(events.length - 1); becsID!Ev = cast(ushort)(events.length - 1);
// events_map.add(Ev.stringof, cast(ushort)(events.length - 1)); // events_map.add(Ev.stringof, cast(ushort)(events.length - 1));
events_map.add(fullName!Ev, cast(ushort)(events.length - 1)); events_map.add(fullName!Ev, cast(ushort)(events.length - 1));
} }
@ -1350,7 +1350,7 @@ export struct EntityManager
// "Function must match system update function."); FIXME: It's lead to crash on android build // "Function must match system update function."); FIXME: It's lead to crash on android build
// static assert(__traits(hasMember, Sys, "system_id"), "Sys must be system type."); // static assert(__traits(hasMember, Sys, "system_id"), "Sys must be system type.");
System* system = getSystem(ecsID!Sys); System* system = getSystem(becsID!Sys);
assert(system != null, assert(system != null,
"System must be registered in EntityManager before any funcion can be called."); "System must be registered in EntityManager before any funcion can be called.");
if (!system.m_any_system_caller) if (!system.m_any_system_caller)
@ -2256,7 +2256,7 @@ export struct EntityManager
ushort[num] del_ids; ushort[num] del_ids;
static foreach (i, comp; Components) static foreach (i, comp; Components)
{ {
del_ids[i] = ecsID!comp; del_ids[i] = becsID!comp;
} }
removeComponents(entity_id, del_ids); removeComponents(entity_id, del_ids);

View file

@ -2,16 +2,22 @@ module bubel.ecs.traits;
import std.traits; import std.traits;
ref ushort ecsID(T)() /************************************************************************************************************************
Return Component/System/Event unique ID
*/
ref ushort becsID(T)()
{ {
__gshared ushort id = ushort.max; __gshared ushort id = ushort.max;
return id; return id;
} }
ref ushort ecsID(T)(T obj) /************************************************************************************************************************
Return Component/System/Event unique ID
*/
ref ushort becsID(T)(T obj)
{ {
static if(isPointer!T)return ecsID!(PointerTarget!T); static if(isPointer!T)return becsID!(PointerTarget!T);
else return ecsID!T; else return becsID!T;
} }
bool isForeachDelegateWithTypes(DG, Types...)() bool isForeachDelegateWithTypes(DG, Types...)()

View file

@ -65,7 +65,7 @@ void beforeEveryTest()
gEM.endRegister(); gEM.endRegister();
tmpl = gEM.allocateTemplate([ecsID!CLong, ecsID!CInt, ecsID!CUInt, ecsID!CBig].staticArray); tmpl = gEM.allocateTemplate([becsID!CLong, becsID!CInt, becsID!CUInt, becsID!CBig].staticArray);
foreach(i; 0 .. 100_000)gEM.addEntity(tmpl); foreach(i; 0 .. 100_000)gEM.addEntity(tmpl);
} }

View file

@ -115,7 +115,7 @@ struct EmptySystem
void beforeEveryTest() void beforeEveryTest()
{ {
ecsID!CUnregistered = ushort.max; becsID!CUnregistered = ushort.max;
gEM.initialize(0); gEM.initialize(0);
gEM.beginRegister(); gEM.beginRegister();
@ -138,17 +138,17 @@ void afterEveryTest()
@("EntityMeta") @("EntityMeta")
unittest unittest
{ {
EntityTemplate* tmpl_ = gEM.allocateTemplate([ecsID!CInt, ecsID!CFloat, ecsID!CFlag].staticArray); EntityTemplate* tmpl_ = gEM.allocateTemplate([becsID!CInt, becsID!CFloat, becsID!CFlag].staticArray);
Entity* entity = gEM.addEntity(tmpl_); Entity* entity = gEM.addEntity(tmpl_);
EntityMeta meta = entity.getMeta(); EntityMeta meta = entity.getMeta();
assert(meta.hasComponent(ecsID!CInt)); assert(meta.hasComponent(becsID!CInt));
assert(meta.getComponent!CInt); assert(meta.getComponent!CInt);
assert(meta.hasComponent(ecsID!CFloat)); assert(meta.hasComponent(becsID!CFloat));
assert(meta.getComponent!CFloat); assert(meta.getComponent!CFloat);
assert(!meta.getComponent!CLong); assert(!meta.getComponent!CLong);
assert(!meta.hasComponent(ecsID!CLong)); assert(!meta.hasComponent(becsID!CLong));
assert(!meta.getComponent!CUnregistered); assert(!meta.getComponent!CUnregistered);
assert(!meta.hasComponent(ecsID!CUnregistered)); assert(!meta.hasComponent(becsID!CUnregistered));
assert(*meta.getComponent!CInt == 1); assert(*meta.getComponent!CInt == 1);
assert(*meta.getComponent!CFloat == 2.0); assert(*meta.getComponent!CFloat == 2.0);
} }
@ -156,7 +156,7 @@ unittest
@("AddEntity") @("AddEntity")
unittest unittest
{ {
EntityTemplate* tmpl_ = gEM.allocateTemplate([ecsID!CInt, ecsID!CFloat, ecsID!CFlag].staticArray); EntityTemplate* tmpl_ = gEM.allocateTemplate([becsID!CInt, becsID!CFloat, becsID!CFlag].staticArray);
assert(tmpl_.info.components.length == 3); assert(tmpl_.info.components.length == 3);
assert(tmpl_.info.size == (CInt.sizeof + CFloat.sizeof + EntityID.sizeof)); assert(tmpl_.info.size == (CInt.sizeof + CFloat.sizeof + EntityID.sizeof));
assert(tmpl_.getComponent!CInt); assert(tmpl_.getComponent!CInt);
@ -185,8 +185,8 @@ unittest
//Entity* entity3 = gEM.addEntity(tmpl_, [cint.ref_, clong.ref_].staticArray); //Entity* entity3 = gEM.addEntity(tmpl_, [cint.ref_, clong.ref_].staticArray);
Entity* entity3 = gEM.addEntity(tmpl_, [CInt(10).ref_, CLong().ref_, CFlag().ref_].staticArray); Entity* entity3 = gEM.addEntity(tmpl_, [CInt(10).ref_, CLong().ref_, CFlag().ref_].staticArray);
EntityID id = entity3.id; EntityID id = entity3.id;
assert(entity3.hasComponent(ecsID!CInt)); assert(entity3.hasComponent(becsID!CInt));
assert(entity3.hasComponent(ecsID!CFloat)); assert(entity3.hasComponent(becsID!CFloat));
assert(*entity3.getComponent!CInt == 10); assert(*entity3.getComponent!CInt == 10);
assert(*entity3.getComponent!CFloat == 2.0); assert(*entity3.getComponent!CFloat == 2.0);
@ -201,7 +201,7 @@ unittest
assert(*entity3.getComponent!CFloat == 2.0); assert(*entity3.getComponent!CFloat == 2.0);
assert(*entity3.getComponent!CShort == 2); assert(*entity3.getComponent!CShort == 2);
gEM.removeComponents(entity3.id, [ecsID!CFlag,ecsID!CShort].staticArray); gEM.removeComponents(entity3.id, [becsID!CFlag,becsID!CShort].staticArray);
gEM.commit(); gEM.commit();
entity3 = gEM.getEntity(id); entity3 = gEM.getEntity(id);
assert(entity3.getComponent!CInt); assert(entity3.getComponent!CInt);
@ -212,7 +212,7 @@ unittest
assert(*entity3.getComponent!CFloat == 2.0); assert(*entity3.getComponent!CFloat == 2.0);
gEM.addComponents(entity3.id, [CFlag().ref_,CShort(2).ref_].staticArray); gEM.addComponents(entity3.id, [CFlag().ref_,CShort(2).ref_].staticArray);
gEM.removeComponents(entity3.id, [ecsID!CUnregistered].staticArray); gEM.removeComponents(entity3.id, [becsID!CUnregistered].staticArray);
gEM.commit(); gEM.commit();
entity3 = gEM.getEntity(id); entity3 = gEM.getEntity(id);
assert(entity3.getComponent!CInt); assert(entity3.getComponent!CInt);
@ -235,7 +235,7 @@ unittest
assert(entity3.getComponent!CUnregistered); assert(entity3.getComponent!CUnregistered);
assert(*entity3.getComponent!CUnregistered == 4); assert(*entity3.getComponent!CUnregistered == 4);
gEM.removeComponents(entity3.id, [ecsID!CUnregistered].staticArray); gEM.removeComponents(entity3.id, [becsID!CUnregistered].staticArray);
gEM.commit(); gEM.commit();
entity3 = gEM.getEntity(id); entity3 = gEM.getEntity(id);
assert(!entity3.getComponent!CUnregistered); assert(!entity3.getComponent!CUnregistered);
@ -247,9 +247,9 @@ unittest
unittest unittest
{ {
//basic template allocation //basic template allocation
ushort[2] ids = [ecsID!CInt, ecsID!CFloat]; ushort[2] ids = [becsID!CInt, becsID!CFloat];
EntityTemplate* tmpl_ = gEM.allocateTemplate(ids); EntityTemplate* tmpl_ = gEM.allocateTemplate(ids);
EntityTemplate* tmpl_d = gEM.allocateTemplate([ecsID!CFloat, ecsID!CInt, ecsID!CFloat].staticArray); EntityTemplate* tmpl_d = gEM.allocateTemplate([becsID!CFloat, becsID!CInt, becsID!CFloat].staticArray);
EntityTemplate* tmpl_cp = gEM.allocateTemplate(tmpl_); EntityTemplate* tmpl_cp = gEM.allocateTemplate(tmpl_);
assert(tmpl_d.info == tmpl_.info); assert(tmpl_d.info == tmpl_.info);
assert(tmpl_cp.info == tmpl_cp.info); assert(tmpl_cp.info == tmpl_cp.info);
@ -268,7 +268,7 @@ unittest
*tmpl_.getComponent!CFloat = 5.0; *tmpl_.getComponent!CFloat = 5.0;
//allocate template from template with additional components //allocate template from template with additional components
ushort[2] ids2 = [ecsID!CDouble,ecsID!CFlag]; ushort[2] ids2 = [becsID!CDouble,becsID!CFlag];
EntityTemplate* tmpl_2 = gEM.allocateTemplate(tmpl_, ids2); EntityTemplate* tmpl_2 = gEM.allocateTemplate(tmpl_, ids2);
assert(tmpl_2.info.components.length == 4); assert(tmpl_2.info.components.length == 4);
assert(tmpl_2.getComponent!CInt); assert(tmpl_2.getComponent!CInt);
@ -313,7 +313,7 @@ unittest
assert(*tmpl_4.getComponent!CDouble == 3.0); assert(*tmpl_4.getComponent!CDouble == 3.0);
//allocate template from template with three additional component //allocate template from template with three additional component
ushort[3] ids3 = [ecsID!CDouble, ecsID!CLong, ecsID!CShort]; ushort[3] ids3 = [becsID!CDouble, becsID!CLong, becsID!CShort];
EntityTemplate* tmpl_5 = gEM.allocateTemplate(tmpl_2, ids3); EntityTemplate* tmpl_5 = gEM.allocateTemplate(tmpl_2, ids3);
assert(tmpl_5.info.components.length == 6); assert(tmpl_5.info.components.length == 6);
assert(tmpl_5.getComponent!CInt); assert(tmpl_5.getComponent!CInt);
@ -328,7 +328,7 @@ unittest
assert(*tmpl_5.getComponent!CShort == 12); assert(*tmpl_5.getComponent!CShort == 12);
//allocate template from template without one component //allocate template from template without one component
ushort[1] rem_ids = [ecsID!CFloat]; ushort[1] rem_ids = [becsID!CFloat];
EntityTemplate* tmpl_6 = gEM.allocateTemplate(tmpl_, null, rem_ids); EntityTemplate* tmpl_6 = gEM.allocateTemplate(tmpl_, null, rem_ids);
assert(tmpl_6.info.components.length == 1); assert(tmpl_6.info.components.length == 1);
assert(tmpl_6.getComponent!CInt); assert(tmpl_6.getComponent!CInt);
@ -358,8 +358,8 @@ unittest
unittest unittest
{ {
//basic template allocation //basic template allocation
ushort[2] ids = [ecsID!CFloat, ecsID!CInt]; ushort[2] ids = [becsID!CFloat, becsID!CInt];
ushort[2] ids2 = [ecsID!CInt, ecsID!CFloat]; ushort[2] ids2 = [becsID!CInt, becsID!CFloat];
EntityTemplate* tmpl_ = gEM.allocateTemplate(ids); EntityTemplate* tmpl_ = gEM.allocateTemplate(ids);
EntityTemplate* tmpl_2 = gEM.allocateTemplate(ids2); EntityTemplate* tmpl_2 = gEM.allocateTemplate(ids2);
assert(tmpl_.info.components.length == 2); assert(tmpl_.info.components.length == 2);
@ -398,9 +398,9 @@ unittest
assert(system !is null); assert(system !is null);
assert(system.count == 0); assert(system.count == 0);
System* ecs_system = gEM.getSystem(ecsID!EmptySystem); System* ecs_system = gEM.getSystem(becsID!EmptySystem);
assert(ecs_system !is null); assert(ecs_system !is null);
assert(ecs_system.id == ecsID!EmptySystem); assert(ecs_system.id == becsID!EmptySystem);
assert(ecs_system.name == "tests.basic.EmptySystem"); assert(ecs_system.name == "tests.basic.EmptySystem");
gEM.begin(); gEM.begin();
@ -502,7 +502,7 @@ unittest
//FIXME: currently destroy is only called with Manager.destory which is bug, but there is no workaround for this by now //FIXME: currently destroy is only called with Manager.destory which is bug, but there is no workaround for this by now
//assert(destroy == 1); //assert(destroy == 1);
System* ecs_system = gEM.getSystem(system.ecsID); System* ecs_system = gEM.getSystem(system.becsID);
ecs_system.enable(); ecs_system.enable();
assert(system.enable == 1); assert(system.enable == 1);
@ -513,7 +513,7 @@ unittest
assert(system.disable == 1); assert(system.disable == 1);
ushort[2] ids = [ecsID!CLong,ecsID!CFloat]; ushort[2] ids = [becsID!CLong,becsID!CFloat];
EntityTemplate* tmpl = gEM.allocateTemplate(ids); EntityTemplate* tmpl = gEM.allocateTemplate(ids);
scope (exit) gEM.freeTemplate(tmpl); scope (exit) gEM.freeTemplate(tmpl);
gEM.addEntity(tmpl); gEM.addEntity(tmpl);
@ -527,7 +527,7 @@ unittest
gEM.end(); gEM.end();
assert(system.end == 1); assert(system.end == 1);
ushort[2] ids2 = [ecsID!CLong, ecsID!CInt]; ushort[2] ids2 = [becsID!CLong, becsID!CInt];
EntityTemplate* tmpl2 = gEM.allocateTemplate(ids2); EntityTemplate* tmpl2 = gEM.allocateTemplate(ids2);
scope (exit) gEM.freeTemplate(tmpl2); scope (exit) gEM.freeTemplate(tmpl2);
gEM.addEntity(tmpl2); gEM.addEntity(tmpl2);
@ -542,7 +542,7 @@ unittest
gEM.end(); gEM.end();
assert(system.end == 2); assert(system.end == 2);
ushort[2] ids3 = [ecsID!CLong, ecsID!CShort]; ushort[2] ids3 = [becsID!CLong, becsID!CShort];
EntityTemplate* tmpl3 = gEM.allocateTemplate(ids3); EntityTemplate* tmpl3 = gEM.allocateTemplate(ids3);
scope (exit) gEM.freeTemplate(tmpl3); scope (exit) gEM.freeTemplate(tmpl3);
gEM.addEntity(tmpl3); gEM.addEntity(tmpl3);
@ -601,13 +601,13 @@ unittest
assert(system !is null); assert(system !is null);
assert(system.updates_count == 0); assert(system.updates_count == 0);
System* ecs_system = gEM.getSystem(ecsID!LongAddSystem); System* ecs_system = gEM.getSystem(becsID!LongAddSystem);
assert(ecs_system !is null); assert(ecs_system !is null);
assert(ecs_system.id == ecsID!LongAddSystem); assert(ecs_system.id == becsID!LongAddSystem);
assert(ecs_system.priority == -1); assert(ecs_system.priority == -1);
assert(ecs_system.name == "tests.basic.LongAddSystem"); assert(ecs_system.name == "tests.basic.LongAddSystem");
ushort[1] ids = [ecsID!CLong]; ushort[1] ids = [becsID!CLong];
EntityTemplate* tmpl = gEM.allocateTemplate(ids); EntityTemplate* tmpl = gEM.allocateTemplate(ids);
scope (exit) gEM.freeTemplate(tmpl); scope (exit) gEM.freeTemplate(tmpl);
gEM.addEntity(tmpl); gEM.addEntity(tmpl);
@ -757,19 +757,19 @@ unittest
assert(system.remove == 0); assert(system.remove == 0);
assert(system.change == 0); assert(system.change == 0);
EntityTemplate* tmpl = gEM.allocateTemplate([ecsID!CLong,ecsID!CFloat].staticArray); EntityTemplate* tmpl = gEM.allocateTemplate([becsID!CLong,becsID!CFloat].staticArray);
scope (exit) gEM.freeTemplate(tmpl); scope (exit) gEM.freeTemplate(tmpl);
EntityID id0 = gEM.addEntity(tmpl).id; EntityID id0 = gEM.addEntity(tmpl).id;
gEM.commit(); gEM.commit();
assert(system.add == 1); assert(system.add == 1);
EntityTemplate* tmpl2 = gEM.allocateTemplate([ecsID!CLong, ecsID!CInt].staticArray); EntityTemplate* tmpl2 = gEM.allocateTemplate([becsID!CLong, becsID!CInt].staticArray);
scope (exit) gEM.freeTemplate(tmpl2); scope (exit) gEM.freeTemplate(tmpl2);
EntityID id1 = gEM.addEntity(tmpl2).id; EntityID id1 = gEM.addEntity(tmpl2).id;
gEM.commit(); gEM.commit();
assert(system.add == 2); assert(system.add == 2);
EntityTemplate* tmpl3 = gEM.allocateTemplate([ecsID!CLong, ecsID!CShort].staticArray); EntityTemplate* tmpl3 = gEM.allocateTemplate([becsID!CLong, becsID!CShort].staticArray);
scope (exit) gEM.freeTemplate(tmpl3); scope (exit) gEM.freeTemplate(tmpl3);
EntityID id2 = gEM.addEntity(tmpl3).id; EntityID id2 = gEM.addEntity(tmpl3).id;
gEM.commit(); gEM.commit();
@ -778,19 +778,19 @@ unittest
gEM.beginRegister(); gEM.beginRegister();
gEM.endRegister(); gEM.endRegister();
gEM.removeComponents(id0, [ecsID!CFloat].staticArray); gEM.removeComponents(id0, [becsID!CFloat].staticArray);
gEM.commit(); gEM.commit();
assert(system.add == 2); assert(system.add == 2);
assert(system.remove == 0); assert(system.remove == 0);
assert(system.change == 0); assert(system.change == 0);
gEM.removeComponents(id1, [ecsID!CInt].staticArray); gEM.removeComponents(id1, [becsID!CInt].staticArray);
gEM.commit(); gEM.commit();
assert(system.add == 2); assert(system.add == 2);
assert(system.remove == 0); assert(system.remove == 0);
assert(system.change == 1); assert(system.change == 1);
gEM.removeComponents(id2, [ecsID!CShort].staticArray); gEM.removeComponents(id2, [becsID!CShort].staticArray);
gEM.commit(); gEM.commit();
assert(system.add == 3); assert(system.add == 3);
assert(system.remove == 0); assert(system.remove == 0);
@ -889,7 +889,7 @@ unittest
} }
assert(gEM.getSystem!TestSystem is null); assert(gEM.getSystem!TestSystem is null);
assert(gEM.getSystem(ecsID!TestSystem) is null); assert(gEM.getSystem(becsID!TestSystem) is null);
} }
@("MultithreadedUpdate") @("MultithreadedUpdate")
@ -961,10 +961,10 @@ unittest
TestSystem* system = gEM.getSystem!TestSystem; TestSystem* system = gEM.getSystem!TestSystem;
TestEmptySystem* empty_system = gEM.getSystem!TestEmptySystem; TestEmptySystem* empty_system = gEM.getSystem!TestEmptySystem;
ushort[2] ids = [ecsID!CLong,ecsID!CFloat]; ushort[2] ids = [becsID!CLong,becsID!CFloat];
EntityTemplate* tmpl = gEM.allocateTemplate(ids); EntityTemplate* tmpl = gEM.allocateTemplate(ids);
scope (exit) gEM.freeTemplate(tmpl); scope (exit) gEM.freeTemplate(tmpl);
EntityTemplate* tmpl2 = gEM.allocateTemplate([ecsID!CLong,ecsID!CInt,ecsID!CShort,ecsID!CFloat].staticArray); EntityTemplate* tmpl2 = gEM.allocateTemplate([becsID!CLong,becsID!CInt,becsID!CShort,becsID!CFloat].staticArray);
scope (exit) gEM.freeTemplate(tmpl2); scope (exit) gEM.freeTemplate(tmpl2);
gEM.begin(); gEM.begin();
@ -1059,7 +1059,7 @@ unittest
@("AddRemoveEntities") @("AddRemoveEntities")
unittest unittest
{ {
ushort[3] ids = [ecsID!CLong,ecsID!CFloat,ecsID!CShort]; ushort[3] ids = [becsID!CLong,becsID!CFloat,becsID!CShort];
EntityTemplate* tmpl = gEM.allocateTemplate(ids); EntityTemplate* tmpl = gEM.allocateTemplate(ids);
scope (exit) gEM.freeTemplate(tmpl); scope (exit) gEM.freeTemplate(tmpl);
@ -1089,7 +1089,7 @@ unittest
gEM.endRegister(); gEM.endRegister();
ushort[1] ids = [ecsID!CLong]; ushort[1] ids = [becsID!CLong];
EntityTemplate* tmpl = gEM.allocateTemplate(ids); EntityTemplate* tmpl = gEM.allocateTemplate(ids);
scope (exit) gEM.freeTemplate(tmpl); scope (exit) gEM.freeTemplate(tmpl);
@ -1118,7 +1118,7 @@ unittest
assert(*entity.getComponent!CShort == 15); assert(*entity.getComponent!CShort == 15);
assert(*entity.getComponent!CFloat == 13); assert(*entity.getComponent!CFloat == 13);
ushort[3] ids2 = [ecsID!CFloat, ecsID!CLong, ecsID!CUnregistered]; ushort[3] ids2 = [becsID!CFloat, becsID!CLong, becsID!CUnregistered];
gEM.removeComponents(id, ids2); gEM.removeComponents(id, ids2);
gEM.commit(); gEM.commit();
@ -1253,10 +1253,10 @@ unittest
gEM.endRegister(); gEM.endRegister();
ushort[1] ids = [ecsID!CLong]; ushort[1] ids = [becsID!CLong];
EntityTemplate* tmpl = gEM.allocateTemplate(ids); EntityTemplate* tmpl = gEM.allocateTemplate(ids);
scope (exit) gEM.freeTemplate(tmpl); scope (exit) gEM.freeTemplate(tmpl);
ushort[1] ids2 = [ecsID!CShort]; ushort[1] ids2 = [becsID!CShort];
EntityTemplate* tmpl2 = gEM.allocateTemplate(ids2); EntityTemplate* tmpl2 = gEM.allocateTemplate(ids2);
scope (exit) gEM.freeTemplate(tmpl2); scope (exit) gEM.freeTemplate(tmpl2);
@ -1348,11 +1348,11 @@ unittest
gEM.endRegister(); gEM.endRegister();
EntityTemplate* tmpl = gEM.allocateTemplate([ecsID!CInt].staticArray); EntityTemplate* tmpl = gEM.allocateTemplate([becsID!CInt].staticArray);
scope (exit) gEM.freeTemplate(tmpl); scope (exit) gEM.freeTemplate(tmpl);
EntityID id1 = gEM.addEntity(tmpl).id; EntityID id1 = gEM.addEntity(tmpl).id;
EntityTemplate* tmpl2 = gEM.allocateTemplate([ecsID!CInt, ecsID!CLong].staticArray); EntityTemplate* tmpl2 = gEM.allocateTemplate([becsID!CInt, becsID!CLong].staticArray);
scope (exit) gEM.freeTemplate(tmpl2); scope (exit) gEM.freeTemplate(tmpl2);
EntityID id2 = gEM.addEntity(tmpl2).id; EntityID id2 = gEM.addEntity(tmpl2).id;
@ -1471,22 +1471,22 @@ unittest
const (EntityManager.UpdatePass)* pass = gEM.getPass("update"); const (EntityManager.UpdatePass)* pass = gEM.getPass("update");
assert(pass != null); assert(pass != null);
assert(pass.system_callers.length == 5); assert(pass.system_callers.length == 5);
assert(pass.system_callers[0].system_id == ecsID!TestSystem); assert(pass.system_callers[0].system_id == becsID!TestSystem);
assert(pass.system_callers[1].system_id == ecsID!TestSystem2); assert(pass.system_callers[1].system_id == becsID!TestSystem2);
assert(pass.system_callers[2].system_id == ecsID!TestSystem3); assert(pass.system_callers[2].system_id == becsID!TestSystem3);
assert(pass.system_callers[3].system_id == ecsID!TestSystem4); assert(pass.system_callers[3].system_id == becsID!TestSystem4);
assert(pass.system_callers[4].system_id == ecsID!TestSystem5); assert(pass.system_callers[4].system_id == becsID!TestSystem5);
assert(pass.system_callers[0].dependencies.length == 0); assert(pass.system_callers[0].dependencies.length == 0);
assert(pass.system_callers[1].dependencies.length == 1); assert(pass.system_callers[1].dependencies.length == 1);
assert(pass.system_callers[2].dependencies.length == 1); assert(pass.system_callers[2].dependencies.length == 1);
assert(pass.system_callers[3].dependencies.length == 3); assert(pass.system_callers[3].dependencies.length == 3);
assert(pass.system_callers[4].dependencies.length == 1); assert(pass.system_callers[4].dependencies.length == 1);
assert(pass.system_callers[1].dependencies[0].system_id == ecsID!TestSystem); assert(pass.system_callers[1].dependencies[0].system_id == becsID!TestSystem);
assert(pass.system_callers[2].dependencies[0].system_id == ecsID!TestSystem2); assert(pass.system_callers[2].dependencies[0].system_id == becsID!TestSystem2);
assert(pass.system_callers[3].dependencies[0].system_id == ecsID!TestSystem); assert(pass.system_callers[3].dependencies[0].system_id == becsID!TestSystem);
assert(pass.system_callers[3].dependencies[1].system_id == ecsID!TestSystem2); assert(pass.system_callers[3].dependencies[1].system_id == becsID!TestSystem2);
assert(pass.system_callers[3].dependencies[2].system_id == ecsID!TestSystem3); assert(pass.system_callers[3].dependencies[2].system_id == becsID!TestSystem3);
assert(pass.system_callers[4].dependencies[0].system_id == ecsID!TestSystem4); assert(pass.system_callers[4].dependencies[0].system_id == becsID!TestSystem4);
} }
@("ExternalSystemDependencies") @("ExternalSystemDependencies")
@ -1598,21 +1598,21 @@ unittest
const (EntityManager.UpdatePass)* pass = gEM.getPass("update"); const (EntityManager.UpdatePass)* pass = gEM.getPass("update");
assert(pass != null); assert(pass != null);
assert(pass.system_callers.length == 5); assert(pass.system_callers.length == 5);
assert(pass.system_callers[0].system_id == ecsID!TestSystem); assert(pass.system_callers[0].system_id == becsID!TestSystem);
assert(pass.system_callers[1].system_id == ecsID!TestSystem2); assert(pass.system_callers[1].system_id == becsID!TestSystem2);
assert(pass.system_callers[2].system_id == ecsID!TestSystem3); assert(pass.system_callers[2].system_id == becsID!TestSystem3);
assert(pass.system_callers[3].system_id == ecsID!TestSystem4); assert(pass.system_callers[3].system_id == becsID!TestSystem4);
assert(pass.system_callers[4].system_id == ecsID!TestSystem5); assert(pass.system_callers[4].system_id == becsID!TestSystem5);
assert(pass.system_callers[0].dependencies.length == 0); assert(pass.system_callers[0].dependencies.length == 0);
assert(pass.system_callers[1].dependencies.length == 1); assert(pass.system_callers[1].dependencies.length == 1);
assert(pass.system_callers[2].dependencies.length == 1); assert(pass.system_callers[2].dependencies.length == 1);
assert(pass.system_callers[3].dependencies.length == 3); assert(pass.system_callers[3].dependencies.length == 3);
assert(pass.system_callers[4].dependencies.length == 2); assert(pass.system_callers[4].dependencies.length == 2);
assert(pass.system_callers[1].dependencies[0].system_id == ecsID!TestSystem); assert(pass.system_callers[1].dependencies[0].system_id == becsID!TestSystem);
assert(pass.system_callers[2].dependencies[0].system_id == ecsID!TestSystem2); assert(pass.system_callers[2].dependencies[0].system_id == becsID!TestSystem2);
assert(pass.system_callers[3].dependencies[0].system_id == ecsID!TestSystem); assert(pass.system_callers[3].dependencies[0].system_id == becsID!TestSystem);
assert(pass.system_callers[3].dependencies[1].system_id == ecsID!TestSystem2); assert(pass.system_callers[3].dependencies[1].system_id == becsID!TestSystem2);
assert(pass.system_callers[3].dependencies[2].system_id == ecsID!TestSystem3); assert(pass.system_callers[3].dependencies[2].system_id == becsID!TestSystem3);
assert(pass.system_callers[4].dependencies[0].system_id == ecsID!TestSystem2); assert(pass.system_callers[4].dependencies[0].system_id == becsID!TestSystem2);
assert(pass.system_callers[4].dependencies[1].system_id == ecsID!TestSystem4); assert(pass.system_callers[4].dependencies[1].system_id == becsID!TestSystem4);
} }

View file

@ -45,7 +45,7 @@ unittest
void onCreate() void onCreate()
{ {
tmpl = gEM.allocateTemplate([ecsID!CInt, ecsID!CLong].staticArray); tmpl = gEM.allocateTemplate([becsID!CInt, becsID!CLong].staticArray);
} }
void onDestroy() void onDestroy()
@ -118,7 +118,7 @@ unittest
gEM.endRegister(); gEM.endRegister();
EntityTemplate* tmpl = gEM.allocateTemplate([ecsID!CInt, ecsID!CLong].staticArray); EntityTemplate* tmpl = gEM.allocateTemplate([becsID!CInt, becsID!CLong].staticArray);
EntityID id = gEM.addEntity(tmpl,[CLong(10).ref_, CInt(6).ref_].staticArray).id; EntityID id = gEM.addEntity(tmpl,[CLong(10).ref_, CInt(6).ref_].staticArray).id;
EntityID id2 = gEM.addEntity(tmpl,[CInt(4).ref_].staticArray).id; EntityID id2 = gEM.addEntity(tmpl,[CInt(4).ref_].staticArray).id;
gEM.freeTemplate(tmpl); gEM.freeTemplate(tmpl);
@ -126,13 +126,13 @@ unittest
gEM.sendEvent(id2, Event1(id)); gEM.sendEvent(id2, Event1(id));
gEM.getSystem(ecsID!System2).disable(); gEM.getSystem(becsID!System2).disable();
gEM.begin(); gEM.begin();
gEM.update(); gEM.update();
gEM.end(); gEM.end();
gEM.getSystem(ecsID!System2).enable(); gEM.getSystem(becsID!System2).enable();
gEM.begin(); gEM.begin();
gEM.update(); gEM.update();

View file

@ -86,22 +86,22 @@ void afterEveryTest()
void smallTmpl() void smallTmpl()
{ {
tmpl = gEM.allocateTemplate([ecsID!CShort].staticArray); tmpl = gEM.allocateTemplate([becsID!CShort].staticArray);
} }
void bigTmpl() void bigTmpl()
{ {
tmpl = gEM.allocateTemplate([ecsID!CBig].staticArray); tmpl = gEM.allocateTemplate([becsID!CBig].staticArray);
} }
void multiSmallTmpl() void multiSmallTmpl()
{ {
tmpl = gEM.allocateTemplate([ecsID!CShort, ecsID!CLong, ecsID!CInt, ecsID!CUInt].staticArray); tmpl = gEM.allocateTemplate([becsID!CShort, becsID!CLong, becsID!CInt, becsID!CUInt].staticArray);
} }
void multiBigTmpl() void multiBigTmpl()
{ {
tmpl = gEM.allocateTemplate([ecsID!CLong, ecsID!CInt, ecsID!CUInt, ecsID!CBig].staticArray); tmpl = gEM.allocateTemplate([becsID!CLong, becsID!CInt, becsID!CUInt, becsID!CBig].staticArray);
} }
@("AddEntities100k1comp2b") @(before, &smallTmpl) @("AddEntities100k1comp2b") @(before, &smallTmpl)
@ -138,25 +138,25 @@ void allocDealloc100k()
void smallTmplPreAlloc() void smallTmplPreAlloc()
{ {
tmpl = gEM.allocateTemplate([ecsID!CShort].staticArray); tmpl = gEM.allocateTemplate([becsID!CShort].staticArray);
allocDealloc100k(); allocDealloc100k();
} }
void bigTmplPreAlloc() void bigTmplPreAlloc()
{ {
tmpl = gEM.allocateTemplate([ecsID!CBig].staticArray); tmpl = gEM.allocateTemplate([becsID!CBig].staticArray);
allocDealloc100k(); allocDealloc100k();
} }
void multiSmallTmplPreAlloc() void multiSmallTmplPreAlloc()
{ {
tmpl = gEM.allocateTemplate([ecsID!CShort, ecsID!CLong, ecsID!CInt, ecsID!CUInt].staticArray); tmpl = gEM.allocateTemplate([becsID!CShort, becsID!CLong, becsID!CInt, becsID!CUInt].staticArray);
allocDealloc100k(); allocDealloc100k();
} }
void multiBigTmplPreAlloc() void multiBigTmplPreAlloc()
{ {
tmpl = gEM.allocateTemplate([ecsID!CLong, ecsID!CInt, ecsID!CUInt, ecsID!CBig].staticArray); tmpl = gEM.allocateTemplate([becsID!CLong, becsID!CInt, becsID!CUInt, becsID!CBig].staticArray);
allocDealloc100k(); allocDealloc100k();
} }