evaera / matter

A modern ECS library for Roblox.
https://eryn.io/matter/
MIT License
141 stars 32 forks source link

Allow components to be constructed with default values #10

Closed benbrimeyer closed 2 years ago

benbrimeyer commented 2 years ago

Often my systems will expect certain fields to exist within components.

It'd be great to have a built-in way to support default values for components when they're assigned to entities.

I'm thinking it could work something like:

local component = Matter.component(name, { foo = "bar", xyz = nil })
world:spawn(component({ xyz = "abc" })) -- an entity is created with component data as { foo = "bar", xyz = "abc" }