From da8011cb14be30d2abff37a2823690f138025a0d Mon Sep 17 00:00:00 2001 From: "Zed A. Shaw" Date: Tue, 29 Oct 2024 17:49:54 -0400 Subject: [PATCH] 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. --- dinkyecs.hpp | 2 +- tests/dinkyecs.cpp | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/dinkyecs.hpp b/dinkyecs.hpp index 2690379..1716a9c 100644 --- a/dinkyecs.hpp +++ b/dinkyecs.hpp @@ -98,7 +98,7 @@ namespace DinkyECS { } template - void send(int event, Entity entity) { + void send(Comp event, Entity entity) { EventQueue &queue = queue_map_for(); queue.push({event, entity}); } diff --git a/tests/dinkyecs.cpp b/tests/dinkyecs.cpp index 363a29d..ac39422 100644 --- a/tests/dinkyecs.cpp +++ b/tests/dinkyecs.cpp @@ -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(gui_ent, gui); - DaGUI &gui_test = world.get(gui_ent); - REQUIRE(gui.event == gui_test.event); + world.set(gui_ent, gui); + auto &gui_test = world.get(gui_ent); + REQUIRE(gui == gui_test); - world.send(FakeEvent::HIT_EVENT, player); + world.send(GUIEvent::HIT, player); - bool ready = world.has_event(); + bool ready = world.has_event(); REQUIRE(ready == true); - auto [event, entity] = world.recv(); - REQUIRE(event == FakeEvent::HIT_EVENT); + auto [event, entity] = world.recv(); + REQUIRE(event == GUIEvent::HIT); REQUIRE(entity == player); - ready = world.has_event(); + ready = world.has_event(); REQUIRE(ready == false); }