mirror of
https://github.com/BlackMATov/evolved.lua.git
synced 2025-12-16 14:11:16 +07:00
28
README.md
28
README.md
@@ -127,9 +127,9 @@ EXECUTE :: fragment
|
|||||||
PROLOGUE :: fragment
|
PROLOGUE :: fragment
|
||||||
EPILOGUE :: fragment
|
EPILOGUE :: fragment
|
||||||
|
|
||||||
DESTROY_POLICY :: fragment
|
DESTRUCTION_POLICY :: fragment
|
||||||
DESTROY_POLICY_DESTROY_ENTITY :: id
|
DESTRUCTION_POLICY_DESTROY_ENTITY :: id
|
||||||
DESTROY_POLICY_REMOVE_FRAGMENT :: id
|
DESTRUCTION_POLICY_REMOVE_FRAGMENT :: id
|
||||||
```
|
```
|
||||||
|
|
||||||
### Functions
|
### Functions
|
||||||
@@ -244,7 +244,7 @@ builder_mt:execute :: {chunk, entity[], integer} -> builder
|
|||||||
builder_mt:prologue :: {} -> builder
|
builder_mt:prologue :: {} -> builder
|
||||||
builder_mt:epilogue :: {} -> builder
|
builder_mt:epilogue :: {} -> builder
|
||||||
|
|
||||||
builder_mt:destroy_policy :: id -> builder
|
builder_mt:destruction_policy :: id -> builder
|
||||||
```
|
```
|
||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
@@ -1061,18 +1061,18 @@ evolved.destroy(world)
|
|||||||
assert(evolved.alive(entity) and not evolved.has(entity, world))
|
assert(evolved.alive(entity) and not evolved.has(entity, world))
|
||||||
```
|
```
|
||||||
|
|
||||||
The default behavior works well in most cases, but you can change it by using the [`evolved.DESTROY_POLICY`](#evolveddestroy_policy) fragment. This fragment expects one of the following predefined identifiers:
|
The default behavior works well in most cases, but you can change it by using the [`evolved.DESTRUCTION_POLICY`](#evolveddestruction_policy) fragment. This fragment expects one of the following predefined identifiers:
|
||||||
|
|
||||||
- [`evolved.DESTROY_POLICY_DESTROY_ENTITY`](#evolveddestroy_policy_destroy_entity) will destroy any entity that has the destroyed fragment. This is useful for cases like the one above, where you want to destroy all entities when their world is destroyed.
|
- [`evolved.DESTRUCTION_POLICY_DESTROY_ENTITY`](#evolveddestruction_policy_destroy_entity) will destroy any entity that has the destroyed fragment. This is useful for cases like the one above, where you want to destroy all entities when their world is destroyed.
|
||||||
|
|
||||||
- [`evolved.DESTROY_POLICY_REMOVE_FRAGMENT`](#evolveddestroy_policy_remove_fragment) will remove the destroyed fragment from all entities that have it. This is the default behavior, so you don't have to set it explicitly, but you can if you want.
|
- [`evolved.DESTRUCTION_POLICY_REMOVE_FRAGMENT`](#evolveddestruction_policy_remove_fragment) will remove the destroyed fragment from all entities that have it. This is the default behavior, so you don't have to set it explicitly, but you can if you want.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
local evolved = require 'evolved'
|
local evolved = require 'evolved'
|
||||||
|
|
||||||
local world = evolved.builder()
|
local world = evolved.builder()
|
||||||
:tag()
|
:tag()
|
||||||
:destroy_policy(evolved.DESTROY_POLICY_DESTROY_ENTITY)
|
:destruction_policy(evolved.DESTRUCTION_POLICY_DESTROY_ENTITY)
|
||||||
:spawn()
|
:spawn()
|
||||||
|
|
||||||
local entity = evolved.builder()
|
local entity = evolved.builder()
|
||||||
@@ -1128,11 +1128,11 @@ assert(not evolved.alive(entity))
|
|||||||
|
|
||||||
### `evolved.EPILOGUE`
|
### `evolved.EPILOGUE`
|
||||||
|
|
||||||
### `evolved.DESTROY_POLICY`
|
### `evolved.DESTRUCTION_POLICY`
|
||||||
|
|
||||||
### `evolved.DESTROY_POLICY_DESTROY_ENTITY`
|
### `evolved.DESTRUCTION_POLICY_DESTROY_ENTITY`
|
||||||
|
|
||||||
### `evolved.DESTROY_POLICY_REMOVE_FRAGMENT`
|
### `evolved.DESTRUCTION_POLICY_REMOVE_FRAGMENT`
|
||||||
|
|
||||||
## Functions
|
## Functions
|
||||||
|
|
||||||
@@ -1710,12 +1710,12 @@ function evolved.builder_mt:prologue(prologue) end
|
|||||||
function evolved.builder_mt:epilogue(epilogue) end
|
function evolved.builder_mt:epilogue(epilogue) end
|
||||||
```
|
```
|
||||||
|
|
||||||
#### `evolved.builder_mt:destroy_policy`
|
#### `evolved.builder_mt:destruction_policy`
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
---@param destroy_policy evolved.id
|
---@param destruction_policy evolved.id
|
||||||
---@return evolved.builder builder
|
---@return evolved.builder builder
|
||||||
function evolved.builder_mt:destroy_policy(destroy_policy) end
|
function evolved.builder_mt:destruction_policy(destruction_policy) end
|
||||||
```
|
```
|
||||||
|
|
||||||
## [License (MIT)](./LICENSE.md)
|
## [License (MIT)](./LICENSE.md)
|
||||||
|
|||||||
@@ -33,11 +33,11 @@ for _, entity in ipairs(all_entity_list) do
|
|||||||
end
|
end
|
||||||
|
|
||||||
if math.random(1, 5) == 1 then
|
if math.random(1, 5) == 1 then
|
||||||
evo.set(entity, evo.DESTROY_POLICY, evo.DESTROY_POLICY_DESTROY_ENTITY)
|
evo.set(entity, evo.DESTRUCTION_POLICY, evo.DESTRUCTION_POLICY_DESTROY_ENTITY)
|
||||||
end
|
end
|
||||||
|
|
||||||
if math.random(1, 5) == 1 then
|
if math.random(1, 5) == 1 then
|
||||||
evo.set(entity, evo.DESTROY_POLICY, evo.DESTROY_POLICY_REMOVE_FRAGMENT)
|
evo.set(entity, evo.DESTRUCTION_POLICY, evo.DESTRUCTION_POLICY_REMOVE_FRAGMENT)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -52,10 +52,10 @@ local should_be_destroyed_entity_list = {} ---@type evolved.entity[]
|
|||||||
local should_be_destroyed_entity_count = 0 ---@type integer
|
local should_be_destroyed_entity_count = 0 ---@type integer
|
||||||
|
|
||||||
local function collect_destroyed_entities_with(entity)
|
local function collect_destroyed_entities_with(entity)
|
||||||
local entity_destroy_policy = evo.get(entity, evo.DESTROY_POLICY)
|
local entity_destruction_policy = evo.get(entity, evo.DESTRUCTION_POLICY)
|
||||||
or evo.DESTROY_POLICY_REMOVE_FRAGMENT
|
or evo.DESTRUCTION_POLICY_REMOVE_FRAGMENT
|
||||||
|
|
||||||
if entity_destroy_policy == evo.DESTROY_POLICY_DESTROY_ENTITY then
|
if entity_destruction_policy == evo.DESTRUCTION_POLICY_DESTROY_ENTITY then
|
||||||
for _, other_entity in ipairs(all_entity_list) do
|
for _, other_entity in ipairs(all_entity_list) do
|
||||||
if evo.has(other_entity, entity) and not should_be_destroyed_entity_set[other_entity] then
|
if evo.has(other_entity, entity) and not should_be_destroyed_entity_set[other_entity] then
|
||||||
should_be_destroyed_entity_count = should_be_destroyed_entity_count + 1
|
should_be_destroyed_entity_count = should_be_destroyed_entity_count + 1
|
||||||
|
|||||||
@@ -33,11 +33,11 @@ for _, entity in ipairs(all_entity_list) do
|
|||||||
end
|
end
|
||||||
|
|
||||||
if math.random(1, 5) == 1 then
|
if math.random(1, 5) == 1 then
|
||||||
evo.set(entity, evo.DESTROY_POLICY, evo.DESTROY_POLICY_DESTROY_ENTITY)
|
evo.set(entity, evo.DESTRUCTION_POLICY, evo.DESTRUCTION_POLICY_DESTROY_ENTITY)
|
||||||
end
|
end
|
||||||
|
|
||||||
if math.random(1, 5) == 1 then
|
if math.random(1, 5) == 1 then
|
||||||
evo.set(entity, evo.DESTROY_POLICY, evo.DESTROY_POLICY_REMOVE_FRAGMENT)
|
evo.set(entity, evo.DESTRUCTION_POLICY, evo.DESTRUCTION_POLICY_REMOVE_FRAGMENT)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -52,10 +52,10 @@ local should_be_destroyed_entity_list = {} ---@type evolved.entity[]
|
|||||||
local should_be_destroyed_entity_count = 0 ---@type integer
|
local should_be_destroyed_entity_count = 0 ---@type integer
|
||||||
|
|
||||||
local function collect_destroyed_entities_with(entity)
|
local function collect_destroyed_entities_with(entity)
|
||||||
local entity_destroy_policy = evo.get(entity, evo.DESTROY_POLICY)
|
local entity_destruction_policy = evo.get(entity, evo.DESTRUCTION_POLICY)
|
||||||
or evo.DESTROY_POLICY_REMOVE_FRAGMENT
|
or evo.DESTRUCTION_POLICY_REMOVE_FRAGMENT
|
||||||
|
|
||||||
if entity_destroy_policy == evo.DESTROY_POLICY_DESTROY_ENTITY then
|
if entity_destruction_policy == evo.DESTRUCTION_POLICY_DESTROY_ENTITY then
|
||||||
for _, other_entity in ipairs(all_entity_list) do
|
for _, other_entity in ipairs(all_entity_list) do
|
||||||
if evo.has(other_entity, entity) and not should_be_destroyed_entity_set[other_entity] then
|
if evo.has(other_entity, entity) and not should_be_destroyed_entity_set[other_entity] then
|
||||||
should_be_destroyed_entity_count = should_be_destroyed_entity_count + 1
|
should_be_destroyed_entity_count = should_be_destroyed_entity_count + 1
|
||||||
|
|||||||
@@ -3958,7 +3958,7 @@ do
|
|||||||
local c1 = assert(evo.chunk(f1))
|
local c1 = assert(evo.chunk(f1))
|
||||||
local c2 = assert(evo.chunk(f2))
|
local c2 = assert(evo.chunk(f2))
|
||||||
local c12 = assert(evo.chunk(f1, f2))
|
local c12 = assert(evo.chunk(f1, f2))
|
||||||
evo.set(f1, evo.DESTROY_POLICY, evo.DESTROY_POLICY_REMOVE_FRAGMENT)
|
evo.set(f1, evo.DESTRUCTION_POLICY, evo.DESTRUCTION_POLICY_REMOVE_FRAGMENT)
|
||||||
evo.set(f1, f1)
|
evo.set(f1, f1)
|
||||||
evo.set(f2, f1)
|
evo.set(f2, f1)
|
||||||
evo.set(f2, f2)
|
evo.set(f2, f2)
|
||||||
@@ -3992,7 +3992,7 @@ do
|
|||||||
local c1 = assert(evo.chunk(f1))
|
local c1 = assert(evo.chunk(f1))
|
||||||
local c2 = assert(evo.chunk(f2))
|
local c2 = assert(evo.chunk(f2))
|
||||||
local c12 = assert(evo.chunk(f1, f2))
|
local c12 = assert(evo.chunk(f1, f2))
|
||||||
evo.set(f1, evo.DESTROY_POLICY, evo.DESTROY_POLICY_DESTROY_ENTITY)
|
evo.set(f1, evo.DESTRUCTION_POLICY, evo.DESTRUCTION_POLICY_DESTROY_ENTITY)
|
||||||
evo.set(f1, f1)
|
evo.set(f1, f1)
|
||||||
evo.set(f2, f1)
|
evo.set(f2, f1)
|
||||||
evo.set(f2, f2)
|
evo.set(f2, f2)
|
||||||
@@ -4050,7 +4050,7 @@ do
|
|||||||
local f1, f2, f3 = evo.id(3)
|
local f1, f2, f3 = evo.id(3)
|
||||||
local c1 = assert(evo.chunk(f1))
|
local c1 = assert(evo.chunk(f1))
|
||||||
local c2 = assert(evo.chunk(f2))
|
local c2 = assert(evo.chunk(f2))
|
||||||
evo.set(f1, evo.DESTROY_POLICY, evo.DESTROY_POLICY_REMOVE_FRAGMENT)
|
evo.set(f1, evo.DESTRUCTION_POLICY, evo.DESTRUCTION_POLICY_REMOVE_FRAGMENT)
|
||||||
evo.set(f2, f1)
|
evo.set(f2, f1)
|
||||||
evo.set(f3, f2)
|
evo.set(f3, f2)
|
||||||
do
|
do
|
||||||
@@ -4077,7 +4077,7 @@ do
|
|||||||
local f1, f2, f3 = evo.id(3)
|
local f1, f2, f3 = evo.id(3)
|
||||||
local c1 = assert(evo.chunk(f1))
|
local c1 = assert(evo.chunk(f1))
|
||||||
local c2 = assert(evo.chunk(f2))
|
local c2 = assert(evo.chunk(f2))
|
||||||
evo.set(f1, evo.DESTROY_POLICY, evo.DESTROY_POLICY_DESTROY_ENTITY)
|
evo.set(f1, evo.DESTRUCTION_POLICY, evo.DESTRUCTION_POLICY_DESTROY_ENTITY)
|
||||||
evo.set(f2, f1)
|
evo.set(f2, f1)
|
||||||
evo.set(f3, f2)
|
evo.set(f3, f2)
|
||||||
do
|
do
|
||||||
@@ -4104,7 +4104,7 @@ do
|
|||||||
evo.set(f1, ft)
|
evo.set(f1, ft)
|
||||||
evo.set(f2, ft)
|
evo.set(f2, ft)
|
||||||
evo.set(f3, ft)
|
evo.set(f3, ft)
|
||||||
evo.set(f3, evo.DESTROY_POLICY, evo.DESTROY_POLICY_DESTROY_ENTITY)
|
evo.set(f3, evo.DESTRUCTION_POLICY, evo.DESTRUCTION_POLICY_DESTROY_ENTITY)
|
||||||
local qt = evo.builder():include(ft):spawn()
|
local qt = evo.builder():include(ft):spawn()
|
||||||
|
|
||||||
local c4 = assert(evo.chunk(f4))
|
local c4 = assert(evo.chunk(f4))
|
||||||
@@ -4139,7 +4139,7 @@ end
|
|||||||
|
|
||||||
do
|
do
|
||||||
local f1 = evo.id()
|
local f1 = evo.id()
|
||||||
evo.set(f1, evo.DESTROY_POLICY, evo.DESTROY_POLICY_DESTROY_ENTITY)
|
evo.set(f1, evo.DESTRUCTION_POLICY, evo.DESTRUCTION_POLICY_DESTROY_ENTITY)
|
||||||
evo.set(f1, f1, f1)
|
evo.set(f1, f1, f1)
|
||||||
|
|
||||||
local remove_count = 0
|
local remove_count = 0
|
||||||
@@ -4165,7 +4165,7 @@ end
|
|||||||
|
|
||||||
do
|
do
|
||||||
local f1 = evo.id()
|
local f1 = evo.id()
|
||||||
evo.set(f1, evo.DESTROY_POLICY, evo.DESTROY_POLICY_REMOVE_FRAGMENT)
|
evo.set(f1, evo.DESTRUCTION_POLICY, evo.DESTRUCTION_POLICY_REMOVE_FRAGMENT)
|
||||||
evo.set(f1, f1, f1)
|
evo.set(f1, f1, f1)
|
||||||
|
|
||||||
local remove_count = 0
|
local remove_count = 0
|
||||||
@@ -4248,7 +4248,7 @@ do
|
|||||||
local f1, f2 = evo.id(2)
|
local f1, f2 = evo.id(2)
|
||||||
evo.set(f1, f1)
|
evo.set(f1, f1)
|
||||||
evo.set(f2, f1)
|
evo.set(f2, f1)
|
||||||
evo.set(f1, evo.DESTROY_POLICY, evo.DESTROY_POLICY_DESTROY_ENTITY)
|
evo.set(f1, evo.DESTRUCTION_POLICY, evo.DESTRUCTION_POLICY_DESTROY_ENTITY)
|
||||||
evo.destroy(f1)
|
evo.destroy(f1)
|
||||||
assert(not evo.alive(f1))
|
assert(not evo.alive(f1))
|
||||||
assert(not evo.alive(f2))
|
assert(not evo.alive(f2))
|
||||||
@@ -4258,7 +4258,7 @@ do
|
|||||||
local f1, f2 = evo.id(2)
|
local f1, f2 = evo.id(2)
|
||||||
evo.set(f1, f1)
|
evo.set(f1, f1)
|
||||||
evo.set(f2, f1)
|
evo.set(f2, f1)
|
||||||
evo.set(f1, evo.DESTROY_POLICY, evo.DESTROY_POLICY_REMOVE_FRAGMENT)
|
evo.set(f1, evo.DESTRUCTION_POLICY, evo.DESTRUCTION_POLICY_REMOVE_FRAGMENT)
|
||||||
evo.destroy(f1)
|
evo.destroy(f1)
|
||||||
assert(not evo.alive(f1))
|
assert(not evo.alive(f1))
|
||||||
assert(evo.alive(f2) and evo.empty(f2))
|
assert(evo.alive(f2) and evo.empty(f2))
|
||||||
@@ -4268,7 +4268,7 @@ end
|
|||||||
do
|
do
|
||||||
local f1, f2 = evo.id(2)
|
local f1, f2 = evo.id(2)
|
||||||
|
|
||||||
evo.set(f1, evo.DESTROY_POLICY, evo.DESTROY_POLICY_DESTROY_ENTITY)
|
evo.set(f1, evo.DESTRUCTION_POLICY, evo.DESTRUCTION_POLICY_DESTROY_ENTITY)
|
||||||
|
|
||||||
local e12a = evo.builder():set(f1, 1):set(f2, 2):spawn()
|
local e12a = evo.builder():set(f1, 1):set(f2, 2):spawn()
|
||||||
local e12b = evo.builder():set(f1, 3):set(f2, 4):spawn()
|
local e12b = evo.builder():set(f1, 3):set(f2, 4):spawn()
|
||||||
@@ -4302,7 +4302,7 @@ do
|
|||||||
evo.set(f1, evo.NAME, "f1")
|
evo.set(f1, evo.NAME, "f1")
|
||||||
evo.set(f2, evo.NAME, "f2")
|
evo.set(f2, evo.NAME, "f2")
|
||||||
|
|
||||||
evo.set(f1, evo.DESTROY_POLICY, evo.DESTROY_POLICY_REMOVE_FRAGMENT)
|
evo.set(f1, evo.DESTRUCTION_POLICY, evo.DESTRUCTION_POLICY_REMOVE_FRAGMENT)
|
||||||
|
|
||||||
local e12a = evo.builder():set(f1, 1):set(f2, 2):spawn()
|
local e12a = evo.builder():set(f1, 1):set(f2, 2):spawn()
|
||||||
local e12b = evo.builder():set(f1, 3):set(f2, 4):spawn()
|
local e12b = evo.builder():set(f1, 3):set(f2, 4):spawn()
|
||||||
@@ -4333,12 +4333,12 @@ do
|
|||||||
local fb = evo.builder()
|
local fb = evo.builder()
|
||||||
|
|
||||||
local f1 = fb:spawn()
|
local f1 = fb:spawn()
|
||||||
local f2 = fb:destroy_policy(evo.DESTROY_POLICY_DESTROY_ENTITY):spawn()
|
local f2 = fb:destruction_policy(evo.DESTRUCTION_POLICY_DESTROY_ENTITY):spawn()
|
||||||
local f3 = fb:destroy_policy(evo.DESTROY_POLICY_REMOVE_FRAGMENT):spawn()
|
local f3 = fb:destruction_policy(evo.DESTRUCTION_POLICY_REMOVE_FRAGMENT):spawn()
|
||||||
|
|
||||||
assert(evo.get(f1, evo.DESTROY_POLICY) == nil)
|
assert(evo.get(f1, evo.DESTRUCTION_POLICY) == nil)
|
||||||
assert(evo.get(f2, evo.DESTROY_POLICY) == evo.DESTROY_POLICY_DESTROY_ENTITY)
|
assert(evo.get(f2, evo.DESTRUCTION_POLICY) == evo.DESTRUCTION_POLICY_DESTROY_ENTITY)
|
||||||
assert(evo.get(f3, evo.DESTROY_POLICY) == evo.DESTROY_POLICY_REMOVE_FRAGMENT)
|
assert(evo.get(f3, evo.DESTRUCTION_POLICY) == evo.DESTRUCTION_POLICY_REMOVE_FRAGMENT)
|
||||||
end
|
end
|
||||||
|
|
||||||
do
|
do
|
||||||
|
|||||||
60
evolved.lua
60
evolved.lua
@@ -1,7 +1,7 @@
|
|||||||
local evolved = {
|
local evolved = {
|
||||||
__HOMEPAGE = 'https://github.com/BlackMATov/evolved.lua',
|
__HOMEPAGE = 'https://github.com/BlackMATov/evolved.lua',
|
||||||
__DESCRIPTION = 'Evolved ECS (Entity-Component-System) for Lua',
|
__DESCRIPTION = 'Evolved ECS (Entity-Component-System) for Lua',
|
||||||
__VERSION = '0.0.1',
|
__VERSION = '1.0.0',
|
||||||
__LICENSE = [[
|
__LICENSE = [[
|
||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
@@ -715,9 +715,9 @@ local __EXECUTE = __acquire_id()
|
|||||||
local __PROLOGUE = __acquire_id()
|
local __PROLOGUE = __acquire_id()
|
||||||
local __EPILOGUE = __acquire_id()
|
local __EPILOGUE = __acquire_id()
|
||||||
|
|
||||||
local __DESTROY_POLICY = __acquire_id()
|
local __DESTRUCTION_POLICY = __acquire_id()
|
||||||
local __DESTROY_POLICY_DESTROY_ENTITY = __acquire_id()
|
local __DESTRUCTION_POLICY_DESTROY_ENTITY = __acquire_id()
|
||||||
local __DESTROY_POLICY_REMOVE_FRAGMENT = __acquire_id()
|
local __DESTRUCTION_POLICY_REMOVE_FRAGMENT = __acquire_id()
|
||||||
|
|
||||||
---
|
---
|
||||||
---
|
---
|
||||||
@@ -726,12 +726,6 @@ local __DESTROY_POLICY_REMOVE_FRAGMENT = __acquire_id()
|
|||||||
---
|
---
|
||||||
|
|
||||||
local __safe_tbls = {
|
local __safe_tbls = {
|
||||||
---@type evolved.entity[]
|
|
||||||
__EMPTY_ENTITY_LIST = __lua_setmetatable({}, {
|
|
||||||
__tostring = function() return 'empty entity list' end,
|
|
||||||
__newindex = function() __error_fmt 'attempt to modify empty entity list' end
|
|
||||||
}),
|
|
||||||
|
|
||||||
---@type table<evolved.fragment, integer>
|
---@type table<evolved.fragment, integer>
|
||||||
__EMPTY_FRAGMENT_SET = __lua_setmetatable({}, {
|
__EMPTY_FRAGMENT_SET = __lua_setmetatable({}, {
|
||||||
__tostring = function() return 'empty fragment set' end,
|
__tostring = function() return 'empty fragment set' end,
|
||||||
@@ -872,14 +866,6 @@ end
|
|||||||
|
|
||||||
local __debug_fns = {}
|
local __debug_fns = {}
|
||||||
|
|
||||||
---@param chunk evolved.chunk
|
|
||||||
function __debug_fns.validate_chunk(chunk)
|
|
||||||
if chunk.__unreachable_or_collected then
|
|
||||||
__error_fmt('the chunk (%s) is unreachable or collected and cannot be used',
|
|
||||||
chunk)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
---@param entity evolved.entity
|
---@param entity evolved.entity
|
||||||
function __debug_fns.validate_entity(entity)
|
function __debug_fns.validate_entity(entity)
|
||||||
local entity_index = entity % 0x100000
|
local entity_index = entity % 0x100000
|
||||||
@@ -924,14 +910,6 @@ function __debug_fns.validate_fragments(...)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param fragment_list evolved.fragment[]
|
|
||||||
---@param fragment_count integer
|
|
||||||
function __debug_fns.validate_fragment_list(fragment_list, fragment_count)
|
|
||||||
for i = 1, fragment_count do
|
|
||||||
__debug_fns.validate_fragment(fragment_list[i])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
---@param components table<evolved.fragment, evolved.component>
|
---@param components table<evolved.fragment, evolved.component>
|
||||||
function __debug_fns.validate_component_map(components)
|
function __debug_fns.validate_component_map(components)
|
||||||
for fragment in __lua_next, components do
|
for fragment in __lua_next, components do
|
||||||
@@ -2182,10 +2160,10 @@ local function __destroy_fragment_list(fragment_list, fragment_count)
|
|||||||
releasing_fragment_count = releasing_fragment_count + 1
|
releasing_fragment_count = releasing_fragment_count + 1
|
||||||
releasing_fragment_list[releasing_fragment_count] = processing_fragment
|
releasing_fragment_list[releasing_fragment_count] = processing_fragment
|
||||||
|
|
||||||
local processing_fragment_destroy_policy = __evolved_get(processing_fragment, __DESTROY_POLICY)
|
local processing_fragment_destruction_policy = __evolved_get(processing_fragment, __DESTRUCTION_POLICY)
|
||||||
or __DESTROY_POLICY_REMOVE_FRAGMENT
|
or __DESTRUCTION_POLICY_REMOVE_FRAGMENT
|
||||||
|
|
||||||
if processing_fragment_destroy_policy == __DESTROY_POLICY_DESTROY_ENTITY then
|
if processing_fragment_destruction_policy == __DESTRUCTION_POLICY_DESTROY_ENTITY then
|
||||||
destroy_entity_policy_fragment_count = destroy_entity_policy_fragment_count + 1
|
destroy_entity_policy_fragment_count = destroy_entity_policy_fragment_count + 1
|
||||||
destroy_entity_policy_fragment_list[destroy_entity_policy_fragment_count] = processing_fragment
|
destroy_entity_policy_fragment_list[destroy_entity_policy_fragment_count] = processing_fragment
|
||||||
|
|
||||||
@@ -2205,12 +2183,12 @@ local function __destroy_fragment_list(fragment_list, fragment_count)
|
|||||||
|
|
||||||
processing_fragment_stack_size = processing_fragment_stack_size + minor_chunk_entity_count
|
processing_fragment_stack_size = processing_fragment_stack_size + minor_chunk_entity_count
|
||||||
end
|
end
|
||||||
elseif processing_fragment_destroy_policy == __DESTROY_POLICY_REMOVE_FRAGMENT then
|
elseif processing_fragment_destruction_policy == __DESTRUCTION_POLICY_REMOVE_FRAGMENT then
|
||||||
remove_fragment_policy_fragment_count = remove_fragment_policy_fragment_count + 1
|
remove_fragment_policy_fragment_count = remove_fragment_policy_fragment_count + 1
|
||||||
remove_fragment_policy_fragment_list[remove_fragment_policy_fragment_count] = processing_fragment
|
remove_fragment_policy_fragment_list[remove_fragment_policy_fragment_count] = processing_fragment
|
||||||
else
|
else
|
||||||
__error_fmt('unknown DESTROY_POLICY policy (%s) on (%s)',
|
__error_fmt('unknown DESTRUCTION_POLICY (%s) on (%s)',
|
||||||
__id_name(processing_fragment_destroy_policy), __id_name(processing_fragment))
|
__id_name(processing_fragment_destruction_policy), __id_name(processing_fragment))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -5192,10 +5170,10 @@ function __builder_mt:epilogue(epilogue)
|
|||||||
return self:set(__EPILOGUE, epilogue)
|
return self:set(__EPILOGUE, epilogue)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param destroy_policy evolved.id
|
---@param destruction_policy evolved.id
|
||||||
---@return evolved.builder builder
|
---@return evolved.builder builder
|
||||||
function __builder_mt:destroy_policy(destroy_policy)
|
function __builder_mt:destruction_policy(destruction_policy)
|
||||||
return self:set(__DESTROY_POLICY, destroy_policy)
|
return self:set(__DESTRUCTION_POLICY, destruction_policy)
|
||||||
end
|
end
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -5269,9 +5247,9 @@ __evolved_set(__EXECUTE, __NAME, 'EXECUTE')
|
|||||||
__evolved_set(__PROLOGUE, __NAME, 'PROLOGUE')
|
__evolved_set(__PROLOGUE, __NAME, 'PROLOGUE')
|
||||||
__evolved_set(__EPILOGUE, __NAME, 'EPILOGUE')
|
__evolved_set(__EPILOGUE, __NAME, 'EPILOGUE')
|
||||||
|
|
||||||
__evolved_set(__DESTROY_POLICY, __NAME, 'DESTROY_POLICY')
|
__evolved_set(__DESTRUCTION_POLICY, __NAME, 'DESTRUCTION_POLICY')
|
||||||
__evolved_set(__DESTROY_POLICY_DESTROY_ENTITY, __NAME, 'DESTROY_POLICY_DESTROY_ENTITY')
|
__evolved_set(__DESTRUCTION_POLICY_DESTROY_ENTITY, __NAME, 'DESTRUCTION_POLICY_DESTROY_ENTITY')
|
||||||
__evolved_set(__DESTROY_POLICY_REMOVE_FRAGMENT, __NAME, 'DESTROY_POLICY_REMOVE_FRAGMENT')
|
__evolved_set(__DESTRUCTION_POLICY_REMOVE_FRAGMENT, __NAME, 'DESTRUCTION_POLICY_REMOVE_FRAGMENT')
|
||||||
|
|
||||||
---
|
---
|
||||||
---
|
---
|
||||||
@@ -5450,9 +5428,9 @@ evolved.EXECUTE = __EXECUTE
|
|||||||
evolved.PROLOGUE = __PROLOGUE
|
evolved.PROLOGUE = __PROLOGUE
|
||||||
evolved.EPILOGUE = __EPILOGUE
|
evolved.EPILOGUE = __EPILOGUE
|
||||||
|
|
||||||
evolved.DESTROY_POLICY = __DESTROY_POLICY
|
evolved.DESTRUCTION_POLICY = __DESTRUCTION_POLICY
|
||||||
evolved.DESTROY_POLICY_DESTROY_ENTITY = __DESTROY_POLICY_DESTROY_ENTITY
|
evolved.DESTRUCTION_POLICY_DESTROY_ENTITY = __DESTRUCTION_POLICY_DESTROY_ENTITY
|
||||||
evolved.DESTROY_POLICY_REMOVE_FRAGMENT = __DESTROY_POLICY_REMOVE_FRAGMENT
|
evolved.DESTRUCTION_POLICY_REMOVE_FRAGMENT = __DESTRUCTION_POLICY_REMOVE_FRAGMENT
|
||||||
|
|
||||||
evolved.id = __evolved_id
|
evolved.id = __evolved_id
|
||||||
|
|
||||||
|
|||||||
34
rockspecs/evolved.lua-1.0.0-0.rockspec
Normal file
34
rockspecs/evolved.lua-1.0.0-0.rockspec
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
rockspec_format = "3.0"
|
||||||
|
package = "evolved.lua"
|
||||||
|
version = "1.0.0-0"
|
||||||
|
source = {
|
||||||
|
url = "git://github.com/BlackMATov/evolved.lua",
|
||||||
|
tag = "v1.0.0",
|
||||||
|
}
|
||||||
|
description = {
|
||||||
|
homepage = "https://github.com/BlackMATov/evolved.lua",
|
||||||
|
summary = "Evolved ECS (Entity-Component-System) for Lua",
|
||||||
|
detailed = [[
|
||||||
|
`evolved.lua` is a fast and flexible ECS (Entity-Component-System) library for Lua.
|
||||||
|
It is designed to be simple and easy to use, while providing all the features needed to create complex systems with blazing performance.
|
||||||
|
]],
|
||||||
|
license = "MIT",
|
||||||
|
labels = {
|
||||||
|
"ecs",
|
||||||
|
"entity",
|
||||||
|
"entities",
|
||||||
|
"component",
|
||||||
|
"components",
|
||||||
|
"entity-component",
|
||||||
|
"entity-component-system",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
dependencies = {
|
||||||
|
"lua >= 5.1",
|
||||||
|
}
|
||||||
|
build = {
|
||||||
|
type = "builtin",
|
||||||
|
modules = {
|
||||||
|
evolved = "evolved.lua",
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,10 +3,15 @@ package = "evolved.lua"
|
|||||||
version = "scm-0"
|
version = "scm-0"
|
||||||
source = {
|
source = {
|
||||||
url = "git://github.com/BlackMATov/evolved.lua",
|
url = "git://github.com/BlackMATov/evolved.lua",
|
||||||
|
branch = "main",
|
||||||
}
|
}
|
||||||
description = {
|
description = {
|
||||||
homepage = "https://github.com/BlackMATov/evolved.lua",
|
homepage = "https://github.com/BlackMATov/evolved.lua",
|
||||||
summary = "Evolved ECS (Entity-Component-System) for Lua",
|
summary = "Evolved ECS (Entity-Component-System) for Lua",
|
||||||
|
detailed = [[
|
||||||
|
`evolved.lua` is a fast and flexible ECS (Entity-Component-System) library for Lua.
|
||||||
|
It is designed to be simple and easy to use, while providing all the features needed to create complex systems with blazing performance.
|
||||||
|
]],
|
||||||
license = "MIT",
|
license = "MIT",
|
||||||
labels = {
|
labels = {
|
||||||
"ecs",
|
"ecs",
|
||||||
|
|||||||
Reference in New Issue
Block a user