bambi wrote:Hi Codders!
RAWR, It's coders...
CODERS!Anyway.. to your question..
bambi wrote:I have a question, is it better to expand a class or to expand from that class's parent such as,
- Code: Select all
class DeusExGameInfo expands GameInfo
config;
Should I expand from DeusExGameInfo and override all its functions, which I want, or should I just expand from GameInfo?
That depends on what you want to do.
I don't know your intention but in case you want to make a new game type for MP, then extending DeusExGameInfo is not the way.
You should always extend the class that has the most similarities to what you want to do.
If you want to make a game class for a game type that's basically Team deathmatch, you should extend it 'TeamDMGame'.
If it shall be a kind of deathmatch, you should extend it 'Deathmatchgame'.
In case you want to make something very different, you should possibly go up one level in the class hierarchy and extend it DeusExMPGame.
If course, you could also extend your TDM game type from DeusExMPGame for instance, but then you have to write all the team game code by yourself, instead of inheriting it from the existing 'TeamDMGame' game class.
A better but common example would be, if you wanted to make a LAM that shots shrapnel for instance. Coding wise, it will make your life much easier if you extend it the LAM class instead of 'DeusExWeapon' or something similar.. because your class will inherit the grenade code from the LAM and you don't have to write it all on your own.
So yeah, exactly what Klop said!