This is more of an academic question, but I don’t understand why we grab singletons through a static method on SystemAPI. I suppose the same question goes for performing queries in general.
(this is in Entities 1.0, if it matters)
I understand that SystemState is used by unmanaged systems to access the current entity state. Component lookups use the SystemState to update themselves, and you can access the EntityManager through it.
But why do we query for singletons, and perform queries in general, through SystemAPI? It seems like you use SystemState to get an EntityQuery, but that you use SystemAPI to actually perform queries.
I’d think you would need to perform the query in a specific world: information that would be attached to be attached to the SystemState, and not necessarily available to the static SystemAPI methods.
SystemAPI is generating code. It does way more than just the line you’re calling. SystemAPI.GetSingleton generates a private EntityQuery and sets it up in OnCreate.
It’s not quite there yet but SystemAPI is trying to reduce boilerplate code. We are missing Component/BufferTypeHandle but ComponentLookup is already implemented. Just calling SystemAPI.GetComponentLookup generates the private ComponentLookup, the Get in OnCreate and an .Update in the system Update method. All with just one line. I think that’s pretty neat.