Weapon system refactor

   Author: Daniel Jackson


  The weapon system as it was functioned perfectly well however anytime anything weapon related was needed, a series of functions needed to be called. In the short term (and to get things off the ground) this was fine however doing these function hundreds of times a second adds up and gets expensive quickly. Because of this when the weapons are fired, even the least expensive weapon, there is a significant drop in frame-rate and while at the moment it's not noticeable it could hurt the final project later on.


    To alleviate the strain of the multiple function calls, I've been working on refactoring the weapon so that each weapon is it's own struct containing the appropriate values for the weapon. Removing the need for function calls entirely, now we simply access the struct and grab the values directly saving us at least roughly 40 frames while the weapon is in use. Additionally, using this new system we can add any extra effect to any weapon we choose at any point.


(list of functions needed for our simplest weapon)


(One struct that can be used to access or add features to any weapon)
(colloquially named Jim)




Comments

Popular posts from this blog

Adding assets to every enemy -- Owen Meyers

Sphere to AABB collision