diff --git a/develop/example.lua b/develop/example.lua index 3573087..9dfe2cc 100644 --- a/develop/example.lua +++ b/develop/example.lua @@ -1,32 +1,32 @@ local evo = require 'evolved.evolved' local singles = { - delta_time = evo.singles.create(0.016), + delta_time = evo.singles.single(0.016), } local fragments = { - position = evo.registry.create_entity(), - velocity = evo.registry.create_entity(), + position = evo.registry.entity(), + velocity = evo.registry.entity(), } local queries = { - bodies = evo.registry.create_query( + bodies = evo.registry.query( fragments.position, fragments.velocity), } do - local entity = evo.registry.create_entity() + local entity = evo.registry.entity() local position = evo.vectors.vector2(512, 50) local velocity = evo.vectors.vector2(math.random(-20, 20), 20) - evo.registry.insert_component(entity, fragments.position, position) - evo.registry.insert_component(entity, fragments.velocity, velocity) + evo.registry.insert(entity, fragments.position, position) + evo.registry.insert(entity, fragments.velocity, velocity) end do local dt = evo.singles.get(singles.delta_time) - for chunk in evo.registry.execute_query(queries.bodies) do + for chunk in evo.registry.execute(queries.bodies) do local ps = chunk.components[fragments.position] local vs = chunk.components[fragments.velocity] diff --git a/evolved/registry.lua b/evolved/registry.lua index 7de2f00..04f4fd6 100644 --- a/evolved/registry.lua +++ b/evolved/registry.lua @@ -17,57 +17,57 @@ evolved_chunk_mt.__index = evolved_chunk_mt ---@return evolved.entity ---@nodiscard -function registry.create_entity() end +function registry.entity() end ---@param entity evolved.entity -function registry.destroy_entity(entity) end +function registry.destroy(entity) end ---@param entity evolved.entity ---@param fragment evolved.entity ---@return any ---@nodiscard -function registry.get_component(entity, fragment) end +function registry.get(entity, fragment) end ---@param entity evolved.entity ---@param fragment evolved.entity ---@return boolean ---@nodiscard -function registry.has_component(entity, fragment) end +function registry.has(entity, fragment) end ---@param entity evolved.entity ---@param ... evolved.entity ---@return boolean ---@nodiscard -function registry.has_all_components(entity, ...) end +function registry.has_all(entity, ...) end ---@param entity evolved.entity ---@param ... evolved.entity ---@return boolean ---@nodiscard -function registry.has_any_components(entity, ...) end +function registry.has_any(entity, ...) end ---@param entity evolved.entity ---@param fragment evolved.entity ---@param component any -function registry.assign_component(entity, fragment, component) end +function registry.assign(entity, fragment, component) end ---@param entity evolved.entity ---@param fragment evolved.entity ---@param component any -function registry.insert_component(entity, fragment, component) end +function registry.insert(entity, fragment, component) end ---@param entity evolved.entity ---@param fragment evolved.entity -function registry.remove_component(entity, fragment) end +function registry.remove(entity, fragment) end ---@param ... evolved.entity ---@return evolved.query ---@nodiscard -function registry.create_query(...) end +function registry.query(...) end ---@param query evolved.query ---@return fun(): evolved.chunk? ---@nodiscard -function registry.execute_query(query) end +function registry.execute(query) end return registry diff --git a/evolved/singles.lua b/evolved/singles.lua index b9e3992..399f1a8 100644 --- a/evolved/singles.lua +++ b/evolved/singles.lua @@ -6,9 +6,9 @@ local singles = {} ---@param component any ---@return evolved.entity ---@nodiscard -function singles.create(component) - local single = registry.create_entity() - registry.insert_component(single, single, component) +function singles.single(component) + local single = registry.entity() + registry.insert(single, single, component) return single end @@ -16,20 +16,20 @@ end ---@return any ---@nodiscard function singles.get(single) - return registry.get_component(single, single) + return registry.get(single, single) end ---@param single evolved.entity ---@return boolean ---@nodiscard function singles.has(single) - return registry.has_component(single, single) + return registry.has(single, single) end ---@param single evolved.entity ---@param component any function singles.assign(single, component) - registry.assign_component(single, single, component) + registry.assign(single, single, component) end return singles