Skip to content

Find and remove all ComponentRegistry misuse. #6440

@moonheart08

Description

@moonheart08

A shocking amount of code treats it as a collection of component types, instead of a collection of instantized components. This is not only wasteful (as you must instantiate components you then don't use), but also actively confusing (people seem to expect the thing only intended to instantiate entities to be some kind of pattern they can match on. This is not how it works and we cannot implement component pattern matching in any reasonable way.)

These all need replaced with a HashSet<Type>.

ComponentRegistry itself needs rewritten to not inherit from Dictionary and spill internal details, for ease of use.

Current culprit APIs in engine:

  • CompRegistryQueryEnumerator
    Also needs optimized to look up all trait dictionaries in advance. The query can never change, so we can rewrite the whole thing to "does this entity exist in all of these trait dicts?"
  • ComponentQueryEnumerator, ditto w/ above.`
  • AddComponents/RemoveComponents. Rather, AddComponents needs an overload that accepts a set of types, and RemoveComponents needs to only accept a set of types.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions