Initial idea for the interactive devices thing but I kind of hate it. Going to try another idea that will be simpler.
parent
e30c18fbdf
commit
8defc0bedf
@ -0,0 +1,19 @@ |
|||||||
|
#include "devices.hpp" |
||||||
|
#include "events.hpp" |
||||||
|
|
||||||
|
namespace components { |
||||||
|
void StairsDown(DinkyECS::Entity player_ent, json &, DinkyECS::World &world) { |
||||||
|
world.send<Events::GUI>(Events::GUI::STAIRS, player_ent, {}); |
||||||
|
} |
||||||
|
|
||||||
|
void StairsUp(DinkyECS::Entity player_ent, json &, DinkyECS::World &world) { |
||||||
|
|
||||||
|
world.send<Events::GUI>(Events::GUI::STAIRS, player_ent, {}); |
||||||
|
} |
||||||
|
|
||||||
|
void Device::hit(DinkyECS::Entity ent, DinkyECS::World &world) { |
||||||
|
for(auto& action : actions) { |
||||||
|
action(ent, config, world); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,19 @@ |
|||||||
|
#pragma once |
||||||
|
#include "dinkyecs.hpp" |
||||||
|
#include <nlohmann/json.hpp> |
||||||
|
#include <vector> |
||||||
|
|
||||||
|
namespace components { |
||||||
|
using namespace nlohmann; |
||||||
|
|
||||||
|
typedef std::function<void(DinkyECS::Entity ent, json &config, DinkyECS::World &world)> Action; |
||||||
|
|
||||||
|
void StairsDown(DinkyECS::Entity player_ent, json &data, DinkyECS::World &world); |
||||||
|
void StairsUp(DinkyECS::Entity player_ent, json &data, DinkyECS::World &world); |
||||||
|
|
||||||
|
struct Device { |
||||||
|
json config; |
||||||
|
std::vector<Action> actions; |
||||||
|
void hit(DinkyECS::Entity ent, DinkyECS::World &world); |
||||||
|
}; |
||||||
|
} |
Loading…
Reference in new issue