-move code from templates to ECS side:
*sendEvent - using EventRef (alias to ComponentRef) *ListenerCallData now contain entities count and pointer to EntityInfo *Remove system_pointer from SystemCallData (use context instead) *Register event -Now all BECS functinality can be used without templates -clean code
This commit is contained in:
parent
0d08b8532a
commit
70a5388820
5 changed files with 126 additions and 261 deletions
|
|
@ -8,6 +8,8 @@ import bubel.ecs.traits : becsID;
|
|||
|
||||
import std.algorithm.comparison : max;
|
||||
|
||||
alias EventRef = ComponentRef;
|
||||
|
||||
package struct EventManager
|
||||
{
|
||||
|
||||
|
|
@ -30,12 +32,17 @@ package struct EventManager
|
|||
}
|
||||
|
||||
export void sendEvent(Ev)(EntityID id, Ev event, uint thread_id = 0) nothrow @nogc
|
||||
{
|
||||
sendEvent(id, EventRef(&event, becsID!Ev), thread_id);
|
||||
}
|
||||
|
||||
export void sendEvent(EntityID id, EventRef event, uint thread_id = 0) nothrow @nogc
|
||||
{
|
||||
uint block_id = current_index + thread_id;
|
||||
|
||||
EventData* data = &events[becsID!Ev];
|
||||
EventData* data = &events[event.component_id];
|
||||
EventBlock* block = data.blocks[block_id];
|
||||
//EntityManager.EventInfo* info = &manager.events[Ev.event_id];
|
||||
EntityManager.EventInfo* info = &manager.events[event.component_id];
|
||||
//event.entity_id = id;
|
||||
|
||||
if (block is null)
|
||||
|
|
@ -61,10 +68,11 @@ package struct EventManager
|
|||
data.blocks[block_id] = block;
|
||||
}
|
||||
|
||||
uint size = Ev.sizeof + EntityID.sizeof;
|
||||
uint size = info.size + EntityID.sizeof;
|
||||
void* ptr = cast(void*) block + data.data_offset + block.count * size;
|
||||
*cast(EntityID*)ptr = id;
|
||||
*cast(Ev*)(ptr + EntityID.sizeof) = event;
|
||||
memcpy(ptr + EntityID.sizeof, event.ptr, info.size);
|
||||
//*cast(Ev*)(ptr + EntityID.sizeof) = event;
|
||||
//Ev* event_array = cast(Ev*)(cast(void*) block + data.data_offset);
|
||||
//event_array[block.count] = event;
|
||||
block.count++;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue