mirror of
https://github.com/BlackMATov/evolved.lua.git
synced 2025-12-16 14:11:16 +07:00
destroy without exceptions
This commit is contained in:
@@ -3,13 +3,10 @@
|
||||
## Backlog
|
||||
|
||||
- [x] add additional oop-like api
|
||||
- [ ] add fluent interface for 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 multi remove fragments function from entities
|
||||
- [ ] add multi get fragments function from entities
|
||||
- [ ] add multi entity creation function
|
||||
- [ ] cache matched chunks in queries
|
||||
- [x] cache transitions between chunks
|
||||
- [x] chunk's children should be stored in an array instead of a table
|
||||
@@ -31,6 +31,28 @@ do
|
||||
assert(not e:remove())
|
||||
end
|
||||
|
||||
do
|
||||
local f1, f2 =
|
||||
evo.registry.entity(),
|
||||
evo.registry.entity()
|
||||
|
||||
local e = evo.registry.entity()
|
||||
|
||||
assert(e:insert(f1))
|
||||
assert(e:insert(f2))
|
||||
|
||||
assert(e:is_alive())
|
||||
assert(e.__chunk == evo.registry.chunk(f1, f2))
|
||||
|
||||
assert(e:destroy())
|
||||
assert(not e:is_alive())
|
||||
assert(e.__chunk == nil)
|
||||
|
||||
assert(not e:destroy())
|
||||
assert(not e:is_alive())
|
||||
assert(e.__chunk == nil)
|
||||
end
|
||||
|
||||
do
|
||||
local f1, f2, f3, f4, f5 =
|
||||
evo.registry.entity(),
|
||||
|
||||
@@ -288,9 +288,10 @@ function registry.is_alive(entity)
|
||||
end
|
||||
|
||||
---@param entity evolved.entity
|
||||
---@return boolean is_destroyed
|
||||
function registry.destroy(entity)
|
||||
if not registry.is_alive(entity) then
|
||||
error(string.format('entity %s is not alive', entity), 2)
|
||||
if not idpools.is_alive(__guids, entity.__guid) then
|
||||
return false
|
||||
end
|
||||
|
||||
if entity.__chunk ~= nil then
|
||||
@@ -298,6 +299,7 @@ function registry.destroy(entity)
|
||||
end
|
||||
|
||||
idpools.release(__guids, entity.__guid)
|
||||
return true
|
||||
end
|
||||
|
||||
---@param entity evolved.entity
|
||||
|
||||
Reference in New Issue
Block a user