Decore - a Defold library for managing ECS game entities and components in a data-driven way. The ECS is based on tiny ECS library.
The API of Tiny ECS is unchanged, so you can get familiar with it first and then use Decore. Decore provides an architecture for your game with additional features, tools and examples.
- Entity Management: Register, create and manage game entities
- Component Management: Add, remove and update entity components
- Easy Integration: Simple setup and integration with Defold projects
Add in your game.project dependencies:
https://github.com/Insality/decore/archive/refs/tags/3.zip
Note: The library size is calculated based on the build report per platform
| Platform | Library Size |
|---|---|
| HTML5 | 11.86 KB |
| Desktop / Mobile | 19.17 KB |
local decore = require("decore.decore")
function init(self)
local world = decore.new_world(
require("system.input.system_input").create(),
require("system.transform.system_transform").create(),
require("system.game_object.system_game_object").create(),
)
decore.register_entities("game", {
["player"] = require("entity.player.player_entity")
})
world:addEntity(decore.create_prefab("player"))
end
function update(self, dt)
self.world:update(dt)
end
function on_input(self, action_id, action)
-- Systems can be accessed via world, if registered
-- Example: https://github.com/Insality/asset-store/blob/main/system/Insality/input/input_command.lua
return self.world.input:on_input(action_id, action)
end
function final(self)
self.world:clearEntities()
self.world:clearSystems()
endLook at next examples to get more information about how to use the library:
- System examples - System examples
- Entity example - Entity example
- Shooting Circles - Game Example
- Cosmic Dash - Game Example
local decore = require("decore.decore")
-- Create new world instance
decore.new_world(...)
-- Create new system instance
decore.system(system_module, system_id, [require_all_filters])
decore.processing_system(system_module, system_id, [require_all_filters])
decore.sorted_system(system_module, system_id, [require_all_filters])
decore.sorted_processing_system(system_module, system_id, [require_all_filters])
-- Register entity to create it with `create_prefab` function
decore.register_entity(entity_id, entity_data, [pack_id])
decore.register_entities(pack_id, entities)
decore.unregister_entities(pack_id)
-- Create new entity instance
decore.create([components])
decore.create_prefab([prefab_id], [pack_id], [components])
-- Register component to decore components
decore.register_component(component_id, [component_data], [pack_id])
decore.register_components(components_data)
decore.unregister_components(pack_id)
-- Create new component instance
decore.create_component(component_id, [component_pack_id])
decore.apply_component(entity, component_id, [component_data])
decore.apply_components(entity, [components])
-- Find entities
decore.find_entities(world, component_id, [component_value])
-- Debug functions
decore.print_loaded_packs_debug_info()
decore.print_loaded_systems_debug_info(world)
-- Logging
decore.set_logger([logger_instance])
decore.get_logger([name], [level])Read the Use Cases file to see several examples of how to use the this module in your Defold game development projects.
This project is licensed under the MIT License - see the LICENSE file for details.
If you have any issues, questions or suggestions please create an issue.
Details
- Initial release
- Reworked API and internal structure
- Updated documentation
- Updated event bus system for better performance
- Update documentation
Your donation helps me stay engaged in creating valuable projects for Defold. If you appreciate what I'm doing, please consider supporting me!
