Update for all entities

This commit is contained in:
mmcomando 2018-09-10 18:52:31 +02:00
parent 4d35bc2a1b
commit 9c5a60447c
2 changed files with 14 additions and 6 deletions

View file

@ -55,8 +55,15 @@ class EntityManager
Sys* s = cast(Sys*) data.system.system_pointer; Sys* s = cast(Sys*) data.system.system_pointer;
EntitiesBlock* block = data.info.first_block; EntitiesBlock* block = data.info.first_block;
while(block !is null)
{
void* data_pointer = block.dataBegin(); void* data_pointer = block.dataBegin();
foreach(i; 0..block.entities_count){
mixin(genCall()); mixin(genCall());
data_pointer+=data.info.size;
}
block=block.next_block;
}
} }
} }
@ -186,7 +193,8 @@ class EntityManager
EntitiesBlock* block=tmpl.info.first_with_free_space;//tmpl.info.first_block; EntitiesBlock* block=tmpl.info.first_with_free_space;//tmpl.info.first_block;
// find block with enought space // find block with enought space
while(1){ while(1)
{
if(block is null) if(block is null)
{ {
block = cast(EntitiesBlock*) AlignedMallocator.instance.alignedAllocate(4096,4096); block = cast(EntitiesBlock*) AlignedMallocator.instance.alignedAllocate(4096,4096);

View file

@ -62,13 +62,13 @@ unittest
assert( cast(ptrdiff_t)&test % TestComp.alignof == 0 ); assert( cast(ptrdiff_t)&test % TestComp.alignof == 0 );
assert( cast(ptrdiff_t)&test2 % TestComp2.alignof == 0 ); assert( cast(ptrdiff_t)&test2 % TestComp2.alignof == 0 );
import std.stdio; import std.stdio;
writeln("Jakis tekst! ",test.b); //writeln("Jakis tekst! ",test.b);
test.a+=1000; test.a+=1000;
test.b+=2000; test.b+=2000;
writeln("Jakis tekst! ",test.b); //writeln("Jakis tekst! ",test.b);
test2.b += 2; test2.b += 2;
test2.a = 1; test2.a = 1;
writeln("Jakis tekst! ",test2.b); //writeln("Jakis tekst! ",test2.b);
} }
void handleEvent(Event event, ref TestComp comp) void handleEvent(Event event, ref TestComp comp)