mizu icon indicating copy to clipboard operation
mizu copied to clipboard

System constructor is not checking if component exist

Open sedyh opened this issue 2 years ago • 0 comments

Problem

When adding systems, there is no check for unregistered components.

func makeSystem(world *world, s interface{}) *system {
    ...
    componentId, found := world.componentIds[componentType.Elem()]
    if !found {
        continue // system pointer field is not component bound
    }
    ...
}

Solution

Setting a panic at this point will solve the problem, but may affect the ability to correctly compare entities by mask, as well as the ability to get optional components. It's also worth noting that fixing issue #1 might fix this issue as well, as before initialization of systems, there will be an initialization of entities in which this check is already present.

sedyh avatar May 13 '22 12:05 sedyh