diff options
| author | ne_mene <[email protected]> | 2026-04-03 21:02:39 +0200 |
|---|---|---|
| committer | ne_mene <[email protected]> | 2026-04-03 21:02:39 +0200 |
| commit | 39e19c7522eabee7da9f4e01dc0e940b7678cf87 (patch) | |
| tree | 7442956b72d8e0908d86f170c3d11d32f6d44cff /src | |
| parent | 7d0786ff6ffb3453f52b07e40e0e728488c96112 (diff) | |
global events
Diffstat (limited to 'src')
| -rw-r--r-- | src/ecs.lua | 4 | ||||
| -rw-r--r-- | src/init.lua | 15 | ||||
| -rw-r--r-- | src/scenes/game.lua | 10 |
3 files changed, 19 insertions, 10 deletions
diff --git a/src/ecs.lua b/src/ecs.lua index a1dab27..8685b2f 100644 --- a/src/ecs.lua +++ b/src/ecs.lua @@ -2,6 +2,10 @@ local current_scene = nil local comp_inits = {} local comp_deinits = {} +global_on_update = new_event() +global_on_draw = new_event() +global_on_ui = new_event() + function TAGCOMP(_) end function new_scene() diff --git a/src/init.lua b/src/init.lua index 66f1b9e..bcf5518 100644 --- a/src/init.lua +++ b/src/init.lua @@ -34,6 +34,19 @@ lf = love.filesystem lw = love.window lmath = love.math +function init_global_systems() + event_bind(global_on_update, "Body", body_sys) + event_bind(global_on_update, "State_Machine", state_update_sys) + event_bind(global_on_update, "Sprite", sprite_anim_sys) + event_bind(global_on_update, "Speck_System", speck_update_sys) + event_bind(global_on_update, "Speck_Entity", speck_entity_system) + event_bind(global_on_update, "Camera", camera_move_system) + + event_bind(global_on_draw, "Sprite", sprite_draw_sys) + event_bind(global_on_draw, "Tilemap", tilemap_draw_sys) + event_bind(global_on_draw, "Speck_System", speck_draw_sys) +end + local function load_dir(path) local files = lf.getDirectoryItems(path) @@ -58,5 +71,7 @@ function main_init() load_dir("src/objs") load_dir("src/scenes") + + init_global_systems() end diff --git a/src/scenes/game.lua b/src/scenes/game.lua index 45083ca..918caa9 100644 --- a/src/scenes/game.lua +++ b/src/scenes/game.lua @@ -2,17 +2,7 @@ function start_game_scene() local scn = new_scene() - event_bind(scn.on_update, "Body", body_sys) event_bind(scn.on_update, "Player", player_update_sys) - event_bind(scn.on_update, "State_Machine", state_update_sys) - event_bind(scn.on_update, "Sprite", sprite_anim_sys) - event_bind(scn.on_update, "Speck_System", speck_update_sys) - event_bind(scn.on_update, "Speck_Entity", speck_entity_system) - event_bind(scn.on_update, "Camera", camera_move_system) - - event_bind(scn.on_draw, "Sprite", sprite_draw_sys) - event_bind(scn.on_draw, "Tilemap", tilemap_draw_sys) - event_bind(scn.on_draw, "Speck_System", speck_draw_sys) event_bind(scn.on_update, "Room_Editor", room_editor_ui_sys) event_bind(scn.on_ui, "Room_Editor", tile_place_sys) |
