-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Hello! This is a really good ECS, and I would like to make a suggestion for improving the systems.
Problem
In the current implementation of the systems, the execute() function only accepts basic parameters (chunk, entity_list, entity_count). This limits the flexibility of the systems, especially when they need to access external data.
For example:
local MovementSystem = evolved.builder()
:query(q)
:execute(function(chunk, list, count)
local st = chunk:components(state.id)
local pos = chunk:components(position.id)
local dir = chunk:components(direction.id)
local spd = chunk:components(move_speed.id)
for i = 1, count do
if st[i] == "moving" then
pos[i].x = pos[i].x + dir[i].x * spd[i] * get_delta()
pos[i].y = pos[i].y + dir[i].y * spd[i] * get_delta()
end
end
end)
:build()The system is tightly coupled with the global function get_delta(), which complicates testing and reuse. The code would be simpler and easier to maintain if it were possible to pass the delta as an argument.
An even clearer example:
local InputSystem = evolved.builder()
:query(q)
:execute(function(chunk, list, count)
-- I want to know which keys are pressed right now!
end)
:build()Proposed solution
Extend the evolved.process() API to support parameters:
evolved.process(MovementSystem, dt)
evolved.process(InputSystem, action)local InputSystem = evolved.builder()
:query(q)
:execute(function(chunk, list, count, action)
-- Happy!
end)
:build()Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request