Non-generic API
Non-generic API, so that you can also work easily with types.
Last updated
Was this helpful?
Non-generic API, so that you can also work easily with types.
Last updated
Was this helpful?
Sometimes we don't know the types and generics at runtime... For example, if we do a lot of dynamic programming such as saving/loading or similar cases. Sometimes we simply cannot express everything using generics, but are forced to fall back on types. And that's where this chapter comes in!
So far, you have only learned about the generic API, which is primarily used in all examples. However, for EVERY single generic method there is also a counterpart that is not generic. This variant uses ComponentType
and Signature
.
Generic values are always known at compile time. To make these available at runtime, there is first of all ComponentType
. This abstracts a component, i.e. expresses the component and its metadata.
And we have already received the ComponentType
without knowing it at runtime. Practical, isn't it? Well, we're almost there, but there's one more important thing.
You now know what a ComponentType
is. What is a Signature
? In the end, a Signature
is just a collection of ComponentTypes
. It is used in different areas, for example to specify the structure of an without generics.
A Signature
is therefore used in many different places. Among other things, it is also used to define queries.
It's as easy as this. Now you should know roughly what a Signature
is good for, shouldn't you?
You should have the basics down now, right? Otherwise there are many other cases where the non-generic API is used.
What more could you want? Now you can manage and command your entities generically and without a generic API, a bright future lies ahead of you!