Skip to content
Pierre-François Gimenez edited this page Jul 14, 2023 · 3 revisions

ECS (entity-component-system) is a software architecture used in many video game and most notably in roguelikes. Each element in the game (weapon, enemy, item, player, etc.) is an "entity" (typically a number in memory) with associated "components" that can be attached or detached.

In Jupiter Hell, the set of components attached to one entity is structured as a tree. For example, the entity associated to the player may have the "player" component (as a root), a weapon component (as a child of the player) and this weapon can have a perk (as a child of the weapon).

Components are created with blueprints, typically with item:attach("blueprint_name") that attaches it to item. To detach something, use world:detach(smthg).

(cpiod: should world:attach or ecs:attach be used?)

ecs:root

ecs:root( self ) is the parent of the parent of the parent (etc.) of self?

ecs:parent

ecs:parent( self ) get the parent of self

self:parent() is identical to ecs:parent( self )?

ecs:children

ecs:children( entity ) is the list of all the children of entity

child

item:child("blueprint_name") gets the child of item that matches the blueprint name

attach

item:attach("blueprint_name") creates a new entity with this blueprint and attaches it to item

ecs:add

ecs:add(entity,"blueprint_name"): what difference with attach?

Clone this wiki locally