Demos #16
17 changed files with 332 additions and 293 deletions
|
|
@ -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();
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
|
|
@ -419,12 +419,12 @@ void brickBreakerStart()
|
||||||
launcher.gui_manager.addComponent(CBVH(), "BVH");
|
launcher.gui_manager.addComponent(CBVH(), "BVH");
|
||||||
launcher.gui_manager.addComponent(CAABB(), "AABB");
|
launcher.gui_manager.addComponent(CAABB(), "AABB");
|
||||||
|
|
||||||
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");
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
|
||||||
|
|
@ -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();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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();
|
||||||
|
|
|
||||||
|
|
@ -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()
|
||||||
|
|
|
||||||
|
|
@ -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,6 +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 : becsID;
|
||||||
|
|
||||||
/************************************************************************************************************************
|
/************************************************************************************************************************
|
||||||
Main struct used as namespace for templates.
|
Main struct used as namespace for templates.
|
||||||
|
|
@ -60,33 +81,30 @@ Main struct used as namespace for templates.
|
||||||
static struct ECS
|
static struct ECS
|
||||||
{
|
{
|
||||||
/************************************************************************************************************************
|
/************************************************************************************************************************
|
||||||
Mark structure as System. Should be added on top of structure (before any data).
|
Set default system parameters (number of parallel jobs)
|
||||||
*/
|
*/
|
||||||
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;
|
||||||
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, component_id);
|
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************************************************************
|
/************************************************************************************************************************
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ module bubel.ecs.entity;
|
||||||
|
|
||||||
import bubel.ecs.system;
|
import bubel.ecs.system;
|
||||||
import bubel.ecs.manager;
|
import bubel.ecs.manager;
|
||||||
|
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!
|
||||||
|
|
@ -40,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(T.component_id);
|
return cast(T*)getComponent(becsID!T);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* getComponent(ushort component_id) const
|
void* getComponent(ushort component_id) const
|
||||||
|
|
@ -81,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(T.component_id);
|
return cast(T*)getComponent(becsID!T);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* getComponent(ushort component_id) const
|
void* getComponent(ushort component_id) const
|
||||||
|
|
@ -125,8 +126,8 @@ export struct EntityTemplate
|
||||||
*/
|
*/
|
||||||
T* getComponent(T)() nothrow @nogc
|
T* getComponent(T)() nothrow @nogc
|
||||||
{
|
{
|
||||||
if(T.component_id >= info.tmpl_deltas.length || info.tmpl_deltas[T.component_id] == 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[T.component_id]);
|
return cast(T*)(entity_data.ptr + info.tmpl_deltas[becsID!T]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************************************************************
|
/************************************************************************************************************************
|
||||||
|
|
|
||||||
|
|
@ -4,6 +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 : becsID;
|
||||||
|
|
||||||
import std.algorithm.comparison : max;
|
import std.algorithm.comparison : max;
|
||||||
|
|
||||||
|
|
@ -32,7 +33,7 @@ package struct EventManager
|
||||||
{
|
{
|
||||||
uint block_id = current_index + thread_id;
|
uint block_id = current_index + thread_id;
|
||||||
|
|
||||||
EventData* data = &events[Ev.event_id];
|
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;
|
||||||
|
|
|
||||||
|
|
@ -367,10 +367,10 @@ export struct EntityManager
|
||||||
System system;
|
System system;
|
||||||
system.m_pass = pass;
|
system.m_pass = pass;
|
||||||
|
|
||||||
static if (!(hasMember!(Sys, "system_id")) || !is(typeof(Sys.system_id) == ushort))
|
// static if (!(hasMember!(Sys, "system_id")) || !is(typeof(Sys.system_id) == ushort))
|
||||||
{
|
// {
|
||||||
static assert(0, "Add \"mixin ECS.System;\" in top of system structure;");
|
// static assert(0, "Add \"mixin ECS.System;\" in top of system structure;");
|
||||||
}
|
// }
|
||||||
|
|
||||||
static if (!(hasMember!(Sys, "EntitiesData")))
|
static if (!(hasMember!(Sys, "EntitiesData")))
|
||||||
{
|
{
|
||||||
|
|
@ -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 = EventParamType.event_id;
|
callers[i].id = becsID!EventParamType;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1153,8 +1153,8 @@ 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;
|
||||||
system.jobs = Mallocator.makeArray!(Job)((cast(Sys*) system.m_system_pointer)
|
static if(__traits(hasMember, Sys ,"__becs_jobs_count"))system.jobs = Mallocator.makeArray!(Job)(Sys.__becs_jobs_count);
|
||||||
.__ecs_jobs_count);
|
else system.jobs = Mallocator.makeArray!(Job)(32);
|
||||||
|
|
||||||
static if (OnUpdateOverloadNum != -1)
|
static if (OnUpdateOverloadNum != -1)
|
||||||
{
|
{
|
||||||
|
|
@ -1222,7 +1222,7 @@ export struct EntityManager
|
||||||
|
|
||||||
systems[$ - 1].enable();
|
systems[$ - 1].enable();
|
||||||
}
|
}
|
||||||
Sys.system_id = system.id;
|
becsID!Sys = system.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************************************************************
|
/************************************************************************************************************************
|
||||||
|
|
@ -1240,9 +1240,9 @@ export struct EntityManager
|
||||||
*/
|
*/
|
||||||
Sys* getSystem(Sys)() nothrow @nogc
|
Sys* getSystem(Sys)() nothrow @nogc
|
||||||
{
|
{
|
||||||
if (Sys.system_id >= systems.length)
|
if (becsID!Sys >= systems.length)
|
||||||
return null;
|
return null;
|
||||||
return cast(Sys*) systems[Sys.system_id].m_system_pointer;
|
return cast(Sys*) systems[becsID!Sys].m_system_pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
export ushort registerPass(const(char)[] name)
|
export ushort registerPass(const(char)[] name)
|
||||||
|
|
@ -1272,10 +1272,10 @@ export struct EntityManager
|
||||||
enum ComponentName = fullName!Comp;
|
enum ComponentName = fullName!Comp;
|
||||||
// enum ComponentName = Comp.stringof;
|
// enum ComponentName = Comp.stringof;
|
||||||
|
|
||||||
static if (!(hasMember!(Comp, "component_id")) || !is(typeof(Comp.component_id) == ushort))
|
// static if (!(hasMember!(Comp, "component_id")) || !is(typeof(Comp.component_id) == ushort))
|
||||||
{
|
// {
|
||||||
static assert(0, "Add \"mixin ECS.Component;\" in top of component structure;");
|
// static assert(0, "Add \"mixin ECS.Component;\" in top of component structure;");
|
||||||
}
|
// }
|
||||||
|
|
||||||
static if (hasMember!(Comp, "onDestroy") && isFunction!(Comp.onDestroy)
|
static if (hasMember!(Comp, "onDestroy") && isFunction!(Comp.onDestroy)
|
||||||
&& is(ReturnType!(Comp.onDestroy) == void)
|
&& is(ReturnType!(Comp.onDestroy) == void)
|
||||||
|
|
@ -1311,7 +1311,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)
|
||||||
{
|
{
|
||||||
Comp.component_id = 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;
|
||||||
|
|
@ -1319,7 +1319,7 @@ export struct EntityManager
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
components.add(info);
|
components.add(info);
|
||||||
Comp.component_id = 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));
|
||||||
}
|
}
|
||||||
|
|
@ -1329,10 +1329,10 @@ export struct EntityManager
|
||||||
{
|
{
|
||||||
EventInfo info;
|
EventInfo info;
|
||||||
|
|
||||||
static if (!(hasMember!(Ev, "event_id")) || !is(typeof(Ev.event_id) == ushort))
|
// static if (!(hasMember!(Ev, "event_id")) || !is(typeof(Ev.event_id) == ushort))
|
||||||
{
|
// {
|
||||||
static assert(0, "Add \"mixin ECS.Event;\" in top of event structure;");
|
// static assert(0, "Add \"mixin ECS.Event;\" in top of event structure;");
|
||||||
}
|
// }
|
||||||
|
|
||||||
static if (hasMember!(Ev, "onDestroy") && isFunction!(Ev.onDestroy)
|
static if (hasMember!(Ev, "onDestroy") && isFunction!(Ev.onDestroy)
|
||||||
&& is(ReturnType!(Ev.onDestroy) == void) && Parameters!(Ev.onDestroy).length == 0)
|
&& is(ReturnType!(Ev.onDestroy) == void) && Parameters!(Ev.onDestroy).length == 0)
|
||||||
|
|
@ -1352,12 +1352,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)
|
||||||
{
|
{
|
||||||
Ev.event_id = event_id;
|
becsID!Ev = event_id;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
events.add(info);
|
events.add(info);
|
||||||
Ev.event_id = 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));
|
||||||
}
|
}
|
||||||
|
|
@ -1376,9 +1376,9 @@ export struct EntityManager
|
||||||
// static assert(is(SetFunctionAttributes!(T, functionLinkage!(s.onUpdate),
|
// static assert(is(SetFunctionAttributes!(T, functionLinkage!(s.onUpdate),
|
||||||
// functionAttributes!(s.onUpdate)) == typeof(&s.onUpdate)),
|
// functionAttributes!(s.onUpdate)) == typeof(&s.onUpdate)),
|
||||||
// "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(Sys.system_id);
|
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)
|
||||||
|
|
@ -2265,7 +2265,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] = comp.component_id;
|
del_ids[i] = becsID!comp;
|
||||||
}
|
}
|
||||||
|
|
||||||
removeComponents(entity_id, del_ids);
|
removeComponents(entity_id, del_ids);
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,24 @@ module bubel.ecs.traits;
|
||||||
|
|
||||||
import std.traits;
|
import std.traits;
|
||||||
|
|
||||||
|
/************************************************************************************************************************
|
||||||
|
Return Component/System/Event unique ID
|
||||||
|
*/
|
||||||
|
ref ushort becsID(T)()
|
||||||
|
{
|
||||||
|
__gshared ushort id = ushort.max;
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/************************************************************************************************************************
|
||||||
|
Return Component/System/Event unique ID
|
||||||
|
*/
|
||||||
|
ref ushort becsID(T)(T obj)
|
||||||
|
{
|
||||||
|
static if(isPointer!T)return becsID!(PointerTarget!T);
|
||||||
|
else return becsID!T;
|
||||||
|
}
|
||||||
|
|
||||||
bool isForeachDelegateWithTypes(DG, Types...)()
|
bool isForeachDelegateWithTypes(DG, Types...)()
|
||||||
{
|
{
|
||||||
return is(DG == delegate) && is(ReturnType!DG == int) && is(Parameters!DG == Types);
|
return is(DG == delegate) && is(ReturnType!DG == int) && is(Parameters!DG == Types);
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ void beforeEveryTest()
|
||||||
|
|
||||||
gEM.endRegister();
|
gEM.endRegister();
|
||||||
|
|
||||||
tmpl = gEM.allocateTemplate([CLong.component_id, CInt.component_id, CUInt.component_id, CBig.component_id].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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
162
tests/basic.d
162
tests/basic.d
|
|
@ -115,7 +115,7 @@ struct EmptySystem
|
||||||
|
|
||||||
void beforeEveryTest()
|
void beforeEveryTest()
|
||||||
{
|
{
|
||||||
CUnregistered.component_id = ushort.max;
|
becsID!CUnregistered = ushort.max;
|
||||||
gEM.initialize(0);
|
gEM.initialize(0);
|
||||||
|
|
||||||
gEM.beginRegister();
|
gEM.beginRegister();
|
||||||
|
|
@ -138,18 +138,18 @@ void afterEveryTest()
|
||||||
@("EntityMeta")
|
@("EntityMeta")
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
EntityTemplate* tmpl_ = gEM.allocateTemplate([CInt.component_id, CFloat.component_id, CFlag.component_id].staticArray);
|
EntityTemplate* tmpl_ = gEM.allocateTemplate([becsID!CInt, becsID!CFloat, becsID!CFlag].staticArray);
|
||||||
scope(exit)gEM.freeTemplate(tmpl_);
|
scope(exit)gEM.freeTemplate(tmpl_);
|
||||||
Entity* entity = gEM.addEntity(tmpl_);
|
Entity* entity = gEM.addEntity(tmpl_);
|
||||||
EntityMeta meta = entity.getMeta();
|
EntityMeta meta = entity.getMeta();
|
||||||
assert(meta.hasComponent(CInt.component_id));
|
assert(meta.hasComponent(becsID!CInt));
|
||||||
assert(meta.getComponent!CInt);
|
assert(meta.getComponent!CInt);
|
||||||
assert(meta.hasComponent(CFloat.component_id));
|
assert(meta.hasComponent(becsID!CFloat));
|
||||||
assert(meta.getComponent!CFloat);
|
assert(meta.getComponent!CFloat);
|
||||||
assert(!meta.getComponent!CLong);
|
assert(!meta.getComponent!CLong);
|
||||||
assert(!meta.hasComponent(CLong.component_id));
|
assert(!meta.hasComponent(becsID!CLong));
|
||||||
assert(!meta.getComponent!CUnregistered);
|
assert(!meta.getComponent!CUnregistered);
|
||||||
assert(!meta.hasComponent(CUnregistered.component_id));
|
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);
|
||||||
}
|
}
|
||||||
|
|
@ -157,7 +157,7 @@ unittest
|
||||||
@("AddEntity")
|
@("AddEntity")
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
EntityTemplate* tmpl_ = gEM.allocateTemplate([CInt.component_id, CFloat.component_id, CFlag.component_id].staticArray);
|
EntityTemplate* tmpl_ = gEM.allocateTemplate([becsID!CInt, becsID!CFloat, becsID!CFlag].staticArray);
|
||||||
scope(exit)gEM.freeTemplate(tmpl_);
|
scope(exit)gEM.freeTemplate(tmpl_);
|
||||||
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));
|
||||||
|
|
@ -187,8 +187,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(CInt.component_id));
|
assert(entity3.hasComponent(becsID!CInt));
|
||||||
assert(entity3.hasComponent(CFloat.component_id));
|
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);
|
||||||
|
|
||||||
|
|
@ -203,7 +203,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, [CFlag().component_id,CShort(2).component_id].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);
|
||||||
|
|
@ -214,7 +214,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, [CUnregistered.component_id].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);
|
||||||
|
|
@ -237,7 +237,7 @@ unittest
|
||||||
assert(entity3.getComponent!CUnregistered);
|
assert(entity3.getComponent!CUnregistered);
|
||||||
assert(*entity3.getComponent!CUnregistered == 4);
|
assert(*entity3.getComponent!CUnregistered == 4);
|
||||||
|
|
||||||
gEM.removeComponents(entity3.id, [CUnregistered.component_id].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);
|
||||||
|
|
@ -249,9 +249,9 @@ unittest
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
//basic template allocation
|
//basic template allocation
|
||||||
ushort[2] ids = [CInt.component_id, CFloat.component_id];
|
ushort[2] ids = [becsID!CInt, becsID!CFloat];
|
||||||
EntityTemplate* tmpl_ = gEM.allocateTemplate(ids);
|
EntityTemplate* tmpl_ = gEM.allocateTemplate(ids);
|
||||||
EntityTemplate* tmpl_d = gEM.allocateTemplate([CFloat.component_id, CInt.component_id, CFloat.component_id].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);
|
||||||
|
|
@ -270,7 +270,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 = [CDouble.component_id,CFlag.component_id];
|
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);
|
||||||
|
|
@ -315,7 +315,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 = [CDouble.component_id, CLong.component_id, CShort.component_id];
|
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);
|
||||||
|
|
@ -330,7 +330,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 = [CFloat.component_id];
|
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);
|
||||||
|
|
@ -361,8 +361,8 @@ unittest
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
//basic template allocation
|
//basic template allocation
|
||||||
ushort[2] ids = [CFloat.component_id, CInt.component_id];
|
ushort[2] ids = [becsID!CFloat, becsID!CInt];
|
||||||
ushort[2] ids2 = [CInt.component_id, CFloat.component_id];
|
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);
|
||||||
|
|
@ -403,9 +403,9 @@ unittest
|
||||||
assert(system !is null);
|
assert(system !is null);
|
||||||
assert(system.count == 0);
|
assert(system.count == 0);
|
||||||
|
|
||||||
System* ecs_system = gEM.getSystem(EmptySystem.system_id);
|
System* ecs_system = gEM.getSystem(becsID!EmptySystem);
|
||||||
assert(ecs_system !is null);
|
assert(ecs_system !is null);
|
||||||
assert(ecs_system.id == EmptySystem.system_id);
|
assert(ecs_system.id == becsID!EmptySystem);
|
||||||
assert(ecs_system.name == "tests.basic.EmptySystem");
|
assert(ecs_system.name == "tests.basic.EmptySystem");
|
||||||
|
|
||||||
gEM.begin();
|
gEM.begin();
|
||||||
|
|
@ -507,7 +507,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.system_id);
|
System* ecs_system = gEM.getSystem(system.becsID);
|
||||||
|
|
||||||
ecs_system.enable();
|
ecs_system.enable();
|
||||||
assert(system.enable == 1);
|
assert(system.enable == 1);
|
||||||
|
|
@ -518,7 +518,7 @@ unittest
|
||||||
assert(system.disable == 1);
|
assert(system.disable == 1);
|
||||||
|
|
||||||
|
|
||||||
ushort[2] ids = [CLong.component_id,CFloat.component_id];
|
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);
|
||||||
|
|
@ -532,7 +532,7 @@ unittest
|
||||||
gEM.end();
|
gEM.end();
|
||||||
assert(system.end == 1);
|
assert(system.end == 1);
|
||||||
|
|
||||||
ushort[2] ids2 = [CLong.component_id, CInt.component_id];
|
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);
|
||||||
|
|
@ -547,7 +547,7 @@ unittest
|
||||||
gEM.end();
|
gEM.end();
|
||||||
assert(system.end == 2);
|
assert(system.end == 2);
|
||||||
|
|
||||||
ushort[2] ids3 = [CLong.component_id, CShort.component_id];
|
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);
|
||||||
|
|
@ -606,13 +606,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(LongAddSystem.system_id);
|
System* ecs_system = gEM.getSystem(becsID!LongAddSystem);
|
||||||
assert(ecs_system !is null);
|
assert(ecs_system !is null);
|
||||||
assert(ecs_system.id == LongAddSystem.system_id);
|
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 = [CLong.component_id];
|
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);
|
||||||
|
|
@ -762,19 +762,19 @@ unittest
|
||||||
assert(system.remove == 0);
|
assert(system.remove == 0);
|
||||||
assert(system.change == 0);
|
assert(system.change == 0);
|
||||||
|
|
||||||
EntityTemplate* tmpl = gEM.allocateTemplate([CLong.component_id,CFloat.component_id].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([CLong.component_id, CInt.component_id].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([CLong.component_id, CShort.component_id].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();
|
||||||
|
|
@ -783,19 +783,19 @@ unittest
|
||||||
gEM.beginRegister();
|
gEM.beginRegister();
|
||||||
gEM.endRegister();
|
gEM.endRegister();
|
||||||
|
|
||||||
gEM.removeComponents(id0, [CFloat.component_id].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, [CInt.component_id].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, [CShort.component_id].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);
|
||||||
|
|
@ -894,7 +894,7 @@ unittest
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(gEM.getSystem!TestSystem is null);
|
assert(gEM.getSystem!TestSystem is null);
|
||||||
assert(gEM.getSystem(TestSystem.system_id) is null);
|
assert(gEM.getSystem(becsID!TestSystem) is null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@("MultithreadedUpdate")
|
@("MultithreadedUpdate")
|
||||||
|
|
@ -966,10 +966,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 = [CLong.component_id,CFloat.component_id];
|
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([CLong.component_id,CInt.component_id,CShort.component_id,CFloat.component_id].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();
|
||||||
|
|
@ -1064,7 +1064,7 @@ unittest
|
||||||
@("AddRemoveEntities")
|
@("AddRemoveEntities")
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
ushort[3] ids = [CLong.component_id,CFloat.component_id,CShort.component_id];
|
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);
|
||||||
|
|
||||||
|
|
@ -1094,7 +1094,7 @@ unittest
|
||||||
|
|
||||||
gEM.endRegister();
|
gEM.endRegister();
|
||||||
|
|
||||||
ushort[1] ids = [CLong.component_id];
|
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);
|
||||||
|
|
||||||
|
|
@ -1123,7 +1123,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 = [CFloat.component_id, CLong.component_id, CUnregistered.component_id];
|
ushort[3] ids2 = [becsID!CFloat, becsID!CLong, becsID!CUnregistered];
|
||||||
gEM.removeComponents(id, ids2);
|
gEM.removeComponents(id, ids2);
|
||||||
gEM.commit();
|
gEM.commit();
|
||||||
|
|
||||||
|
|
@ -1166,12 +1166,12 @@ unittest
|
||||||
{
|
{
|
||||||
struct ETest
|
struct ETest
|
||||||
{
|
{
|
||||||
mixin ECS.Event;
|
// mixin ECS.Event;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ETest2
|
struct ETest2
|
||||||
{
|
{
|
||||||
mixin ECS.Event;
|
// mixin ECS.Event;
|
||||||
|
|
||||||
void onDestroy()
|
void onDestroy()
|
||||||
{
|
{
|
||||||
|
|
@ -1258,10 +1258,10 @@ unittest
|
||||||
|
|
||||||
gEM.endRegister();
|
gEM.endRegister();
|
||||||
|
|
||||||
ushort[1] ids = [CLong.component_id];
|
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 = [CShort.component_id];
|
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);
|
||||||
|
|
||||||
|
|
@ -1353,11 +1353,11 @@ unittest
|
||||||
|
|
||||||
gEM.endRegister();
|
gEM.endRegister();
|
||||||
|
|
||||||
EntityTemplate* tmpl = gEM.allocateTemplate([CInt.component_id].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([CInt.component_id, CLong.component_id].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;
|
||||||
|
|
||||||
|
|
@ -1476,22 +1476,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 == TestSystem.system_id);
|
assert(pass.system_callers[0].system_id == becsID!TestSystem);
|
||||||
assert(pass.system_callers[1].system_id == TestSystem2.system_id);
|
assert(pass.system_callers[1].system_id == becsID!TestSystem2);
|
||||||
assert(pass.system_callers[2].system_id == TestSystem3.system_id);
|
assert(pass.system_callers[2].system_id == becsID!TestSystem3);
|
||||||
assert(pass.system_callers[3].system_id == TestSystem4.system_id);
|
assert(pass.system_callers[3].system_id == becsID!TestSystem4);
|
||||||
assert(pass.system_callers[4].system_id == TestSystem5.system_id);
|
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 == TestSystem.system_id);
|
assert(pass.system_callers[1].dependencies[0].system_id == becsID!TestSystem);
|
||||||
assert(pass.system_callers[2].dependencies[0].system_id == TestSystem2.system_id);
|
assert(pass.system_callers[2].dependencies[0].system_id == becsID!TestSystem2);
|
||||||
assert(pass.system_callers[3].dependencies[0].system_id == TestSystem.system_id);
|
assert(pass.system_callers[3].dependencies[0].system_id == becsID!TestSystem);
|
||||||
assert(pass.system_callers[3].dependencies[1].system_id == TestSystem2.system_id);
|
assert(pass.system_callers[3].dependencies[1].system_id == becsID!TestSystem2);
|
||||||
assert(pass.system_callers[3].dependencies[2].system_id == TestSystem3.system_id);
|
assert(pass.system_callers[3].dependencies[2].system_id == becsID!TestSystem3);
|
||||||
assert(pass.system_callers[4].dependencies[0].system_id == TestSystem4.system_id);
|
assert(pass.system_callers[4].dependencies[0].system_id == becsID!TestSystem4);
|
||||||
}
|
}
|
||||||
|
|
||||||
@("ExternalSystemDependencies")
|
@("ExternalSystemDependencies")
|
||||||
|
|
@ -1603,23 +1603,23 @@ 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 == TestSystem.system_id);
|
assert(pass.system_callers[0].system_id == becsID!TestSystem);
|
||||||
assert(pass.system_callers[1].system_id == TestSystem2.system_id);
|
assert(pass.system_callers[1].system_id == becsID!TestSystem2);
|
||||||
assert(pass.system_callers[2].system_id == TestSystem3.system_id);
|
assert(pass.system_callers[2].system_id == becsID!TestSystem3);
|
||||||
assert(pass.system_callers[3].system_id == TestSystem4.system_id);
|
assert(pass.system_callers[3].system_id == becsID!TestSystem4);
|
||||||
assert(pass.system_callers[4].system_id == TestSystem5.system_id);
|
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 == TestSystem.system_id);
|
assert(pass.system_callers[1].dependencies[0].system_id == becsID!TestSystem);
|
||||||
assert(pass.system_callers[2].dependencies[0].system_id == TestSystem2.system_id);
|
assert(pass.system_callers[2].dependencies[0].system_id == becsID!TestSystem2);
|
||||||
assert(pass.system_callers[3].dependencies[0].system_id == TestSystem.system_id);
|
assert(pass.system_callers[3].dependencies[0].system_id == becsID!TestSystem);
|
||||||
assert(pass.system_callers[3].dependencies[1].system_id == TestSystem2.system_id);
|
assert(pass.system_callers[3].dependencies[1].system_id == becsID!TestSystem2);
|
||||||
assert(pass.system_callers[3].dependencies[2].system_id == TestSystem3.system_id);
|
assert(pass.system_callers[3].dependencies[2].system_id == becsID!TestSystem3);
|
||||||
assert(pass.system_callers[4].dependencies[0].system_id == TestSystem2.system_id);
|
assert(pass.system_callers[4].dependencies[0].system_id == becsID!TestSystem2);
|
||||||
assert(pass.system_callers[4].dependencies[1].system_id == TestSystem4.system_id);
|
assert(pass.system_callers[4].dependencies[1].system_id == becsID!TestSystem4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1641,11 +1641,11 @@ unittest
|
||||||
|
|
||||||
bool filterEntity(EntityManager.EntityInfo* info)
|
bool filterEntity(EntityManager.EntityInfo* info)
|
||||||
{
|
{
|
||||||
if(!info.hasComponent(CInt.component_id))return false;
|
if(!info.hasComponent(becsID!CInt))return false;
|
||||||
int one_from = 0;
|
int one_from = 0;
|
||||||
if(info.hasComponent(CLong.component_id))one_from++;
|
if(info.hasComponent(becsID!CLong))one_from++;
|
||||||
if(info.hasComponent(CFloat.component_id))one_from++;
|
if(info.hasComponent(becsID!CFloat))one_from++;
|
||||||
if(info.hasComponent(CDouble.component_id))one_from++;
|
if(info.hasComponent(becsID!CDouble))one_from++;
|
||||||
if(one_from == 1)return true;
|
if(one_from == 1)return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -1673,8 +1673,8 @@ unittest
|
||||||
|
|
||||||
bool filterEntity(EntityManager.EntityInfo* info)
|
bool filterEntity(EntityManager.EntityInfo* info)
|
||||||
{
|
{
|
||||||
if(info.hasComponent(CInt.component_id) && info.hasComponent(CFloat.component_id) && !info.hasComponent(CLong.component_id) && !info.hasComponent(CDouble.component_id))return true;
|
if(info.hasComponent(becsID!CInt) && info.hasComponent(becsID!CFloat) && !info.hasComponent(becsID!CLong) && !info.hasComponent(becsID!CDouble))return true;
|
||||||
if(info.hasComponent(CLong.component_id) && info.hasComponent(CDouble.component_id) && !info.hasComponent(CInt.component_id) && !info.hasComponent(CFloat.component_id))return true;
|
if(info.hasComponent(becsID!CLong) && info.hasComponent(becsID!CDouble) && !info.hasComponent(becsID!CInt) && !info.hasComponent(becsID!CFloat))return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1694,17 +1694,17 @@ unittest
|
||||||
gEM.endRegister();
|
gEM.endRegister();
|
||||||
|
|
||||||
|
|
||||||
EntityTemplate* tmpl_ = gEM.allocateTemplate([CInt.component_id, CLong.component_id, CFloat.component_id, CDouble.component_id].staticArray);
|
EntityTemplate* tmpl_ = gEM.allocateTemplate([becsID!CInt, becsID!CLong, becsID!CFloat, becsID!CDouble].staticArray);
|
||||||
scope(exit)gEM.freeTemplate(tmpl_);
|
scope(exit)gEM.freeTemplate(tmpl_);
|
||||||
EntityTemplate* tmpl_2 = gEM.allocateTemplate([CInt.component_id, CFloat.component_id].staticArray);
|
EntityTemplate* tmpl_2 = gEM.allocateTemplate([becsID!CInt, becsID!CFloat].staticArray);
|
||||||
scope(exit)gEM.freeTemplate(tmpl_2);
|
scope(exit)gEM.freeTemplate(tmpl_2);
|
||||||
EntityTemplate* tmpl_3 = gEM.allocateTemplate([CLong.component_id, CDouble.component_id].staticArray);
|
EntityTemplate* tmpl_3 = gEM.allocateTemplate([becsID!CLong, becsID!CDouble].staticArray);
|
||||||
scope(exit)gEM.freeTemplate(tmpl_3);
|
scope(exit)gEM.freeTemplate(tmpl_3);
|
||||||
EntityTemplate* tmpl_4 = gEM.allocateTemplate([CInt.component_id, CLong.component_id, CDouble.component_id].staticArray);
|
EntityTemplate* tmpl_4 = gEM.allocateTemplate([becsID!CInt, becsID!CLong, becsID!CDouble].staticArray);
|
||||||
scope(exit)gEM.freeTemplate(tmpl_4);
|
scope(exit)gEM.freeTemplate(tmpl_4);
|
||||||
EntityTemplate* tmpl_5 = gEM.allocateTemplate([CInt.component_id, CDouble.component_id].staticArray);
|
EntityTemplate* tmpl_5 = gEM.allocateTemplate([becsID!CInt, becsID!CDouble].staticArray);
|
||||||
scope(exit)gEM.freeTemplate(tmpl_5);
|
scope(exit)gEM.freeTemplate(tmpl_5);
|
||||||
EntityTemplate* tmpl_6 = gEM.allocateTemplate([CDouble.component_id].staticArray);
|
EntityTemplate* tmpl_6 = gEM.allocateTemplate([becsID!CDouble].staticArray);
|
||||||
scope(exit)gEM.freeTemplate(tmpl_6);
|
scope(exit)gEM.freeTemplate(tmpl_6);
|
||||||
|
|
||||||
gEM.addEntity(tmpl_);
|
gEM.addEntity(tmpl_);
|
||||||
|
|
|
||||||
12
tests/bugs.d
12
tests/bugs.d
|
|
@ -21,14 +21,14 @@ unittest
|
||||||
{
|
{
|
||||||
struct Event1
|
struct Event1
|
||||||
{
|
{
|
||||||
mixin ECS.Event;
|
// mixin ECS.Event;
|
||||||
|
|
||||||
EntityID id;
|
EntityID id;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Event2
|
struct Event2
|
||||||
{
|
{
|
||||||
mixin ECS.Event;
|
// mixin ECS.Event;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct System1
|
struct System1
|
||||||
|
|
@ -45,7 +45,7 @@ unittest
|
||||||
|
|
||||||
void onCreate()
|
void onCreate()
|
||||||
{
|
{
|
||||||
tmpl = gEM.allocateTemplate([CInt.component_id, CLong.component_id].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([CInt.component_id, CLong.component_id].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(System2.system_id).disable();
|
gEM.getSystem(becsID!System2).disable();
|
||||||
|
|
||||||
gEM.begin();
|
gEM.begin();
|
||||||
gEM.update();
|
gEM.update();
|
||||||
gEM.end();
|
gEM.end();
|
||||||
|
|
||||||
gEM.getSystem(System2.system_id).enable();
|
gEM.getSystem(becsID!System2).enable();
|
||||||
|
|
||||||
gEM.begin();
|
gEM.begin();
|
||||||
gEM.update();
|
gEM.update();
|
||||||
|
|
|
||||||
16
tests/perf.d
16
tests/perf.d
|
|
@ -86,22 +86,22 @@ void afterEveryTest()
|
||||||
|
|
||||||
void smallTmpl()
|
void smallTmpl()
|
||||||
{
|
{
|
||||||
tmpl = gEM.allocateTemplate([CShort.component_id].staticArray);
|
tmpl = gEM.allocateTemplate([becsID!CShort].staticArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
void bigTmpl()
|
void bigTmpl()
|
||||||
{
|
{
|
||||||
tmpl = gEM.allocateTemplate([CBig.component_id].staticArray);
|
tmpl = gEM.allocateTemplate([becsID!CBig].staticArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
void multiSmallTmpl()
|
void multiSmallTmpl()
|
||||||
{
|
{
|
||||||
tmpl = gEM.allocateTemplate([CShort.component_id, CLong.component_id, CInt.component_id, CUInt.component_id].staticArray);
|
tmpl = gEM.allocateTemplate([becsID!CShort, becsID!CLong, becsID!CInt, becsID!CUInt].staticArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
void multiBigTmpl()
|
void multiBigTmpl()
|
||||||
{
|
{
|
||||||
tmpl = gEM.allocateTemplate([CLong.component_id, CInt.component_id, CUInt.component_id, CBig.component_id].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([CShort.component_id].staticArray);
|
tmpl = gEM.allocateTemplate([becsID!CShort].staticArray);
|
||||||
allocDealloc100k();
|
allocDealloc100k();
|
||||||
}
|
}
|
||||||
|
|
||||||
void bigTmplPreAlloc()
|
void bigTmplPreAlloc()
|
||||||
{
|
{
|
||||||
tmpl = gEM.allocateTemplate([CBig.component_id].staticArray);
|
tmpl = gEM.allocateTemplate([becsID!CBig].staticArray);
|
||||||
allocDealloc100k();
|
allocDealloc100k();
|
||||||
}
|
}
|
||||||
|
|
||||||
void multiSmallTmplPreAlloc()
|
void multiSmallTmplPreAlloc()
|
||||||
{
|
{
|
||||||
tmpl = gEM.allocateTemplate([CShort.component_id, CLong.component_id, CInt.component_id, CUInt.component_id].staticArray);
|
tmpl = gEM.allocateTemplate([becsID!CShort, becsID!CLong, becsID!CInt, becsID!CUInt].staticArray);
|
||||||
allocDealloc100k();
|
allocDealloc100k();
|
||||||
}
|
}
|
||||||
|
|
||||||
void multiBigTmplPreAlloc()
|
void multiBigTmplPreAlloc()
|
||||||
{
|
{
|
||||||
tmpl = gEM.allocateTemplate([CLong.component_id, CInt.component_id, CUInt.component_id, CBig.component_id].staticArray);
|
tmpl = gEM.allocateTemplate([becsID!CLong, becsID!CInt, becsID!CUInt, becsID!CBig].staticArray);
|
||||||
allocDealloc100k();
|
allocDealloc100k();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue