So I’m working on a weapon system which I try to design as follows:
Each type of weapon inherits from a MasterWeapon class. So AssaultRifle, SMG, Pistol and Shotgun classes inherit from master weapon and I create different archetypes of those types for each weapon.
So for example if I had an M4A1 weapon it would be like:
MasterWeapon - this is an abstract class that holds no implementation
AssaultRifle - this class implements functions from the abstract class like Shoot() / Reload()
[INDENT]M4A1[/INDENT] - this class just hold the different configuration for the current weapon like Rate of Fire, Ammo etc
So my question is:
So what I need is my character to keep track of the two currently holding weapons (primary and secondary) So I thought of creating this:
So, for example if I get a reference of M4A1 class, can I set it to the PrimaryWeapon pointer? And will it keep the data? Is that a good approach? Is there a better solution for this problem?