mirror of
https://github.com/enduro2d/enduro2d.git
synced 2025-12-15 00:11:55 +07:00
rewrite update systems logic to features and events
This commit is contained in:
@@ -9,10 +9,13 @@ using namespace e2d;
|
||||
|
||||
namespace
|
||||
{
|
||||
class game_system final : public ecs::system {
|
||||
class game_system final : public systems::update_system {
|
||||
public:
|
||||
void process(ecs::registry& owner) override {
|
||||
E2D_UNUSED(owner);
|
||||
void process(
|
||||
ecs::registry& owner,
|
||||
const systems::update_event& event) override
|
||||
{
|
||||
E2D_UNUSED(owner, event);
|
||||
const keyboard& k = the<input>().keyboard();
|
||||
|
||||
if ( k.is_key_just_released(keyboard_key::f12) ) {
|
||||
@@ -68,9 +71,13 @@ namespace
|
||||
}
|
||||
};
|
||||
|
||||
class camera_system final : public ecs::system {
|
||||
class camera_system final : public systems::render_system {
|
||||
public:
|
||||
void process(ecs::registry& owner) override {
|
||||
void process(
|
||||
ecs::registry& owner,
|
||||
const systems::render_event& event) override
|
||||
{
|
||||
E2D_UNUSED(event);
|
||||
owner.for_joined_components<camera>(
|
||||
[](const ecs::const_entity&, camera& cam){
|
||||
if ( !cam.target() ) {
|
||||
@@ -100,8 +107,9 @@ namespace
|
||||
|
||||
bool create_systems() {
|
||||
ecs::registry_filler(the<world>().registry())
|
||||
.system<game_system>(world::priority_update)
|
||||
.system<camera_system>(world::priority_pre_render);
|
||||
.feature<struct game_feature>(ecs::feature()
|
||||
.add_system<game_system>()
|
||||
.add_system<camera_system>());
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user