diff --git a/README.md b/README.md index 58bf6d0..65648c8 100644 --- a/README.md +++ b/README.md @@ -99,9 +99,6 @@ process :: system... -> () spawn :: ? -> entity clone :: entity -> ? -> entity -spawn_single :: component, ? -> entity -clone_single :: entity -> component -> ? -> entity - debug_mode :: boolean -> () collect_garbage :: () ``` @@ -166,9 +163,6 @@ builder:destroy_policy :: id -> builder builder:spawn :: entity builder:clone :: entity -> entity - -builder:spawn_single :: component -> entity -builder:clone_single :: entity -> component -> entity ``` ## [License (MIT)](./LICENSE.md) diff --git a/develop/example.lua b/develop/example.lua index 1d1be94..a2cc625 100644 --- a/develop/example.lua +++ b/develop/example.lua @@ -17,6 +17,11 @@ local function vector2(x, y) return { x = x, y = y } end +local consts = { + delta_time = 0.016, + physics_gravity = vector2(0, 9.81), +} + local groups = { awake = evo.spawn(), physics = evo.spawn(), @@ -24,11 +29,6 @@ local groups = { shutdown = evo.spawn(), } -local singles = { - delta_time = evo.spawn_single(0.016), - physics_gravity = evo.spawn_single(vector2(0, 9.81)), -} - local fragments = { force = evo.spawn(), position = evo.spawn(), @@ -56,10 +56,8 @@ local integrate_forces_system = evo.builder() :group(groups.physics) :query(queries.physics_bodies) :execute(function(chunk, entities, entity_count) - ---@type number, evolved.vector2 local delta_time, physics_gravity = - evo.get(singles.delta_time, singles.delta_time), - evo.get(singles.physics_gravity, singles.physics_gravity) + consts.delta_time, consts.physics_gravity ---@type evolved.vector2[], evolved.vector2[] local forces, velocities = chunk:components( @@ -77,9 +75,8 @@ local integrate_velocities_system = evo.builder() :group(groups.physics) :query(queries.physics_bodies) :execute(function(chunk, entities, entity_count) - ---@type number local delta_time = - evo.get(singles.delta_time, singles.delta_time) + consts.delta_time ---@type evolved.vector2[], evolved.vector2[], evolved.vector2[] local forces, positions, velocities = chunk:components( diff --git a/develop/untests.lua b/develop/untests.lua index 5889cac..9837bc9 100644 --- a/develop/untests.lua +++ b/develop/untests.lua @@ -3816,23 +3816,6 @@ do end end -do - do - local f = evo.builder():default():spawn() - assert(evo.has(f, evo.DEFAULT)) - end - - do - local f = evo.builder():spawn_single() - assert(evo.has(f, f)) - end - - do - local f = evo.builder():spawn_single(42) - assert(evo.has(f, f) and evo.get(f, f) == 42) - end -end - do local f1, f2 = evo.id(2) @@ -3893,34 +3876,6 @@ do end end -do - local fb = evo.builder() - local qb = evo.builder() - local sb = evo.builder() - - do - local f = fb:spawn_single(false) - assert(evo.get(f, f) == false) - - local q = qb:spawn_single(false) - assert(evo.get(q, q) == false) - - local s = sb:spawn_single(false) - assert(evo.get(s, s) == false) - end - - do - local f = fb:spawn() - assert(evo.get(f, f) == nil) - - local q = qb:spawn() - assert(evo.get(q, q) == nil) - - local s = sb:spawn() - assert(evo.get(s, s) == nil) - end -end - do local f1, f2 = evo.id(2) @@ -5083,13 +5038,9 @@ do local g1 = gb:clear():spawn() local g2 = gb:clear():name('g2'):spawn() - local g3 = gb:clear():spawn_single(42) - local g4 = gb:clear():name('g4'):spawn_single(43) assert(not evo.has(g1, evo.NAME) and not evo.has(g1, g1)) assert(evo.get(g2, evo.NAME) == 'g2' and not evo.has(g2, g2)) - assert(not evo.has(g3, evo.NAME) and evo.get(g3, g3) == 42) - assert(evo.get(g4, evo.NAME) == 'g4' and evo.get(g4, g4) == 43) end do @@ -5927,34 +5878,6 @@ do end end -do - local f1 = evo.id(1) - - do - local b = evo.builder():set(f1, 11) - - local e1 = b:spawn_single(1) - assert(evo.has(e1, e1) and evo.get(e1, e1) == 1) - assert(evo.has(e1, f1) and evo.get(e1, f1) == 11) - - assert(not b:has(e1) and b:get(e1) == nil) - - local e2 = b:spawn_single(1) - - assert(not evo.has(e2, e1) and evo.get(e2, e1) == nil) - - assert(evo.has(e2, e2) and evo.get(e2, e2) == 1) - assert(evo.has(e2, f1) and evo.get(e2, f1) == 11) - - local e3 = b:clear():spawn() - - assert(not evo.has(e3, e1) and evo.get(e3, e1) == nil) - assert(not evo.has(e3, e2) and evo.get(e3, e2) == nil) - assert(not evo.has(e3, e3) and evo.get(e3, e3) == nil) - assert(not evo.has(e3, f1) and evo.get(e3, f1) == nil) - end -end - do local f1, f2 = evo.id(2) diff --git a/evolved.lua b/evolved.lua index 93537c8..15e9387 100644 --- a/evolved.lua +++ b/evolved.lua @@ -726,9 +726,6 @@ local __evolved_process local __evolved_spawn local __evolved_clone -local __evolved_spawn_single -local __evolved_clone_single - local __evolved_debug_mode local __evolved_collect_garbage @@ -4404,106 +4401,6 @@ function __evolved_clone(prefab, components) return entity end ----@param single evolved.component ----@param components? table ----@return evolved.entity -function __evolved_spawn_single(single, components) - if not components then - components = {} - end - - if __debug_mode then - __debug_fns.validate_component_map(components) - end - - do - ---@type evolved.default?, evolved.duplicate? - local single_default, single_duplicate = - components[__DEFAULT], components[__DUPLICATE] - - if single == nil then - single = single_default - end - - if single == nil and single_duplicate then - single = single_duplicate(single) - end - - if single == nil then - single = true - end - end - - local entity = __acquire_id() - - if __defer_depth > 0 then - components[entity] = single - __defer_spawn_entity(entity, components) - components[entity] = nil - else - __evolved_defer() - do - components[entity] = single - __spawn_entity(entity, components) - components[entity] = nil - end - __evolved_commit() - end - - return entity -end - ----@param prefab evolved.entity ----@param single evolved.component ----@param components? table ----@return evolved.entity -function __evolved_clone_single(prefab, single, components) - if not components then - components = {} - end - - if __debug_mode then - __debug_fns.validate_prefab(prefab) - __debug_fns.validate_component_map(components) - end - - do - ---@type evolved.default?, evolved.duplicate? - local single_default, single_duplicate = - components[__DEFAULT], components[__DUPLICATE] - - if single == nil then - single = single_default - end - - if single == nil and single_duplicate then - single = single_duplicate(single) - end - - if single == nil then - single = true - end - end - - local entity = __acquire_id() - - if __defer_depth > 0 then - components[entity] = single - __defer_clone_entity(entity, prefab, components) - components[entity] = nil - else - __evolved_defer() - do - components[entity] = single - __clone_entity(entity, prefab, components) - components[entity] = nil - end - __evolved_commit() - end - - return entity -end - --- --- --- @@ -5109,100 +5006,6 @@ function __debug_fns.builder_mt:clone(prefab) return entity end ----@param single evolved.component ----@return evolved.entity -function __debug_fns.builder_mt:spawn_single(single) - local components = self.__components - - if __debug_mode then - __debug_fns.validate_component_map(components) - end - - do - ---@type evolved.default?, evolved.duplicate? - local single_default, single_duplicate = - components[__DEFAULT], components[__DUPLICATE] - - if single == nil then - single = single_default - end - - if single == nil and single_duplicate then - single = single_duplicate(single) - end - - if single == nil then - single = true - end - end - - local entity = __acquire_id() - - if __defer_depth > 0 then - components[entity] = single - __defer_spawn_entity(entity, components) - components[entity] = nil - else - __evolved_defer() - do - components[entity] = single - __spawn_entity(entity, components) - components[entity] = nil - end - __evolved_commit() - end - - return entity -end - ----@param prefab evolved.entity ----@param single evolved.component ----@return evolved.entity -function __debug_fns.builder_mt:clone_single(prefab, single) - local components = self.__components - - if __debug_mode then - __debug_fns.validate_prefab(prefab) - __debug_fns.validate_component_map(components) - end - - do - ---@type evolved.default?, evolved.duplicate? - local single_default, single_duplicate = - components[__DEFAULT], components[__DUPLICATE] - - if single == nil then - single = single_default - end - - if single == nil and single_duplicate then - single = single_duplicate(single) - end - - if single == nil then - single = true - end - end - - local entity = __acquire_id() - - if __defer_depth > 0 then - components[entity] = single - __defer_clone_entity(entity, prefab, components) - components[entity] = nil - else - __evolved_defer() - do - components[entity] = single - __clone_entity(entity, prefab, components) - components[entity] = nil - end - __evolved_commit() - end - - return entity -end - --- --- --- @@ -5575,9 +5378,6 @@ evolved.process = __evolved_process evolved.spawn = __evolved_spawn evolved.clone = __evolved_clone -evolved.spawn_single = __evolved_spawn_single -evolved.clone_single = __evolved_clone_single - evolved.debug_mode = __evolved_debug_mode evolved.collect_garbage = __evolved_collect_garbage