I’m wondering as to the best way to store different types of weapons for my game. Say for instance that I have a weapon with three different variables to it: fireRate, damage, and accuracy (simplified for the sake of explanation). What would be the best way to create many different versions of the base weapon where say the SMG has a firerate of 0.1, damage of 5, and accuracy of 5, where the Rifle has a firerate of 1, damage of 20, and accuracy of 1? One attempt I have made was to create a base struct or class called BulletType containing the basic variables fireRate, damage, and accuracy, and then multiple other classes/structs that extend BulletType and assign their own values to the variables inherited from BulletType. In practice, I want to be able to create a new instance of, say, the SMG class, and add it to the List of bullet types that can be toggled between on the player.
In essence, my question boils down to two things:
- Are structs or classes ideal for
this basic storage of weapon types - Is this approach the way to go about storing this data? The data is very simple and there is not much more to be stored besides a bunch of floats and bools, I just need a simple way to go about creating and storing weapon types that can be called easily at runtime.