nanderv / ECFS

Entity Component Filter System for Love2d. First step: writing down what the hell it even means.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Entity Component Filter System

Entity Component Filter System for Love2d. First step: writing down what the hell it even means.

What is an Entity Component Filter System?

And entity component filter system is a way to organize the way data influences logic within a game. It is built around the idea of splitting up responsibilities between plain data objects, filters and systems.

Entity

Entities are the objects within the game. In the most basic idea they are an entry in the entity-table, with a table containing their properties. The properties of entities are called components.

Component

Components are properties of entities.

Filter

Filters are pretty much a reverse inheritence system. 'It has four wheels, so it is a car' is a sort-of-correct example of how a filter works.

System

A system is a piece of logic. It contains logic functions that run each frame (update, draw), logic functions that run upon load (load), and logic functions that run when an entity registers to a certain filter:

local s = {}
s.functions = {}
s.functions.update = function() end
s.register = {}
s.unregister = {}
s.register.wall   = function(entity) end
s.unregister.wall = function(entity) end

Event System

The Event System used here uses a double-buffer sort of methodology. Events get added to a double-buffer, and get handled in the next frame. A delay of 16 ms is introduced, but this should be fine.

And event has the following shape:

{
    funct= function(dt) end,
    data = {someData},
    object = {someStateObject}    
}

If the object is null, then it's seen as an event that will fire regardless of object.

About

Entity Component Filter System for Love2d. First step: writing down what the hell it even means.

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:Lua 100.0%Language:Batchfile 0.0%