Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/liuhaopen/ecs
unity ecs framework implemented by Lua
https://github.com/liuhaopen/ecs
ecs entities lua luaecs unityecs
Last synced: 2 months ago
JSON representation
unity ecs framework implemented by Lua
- Host: GitHub
- URL: https://github.com/liuhaopen/ecs
- Owner: liuhaopen
- Created: 2019-01-18T07:08:17.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2021-06-23T15:00:23.000Z (over 3 years ago)
- Last Synced: 2024-11-10T23:37:18.475Z (3 months ago)
- Topics: ecs, entities, lua, luaecs, unityecs
- Language: Lua
- Size: 149 KB
- Stars: 58
- Watchers: 6
- Forks: 18
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# usage
```
local ecs = require "ecs.ecs"local world = ecs.world:new()
local entity_mgr = world.entity_mgrlocal entity = entity_mgr:create_entity("move_info", "speed", "height")
entity_mgr:set_component(entity, "move_info", {x=1, y=2, z=3})
local move_info = entity_mgr:get_component(entity, "move_info")
entity_mgr:remove_component(entity, "move_info")
entity_mgr:destroy_entity(entity)local move_sys = ecs.class("move_sys", ecs.system)
function move_sys:on_update()
self.filter = self.filter or ecs.all("move_info", "speed")
--complex version: ecs.all(ecs.any("com1", "com2"), ecs.any("com3", "com4"), ecs.no("com5", "com6"))
self:foreach(self.filter, function(ed)
ed.move_info.x = 3
ed.speed = 4
end)
end
world:add_system(move_sys)world:update()
```