This idea:
* Should improve performance (eg. less memory allocation, smaller objects)
* Ensures values like .cargoSize and .cargoUsed are always present (defaulting to null on non-transporter objects)
* Allows scripters to add their own methods and properties to game objects
I tried writing this down in forums, but was struggling so ended up putting on a wiki page (sorry for inconvenience):
Classes for game objects
Idea for shrinking sizes of game objects, etc...
Idea for shrinking sizes of game objects, etc...
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
-- https://warzone.atlassian.net/wiki/display/GO
Re: Idea for shrinking sizes of game objects, etc...
Interesting idea. I'll have to look into the prototype support in the engine on the c++ side a bit more before I can comment on the feasibility of it.
Re: Idea for shrinking sizes of game objects, etc...
BTW: .prototype and .__proto__ are just normal JS objects, automatically created when a new object of any kind is instantiated (regardless of whether it's instantiated by C++ or JS).
The approach I was suggesting doesn't involve instantiating any classes, it's more of a cheat (less processing work) to fool JS in to thinking the game objects were instantiated from their respective classes. At the end of the day, JS just follows the __proto__ chain regardless of how it was formed. The extra bits are just to ensure useful operators such as typeof and instanceof will work correctly.
The approach I was suggesting doesn't involve instantiating any classes, it's more of a cheat (less processing work) to fool JS in to thinking the game objects were instantiated from their respective classes. At the end of the day, JS just follows the __proto__ chain regardless of how it was formed. The extra bits are just to ensure useful operators such as typeof and instanceof will work correctly.
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
-- https://warzone.atlassian.net/wiki/display/GO