Idea for shrinking sizes of game objects, etc...

For AI and campaign script related discussions and questions
Post Reply
User avatar
aubergine
Professional
Professional
Posts: 3459
Joined: 10 Oct 2010, 00:58
Contact:

Idea for shrinking sizes of game objects, etc...

Post by aubergine » 19 Jan 2013, 01:48

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
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO

Per
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 3753
Joined: 03 Aug 2006, 19:39

Re: Idea for shrinking sizes of game objects, etc...

Post by Per » 19 Jan 2013, 14:43

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.

User avatar
aubergine
Professional
Professional
Posts: 3459
Joined: 10 Oct 2010, 00:58
Contact:

Re: Idea for shrinking sizes of game objects, etc...

Post by aubergine » 19 Jan 2013, 15:34

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.
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO

Post Reply