|
|
|
@ -40,6 +40,7 @@ struct SpaceInvaders
|
|
|
|
EntityTemplate* enemy_tmpl;
|
|
|
|
EntityTemplate* enemy_tmpl;
|
|
|
|
EntityTemplate* ship_tmpl;
|
|
|
|
EntityTemplate* ship_tmpl;
|
|
|
|
EntityTemplate* laser_tmpl;
|
|
|
|
EntityTemplate* laser_tmpl;
|
|
|
|
|
|
|
|
EntityTemplate*[5] bullet_tmpl;
|
|
|
|
Texture texture;
|
|
|
|
Texture texture;
|
|
|
|
|
|
|
|
|
|
|
|
ShootGrid* shoot_grid;
|
|
|
|
ShootGrid* shoot_grid;
|
|
|
|
@ -55,9 +56,13 @@ struct SpaceInvaders
|
|
|
|
~this() @nogc nothrow
|
|
|
|
~this() @nogc nothrow
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(shoot_grid)Mallocator.dispose(shoot_grid);
|
|
|
|
if(shoot_grid)Mallocator.dispose(shoot_grid);
|
|
|
|
launcher.manager.freeTemplate(enemy_tmpl);
|
|
|
|
if(enemy_tmpl)launcher.manager.freeTemplate(enemy_tmpl);
|
|
|
|
launcher.manager.freeTemplate(ship_tmpl);
|
|
|
|
if(ship_tmpl)launcher.manager.freeTemplate(ship_tmpl);
|
|
|
|
launcher.manager.freeTemplate(laser_tmpl);
|
|
|
|
if(laser_tmpl)launcher.manager.freeTemplate(laser_tmpl);
|
|
|
|
|
|
|
|
foreach (EntityTemplate* tmpl; bullet_tmpl)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(tmpl)launcher.manager.freeTemplate(tmpl);
|
|
|
|
|
|
|
|
}
|
|
|
|
texture.destory();
|
|
|
|
texture.destory();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -115,7 +120,7 @@ struct CLocation
|
|
|
|
|
|
|
|
|
|
|
|
alias value this;
|
|
|
|
alias value this;
|
|
|
|
|
|
|
|
|
|
|
|
vec2 value;
|
|
|
|
vec2 value = vec2(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct CScale
|
|
|
|
struct CScale
|
|
|
|
@ -192,7 +197,7 @@ struct CGuild
|
|
|
|
byte guild;
|
|
|
|
byte guild;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct CLaser
|
|
|
|
struct CBullet
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mixin ECS.Component;
|
|
|
|
mixin ECS.Component;
|
|
|
|
|
|
|
|
|
|
|
|
@ -408,12 +413,35 @@ struct CParticleEmitterTime
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mixin ECS.Component;
|
|
|
|
mixin ECS.Component;
|
|
|
|
|
|
|
|
|
|
|
|
float time;
|
|
|
|
float time = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///You can create separate component for every kind of spawned entities but it's not practial due to archetype fragmentation.
|
|
|
|
|
|
|
|
///Second approach can be commented code. It's gives good flexibility inchoosing entity, but it limits to one entity.
|
|
|
|
|
|
|
|
///Instead of entity it can be array of templates which is good solution, but if possibilities is known at time of game development it
|
|
|
|
|
|
|
|
///can be simply index/enum for type of spawn. Bad thing about this solution is problem witch merging multiple spawning types during
|
|
|
|
|
|
|
|
///gameplay, i.e. giving buff which cast firebols upon death.
|
|
|
|
|
|
|
|
struct CSpawnUponDeath
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
mixin ECS.Component;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enum Type
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
flashes_emitter,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//EntityID parent;
|
|
|
|
|
|
|
|
//EntityTemplate* tmpl;
|
|
|
|
|
|
|
|
Type type;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///This component can be replaced by "CSpawnUponDeath" but I want to gives possibility to add this component to every entity
|
|
|
|
|
|
|
|
///during gameplay. End application works exacly the same way for every demo so I can't use different way as adding component.
|
|
|
|
struct CShootWaveUponDeath
|
|
|
|
struct CShootWaveUponDeath
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mixin ECS.Component;
|
|
|
|
mixin ECS.Component;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CWeapon.Type bullet_type;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*#######################################################################################################################
|
|
|
|
/*#######################################################################################################################
|
|
|
|
@ -604,7 +632,7 @@ struct ShootGridManager
|
|
|
|
struct EntitiesData
|
|
|
|
struct EntitiesData
|
|
|
|
{
|
|
|
|
{
|
|
|
|
uint length;
|
|
|
|
uint length;
|
|
|
|
uint thread_id;
|
|
|
|
//uint thread_id;
|
|
|
|
const (Entity)[] entity;
|
|
|
|
const (Entity)[] entity;
|
|
|
|
@readonly CLocation[] locations;
|
|
|
|
@readonly CLocation[] locations;
|
|
|
|
@readonly CShootGrid[] grid_flag;
|
|
|
|
@readonly CShootGrid[] grid_flag;
|
|
|
|
@ -748,7 +776,8 @@ struct ShipWeaponSystem
|
|
|
|
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;
|
|
|
|
weapon_tmpl.getComponent!CScale().value = vec2(4,16);
|
|
|
|
weapon_tmpl.getComponent!CScale().value = vec2(4,16);
|
|
|
|
weapon_tmpl.getComponent!CWeapon().level = 1;
|
|
|
|
//weapon_tmpl.getComponent!CWeapon().level = 1;
|
|
|
|
|
|
|
|
*weapon_tmpl.getComponent!CWeapon() = CWeapon(0,CWeapon.Type.canon,1);
|
|
|
|
weapon_tmpl.getComponent!CDepth().depth = -1;
|
|
|
|
weapon_tmpl.getComponent!CDepth().depth = -1;
|
|
|
|
weapon_tmpl.getComponent!CTexture().coords = vec4(136,96,4,16)*px;
|
|
|
|
weapon_tmpl.getComponent!CTexture().coords = vec4(136,96,4,16)*px;
|
|
|
|
weapon_tmpl.getComponent!CWeaponLocation().rel_pos = vec2(0,12);
|
|
|
|
weapon_tmpl.getComponent!CWeaponLocation().rel_pos = vec2(0,12);
|
|
|
|
@ -801,7 +830,8 @@ struct ShipWeaponSystem
|
|
|
|
[CHitMark.component_id, CHitPoints.component_id, CLocation.component_id,
|
|
|
|
[CHitMark.component_id, CHitPoints.component_id, CLocation.component_id,
|
|
|
|
CTexture.component_id, CScale.component_id, CEnemy.component_id,
|
|
|
|
CTexture.component_id, CScale.component_id, CEnemy.component_id,
|
|
|
|
CShootGrid.component_id, CGuild.component_id, CInit.component_id,
|
|
|
|
CShootGrid.component_id, CGuild.component_id, CInit.component_id,
|
|
|
|
CChildren.component_id, CDepth.component_id, CTargetParent.component_id].staticArray
|
|
|
|
CChildren.component_id, CDepth.component_id, CTargetParent.component_id,
|
|
|
|
|
|
|
|
CSpawnUponDeath.component_id, CShootWaveUponDeath.component_id].staticArray
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
CTexture* tex_comp = tower1_tmpl.getComponent!CTexture;
|
|
|
|
CTexture* tex_comp = tower1_tmpl.getComponent!CTexture;
|
|
|
|
@ -813,6 +843,7 @@ struct ShipWeaponSystem
|
|
|
|
tower1_tmpl.getComponent!CInit().type = CInit.Type.tower;
|
|
|
|
tower1_tmpl.getComponent!CInit().type = CInit.Type.tower;
|
|
|
|
tower1_tmpl.getComponent!CHitPoints().value = 10;
|
|
|
|
tower1_tmpl.getComponent!CHitPoints().value = 10;
|
|
|
|
tower1_tmpl.getComponent!CDepth().depth = -2;
|
|
|
|
tower1_tmpl.getComponent!CDepth().depth = -2;
|
|
|
|
|
|
|
|
tower1_tmpl.getComponent!CShootWaveUponDeath().bullet_type = CWeapon.Type.canon;
|
|
|
|
tower1_tmpl.getComponent!CTargetParent().rel_pos = vec2(-33,2);
|
|
|
|
tower1_tmpl.getComponent!CTargetParent().rel_pos = vec2(-33,2);
|
|
|
|
|
|
|
|
|
|
|
|
tower2_tmpl = launcher.manager.allocateTemplate(tower1_tmpl);
|
|
|
|
tower2_tmpl = launcher.manager.allocateTemplate(tower1_tmpl);
|
|
|
|
@ -865,22 +896,12 @@ struct ShipWeaponSystem
|
|
|
|
{
|
|
|
|
{
|
|
|
|
foreach(i; 0..data.length)
|
|
|
|
foreach(i; 0..data.length)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
/*if(data.children[i].childern.length != 0)continue;
|
|
|
|
|
|
|
|
EntityID[3] weapons;
|
|
|
|
|
|
|
|
laser1_tmpl.getComponent!CTargetParent().parent = data.entity[i].id;
|
|
|
|
|
|
|
|
laser2_tmpl.getComponent!CTargetParent().parent = data.entity[i].id;
|
|
|
|
|
|
|
|
main_weapon_tmpl.getComponent!CTargetParent().parent = data.entity[i].id;
|
|
|
|
|
|
|
|
weapons[0] = launcher.manager.addEntity(laser1_tmpl).id;
|
|
|
|
|
|
|
|
weapons[1] = launcher.manager.addEntity(laser2_tmpl).id;
|
|
|
|
|
|
|
|
weapons[2] = launcher.manager.addEntity(main_weapon_tmpl).id;
|
|
|
|
|
|
|
|
data.children[i].childern = Mallocator.makeArray(weapons);*/
|
|
|
|
|
|
|
|
final switch(data.init[i].type)
|
|
|
|
final switch(data.init[i].type)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
case CInit.Type.space_ship:ship.add(&data.entity[i]);break;
|
|
|
|
case CInit.Type.space_ship:ship.add(&data.entity[i]);break;
|
|
|
|
case CInit.Type.tower:tower.add(&data.entity[i]);break;
|
|
|
|
case CInit.Type.tower:tower.add(&data.entity[i]);break;
|
|
|
|
case CInit.Type.boss:boss.add(&data.entity[i]);break;
|
|
|
|
case CInit.Type.boss:boss.add(&data.entity[i]);break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -942,7 +963,7 @@ struct DrawSystem
|
|
|
|
struct EntitiesData
|
|
|
|
struct EntitiesData
|
|
|
|
{
|
|
|
|
{
|
|
|
|
uint length;
|
|
|
|
uint length;
|
|
|
|
uint thread_id;
|
|
|
|
//uint thread_id;
|
|
|
|
uint job_id;
|
|
|
|
uint job_id;
|
|
|
|
@readonly CTexture[] textures;
|
|
|
|
@readonly CTexture[] textures;
|
|
|
|
@readonly CLocation[] locations;
|
|
|
|
@readonly CLocation[] locations;
|
|
|
|
@ -1046,8 +1067,6 @@ struct LaserShootingSystem
|
|
|
|
mixin ECS.System!32;
|
|
|
|
mixin ECS.System!32;
|
|
|
|
|
|
|
|
|
|
|
|
bool shoot = false;
|
|
|
|
bool shoot = false;
|
|
|
|
//static float[18] laser_shoot_times = [500,400,300,200,100,50,25,10,5,2,1,0.8,0.6,0.5,0.4,0.3,0.2,0.1];
|
|
|
|
|
|
|
|
//static float[18] laser_shoot_disp = [0,0,0,0,0.05,0.06,0.08,0.1,0.14,0.18,0.2,0.25,0.26,0.27,0.28,0.29,0.3,0.4];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
__gshared vec4[] fire_frames = [vec4(96,64,8,16)*px,vec4(104,64,8,16)*px,vec4(112,64,8,16)*px,vec4(120,64,8,16)*px,vec4(128,64,8,16)*px,
|
|
|
|
__gshared vec4[] fire_frames = [vec4(96,64,8,16)*px,vec4(104,64,8,16)*px,vec4(112,64,8,16)*px,vec4(120,64,8,16)*px,vec4(128,64,8,16)*px,
|
|
|
|
vec4(136,64,8,16)*px,vec4(144,64,8,16)*px,vec4(152,64,8,16)*px,vec4(160,64,8,16)*px];
|
|
|
|
vec4(136,64,8,16)*px,vec4(144,64,8,16)*px,vec4(152,64,8,16)*px,vec4(160,64,8,16)*px];
|
|
|
|
@ -1055,16 +1074,10 @@ struct LaserShootingSystem
|
|
|
|
// __gshared vec4[] fire_frames = [vec4(0,160,8,16)*px,vec4(16,160,16,16)*px,vec4(32,160,16,16)*px,vec4(48,160,16,16)*px,vec4(64,160,16,16)*px,
|
|
|
|
// __gshared vec4[] fire_frames = [vec4(0,160,8,16)*px,vec4(16,160,16,16)*px,vec4(32,160,16,16)*px,vec4(48,160,16,16)*px,vec4(64,160,16,16)*px,
|
|
|
|
// vec4(80,160,16,16)*px,vec4(96,160,16,16)*px,vec4(112,160,16,16)*px];
|
|
|
|
// vec4(80,160,16,16)*px,vec4(96,160,16,16)*px,vec4(112,160,16,16)*px];
|
|
|
|
|
|
|
|
|
|
|
|
/*CLocation* laser_location;
|
|
|
|
|
|
|
|
CVelocity* laser_velocity;
|
|
|
|
|
|
|
|
CGuild* laser_guild;*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct EntitiesData
|
|
|
|
struct EntitiesData
|
|
|
|
{
|
|
|
|
{
|
|
|
|
///variable named "length" contain entites count
|
|
|
|
///variable named "length" contain entites count
|
|
|
|
uint length;
|
|
|
|
uint length;
|
|
|
|
///variable named "length" contain thread identifier
|
|
|
|
|
|
|
|
uint thread_id;
|
|
|
|
|
|
|
|
CWeapon[] laser;
|
|
|
|
CWeapon[] laser;
|
|
|
|
@readonly CLocation[] location;
|
|
|
|
@readonly CLocation[] location;
|
|
|
|
@readonly CGuild[] guild;
|
|
|
|
@readonly CGuild[] guild;
|
|
|
|
@ -1076,77 +1089,53 @@ struct LaserShootingSystem
|
|
|
|
@optional @readonly CRotation[] rotation;
|
|
|
|
@optional @readonly CRotation[] rotation;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct ThreadData
|
|
|
|
//EntityTemplate* laser_tmpl;
|
|
|
|
{
|
|
|
|
|
|
|
|
EntityTemplate* laser_tmpl;
|
|
|
|
|
|
|
|
CLocation* laser_location;
|
|
|
|
|
|
|
|
CVelocity* laser_velocity;
|
|
|
|
|
|
|
|
CGuild* laser_guild;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EntityTemplate* fire_tmpl;
|
|
|
|
EntityTemplate* fire_tmpl;
|
|
|
|
CLocation* fire_location;
|
|
|
|
|
|
|
|
CVelocity* fire_velocity;
|
|
|
|
|
|
|
|
CRotation* fire_rotation;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ThreadData[] threads;
|
|
|
|
//EntityTemplate*[5] bullet_tmpl;
|
|
|
|
|
|
|
|
|
|
|
|
///Called inside "registerSystem" function
|
|
|
|
///Called inside "registerSystem" function
|
|
|
|
void onCreate()
|
|
|
|
void onCreate()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
threads = Mallocator.makeArray!ThreadData(32);
|
|
|
|
/*bullet_tmpl[0] = launcher.manager.allocateTemplate(
|
|
|
|
threads[0].laser_tmpl = launcher.manager.allocateTemplate(
|
|
|
|
|
|
|
|
[CLocation.component_id, CTexture.component_id, CVelocity.component_id,
|
|
|
|
[CLocation.component_id, CTexture.component_id, CVelocity.component_id,
|
|
|
|
CScale.component_id, CLaser.component_id, CGuild.component_id].staticArray
|
|
|
|
CScale.component_id, CBullet.component_id, CGuild.component_id].staticArray
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
bullet_tmpl[0].getComponent!CTexture().coords = vec4(0,24,2,8)*px;
|
|
|
|
|
|
|
|
bullet_tmpl[0].getComponent!CScale().value = vec2(2,8);
|
|
|
|
|
|
|
|
|
|
|
|
CTexture* tex_comp = threads[0].laser_tmpl.getComponent!CTexture;
|
|
|
|
bullet_tmpl[1] = launcher.manager.allocateTemplate(bullet_tmpl[0]);
|
|
|
|
//tex_comp.tex = space_invaders.texture;//laser_tex;
|
|
|
|
bullet_tmpl[2] = launcher.manager.allocateTemplate(bullet_tmpl[0]);
|
|
|
|
tex_comp.coords = vec4(0*px,24*px,2*px,8*px);
|
|
|
|
bullet_tmpl[2].getComponent!CTexture().coords = vec4(64,32,8,16)*px;
|
|
|
|
CScale* scale_comp = threads[0].laser_tmpl.getComponent!CScale;
|
|
|
|
bullet_tmpl[2].getComponent!CScale().value = vec2(8,16);
|
|
|
|
scale_comp.value = vec2(2,8);
|
|
|
|
bullet_tmpl[3] = launcher.manager.allocateTemplate(bullet_tmpl[0]);
|
|
|
|
threads[0].laser_location = threads[0].laser_tmpl.getComponent!CLocation;
|
|
|
|
bullet_tmpl[3].getComponent!CTexture().coords = vec4(56,32,2,2)*px;
|
|
|
|
threads[0].laser_velocity = threads[0].laser_tmpl.getComponent!CVelocity;
|
|
|
|
bullet_tmpl[3].getComponent!CScale().value = vec2(2,2);
|
|
|
|
threads[0].laser_guild = threads[0].laser_tmpl.getComponent!CGuild;
|
|
|
|
// bullet_tmpl[3].getComponent!CTexture().coords = vec4(48,32,8,8)*px;
|
|
|
|
|
|
|
|
// bullet_tmpl[3].getComponent!CScale().value = vec2(8,8);
|
|
|
|
|
|
|
|
bullet_tmpl[4] = launcher.manager.allocateTemplate(bullet_tmpl[0]);*/
|
|
|
|
|
|
|
|
|
|
|
|
threads[0].fire_tmpl = launcher.manager.allocateTemplate(
|
|
|
|
|
|
|
|
|
|
|
|
fire_tmpl = launcher.manager.allocateTemplate(
|
|
|
|
[CLocation.component_id, CTexture.component_id, CScale.component_id,
|
|
|
|
[CLocation.component_id, CTexture.component_id, CScale.component_id,
|
|
|
|
CAnimation.component_id, CParticle.component_id, CRotation.component_id,
|
|
|
|
CAnimation.component_id, CParticle.component_id, CRotation.component_id,
|
|
|
|
CVelocity.component_id, CDamping.component_id].staticArray
|
|
|
|
CVelocity.component_id, CDamping.component_id].staticArray
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
tex_comp = threads[0].fire_tmpl.getComponent!CTexture;
|
|
|
|
fire_tmpl.getComponent!CTexture().coords = vec4(96,64,8,16)*px;
|
|
|
|
//tex_comp.tex = space_invaders.texture;//laser_tex;
|
|
|
|
fire_tmpl.getComponent!CScale().value = vec2(8,16);
|
|
|
|
tex_comp.coords = vec4(96*px,64*px,8*px,16*px);
|
|
|
|
fire_tmpl.getComponent!(CParticle).life = 300;
|
|
|
|
scale_comp = threads[0].fire_tmpl.getComponent!CScale;
|
|
|
|
*fire_tmpl.getComponent!(CAnimation) = CAnimation(fire_frames, 0, 3);
|
|
|
|
scale_comp.value = vec2(8,16);
|
|
|
|
|
|
|
|
threads[0].fire_location = threads[0].fire_tmpl.getComponent!CLocation;
|
|
|
|
|
|
|
|
threads[0].fire_rotation = threads[0].fire_tmpl.getComponent!CRotation;
|
|
|
|
|
|
|
|
threads[0].fire_velocity = threads[0].fire_tmpl.getComponent!CVelocity;
|
|
|
|
|
|
|
|
threads[0].fire_tmpl.getComponent!(CParticle).life = 300;
|
|
|
|
|
|
|
|
*threads[0].fire_tmpl.getComponent!(CAnimation) = CAnimation(fire_frames, 0, 3);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach(ref ThreadData thread;threads[1..$])
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
thread.laser_tmpl = launcher.manager.allocateTemplate(threads[0].laser_tmpl);
|
|
|
|
|
|
|
|
thread.laser_location = thread.laser_tmpl.getComponent!CLocation;
|
|
|
|
|
|
|
|
thread.laser_velocity = thread.laser_tmpl.getComponent!CVelocity;
|
|
|
|
|
|
|
|
thread.laser_guild = thread.laser_tmpl.getComponent!CGuild;
|
|
|
|
|
|
|
|
thread.fire_tmpl = launcher.manager.allocateTemplate(threads[0].fire_tmpl);
|
|
|
|
|
|
|
|
thread.fire_location = thread.fire_tmpl.getComponent!CLocation;
|
|
|
|
|
|
|
|
thread.fire_rotation = thread.fire_tmpl.getComponent!CRotation;
|
|
|
|
|
|
|
|
thread.fire_velocity = thread.fire_tmpl.getComponent!CVelocity;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//laser_location = space_invaders.laser_tmpl.getComponent!CLocation;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void onDestroy()
|
|
|
|
void onDestroy()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
foreach(ref ThreadData thread;threads[1..$])
|
|
|
|
//launcher.manager.freeTemplate(laser_tmpl);
|
|
|
|
|
|
|
|
/*foreach (EntityTemplate* tmpl; bullet_tmpl)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
launcher.manager.freeTemplate(thread.laser_tmpl);
|
|
|
|
launcher.manager.freeTemplate(tmpl);
|
|
|
|
}
|
|
|
|
}*/
|
|
|
|
Mallocator.dispose(threads);
|
|
|
|
launcher.manager.freeTemplate(fire_tmpl);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool onBegin()
|
|
|
|
bool onBegin()
|
|
|
|
@ -1164,7 +1153,6 @@ struct LaserShootingSystem
|
|
|
|
|
|
|
|
|
|
|
|
void onUpdate(EntitiesData data)
|
|
|
|
void onUpdate(EntitiesData data)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ThreadData* thread = &threads[data.thread_id];
|
|
|
|
|
|
|
|
//conditional branch for whole entities block
|
|
|
|
//conditional branch for whole entities block
|
|
|
|
if(shoot || data.auto_shoot)
|
|
|
|
if(shoot || data.auto_shoot)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@ -1174,58 +1162,65 @@ struct LaserShootingSystem
|
|
|
|
laser.shoot_time += launcher.delta_time;
|
|
|
|
laser.shoot_time += launcher.delta_time;
|
|
|
|
while(laser.shoot_time > CWeapon.levels[laser.level - 1].reload_time)
|
|
|
|
while(laser.shoot_time > CWeapon.levels[laser.level - 1].reload_time)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
CVelocity laser_velocity;
|
|
|
|
|
|
|
|
CGuild laser_guild;
|
|
|
|
|
|
|
|
CLocation laser_location;
|
|
|
|
|
|
|
|
CVelocity fire_velocity;
|
|
|
|
|
|
|
|
CLocation fire_location;
|
|
|
|
|
|
|
|
CRotation fire_rotation;
|
|
|
|
|
|
|
|
|
|
|
|
laser.shoot_time -= CWeapon.levels[laser.level - 1].reload_time;
|
|
|
|
laser.shoot_time -= CWeapon.levels[laser.level - 1].reload_time;
|
|
|
|
thread.laser_location.value = data.location[i];
|
|
|
|
laser_location.value = data.location[i];
|
|
|
|
|
|
|
|
|
|
|
|
thread.laser_velocity.value = vec2((randomf()*2-1) * CWeapon.levels[laser.level - 1].dispersion,1);//data.shoot_direction[i].direction == Direction.up ? 1.0 : -1.0);
|
|
|
|
laser_velocity.value = vec2((randomf()*2-1) * CWeapon.levels[laser.level - 1].dispersion,1);//data.shoot_direction[i].direction == Direction.up ? 1.0 : -1.0);
|
|
|
|
if(data.shoot_direction && data.shoot_direction[i].direction == Direction.down)thread.laser_velocity.y = -1;
|
|
|
|
if(data.shoot_direction && data.shoot_direction[i].direction == Direction.down)laser_velocity.y = -1;
|
|
|
|
|
|
|
|
|
|
|
|
thread.laser_guild.guild = data.guild[i].guild;
|
|
|
|
laser_guild.guild = data.guild[i].guild;
|
|
|
|
|
|
|
|
|
|
|
|
if(laser.level < 3)thread.laser_velocity.value = thread.laser_velocity.value * 0.4f;
|
|
|
|
if(laser.level < 3)laser_velocity.value = laser_velocity.value * 0.4f;
|
|
|
|
|
|
|
|
|
|
|
|
if(data.velocity)
|
|
|
|
if(data.velocity)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
thread.fire_velocity.value = data.velocity[i];
|
|
|
|
fire_velocity.value = data.velocity[i];
|
|
|
|
//thread.laser_velocity.value += data.velocity[i] * 0.5;
|
|
|
|
//laser_velocity.value += data.velocity[i] * 0.5;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else thread.fire_velocity.value = vec2(0,0);
|
|
|
|
else fire_velocity.value = vec2(0,0);
|
|
|
|
|
|
|
|
|
|
|
|
thread.fire_location.value = data.location[i];
|
|
|
|
fire_location.value = data.location[i];
|
|
|
|
if(data.shoot_direction[i].direction == Direction.down)
|
|
|
|
if(data.shoot_direction[i].direction == Direction.down)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
thread.fire_rotation.value = PI;
|
|
|
|
fire_rotation.value = PI;
|
|
|
|
//thread.fire_location.value.y -= 16;
|
|
|
|
//fire_location.value.y -= 16;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
thread.fire_rotation.value = 0;
|
|
|
|
fire_rotation.value = 0;
|
|
|
|
//thread.fire_location.value.y += 24;
|
|
|
|
//fire_location.value.y += 24;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(data.rotation)
|
|
|
|
if(data.rotation)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
float sinn = sinf(data.rotation[i]);
|
|
|
|
float sinn = sinf(data.rotation[i]);
|
|
|
|
float coss = cosf(data.rotation[i]);
|
|
|
|
float coss = cosf(data.rotation[i]);
|
|
|
|
float x = thread.laser_velocity.y*sinn + thread.laser_velocity.x*coss;
|
|
|
|
float x = laser_velocity.y*sinn + laser_velocity.x*coss;
|
|
|
|
float y = thread.laser_velocity.y*coss + thread.laser_velocity.x*sinn;
|
|
|
|
float y = laser_velocity.y*coss + laser_velocity.x*sinn;
|
|
|
|
thread.laser_velocity.value = vec2(x,y);
|
|
|
|
laser_velocity.value = vec2(x,y);
|
|
|
|
thread.fire_rotation.value = data.rotation[i];
|
|
|
|
fire_rotation.value = data.rotation[i];
|
|
|
|
if(data.weapon_location)
|
|
|
|
if(data.weapon_location)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
vec2 rel_pos = vec2(data.weapon_location[i].rel_pos.y*sinn+data.weapon_location[i].rel_pos.x*coss, data.weapon_location[i].rel_pos.y*coss+data.weapon_location[i].rel_pos.x*sinn);
|
|
|
|
vec2 rel_pos = vec2(data.weapon_location[i].rel_pos.y*sinn+data.weapon_location[i].rel_pos.x*coss, data.weapon_location[i].rel_pos.y*coss+data.weapon_location[i].rel_pos.x*sinn);
|
|
|
|
thread.laser_location.value += rel_pos;
|
|
|
|
laser_location.value += rel_pos;
|
|
|
|
thread.fire_location.value += rel_pos;
|
|
|
|
fire_location.value += rel_pos;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(data.weapon_location)
|
|
|
|
else if(data.weapon_location)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
thread.laser_location.value += data.weapon_location[i].rel_pos;
|
|
|
|
laser_location.value += data.weapon_location[i].rel_pos;
|
|
|
|
thread.fire_location.value += data.weapon_location[i].rel_pos;
|
|
|
|
fire_location.value += data.weapon_location[i].rel_pos;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
launcher.manager.addEntity(thread.laser_tmpl);
|
|
|
|
launcher.manager.addEntity(space_invaders.bullet_tmpl[data.laser[i].type],[laser_velocity.ref_, laser_guild.ref_, laser_location.ref_].staticArray);
|
|
|
|
launcher.manager.addEntity(thread.fire_tmpl);
|
|
|
|
launcher.manager.addEntity(fire_tmpl,[fire_location.ref_, fire_rotation.ref_, fire_velocity.ref_].staticArray);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -1287,7 +1282,7 @@ struct LaserCollisionSystem
|
|
|
|
uint length;
|
|
|
|
uint length;
|
|
|
|
const (Entity)[] entity;
|
|
|
|
const (Entity)[] entity;
|
|
|
|
@readonly CLocation[] location;
|
|
|
|
@readonly CLocation[] location;
|
|
|
|
@readonly CLaser[] laser;
|
|
|
|
@readonly CBullet[] laser;
|
|
|
|
@readonly CGuild[] guild;
|
|
|
|
@readonly CGuild[] guild;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -1312,69 +1307,63 @@ struct ParticleEmittingSystem
|
|
|
|
struct EntitiesData
|
|
|
|
struct EntitiesData
|
|
|
|
{
|
|
|
|
{
|
|
|
|
uint length;
|
|
|
|
uint length;
|
|
|
|
uint thread_id;
|
|
|
|
//uint thread_id;
|
|
|
|
CParticleEmitterTime[] emit_time;
|
|
|
|
CParticleEmitterTime[] emit_time;
|
|
|
|
@readonly CLocation[] location;
|
|
|
|
@readonly CLocation[] location;
|
|
|
|
@readonly CParticleEmitter[] emitter;
|
|
|
|
@readonly CParticleEmitter[] emitter;
|
|
|
|
|
|
|
|
|
|
|
|
@optional @readonly CVelocity[] velocity;
|
|
|
|
@optional @readonly CVelocity[] velocity;
|
|
|
|
|
|
|
|
@optional @readonly CDepth[] depth;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct Thread
|
|
|
|
__gshared vec4[] flashes = [vec4(224,0,16,16)*px,vec4(240,0,16,16)*px,vec4(256,0,16,16)*px,vec4(272,0,16,16)*px,vec4(288,0,16,16)*px,
|
|
|
|
{
|
|
|
|
vec4(304,0,16,16)*px,vec4(320,0,16,16)*px];
|
|
|
|
|
|
|
|
|
|
|
|
EntityTemplate*[1] templates;
|
|
|
|
EntityTemplate*[1] templates;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Thread[] threads;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void onCreate()
|
|
|
|
void onCreate()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
threads = Mallocator.makeArray!Thread(32);
|
|
|
|
templates[0] = launcher.manager.allocateTemplate(
|
|
|
|
|
|
|
|
|
|
|
|
threads[0].templates[0] = launcher.manager.allocateTemplate(
|
|
|
|
|
|
|
|
[CLocation.component_id, CTexture.component_id, CScale.component_id,
|
|
|
|
[CLocation.component_id, CTexture.component_id, CScale.component_id,
|
|
|
|
CAnimation.component_id, CParticle.component_id, CRotation.component_id,
|
|
|
|
CAnimation.component_id, CParticle.component_id, CRotation.component_id,
|
|
|
|
CVelocity.component_id, CDamping.component_id].staticArray);
|
|
|
|
CVelocity.component_id, CDamping.component_id, CDepth.component_id].staticArray);
|
|
|
|
|
|
|
|
*templates[0].getComponent!CAnimation() = CAnimation(flashes,0,2);
|
|
|
|
foreach(ref thread;threads[1 .. $])
|
|
|
|
*templates[0].getComponent!CParticle() = CParticle(350);
|
|
|
|
{
|
|
|
|
//*templates[0].getComponent!CDepth() = CDepth(-3);
|
|
|
|
thread.templates[0] = launcher.manager.allocateTemplate(threads[0].templates[0]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void onDestroy()
|
|
|
|
void onDestroy()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
foreach(ref thread;threads[1 .. $])
|
|
|
|
foreach(tmpl; templates)
|
|
|
|
{
|
|
|
|
|
|
|
|
foreach(tmpl; thread.templates)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
launcher.manager.freeTemplate(tmpl);
|
|
|
|
launcher.manager.freeTemplate(tmpl);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Mallocator.dispose(threads);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void onUpdate(EntitiesData data)
|
|
|
|
void onUpdate(EntitiesData data)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Thread* thread = &threads[data.thread_id];
|
|
|
|
|
|
|
|
foreach(i;0..data.length)
|
|
|
|
foreach(i;0..data.length)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
data.emit_time[i].time -= launcher.delta_time;
|
|
|
|
data.emit_time[i].time -= launcher.delta_time;
|
|
|
|
while(data.emit_time[i].time < 0)
|
|
|
|
while(data.emit_time[i].time < 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
CVelocity velocity;
|
|
|
|
|
|
|
|
CDepth depth;
|
|
|
|
|
|
|
|
|
|
|
|
CParticleEmitter* emitter = &data.emitter[i];
|
|
|
|
CParticleEmitter* emitter = &data.emitter[i];
|
|
|
|
data.emit_time[i].time += emitter.time_range.x + randomf() * emitter.time_range.y;
|
|
|
|
data.emit_time[i].time += emitter.time_range.x + randomf() * emitter.time_range.y;
|
|
|
|
|
|
|
|
|
|
|
|
EntityTemplate* tmpl = thread.templates[emitter.tmpl_id];
|
|
|
|
|
|
|
|
CLocation* location = tmpl.getComponent!CLocation;
|
|
|
|
|
|
|
|
if(location)location.value = data.location[i];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(data.velocity)
|
|
|
|
if(data.velocity)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
CVelocity* velocity = tmpl.getComponent!CVelocity;
|
|
|
|
velocity.value = data.velocity[i];
|
|
|
|
if(velocity)velocity.value = data.velocity[i];
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
launcher.manager.addEntity(tmpl);
|
|
|
|
|
|
|
|
|
|
|
|
if(data.depth)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
depth.depth = data.depth[i];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
launcher.manager.addEntity(templates[0],[data.location[i].ref_,velocity.ref_,depth.ref_].staticArray);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -1617,10 +1606,7 @@ struct HitPointsSystem
|
|
|
|
__gshared vec4[] explosion_laser_frames = [vec4(80,128,16,16)*px,vec4(96,128,16,16)*px,vec4(112,128,16,16)*px,vec4(128,128,16,16)*px,vec4(144,128,16,16)*px,vec4(160,128,16,16)*px,vec4(176,128,16,16)*px,vec4(192,128,16,16)*px,vec4(208,128,16,16)*px];
|
|
|
|
__gshared vec4[] explosion_laser_frames = [vec4(80,128,16,16)*px,vec4(96,128,16,16)*px,vec4(112,128,16,16)*px,vec4(128,128,16,16)*px,vec4(144,128,16,16)*px,vec4(160,128,16,16)*px,vec4(176,128,16,16)*px,vec4(192,128,16,16)*px,vec4(208,128,16,16)*px];
|
|
|
|
|
|
|
|
|
|
|
|
EntityTemplate* upgrade_tmpl;
|
|
|
|
EntityTemplate* upgrade_tmpl;
|
|
|
|
CLocation* upgrade_location;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EntityTemplate* explosion_tmpl;
|
|
|
|
EntityTemplate* explosion_tmpl;
|
|
|
|
CLocation* explosion_location;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct EntitiesData
|
|
|
|
struct EntitiesData
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@ -1629,29 +1615,31 @@ struct HitPointsSystem
|
|
|
|
|
|
|
|
|
|
|
|
void onCreate()
|
|
|
|
void onCreate()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
upgrade_tmpl = launcher.manager.allocateTemplate([CVelocity.component_id, CLocation.component_id, CTexture.component_id, CScale.component_id, CUpgrade.component_id, CAnimation.component_id, CAnimationLooped.component_id].staticArray);
|
|
|
|
upgrade_tmpl = launcher.manager.allocateTemplate(
|
|
|
|
CTexture* tex_comp = upgrade_tmpl.getComponent!CTexture;
|
|
|
|
[CVelocity.component_id, CLocation.component_id, CTexture.component_id,
|
|
|
|
|
|
|
|
CScale.component_id, CUpgrade.component_id, CAnimation.component_id,
|
|
|
|
|
|
|
|
CAnimationLooped.component_id].staticArray);
|
|
|
|
//tex_comp.tex = space_invaders.texture;//ship_tex;
|
|
|
|
//tex_comp.tex = space_invaders.texture;//ship_tex;
|
|
|
|
tex_comp.coords = vec4(0*px,32*px,16*px,16*px);
|
|
|
|
upgrade_tmpl.getComponent!CTexture().coords = 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);
|
|
|
|
CVelocity* vel_comp = upgrade_tmpl.getComponent!CVelocity;
|
|
|
|
upgrade_tmpl.getComponent!CVelocity().value = vec2(0,-0.1);
|
|
|
|
vel_comp.value = vec2(0,-0.1);
|
|
|
|
|
|
|
|
upgrade_location = upgrade_tmpl.getComponent!CLocation;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
explosion_tmpl = launcher.manager.allocateTemplate([CDepth.component_id, CParticle.component_id, CLocation.component_id, CTexture.component_id, CScale.component_id, CAnimation.component_id].staticArray);
|
|
|
|
explosion_tmpl = launcher.manager.allocateTemplate(
|
|
|
|
|
|
|
|
[CDepth.component_id, CParticle.component_id, CLocation.component_id,
|
|
|
|
|
|
|
|
CTexture.component_id, CScale.component_id, CAnimation.component_id].staticArray);
|
|
|
|
//explosion_tmpl.getComponent!(CTexture).tex = space_invaders.texture;
|
|
|
|
//explosion_tmpl.getComponent!(CTexture).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;
|
|
|
|
*explosion_tmpl.getComponent!CDepth = -1;
|
|
|
|
*explosion_tmpl.getComponent!CDepth = -1;
|
|
|
|
explosion_location = explosion_tmpl.getComponent!CLocation;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void onDestroy()
|
|
|
|
void onDestroy()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
launcher.manager.freeTemplate(upgrade_tmpl);
|
|
|
|
launcher.manager.freeTemplate(upgrade_tmpl);
|
|
|
|
|
|
|
|
launcher.manager.freeTemplate(explosion_tmpl);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void handleEvent(Entity* entity, EDamage event)
|
|
|
|
/*void handleEvent(Entity* entity, EDamage event)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
CHitPoints* hp = entity.getComponent!CHitPoints;
|
|
|
|
CHitPoints* hp = entity.getComponent!CHitPoints;
|
|
|
|
if(*hp <= 0)return;
|
|
|
|
if(*hp <= 0)return;
|
|
|
|
@ -1663,7 +1651,7 @@ struct HitPointsSystem
|
|
|
|
}
|
|
|
|
}
|
|
|
|
CHitMark* hit_mark = entity.getComponent!CHitMark;
|
|
|
|
CHitMark* hit_mark = entity.getComponent!CHitMark;
|
|
|
|
if(hit_mark)hit_mark.value = 127;
|
|
|
|
if(hit_mark)hit_mark.value = 127;
|
|
|
|
}
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
|
|
void handleEvent(Entity* entity, EBulletHit event)
|
|
|
|
void handleEvent(Entity* entity, EBulletHit event)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@ -1690,11 +1678,9 @@ struct HitPointsSystem
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(randomRange(0, 1000) < 5)
|
|
|
|
if(randomRange(0, 1000) < 5)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
*upgrade_location = *location;
|
|
|
|
launcher.manager.addEntity(upgrade_tmpl,[location.ref_].staticArray);
|
|
|
|
launcher.manager.addEntity(upgrade_tmpl);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*explosion_location = *location;
|
|
|
|
launcher.manager.addEntity(explosion_tmpl,[location.ref_].staticArray);
|
|
|
|
launcher.manager.addEntity(explosion_tmpl);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
launcher.manager.removeEntity(entity.id);
|
|
|
|
launcher.manager.removeEntity(entity.id);
|
|
|
|
@ -1720,6 +1706,55 @@ struct ChildDestroySystem
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct ShootWaveSystem
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
mixin ECS.System;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct EntitiesData
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
CLocation[] location;
|
|
|
|
|
|
|
|
CShootWaveUponDeath[] shoot_wave;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vec2[] dirs;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void onCreate()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
enum count = 24;
|
|
|
|
|
|
|
|
dirs = Mallocator.makeArray!vec2(count);
|
|
|
|
|
|
|
|
float step = 2 * PI / cast(float)count;
|
|
|
|
|
|
|
|
foreach(i;0..count)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
float angle = step * i;
|
|
|
|
|
|
|
|
dirs[i] = vec2(sinf(angle),cosf(angle)) * 0.2;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void onDestroy()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Mallocator.dispose(dirs);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void handleEvent(Entity* entity, EDeath event)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CShootWaveUponDeath* wave = entity.getComponent!CShootWaveUponDeath;
|
|
|
|
|
|
|
|
CLocation* location = entity.getComponent!CLocation;
|
|
|
|
|
|
|
|
CGuild* guild = entity.getComponent!CGuild;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//LaserShootingSystem.bullet_tmpl
|
|
|
|
|
|
|
|
EntityTemplate* tmpl = space_invaders.bullet_tmpl[wave.bullet_type];
|
|
|
|
|
|
|
|
foreach(dir;dirs)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(guild)launcher.manager.addEntity(tmpl,[location.ref_,guild.ref_,CVelocity(dir).ref_].staticArray);
|
|
|
|
|
|
|
|
else launcher.manager.addEntity(tmpl,[location.ref_,CVelocity(dir).ref_].staticArray);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//launcher.manager.addEntity(tmpl);//,[location.ref_].staticArray);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//launcher.manager.addEntity(space_invaders.bullet_tmpl[0]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct PartsDestroySystem
|
|
|
|
struct PartsDestroySystem
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mixin ECS.System;
|
|
|
|
mixin ECS.System;
|
|
|
|
@ -1738,9 +1773,14 @@ struct PartsDestroySystem
|
|
|
|
flashes_emitter = launcher.manager.allocateTemplate(
|
|
|
|
flashes_emitter = launcher.manager.allocateTemplate(
|
|
|
|
[
|
|
|
|
[
|
|
|
|
CVelocity.component_id, CLocation.component_id, CParticleEmitter.component_id,
|
|
|
|
CVelocity.component_id, CLocation.component_id, CParticleEmitter.component_id,
|
|
|
|
CParticleEmitterTime.component_id, CTargetParent.component_id
|
|
|
|
CParticleEmitterTime.component_id, CTargetParent.component_id, CDepth.component_id
|
|
|
|
].staticArray);
|
|
|
|
].staticArray);
|
|
|
|
*flashes_emitter.getComponent!CParticleEmitter() = CParticleEmitter(vec2(0,0), vec2(400,400), 0);
|
|
|
|
*flashes_emitter.getComponent!CParticleEmitter() = CParticleEmitter(vec2(0,0), vec2(800,1600), 0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void onDestroy()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
launcher.manager.freeTemplate(flashes_emitter);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void handleEvent(Entity* entity, EDestroyedChild event)
|
|
|
|
void handleEvent(Entity* entity, EDestroyedChild event)
|
|
|
|
@ -1752,17 +1792,24 @@ struct PartsDestroySystem
|
|
|
|
if(init.type == CInit.Type.boss)
|
|
|
|
if(init.type == CInit.Type.boss)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
CChildren* children = entity.getComponent!CChildren;
|
|
|
|
CChildren* children = entity.getComponent!CChildren;
|
|
|
|
foreach(EntityID child; children.childern)
|
|
|
|
foreach(ref EntityID child; children.childern)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(child == event.id)
|
|
|
|
if(child == event.id)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Entity* child_entity = launcher.manager.getEntity(child);
|
|
|
|
Entity* child_entity = launcher.manager.getEntity(child);
|
|
|
|
if(child_entity)
|
|
|
|
if(child_entity)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
CLocation location;
|
|
|
|
CTargetParent* target_parent = child_entity.getComponent!CTargetParent;
|
|
|
|
CTargetParent* target_parent = child_entity.getComponent!CTargetParent;
|
|
|
|
|
|
|
|
CDepth* target_depth = child_entity.getComponent!CDepth;
|
|
|
|
|
|
|
|
CLocation* target_location = child_entity.getComponent!CLocation;
|
|
|
|
|
|
|
|
//CVelocity* velocity = child_entity.getComponent!CTargetParent;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(target_location)location = *target_location;
|
|
|
|
|
|
|
|
|
|
|
|
*flashes_emitter.getComponent!CTargetParent() = *target_parent;
|
|
|
|
*flashes_emitter.getComponent!CTargetParent() = *target_parent;
|
|
|
|
launcher.manager.addEntity(flashes_emitter);
|
|
|
|
if(target_depth)child = launcher.manager.addEntity(flashes_emitter, [target_depth.ref_, location.ref_].staticArray).id;
|
|
|
|
|
|
|
|
else child = launcher.manager.addEntity(flashes_emitter, [location.ref_].staticArray).id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -1793,7 +1840,7 @@ struct ClampPositionSystem
|
|
|
|
|
|
|
|
|
|
|
|
@optional @readonly CColliderScale[] collider_scale;
|
|
|
|
@optional @readonly CColliderScale[] collider_scale;
|
|
|
|
@optional @readonly CScale[] scale;
|
|
|
|
@optional @readonly CScale[] scale;
|
|
|
|
@optional const (CLaser)[] laser;
|
|
|
|
@optional const (CBullet)[] laser;
|
|
|
|
@optional const (CUpgrade)[] upgrade;
|
|
|
|
@optional const (CUpgrade)[] upgrade;
|
|
|
|
//@optional CVelocity[] velocity;
|
|
|
|
//@optional CVelocity[] velocity;
|
|
|
|
//@optional const (CSideMove)[] side_move;
|
|
|
|
//@optional const (CSideMove)[] side_move;
|
|
|
|
@ -1891,7 +1938,7 @@ struct MovementSystem
|
|
|
|
const (CVelocity)[] velocity;
|
|
|
|
const (CVelocity)[] velocity;
|
|
|
|
//components are treated as required by default
|
|
|
|
//components are treated as required by default
|
|
|
|
CLocation[] locations;
|
|
|
|
CLocation[] locations;
|
|
|
|
//@optional const (CLaser)[] laser;
|
|
|
|
//@optional const (CBullet)[] laser;
|
|
|
|
const (Entity)[] entities;
|
|
|
|
const (Entity)[] entities;
|
|
|
|
|
|
|
|
|
|
|
|
//@optional CSideMove[] side_move;
|
|
|
|
//@optional CSideMove[] side_move;
|
|
|
|
@ -1927,8 +1974,10 @@ struct AnimationSystem
|
|
|
|
foreach(i;0..data.length)
|
|
|
|
foreach(i;0..data.length)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
data.animation[i].time += dt * data.animation[i].speed;
|
|
|
|
data.animation[i].time += dt * data.animation[i].speed;
|
|
|
|
while(data.animation[i].time >= data.animation[i].frames.length)data.animation[i].time -= cast(float)data.animation[i].frames.length;
|
|
|
|
while(cast(uint)data.animation[i].time >= data.animation[i].frames.length)data.animation[i].time -= cast(float)data.animation[i].frames.length;
|
|
|
|
data.texture[i].coords = data.animation[i].frames[cast(int)(data.animation[i].time)];
|
|
|
|
if(cast(uint)(data.animation[i].time) >= data.animation[i].frames.length)assert(0);
|
|
|
|
|
|
|
|
uint index = cast(uint)(data.animation[i].time);
|
|
|
|
|
|
|
|
if(index < data.animation[i].frames.length)data.texture[i].coords = data.animation[i].frames[index];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
@ -1936,8 +1985,9 @@ struct AnimationSystem
|
|
|
|
foreach(i;0..data.length)
|
|
|
|
foreach(i;0..data.length)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
data.animation[i].time += dt * data.animation[i].speed;
|
|
|
|
data.animation[i].time += dt * data.animation[i].speed;
|
|
|
|
if(data.animation[i].time >= data.animation[i].frames.length)data.animation[i].time = data.animation[i].frames.length - 0.1;
|
|
|
|
if(cast(uint)data.animation[i].time >= data.animation[i].frames.length)data.animation[i].time = data.animation[i].frames.length - 0.9;
|
|
|
|
data.texture[i].coords = data.animation[i].frames[cast(int)(data.animation[i].time)];
|
|
|
|
uint index = cast(uint)(data.animation[i].time);
|
|
|
|
|
|
|
|
if(index < data.animation[i].frames.length)data.texture[i].coords = data.animation[i].frames[index];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -2070,6 +2120,66 @@ struct CShipIterator
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*struct SpawnUponDeathSystem
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
mixin ECS.System;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct EntitiesData
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
@readonly CSpawnUponDeath[] spawn;
|
|
|
|
|
|
|
|
@optional CTargetParent[] parent;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EntityTemplate* flashes_emitter;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void onCreate()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
flashes_emitter = launcher.manager.allocateTemplate(
|
|
|
|
|
|
|
|
[
|
|
|
|
|
|
|
|
CVelocity.component_id, CLocation.component_id, CParticleEmitter.component_id,
|
|
|
|
|
|
|
|
CParticleEmitterTime.component_id, CTargetParent.component_id
|
|
|
|
|
|
|
|
].staticArray);
|
|
|
|
|
|
|
|
*flashes_emitter.getComponent!CParticleEmitter() = CParticleEmitter(vec2(0,0), vec2(400,400), 0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void onDestroy()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
launcher.manager.freeTemplate(flashes_emitter);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void onRemoveEntity(EntitiesData data)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
//CSpawnUponDeath[] spawn =
|
|
|
|
|
|
|
|
switch(data.spawn[0].type)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
case CSpawnUponDeath.Type.flashes_emitter:
|
|
|
|
|
|
|
|
if(data.parent)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
/*Entity* parent_entity = launcher.manager.getEntity(data.parent[0].parent);
|
|
|
|
|
|
|
|
CChildren* children = entity.getComponent!CChildren;
|
|
|
|
|
|
|
|
foreach(ref EntityID child; children.childern)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(child == event.id)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Entity* child_entity = launcher.manager.getEntity(child);
|
|
|
|
|
|
|
|
if(child_entity)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
*flashes_emitter.getComponent!CTargetParent = data.parent[0];
|
|
|
|
|
|
|
|
launcher.manager.addEntity(flashes_emitter);
|
|
|
|
|
|
|
|
//child = launcher.manager.addEntity(flashes_emitter);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//void handleEvent(Entity* entity, )
|
|
|
|
|
|
|
|
}//*/
|
|
|
|
|
|
|
|
|
|
|
|
extern(C) float sqrtf(float x) @nogc nothrow @system;
|
|
|
|
extern(C) float sqrtf(float x) @nogc nothrow @system;
|
|
|
|
extern(C) float acosf(float x) @nogc nothrow @system;
|
|
|
|
extern(C) float acosf(float x) @nogc nothrow @system;
|
|
|
|
extern(C) float sinf(float x) @nogc nothrow @system;
|
|
|
|
extern(C) float sinf(float x) @nogc nothrow @system;
|
|
|
|
@ -2198,7 +2308,7 @@ void spaceInvadersStart()
|
|
|
|
launcher.manager.registerComponent!CAutoShoot;
|
|
|
|
launcher.manager.registerComponent!CAutoShoot;
|
|
|
|
launcher.manager.registerComponent!CWeapon;
|
|
|
|
launcher.manager.registerComponent!CWeapon;
|
|
|
|
launcher.manager.registerComponent!CVelocity;
|
|
|
|
launcher.manager.registerComponent!CVelocity;
|
|
|
|
launcher.manager.registerComponent!CLaser;
|
|
|
|
launcher.manager.registerComponent!CBullet;
|
|
|
|
launcher.manager.registerComponent!CSideMove;
|
|
|
|
launcher.manager.registerComponent!CSideMove;
|
|
|
|
launcher.manager.registerComponent!CDepth;
|
|
|
|
launcher.manager.registerComponent!CDepth;
|
|
|
|
launcher.manager.registerComponent!CShootGrid;
|
|
|
|
launcher.manager.registerComponent!CShootGrid;
|
|
|
|
@ -2223,6 +2333,8 @@ void spaceInvadersStart()
|
|
|
|
launcher.manager.registerComponent!CColliderScale;
|
|
|
|
launcher.manager.registerComponent!CColliderScale;
|
|
|
|
launcher.manager.registerComponent!CParticleEmitter;
|
|
|
|
launcher.manager.registerComponent!CParticleEmitter;
|
|
|
|
launcher.manager.registerComponent!CParticleEmitterTime;
|
|
|
|
launcher.manager.registerComponent!CParticleEmitterTime;
|
|
|
|
|
|
|
|
launcher.manager.registerComponent!CSpawnUponDeath;
|
|
|
|
|
|
|
|
launcher.manager.registerComponent!CShootWaveUponDeath;
|
|
|
|
|
|
|
|
|
|
|
|
launcher.manager.registerEvent!EChangeDirection;
|
|
|
|
launcher.manager.registerEvent!EChangeDirection;
|
|
|
|
launcher.manager.registerEvent!EDamage;
|
|
|
|
launcher.manager.registerEvent!EDamage;
|
|
|
|
@ -2248,16 +2360,17 @@ void spaceInvadersStart()
|
|
|
|
launcher.manager.registerSystem!ParticleSystem(-100);
|
|
|
|
launcher.manager.registerSystem!ParticleSystem(-100);
|
|
|
|
launcher.manager.registerSystem!AnimationSystem(-100);
|
|
|
|
launcher.manager.registerSystem!AnimationSystem(-100);
|
|
|
|
launcher.manager.registerSystem!DampingSystem(-101);
|
|
|
|
launcher.manager.registerSystem!DampingSystem(-101);
|
|
|
|
launcher.manager.registerSystem!MoveToParentTargetSystem(99);
|
|
|
|
launcher.manager.registerSystem!MoveToParentTargetSystem(-98);
|
|
|
|
launcher.manager.registerSystem!ParentOwnerSystem(-101);
|
|
|
|
launcher.manager.registerSystem!ParentOwnerSystem(-101);
|
|
|
|
launcher.manager.registerSystem!ShipWeaponSystem(-100);
|
|
|
|
launcher.manager.registerSystem!ShipWeaponSystem(-100);
|
|
|
|
launcher.manager.registerSystem!ParticleEmittingSystem(-100);
|
|
|
|
launcher.manager.registerSystem!ParticleEmittingSystem(-95);
|
|
|
|
|
|
|
|
|
|
|
|
launcher.manager.registerSystem!RotateToTargetSystem(-100);
|
|
|
|
launcher.manager.registerSystem!RotateToTargetSystem(-100);
|
|
|
|
launcher.manager.registerSystem!ShipTargetSystem(-110);
|
|
|
|
launcher.manager.registerSystem!ShipTargetSystem(-110);
|
|
|
|
launcher.manager.registerSystem!CShipIterator(-100);
|
|
|
|
launcher.manager.registerSystem!CShipIterator(-100);
|
|
|
|
launcher.manager.registerSystem!PartsDestroySystem(-80);
|
|
|
|
launcher.manager.registerSystem!PartsDestroySystem(-80);
|
|
|
|
launcher.manager.registerSystem!ChildDestroySystem(-110);
|
|
|
|
launcher.manager.registerSystem!ChildDestroySystem(-110);
|
|
|
|
|
|
|
|
launcher.manager.registerSystem!ShootWaveSystem(-100);
|
|
|
|
|
|
|
|
//launcher.manager.registerSystem!SpawnUponDeathSystem(-110);
|
|
|
|
|
|
|
|
|
|
|
|
launcher.manager.endRegister();
|
|
|
|
launcher.manager.endRegister();
|
|
|
|
|
|
|
|
|
|
|
|
@ -2267,19 +2380,26 @@ void spaceInvadersStart()
|
|
|
|
launcher.gui_manager.addSystem(MovementSystem.system_id,"Movement System");
|
|
|
|
launcher.gui_manager.addSystem(MovementSystem.system_id,"Movement System");
|
|
|
|
launcher.gui_manager.addSystem(ClampPositionSystem.system_id,"Clamp Position System");
|
|
|
|
launcher.gui_manager.addSystem(ClampPositionSystem.system_id,"Clamp Position System");
|
|
|
|
launcher.gui_manager.addSystem(ChangeDirectionSystem.system_id,"Change Direction System");
|
|
|
|
launcher.gui_manager.addSystem(ChangeDirectionSystem.system_id,"Change Direction System");
|
|
|
|
launcher.gui_manager.addSystem(LaserCollisionSystem.system_id,"Draw System");
|
|
|
|
launcher.gui_manager.addSystem(LaserCollisionSystem.system_id,"Laser Collision System");
|
|
|
|
launcher.gui_manager.addSystem(ShootGridManager.system_id,"Shoot Grid Manager");
|
|
|
|
launcher.gui_manager.addSystem(ShootGridManager.system_id,"Shoot Grid Manager");
|
|
|
|
launcher.gui_manager.addSystem(ShootGridCleaner.system_id,"Shoot Grid Cleaner");
|
|
|
|
launcher.gui_manager.addSystem(ShootGridCleaner.system_id,"Shoot Grid Cleaner");
|
|
|
|
launcher.gui_manager.addSystem(HitPointsSystem.system_id,"Hit Points System");
|
|
|
|
launcher.gui_manager.addSystem(HitPointsSystem.system_id,"Hit Points System");
|
|
|
|
launcher.gui_manager.addSystem(HitMarkingSystem.system_id,"Hit Matking System");
|
|
|
|
launcher.gui_manager.addSystem(HitMarkingSystem.system_id,"Hit Marking System");
|
|
|
|
launcher.gui_manager.addSystem(UpgradeCollisionSystem.system_id,"Upgrade Collision System");
|
|
|
|
launcher.gui_manager.addSystem(UpgradeCollisionSystem.system_id,"Upgrade Collision System");
|
|
|
|
launcher.gui_manager.addSystem(UpgradeSystem.system_id,"Upgrade System");
|
|
|
|
launcher.gui_manager.addSystem(UpgradeSystem.system_id,"Upgrade System");
|
|
|
|
launcher.gui_manager.addSystem(ParticleSystem.system_id,"Particle System");
|
|
|
|
launcher.gui_manager.addSystem(ParticleSystem.system_id,"Particle System");
|
|
|
|
launcher.gui_manager.addSystem(AnimationSystem.system_id,"Animation System");
|
|
|
|
launcher.gui_manager.addSystem(AnimationSystem.system_id,"Animation System");
|
|
|
|
launcher.gui_manager.addSystem(DampingSystem.system_id,"Damping System");
|
|
|
|
launcher.gui_manager.addSystem(DampingSystem.system_id,"Damping System");
|
|
|
|
launcher.gui_manager.addSystem(MoveToParentTargetSystem.system_id,"Move To Target System");
|
|
|
|
launcher.gui_manager.addSystem(MoveToParentTargetSystem.system_id,"Move To Target System");
|
|
|
|
launcher.gui_manager.addSystem(ParentOwnerSystem.system_id,"Parent Owner System System");
|
|
|
|
launcher.gui_manager.addSystem(ParentOwnerSystem.system_id,"Parent Owner System");
|
|
|
|
launcher.gui_manager.addSystem(ShipWeaponSystem.system_id,"Ship Weapon System");
|
|
|
|
launcher.gui_manager.addSystem(ShipWeaponSystem.system_id,"Ship Weapon System");
|
|
|
|
|
|
|
|
launcher.gui_manager.addSystem(ParticleEmittingSystem.system_id,"Particle Emitting System");
|
|
|
|
|
|
|
|
launcher.gui_manager.addSystem(RotateToTargetSystem.system_id,"Rotate To Target System");
|
|
|
|
|
|
|
|
launcher.gui_manager.addSystem(ShipTargetSystem.system_id,"Ship Target System");
|
|
|
|
|
|
|
|
launcher.gui_manager.addSystem(PartsDestroySystem.system_id,"Parts Destroy System");
|
|
|
|
|
|
|
|
launcher.gui_manager.addSystem(ChildDestroySystem.system_id,"Child Destroy System");
|
|
|
|
|
|
|
|
launcher.gui_manager.addSystem(ShootWaveSystem.system_id,"Shoot Wave System");
|
|
|
|
|
|
|
|
//launcher.gui_manager.addSystem(SpawnUponDeathSystem.system_id,"Child Destroy System");
|
|
|
|
|
|
|
|
|
|
|
|
//launcher.manager.getSystem(CleanSystem.system_id).disable();
|
|
|
|
//launcher.manager.getSystem(CleanSystem.system_id).disable();
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@ -2290,30 +2410,23 @@ void spaceInvadersStart()
|
|
|
|
CShootDirection.component_id, CShootGrid.component_id, CGuild.component_id,
|
|
|
|
CShootDirection.component_id, CShootGrid.component_id, CGuild.component_id,
|
|
|
|
CDamping.component_id, CChildren.component_id, CInit.component_id].staticArray
|
|
|
|
CDamping.component_id, CChildren.component_id, CInit.component_id].staticArray
|
|
|
|
);
|
|
|
|
);
|
|
|
|
//CWeapon* weapon = space_invaders.ship_tmpl.getComponent!CWeapon;
|
|
|
|
space_invaders.ship_tmpl.getComponent!CTexture().coords = vec4(0,80,48,32)*px;
|
|
|
|
//weapon.level = 3;
|
|
|
|
|
|
|
|
space_invaders.ship_tmpl.getComponent!CTexture().coords = vec4(0*px,80*px,48*px,32*px);
|
|
|
|
|
|
|
|
space_invaders.ship_tmpl.getComponent!CScale().value = vec2(48,32);
|
|
|
|
space_invaders.ship_tmpl.getComponent!CScale().value = vec2(48,32);
|
|
|
|
space_invaders.ship_tmpl.getComponent!CLocation().value = vec2(64,64);
|
|
|
|
|
|
|
|
space_invaders.ship_tmpl.getComponent!CHitPoints().value = 1000;
|
|
|
|
space_invaders.ship_tmpl.getComponent!CHitPoints().value = 1000;
|
|
|
|
space_invaders.ship_tmpl.getComponent!CDamping().value = 7;
|
|
|
|
space_invaders.ship_tmpl.getComponent!CDamping().value = 7;
|
|
|
|
space_invaders.ship_tmpl.getComponent!CInit().type = CInit.Type.space_ship;
|
|
|
|
space_invaders.ship_tmpl.getComponent!CInit().type = CInit.Type.space_ship;
|
|
|
|
space_invaders.ship_tmpl.getComponent!CColliderScale().value = vec2(26,24);
|
|
|
|
space_invaders.ship_tmpl.getComponent!CColliderScale().value = vec2(26,24);
|
|
|
|
|
|
|
|
|
|
|
|
launcher.manager.addEntity(space_invaders.ship_tmpl);
|
|
|
|
launcher.manager.addEntity(space_invaders.ship_tmpl,[CLocation(vec2(64,64)).ref_].staticArray);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ushort[6] components = [CLocation.component_id, CTexture.component_id, CVelocity.component_id, CScale.component_id, CLaser.component_id, CGuild.component_id];
|
|
|
|
ushort[6] components = [CLocation.component_id, CTexture.component_id, CVelocity.component_id, CScale.component_id, CBullet.component_id, CGuild.component_id];
|
|
|
|
space_invaders.laser_tmpl = launcher.manager.allocateTemplate(components);
|
|
|
|
space_invaders.laser_tmpl = launcher.manager.allocateTemplate(components);
|
|
|
|
|
|
|
|
|
|
|
|
CTexture* tex_comp = space_invaders.laser_tmpl.getComponent!CTexture;
|
|
|
|
space_invaders.laser_tmpl.getComponent!CTexture().coords = vec4(0,24,2,8)*px;
|
|
|
|
//tex_comp.tex = 0;//space_invaders.texture;//laser_tex;
|
|
|
|
space_invaders.laser_tmpl.getComponent!CScale().value = vec2(2,8);
|
|
|
|
tex_comp.coords = vec4(0*px,24*px,2*px,8*px);
|
|
|
|
space_invaders.laser_tmpl.getComponent!CVelocity().value = vec2(0,1);
|
|
|
|
CScale* scale_comp = space_invaders.laser_tmpl.getComponent!CScale;
|
|
|
|
|
|
|
|
scale_comp.value = vec2(2,8);
|
|
|
|
|
|
|
|
CVelocity* vel_comp = space_invaders.laser_tmpl.getComponent!CVelocity;
|
|
|
|
|
|
|
|
vel_comp.value = vec2(0,1);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
EntityTemplate* enemy_tmpl;
|
|
|
|
EntityTemplate* enemy_tmpl;
|
|
|
|
@ -2333,11 +2446,12 @@ void spaceInvadersStart()
|
|
|
|
CDepth.component_id].staticArray
|
|
|
|
CDepth.component_id].staticArray
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
CTexture* tex_comp = boss_tmpl.getComponent!CTexture;
|
|
|
|
//CTexture* tex_comp = boss_tmpl.getComponent!CTexture;
|
|
|
|
//tex_comp.tex = space_invaders.texture;//ship_tex;
|
|
|
|
//tex_comp.tex = space_invaders.texture;//ship_tex;
|
|
|
|
tex_comp.coords = vec4(128*px,0*px,96*px,48*px);
|
|
|
|
//tex_comp.coords = vec4(128*px,0*px,96*px,48*px);
|
|
|
|
CLocation* loc_comp = boss_tmpl.getComponent!CLocation;
|
|
|
|
//CLocation* loc_comp = boss_tmpl.getComponent!CLocation;
|
|
|
|
loc_comp.value = vec2(64,space_invaders.map_size.y - 16);
|
|
|
|
//loc_comp.value = vec2(64,space_invaders.map_size.y - 16);
|
|
|
|
|
|
|
|
boss_tmpl.getComponent!CTexture().coords = vec4(128,0,96,48)*px;
|
|
|
|
boss_tmpl.getComponent!CGuild().guild = 1;
|
|
|
|
boss_tmpl.getComponent!CGuild().guild = 1;
|
|
|
|
boss_tmpl.getComponent!CInit().type = CInit.Type.boss;
|
|
|
|
boss_tmpl.getComponent!CInit().type = CInit.Type.boss;
|
|
|
|
boss_tmpl.getComponent!CScale().value = vec2(96,48);
|
|
|
|
boss_tmpl.getComponent!CScale().value = vec2(96,48);
|
|
|
|
@ -2354,11 +2468,7 @@ void spaceInvadersStart()
|
|
|
|
CChildren.component_id].staticArray
|
|
|
|
CChildren.component_id].staticArray
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
CTexture* tex_comp = tower_tmpl.getComponent!CTexture;
|
|
|
|
tower_tmpl.getComponent!CTexture().coords = vec4(96,96,16,16)*px;
|
|
|
|
//tex_comp.tex = space_invaders.texture;//ship_tex;
|
|
|
|
|
|
|
|
tex_comp.coords = vec4(96*px,96*px,16*px,16*px);
|
|
|
|
|
|
|
|
CLocation* loc_comp = tower_tmpl.getComponent!CLocation;
|
|
|
|
|
|
|
|
loc_comp.value = vec2(64,space_invaders.map_size.y - 16);
|
|
|
|
|
|
|
|
tower_tmpl.getComponent!CGuild().guild = 1;
|
|
|
|
tower_tmpl.getComponent!CGuild().guild = 1;
|
|
|
|
tower_tmpl.getComponent!CInit().type = CInit.Type.tower;
|
|
|
|
tower_tmpl.getComponent!CInit().type = CInit.Type.tower;
|
|
|
|
tower_tmpl.getComponent!CHitPoints().value = 10;
|
|
|
|
tower_tmpl.getComponent!CHitPoints().value = 10;
|
|
|
|
@ -2373,35 +2483,29 @@ void spaceInvadersStart()
|
|
|
|
CGuild.component_id].staticArray
|
|
|
|
CGuild.component_id].staticArray
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
CTexture* tex_comp = space_invaders.enemy_tmpl.getComponent!CTexture;
|
|
|
|
space_invaders.enemy_tmpl.getComponent!CTexture().coords = vec4(32,32,16,16)*px;
|
|
|
|
//tex_comp.tex = space_invaders.texture;//ship_tex;
|
|
|
|
space_invaders.enemy_tmpl.getComponent!CShootDirection().direction = Direction.down;
|
|
|
|
tex_comp.coords = vec4(32*px,32*px,16*px,16*px);
|
|
|
|
space_invaders.enemy_tmpl.getComponent!CVelocity().value = vec2(0.1,0);
|
|
|
|
CLocation* loc_comp = space_invaders.enemy_tmpl.getComponent!CLocation;
|
|
|
|
|
|
|
|
loc_comp.value = vec2(64,space_invaders.map_size.y - 16);
|
|
|
|
|
|
|
|
CShootDirection* shoot_dir_comp = space_invaders.enemy_tmpl.getComponent!CShootDirection;
|
|
|
|
|
|
|
|
shoot_dir_comp.direction = Direction.down;
|
|
|
|
|
|
|
|
CVelocity* vel_comp = space_invaders.enemy_tmpl.getComponent!CVelocity;
|
|
|
|
|
|
|
|
vel_comp.value = vec2(0.1,0);
|
|
|
|
|
|
|
|
space_invaders.enemy_tmpl.getComponent!CGuild().guild = 1;
|
|
|
|
space_invaders.enemy_tmpl.getComponent!CGuild().guild = 1;
|
|
|
|
space_invaders.enemy_tmpl.getComponent!CWeaponLocation().rel_pos = vec2(0,-15);
|
|
|
|
space_invaders.enemy_tmpl.getComponent!CWeaponLocation().rel_pos = vec2(0,-15);
|
|
|
|
|
|
|
|
|
|
|
|
Entity* current_entity;
|
|
|
|
Entity* current_entity;
|
|
|
|
|
|
|
|
|
|
|
|
current_entity = launcher.manager.addEntity(space_invaders.enemy_tmpl);
|
|
|
|
current_entity = launcher.manager.addEntity(space_invaders.enemy_tmpl,[CLocation(vec2(32,space_invaders.map_size.y - 16)).ref_].staticArray);
|
|
|
|
launcher.manager.addComponents(current_entity.id,CSideMove(0));
|
|
|
|
launcher.manager.addComponents(current_entity.id,CSideMove(0));
|
|
|
|
|
|
|
|
|
|
|
|
loc_comp.value = vec2(128,space_invaders.map_size.y - 16);
|
|
|
|
//loc_comp.value = vec2(128,space_invaders.map_size.y - 16);
|
|
|
|
current_entity = launcher.manager.addEntity(space_invaders.enemy_tmpl);
|
|
|
|
current_entity = launcher.manager.addEntity(space_invaders.enemy_tmpl,[CLocation(vec2(128,space_invaders.map_size.y - 16)).ref_].staticArray);
|
|
|
|
launcher.manager.addComponents(current_entity.id,CSideMove(-1));
|
|
|
|
launcher.manager.addComponents(current_entity.id,CSideMove(-1));
|
|
|
|
|
|
|
|
|
|
|
|
enemy_id = current_entity.id;
|
|
|
|
enemy_id = current_entity.id;
|
|
|
|
//enemy_tmpl = launcher.manager.allocateTemplate(current_entity.id);
|
|
|
|
//enemy_tmpl = launcher.manager.allocateTemplate(current_entity.id);
|
|
|
|
|
|
|
|
|
|
|
|
loc_comp.value = vec2(256,space_invaders.map_size.y - 16);
|
|
|
|
//loc_comp.value = vec2(256,space_invaders.map_size.y - 16);
|
|
|
|
launcher.manager.addEntity(space_invaders.enemy_tmpl);
|
|
|
|
launcher.manager.addEntity(space_invaders.enemy_tmpl,[CLocation(vec2(256,space_invaders.map_size.y - 16)).ref_].staticArray);
|
|
|
|
|
|
|
|
|
|
|
|
loc_comp.value = vec2(0,space_invaders.map_size.y - 16);
|
|
|
|
//loc_comp.value = vec2(0,space_invaders.map_size.y - 16);
|
|
|
|
current_entity = launcher.manager.addEntity(space_invaders.enemy_tmpl);
|
|
|
|
current_entity = launcher.manager.addEntity(space_invaders.enemy_tmpl,[CLocation(vec2(0,space_invaders.map_size.y - 16)).ref_].staticArray);
|
|
|
|
launcher.manager.addComponents(current_entity.id,CSideMove(0));
|
|
|
|
launcher.manager.addComponents(current_entity.id,CSideMove(0));
|
|
|
|
|
|
|
|
|
|
|
|
grouped_id = current_entity.id;
|
|
|
|
grouped_id = current_entity.id;
|
|
|
|
@ -2412,11 +2516,8 @@ void spaceInvadersStart()
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
upgrade_tmpl = launcher.manager.allocateTemplate([CVelocity.component_id, CLocation.component_id, CTexture.component_id, CScale.component_id, CUpgrade.component_id, CAnimationLooped.component_id, CAnimation.component_id].staticArray);
|
|
|
|
upgrade_tmpl = launcher.manager.allocateTemplate([CVelocity.component_id, CLocation.component_id, CTexture.component_id, CScale.component_id, CUpgrade.component_id, CAnimationLooped.component_id, CAnimation.component_id].staticArray);
|
|
|
|
CTexture* tex_comp = upgrade_tmpl.getComponent!CTexture;
|
|
|
|
upgrade_tmpl.getComponent!CTexture().coords = vec4(0,32,16,16)*px;
|
|
|
|
//tex_comp.tex = space_invaders.texture;//ship_tex;
|
|
|
|
upgrade_tmpl.getComponent!CVelocity().value = vec2(0,-0.1);
|
|
|
|
tex_comp.coords = vec4(0*px,32*px,16*px,16*px);
|
|
|
|
|
|
|
|
CVelocity* vel_comp = upgrade_tmpl.getComponent!CVelocity;
|
|
|
|
|
|
|
|
vel_comp.value = vec2(0,-0.1);
|
|
|
|
|
|
|
|
*upgrade_tmpl.getComponent!CAnimation = CAnimation(HitPointsSystem.upgrade_laser_frames, 0, 0.75);
|
|
|
|
*upgrade_tmpl.getComponent!CAnimation = CAnimation(HitPointsSystem.upgrade_laser_frames, 0, 0.75);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -2425,6 +2526,24 @@ void spaceInvadersStart()
|
|
|
|
enemy_tmpl = launcher.manager.allocateTemplate(enemy_id);
|
|
|
|
enemy_tmpl = launcher.manager.allocateTemplate(enemy_id);
|
|
|
|
grouped_tmpl = launcher.manager.allocateTemplate(grouped_id);
|
|
|
|
grouped_tmpl = launcher.manager.allocateTemplate(grouped_id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
space_invaders.bullet_tmpl[0] = launcher.manager.allocateTemplate(
|
|
|
|
|
|
|
|
[CLocation.component_id, CTexture.component_id, CVelocity.component_id,
|
|
|
|
|
|
|
|
CScale.component_id, CBullet.component_id, CGuild.component_id].staticArray
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
space_invaders.bullet_tmpl[0].getComponent!CTexture().coords = vec4(0,24,2,8)*px;
|
|
|
|
|
|
|
|
space_invaders.bullet_tmpl[0].getComponent!CScale().value = vec2(2,8);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
space_invaders.bullet_tmpl[1] = launcher.manager.allocateTemplate(space_invaders.bullet_tmpl[0]);
|
|
|
|
|
|
|
|
space_invaders.bullet_tmpl[2] = launcher.manager.allocateTemplate(space_invaders.bullet_tmpl[0]);
|
|
|
|
|
|
|
|
space_invaders.bullet_tmpl[2].getComponent!CTexture().coords = vec4(64,32,8,16)*px;
|
|
|
|
|
|
|
|
space_invaders.bullet_tmpl[2].getComponent!CScale().value = vec2(8,16);
|
|
|
|
|
|
|
|
space_invaders.bullet_tmpl[3] = launcher.manager.allocateTemplate(space_invaders.bullet_tmpl[0]);
|
|
|
|
|
|
|
|
space_invaders.bullet_tmpl[3].getComponent!CTexture().coords = vec4(56,32,2,2)*px;
|
|
|
|
|
|
|
|
space_invaders.bullet_tmpl[3].getComponent!CScale().value = vec2(2,2);
|
|
|
|
|
|
|
|
// bullet_tmpl[3].getComponent!CTexture().coords = vec4(48,32,8,8)*px;
|
|
|
|
|
|
|
|
// bullet_tmpl[3].getComponent!CScale().value = vec2(8,8);
|
|
|
|
|
|
|
|
space_invaders.bullet_tmpl[4] = launcher.manager.allocateTemplate(space_invaders.bullet_tmpl[0]);
|
|
|
|
|
|
|
|
|
|
|
|
launcher.gui_manager.addTemplate(enemy_tmpl,"Enemy");
|
|
|
|
launcher.gui_manager.addTemplate(enemy_tmpl,"Enemy");
|
|
|
|
launcher.gui_manager.addTemplate(grouped_tmpl,"Grouped enemy");
|
|
|
|
launcher.gui_manager.addTemplate(grouped_tmpl,"Grouped enemy");
|
|
|
|
launcher.gui_manager.addTemplate(launcher.manager.allocateTemplate(space_invaders.ship_tmpl),"Ship");
|
|
|
|
launcher.gui_manager.addTemplate(launcher.manager.allocateTemplate(space_invaders.ship_tmpl),"Ship");
|
|
|
|
@ -2432,6 +2551,9 @@ void spaceInvadersStart()
|
|
|
|
launcher.gui_manager.addTemplate(upgrade_tmpl,"Upgrade");
|
|
|
|
launcher.gui_manager.addTemplate(upgrade_tmpl,"Upgrade");
|
|
|
|
launcher.gui_manager.addTemplate(tower_tmpl,"Tower");
|
|
|
|
launcher.gui_manager.addTemplate(tower_tmpl,"Tower");
|
|
|
|
launcher.gui_manager.addTemplate(boss_tmpl,"Boss");
|
|
|
|
launcher.gui_manager.addTemplate(boss_tmpl,"Boss");
|
|
|
|
|
|
|
|
launcher.gui_manager.addTemplate(launcher.manager.allocateTemplate(space_invaders.bullet_tmpl[3]),"Cannon bullet");
|
|
|
|
|
|
|
|
//launcher.gui_manager.addTemplate(launcher.manager.allocateTemplate(space_invaders.bullet_tmpl[4]),"Laser");
|
|
|
|
|
|
|
|
//launcher.gui_manager.addTemplate(launcher.manager.allocateTemplate(space_invaders.bullet_tmpl[5]),"Laser");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void spaceInvadersEnd()
|
|
|
|
void spaceInvadersEnd()
|
|
|
|
@ -2445,6 +2567,7 @@ void spaceInvadersEnd()
|
|
|
|
|
|
|
|
|
|
|
|
//launcher.manager.freeTemplate(space_invaders.enemy_tmpl);
|
|
|
|
//launcher.manager.freeTemplate(space_invaders.enemy_tmpl);
|
|
|
|
Mallocator.dispose(space_invaders);
|
|
|
|
Mallocator.dispose(space_invaders);
|
|
|
|
|
|
|
|
space_invaders = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void spaceInvadersTool(vec2 position, Tool tool, int size)
|
|
|
|
void spaceInvadersTool(vec2 position, Tool tool, int size)
|
|
|
|
|