🥳 New feature: entity class composition with reusable component sets
I added the new extends
keyword to the EntityBuilder DSL because a lot of entities start out with the same handful of components, and repeating all of this boilerplate in each new entity definition can end up obscuring all the interesting stuff that makes each one of those entities different. Now you can mix and match component sets and reuse them by extending the components of another class, or even merge several other entities together.
You can use extends
to merge the set of components and default attributes from one or more existing entities to create new ones through composition rather than inheritance.
Example
Shape = entity do
Position()
Scale()
Rotation()
end
Container = entity do
Position({ x: 0, y: 0})
Scale({ width: 1024, height: 1024 })
Centered()
end
Label = entity do
extends Shape
Text()
Font()
end
Title = entity do
extends Label, Container
Text({ color: "#cca533".rgb.lighten(0.25) })
Font({ size: 48 })
Visible()
end