Closed raineszm closed 3 years ago
Hello, this is actually by design :) Since Entity
is a struct, its default value would have the internal WorldId 0 so this means you could access a real entity data with the default value if 0 were a valid WorldId, which would be weird.
Also doing so leave the id 0 in the Publisher open to be used for static subscription that is used internally, ex:
https://github.com/Doraku/DefaultEcs/blob/a86000d2ab0588e0da81a0ea38d8aa5b949b5dc0/source/DefaultEcs/Technical/ComponentManager.cs#L33
I could just do a WorldId - 1 when accessing the arrays but I think it would incur a small performance loss, so all in all I think the tradeoff of losing (n + 1) * IntPtr
amount of memory (n: number of components) for all this is acceptable.
Ah. That's clever. I see. Never mind. Thanks for a great library!
Thanks, don't hesitate if you have questions.
The static constructor for World is
This leads to the lowest world Id being
1
and the first element of the Worlds array being empty.