|
|
@ -121,29 +121,29 @@ TEST_CASE("confirm ECS system works", "[ecs]") { |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
enum FakeEvent { |
|
|
|
enum GUIEvent { |
|
|
|
HIT_EVENT, MISS_EVENT |
|
|
|
HIT, MISS |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
TEST_CASE("confirm that the event system works", "[ecs]") { |
|
|
|
TEST_CASE("confirm that the event system works", "[ecs]") { |
|
|
|
DinkyECS::World world; |
|
|
|
DinkyECS::World world; |
|
|
|
DinkyECS::Entity gui_ent = world.entity(); |
|
|
|
DinkyECS::Entity gui_ent = world.entity(); |
|
|
|
DinkyECS::Entity player = world.entity(); |
|
|
|
DinkyECS::Entity player = world.entity(); |
|
|
|
DaGUI gui{384}; |
|
|
|
GUIEvent gui{GUIEvent::HIT}; |
|
|
|
|
|
|
|
|
|
|
|
world.set<DaGUI>(gui_ent, gui); |
|
|
|
world.set<GUIEvent>(gui_ent, gui); |
|
|
|
DaGUI &gui_test = world.get<DaGUI>(gui_ent); |
|
|
|
auto &gui_test = world.get<GUIEvent>(gui_ent); |
|
|
|
REQUIRE(gui.event == gui_test.event); |
|
|
|
REQUIRE(gui == gui_test); |
|
|
|
|
|
|
|
|
|
|
|
world.send<DaGUI>(FakeEvent::HIT_EVENT, player); |
|
|
|
world.send<GUIEvent>(GUIEvent::HIT, player); |
|
|
|
|
|
|
|
|
|
|
|
bool ready = world.has_event<DaGUI>(); |
|
|
|
bool ready = world.has_event<GUIEvent>(); |
|
|
|
REQUIRE(ready == true); |
|
|
|
REQUIRE(ready == true); |
|
|
|
|
|
|
|
|
|
|
|
auto [event, entity] = world.recv<DaGUI>(); |
|
|
|
auto [event, entity] = world.recv<GUIEvent>(); |
|
|
|
REQUIRE(event == FakeEvent::HIT_EVENT); |
|
|
|
REQUIRE(event == GUIEvent::HIT); |
|
|
|
REQUIRE(entity == player); |
|
|
|
REQUIRE(entity == player); |
|
|
|
|
|
|
|
|
|
|
|
ready = world.has_event<DaGUI>(); |
|
|
|
ready = world.has_event<GUIEvent>(); |
|
|
|
REQUIRE(ready == false); |
|
|
|
REQUIRE(ready == false); |
|
|
|
} |
|
|
|
} |
|
|
|