This PR introduces EntityFactory to manage entity creation, and EntityController, to encapsulate position and other state updates of entities.
I made almost everything non-static, because the initialization of TextureManager (reading in texture files) seem to have quite a big performance overhead if done in a static (actually it probably takes the same amount of time, but it happens at a totally unexpected and annoying time).
Also made every class explcitily public if it wasn't aleady.
Pay special attention to the part
Placeholder entities also have to have their own EntityController, otherwise the GetComponent calls return nulls, accessing those naturally cause NullReferenceExceptions (and consequently lag spikes), and to make things worse, for whatever reason Unity seems to swallow exceptions, so it's pretty hard to track down. Further details here: https://www.reddit.com/r/Unity2D/comments/egda2u/unity_swallowing_exceptions/
Edit: Unity does not swallow exceptions, they should be shown on the console, unless it's explicitly turned off by the button above the console, to right. Which in my setting was unfortunately outside of my computer's screen.
This PR introduces
EntityFactory
to manage entity creation, andEntityController
, to encapsulate position and other state updates of entities. I made almost everything non-static, because the initialization ofTextureManager
(reading in texture files) seem to have quite a big performance overhead if done in astatic
(actually it probably takes the same amount of time, but it happens at a totally unexpected and annoying time). Also made every class explcitily public if it wasn't aleady. Pay special attention to the partPlaceholder entities also have to have their own
EntityController
, otherwise theGetComponent
calls returnnulls
, accessing those naturally causeNullReferenceException
s (and consequently lag spikes), and to make things worse, for whatever reason Unity seems to swallow exceptions, so it's pretty hard to track down. Further details here: https://www.reddit.com/r/Unity2D/comments/egda2u/unity_swallowing_exceptions/ Edit: Unity does not swallow exceptions, they should be shown on the console, unless it's explicitly turned off by the button above the console, to right. Which in my setting was unfortunately outside of my computer's screen.