Can just use the enum as the type for the map but it'd be nicer if I could use a class enum without tons of template BS.
This commit is contained in:
parent
3f87d19911
commit
da8011cb14
2 changed files with 12 additions and 12 deletions
|
@ -121,29 +121,29 @@ TEST_CASE("confirm ECS system works", "[ecs]") {
|
|||
});
|
||||
}
|
||||
|
||||
enum FakeEvent {
|
||||
HIT_EVENT, MISS_EVENT
|
||||
enum GUIEvent {
|
||||
HIT, MISS
|
||||
};
|
||||
|
||||
TEST_CASE("confirm that the event system works", "[ecs]") {
|
||||
DinkyECS::World world;
|
||||
DinkyECS::Entity gui_ent = world.entity();
|
||||
DinkyECS::Entity player = world.entity();
|
||||
DaGUI gui{384};
|
||||
GUIEvent gui{GUIEvent::HIT};
|
||||
|
||||
world.set<DaGUI>(gui_ent, gui);
|
||||
DaGUI &gui_test = world.get<DaGUI>(gui_ent);
|
||||
REQUIRE(gui.event == gui_test.event);
|
||||
world.set<GUIEvent>(gui_ent, gui);
|
||||
auto &gui_test = world.get<GUIEvent>(gui_ent);
|
||||
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);
|
||||
|
||||
auto [event, entity] = world.recv<DaGUI>();
|
||||
REQUIRE(event == FakeEvent::HIT_EVENT);
|
||||
auto [event, entity] = world.recv<GUIEvent>();
|
||||
REQUIRE(event == GUIEvent::HIT);
|
||||
REQUIRE(entity == player);
|
||||
|
||||
ready = world.has_event<DaGUI>();
|
||||
ready = world.has_event<GUIEvent>();
|
||||
REQUIRE(ready == false);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue