Skip to content

execute_flat #50

Description

@bus693

I'm new to evolved and ecs, thanks for making this library!

I'm working on a naive implementation of AABB collision.

local es = <all entities that have FRAGMENTS.POSITION>
for _, e1 in ipairs(es) do
  for _, e2 in ipairs(es) do
    if e1 ~= e2 then
      -- check for and handle collision
    end
  end
end

When using the builder pattern, the callback within :execute() only has access to the individual chunk, so we need a helper function to aggregate the entities across different chunks.

Would it make sense to include something like :execute_flat(callback) where the callback receives a list of all the entities, so that we can write something like this?

evolved
	.builder()
	:name("SYSTEM.COLLISION")
	:include(FRAGMENTS.POSITION)
	:execute_flat(function(chunk_list, entities, entity_count, dt)
          -- the nested for loops
	end)
	:build()

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestquestionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions