invest more in plugins

This commit is contained in:
wooshings
2026-10-27 14:04:49 -07:00
parent 65970091b4
commit c69bf5cabf
3 changed files with 37 additions and 18 deletions
+7 -2
View File
@@ -1,8 +1,13 @@
package shoal
STARTUP :: 0
UPDATE :: 1
DRAW :: 2
PRE_UPDATE :: 1
UPDATE :: 2
POST_UPDATE :: 3
PRE_DRAW :: 4
DRAW :: 5
POST_DRAW :: 6
DESTROY :: 7
EASE_IN :: 0
EASE_OUT :: 1
+16 -16
View File
@@ -1,6 +1,5 @@
package shoal
import ui "../ui"
import "core:strings"
import "core:thread"
import ml "vendor:microui"
@@ -34,27 +33,28 @@ add_plugin :: proc(app: ^App, plugin: proc(app: ^App)) {
append(&app.plugins, plugin)
}
// run the app
run :: proc(app: ^App, entity_limit: int = 1000) {
sparse_entity_limit = entity_limit
get_system :: proc(app: ^App, schedule: int) -> [dynamic]proc() {
if systems, ok := app.systems[schedule]; ok && len(systems) > 0 {
return systems
}
return [dynamic]proc(){}
}
// run the app
run :: proc(app: ^App) {
for p in app.plugins {
p(app)
}
for i in app.systems[STARTUP] {i()}
window, _ := single(&Window)
rl.InitWindow(window.width, window.height, strings.clone_to_cstring(window.title))
ui.ui_ctx = ui.init_scope()
defer rl.CloseWindow()
rl.SetTargetFPS(60)
for !rl.WindowShouldClose() {
defer free_all(context.temp_allocator)
for i in app.systems[UPDATE] {i()}
rl.BeginDrawing(); defer rl.EndDrawing()
ui.begin_scope()
rl.ClearBackground(window.background)
for i in app.systems[DRAW] {i()}
for i in get_system(app, PRE_UPDATE) {i()}
for i in get_system(app, UPDATE) {i()}
for i in get_system(app, POST_UPDATE) {i()}
for i in get_system(app, PRE_DRAW) {i()}
for i in get_system(app, DRAW) {i()}
for i in get_system(app, POST_DRAW) {i()}
}
for i in get_system(app, DESTROY) {i()}
}
+14
View File
@@ -1,12 +1,19 @@
package shoal
import "core:strings"
import rl "vendor:raylib"
DefaultPlugin :: proc(app: ^App) {
add_system(app, STARTUP, startup_window)
add_system(app, DRAW, draw_sprite)
add_system(app, UPDATE, signal_system)
add_system(app, UPDATE, run_timers)
add_system(app, UPDATE, update_cursor_position)
add_system(app, PRE_DRAW, proc() {rl.BeginDrawing()
window, _ := single(&Window)
rl.ClearBackground(window.background)})
add_system(app, POST_DRAW, proc() {rl.EndDrawing()})
add_system(app, DESTROY, proc() {rl.CloseWindow()})
display := spawn_entity(app)
add_component(
@@ -39,3 +46,10 @@ draw_sprite :: proc() {
)
}
}
@(private)
startup_window :: proc() {
window, _ := single(&Window)
rl.InitWindow(window.width, window.height, strings.clone_to_cstring(window.title))
rl.SetTargetFPS(60)
}