Posted 13 June 2001 - 07:40 AM
Ok, here''s the situation. I''m working on a game where the end user will be able to create new game objects. Anyways I''m setting it up so that these new objects can spawn objects (e.g. a missile launcher spawns missile objects).
Now each of these objects (missile and missile launcher) will reside in different files, and all object files will be loaded at load time.
Due to the fact that I''m keeping objects seperate, and each object won''t know what objects actually reside in the system until load time (not compile time) I plan on using the Class class and the forName function.
Class missileToSpawn = Class.forName("MyNewMissile");
Now because the MyNewMissile class was loaded into the RTTI at load time this should work fine.
My question is -- Is the RTTI ever garbage collected?
If so, does it follow that same rules as objects, as long as it is being referenced, it will exist.
So by making missileToSpawn variable static, MyNewMissile will always reside in memory, therefore be quick to access?
I can''t seem to find anything on the web, and my concern is speed. If the MyNewMissile class ever got garbage collected, the next time I tried to spawn one, there would be file access -- NOT GOOD.
I''m keeping things seperate becuase I want other missile launcher classes be able to spawn this type of missile. But because things are in seperate files, I don''t want the MissileLauncher class to have direct access to MyNewMissile, I don''t know what would happen if someone downloaded the missile launcher class but not the MyNewMissile class. By doing it this way I can make the game engine simply invalidate the missile launcher class if a class by the name of "MyNewMissile" doesn''t exist in memory.
I hope this message is clear enough. And thanks in advance if anyone out there can help.