-events are simplified to handleEvent(Entity*,Event) (use entity.getComponent to get entity components)
This commit is contained in:
parent
9402e917f2
commit
beab56033c
2 changed files with 28 additions and 13 deletions
|
|
@ -304,9 +304,9 @@ export class EntityManager
|
|||
{
|
||||
static void callEventHandler(Type)(ref EventCallData data)
|
||||
{
|
||||
Sys.EventInput input;
|
||||
//Sys.EventInput input;
|
||||
Sys* data_system = cast(Sys*) data.system_pointer;
|
||||
EntityInfo* info = data.block.type_info;
|
||||
/*EntityInfo* info = data.block.type_info;
|
||||
|
||||
alias EventFields = Fields!(Sys.EventInput);
|
||||
foreach (ref event_field; input.tupleof)
|
||||
|
|
@ -343,8 +343,9 @@ export class EntityManager
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
data_system.handleEvent(input, *cast(Type*) data.event);
|
||||
}//*/
|
||||
Type* event = cast(Type*) data.event;
|
||||
data_system.handleEvent(/*input, */gEM.getEntity(event.entity_id), *event);
|
||||
}
|
||||
|
||||
void setEventCallers(Sys)(ref System system)
|
||||
|
|
@ -357,7 +358,19 @@ export class EntityManager
|
|||
{
|
||||
alias Params = Parameters!(__traits(getOverloads,
|
||||
Sys, "handleEvent")[j]);
|
||||
static if(Params.length == 2 && is(Params[0] == __traits(getMember, Sys, "EventInput")))
|
||||
/*static if(Params.length == 2 && is(Params[0] == __traits(getMember, Sys, "EventInput")))
|
||||
{
|
||||
alias EventParamType = Params[1];
|
||||
enum EventName = Unqual!(EventParamType).stringof;
|
||||
ushort evt = events_map.get(cast(char[]) EventName, ushort.max);
|
||||
assert(evt != ushort.max, "Can't register system \""~Sys.stringof~"\" due to non existing event \""~EventName~"\".");
|
||||
|
||||
callers[i].callback = cast(
|
||||
void*)&callEventHandler!(EventParamType);
|
||||
callers[i].id = EventParamType.event_id;
|
||||
i++;
|
||||
}*/
|
||||
static if(Params.length == 2 && is(Params[0] == Entity*))
|
||||
{
|
||||
alias EventParamType = Params[1];
|
||||
enum EventName = Unqual!(EventParamType).stringof;
|
||||
|
|
@ -389,9 +402,9 @@ export class EntityManager
|
|||
static struct ComponentsIndices
|
||||
{
|
||||
CompInfo[] readonly;
|
||||
CompInfo[] mutable;
|
||||
CompInfo[] excluded;
|
||||
CompInfo[] optional;
|
||||
CompInfo[] mutable;
|
||||
CompInfo[] req;
|
||||
string entites_array;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -376,22 +376,24 @@ struct TestSystem2
|
|||
//TestComp* tt;
|
||||
}
|
||||
|
||||
void handleEvent(EventInput input)
|
||||
/*void handleEvent(EventInput input)
|
||||
{
|
||||
|
||||
}
|
||||
}*/
|
||||
|
||||
void handleEvent(EventInput input, ref TestEvent event)
|
||||
void handleEvent(/*EventInput input, */Entity* entity, ref TestEvent event)
|
||||
{
|
||||
input.test.bg = event.a;
|
||||
TestComp3* test = entity.getComponent!TestComp3;
|
||||
test.bg = event.a;
|
||||
TestEvent2 event2;
|
||||
event2.a = event.a + 8;
|
||||
gEM.sendEvent(input.entity.id, event2);
|
||||
gEM.sendEvent(entity.id, event2);
|
||||
}
|
||||
|
||||
void handleEvent(EventInput input, ref TestEvent2 event)
|
||||
void handleEvent(/*EventInput input, */Entity* entity, ref TestEvent2 event)
|
||||
{
|
||||
input.test.gg = cast(uint) event.a;
|
||||
TestComp3* test = entity.getComponent!TestComp3;
|
||||
test.gg = cast(uint) event.a;
|
||||
}
|
||||
|
||||
void onEnable()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue