8000 GitHub - Aloroid/ecr: A fast entity component system for Luau.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Aloroid/ecr

 
 

Repository files navigation




⚠️ This library is in early stages of development with breaking changes being made often.

ECR is a pure Luau ECS library.

  • Uses Luau typechecking
  • A library and not a framework
  • Cache friendly sparse-set based storage that can support perfect SoA.
  • Carefully optimized memory usage and performance.
  • Signals and observers for detecting changes to components.
  • Utilities for common practices such as queuing events.
  • ⚡ Blazingly fast

Getting started

Read the crash course for a brief introduction to the library.

Code sample

local ecr = require(ecr)

-- define components
local Position = ecr.component() :: Vector3
local Velocity = ecr.component() :: Vector3

-- define a system
local function update_physics(world: ecr.Registry, dt: number)
    for id, pos, vel in world:view(Position, Velocity) do
        world:set(id, Position, pos + vel*dt)
    end
end

-- instantiate the world
local world = ecr.registry()

-- create entities and assign components
for i = 1, 10 do
    local id = world:create()
    world:set(id, Position, Vector3.new(i, 1, 1))
    world:set(id, Velocity, Vector3.new(10, 0, 0))
end

-- run system
update_physics(world, 1/60)

About

A fast entity component system for Luau.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Lua 100.0%
0