[ad_1]
How do on-line video games deal with creation of latest entities? I at present have an EntityManufacturing unit class that requires an ID (specifying the entity sort). A bunch of subroutines are executed to find out precisely what the entity is and the way it ought to be composed, after which the ultimate perform spits out the outcome.
I see just a few potential points with this method although:
- First of all, it is tough so as to add new entity sorts. I do not like having to enter my sport’s code with the intention to change entity behaviour.
- Second, it is unattainable to switch the way in which entities are generated at runtime. It could be good to have this performance, particularly when testing sport mechanics.
- And lastly, since the entire details about creating objects is inside my sport code, I’m apprehensive about efficiency turning into a difficulty when I’ve a lot of entities that may be created. I take advantage of inheritance for entities in the identical “class” to scale back the quantity of code I want to put in writing, but it surely’s nonetheless quite a lot of code.
I’ve heard of utilizing JSON to fight a few of these points, however I am unable to image how that will work.
If I load the entire JSON information into the sport upon beginning the server, then I resolve the primary situation, however not the second and third.
If I solely “require” the JSON as I want it and have not one of the information in reminiscence, then I resolve the second situation as properly, however is not this even worse for efficiency? I am unable to think about this could be higher than preserving every part in reminiscence, as a result of I would want to deserialize in realtime.
I might do each, preserving all “present” information about entity initialization in reminiscence, and solely deserialize when a change is made to a file. I am unable to assist however really feel like there are higher choices although. For instance, if a monster is simply spawned as soon as each 100 hours, it does not actually make sense to me to not have it in a separate file someplace and solely learn when essential.
I suppose I can maintain information that’s wanted incessantly deserialized always and information that is not required usually could be deserialized on request?
If anybody has expertise with these subjects I’d actually recognize some perception into the matter.
[ad_2]