mirror of
https://github.com/BlackMATov/evolved.lua.git
synced 2025-12-14 20:11:27 +07:00
check modifications after destroying
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
- [x] add additional oop-like api
|
||||
- [ ] add blocklist of fragments for queries
|
||||
- [ ] add checks of prohibited changes while querying
|
||||
- [ ] add check inserts and removes after destroying entity
|
||||
- [x] add check inserts and removes after destroying entity
|
||||
- [x] add multi remove fragments function from entities
|
||||
- [ ] cache matched chunks in queries
|
||||
- [x] cache transitions between chunks
|
||||
|
||||
@@ -162,6 +162,38 @@ do
|
||||
end
|
||||
end
|
||||
|
||||
do
|
||||
local f1, f2 = evo.registry.entity(), evo.registry.entity()
|
||||
|
||||
local e = evo.registry.entity()
|
||||
assert(e:insert(f1))
|
||||
assert(e:is_alive())
|
||||
assert(e.__chunk == evo.registry.chunk(f1))
|
||||
|
||||
assert(e:destroy())
|
||||
assert(not e:is_alive())
|
||||
assert(e.__chunk == nil)
|
||||
|
||||
assert(not e:assign(f1, 42))
|
||||
assert(not e:assign(f2, 42))
|
||||
assert(not e:is_alive())
|
||||
assert(e.__chunk == nil)
|
||||
|
||||
assert(not e:insert(f1, 42))
|
||||
assert(not e:insert(f2, 42))
|
||||
assert(not e:is_alive())
|
||||
assert(e.__chunk == nil)
|
||||
|
||||
assert(not e:remove(f1, 42))
|
||||
assert(not e:remove(f2, 42))
|
||||
assert(not e:is_alive())
|
||||
assert(e.__chunk == nil)
|
||||
|
||||
assert(not e:clear())
|
||||
assert(not e:is_alive())
|
||||
assert(e.__chunk == nil)
|
||||
end
|
||||
|
||||
for _ = 1, 100 do
|
||||
local insert_fragments = {} ---@type evolved.entity[]
|
||||
local insert_fragment_count = math.random(0, 10)
|
||||
|
||||
@@ -349,6 +349,10 @@ end
|
||||
---@param component any
|
||||
---@return boolean is_assigned
|
||||
function registry.assign(entity, fragment, component)
|
||||
if not idpools.is_alive(__guids, entity.__guid) then
|
||||
return false
|
||||
end
|
||||
|
||||
component = component == nil and true or component
|
||||
|
||||
local chunk_components = entity.__chunk and entity.__chunk.__components[fragment]
|
||||
@@ -366,6 +370,10 @@ end
|
||||
---@param component any
|
||||
---@return boolean is_inserted
|
||||
function registry.insert(entity, fragment, component)
|
||||
if not idpools.is_alive(__guids, entity.__guid) then
|
||||
return false
|
||||
end
|
||||
|
||||
component = component == nil and true or component
|
||||
|
||||
local old_chunk = entity.__chunk
|
||||
@@ -402,6 +410,10 @@ end
|
||||
---@param ... evolved.entity fragments
|
||||
---@return boolean is_removed
|
||||
function registry.remove(entity, ...)
|
||||
if not idpools.is_alive(__guids, entity.__guid) then
|
||||
return false
|
||||
end
|
||||
|
||||
local old_chunk = entity.__chunk
|
||||
local new_chunk = entity.__chunk
|
||||
|
||||
@@ -442,6 +454,10 @@ end
|
||||
---@param entity evolved.entity
|
||||
---@return boolean is_cleared
|
||||
function registry.clear(entity)
|
||||
if not idpools.is_alive(__guids, entity.__guid) then
|
||||
return false
|
||||
end
|
||||
|
||||
if entity.__chunk == nil then
|
||||
return false
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user