Need advice on handling weapon reload animations for weapon with dual fire modes and magazines.
Hello. This might seem like a simple problem but there are some things that make it more complex than it should be, so I decided to ask for advice here.
Weapons in my game work as follows: They have two fire modes, the primary which is fired with LMB and the secondary which is fired with RMB, a weapon might use the same magazine for both fire modes, have different magazines for different fire modes or have one or both fire modes not use magazines, this introduces a bit of a problem when it comes to reloading.
This is because a weapon might have to use an animation for reloading the primary clip, an animation for reloading the secondary clip, and an animation for reloading both at the same time, and not every weapon might need all these animations: some weapons might use none because they don't use clips, some might only need the primary or the secondary, some may need the primary and the secondary but not the animation for reloading both and so on.
I could have the weapons hold three pointers to animations and just not worry if some of these are set to null because it won't cause a massive memory waste, but the situation gets more complicated when you factor in the possibility for reloading on an empty mag: as you know some weapons might use a different animation for reloading when the mag is empty, and in the case of my game, this would need to apply to the singular fire modes, doubling the max number of animations a weapon could have from 3 to 6, and most weapons won't use all 6, I calculated that there are a grand total of 19 possible cases.
Of course, just shoving 6 animation pointers in the weapon class is not good practice for a plethora of reasons, so I began rethinking stuff:
First off, I decided to isolate "fringe cases" that are so rare it's not worth it to implement them in the base class, those being the cases in which an animation for reloading both mags is needed, there will be at most one weapon in the game that will need this so I can just code it in the specific weapon itself, the max number of animations goes down to 4.
Secondly, I thought about offloading handling animations and possibly reloading itself to components for each fire mode, so a firemode has a pointer to a reload manager which can hold one or two animations, which will then decide which one to play and possibly also replenish the weapon's clip accordingly, the downsides are that this would take much more memory than just having 4 animation pointers in and would introduce a bit of neddless complexity in the code.
What is making me reconsider the components path though is the fact that some weapons (and not few since most weapons are based on WW1 guns) might need to reload rounds singularly, so I need to handle that case too, this is where using the component thing could help, but at the same time I could have an enum in the weapon class that, for each firemode, specifies if the mode needs no reload, a simple reload, support for empty mag reload or rounds reload.
I also looked at how other games handle this problem and found that... They just don't, most games with dual fire mode weapons either don't use mags (Unreal for example) or use a singular mag for both fire modes (Half-Life), I'm not sure though this could fit the needs of my game, but I could try to redo that "isolation of fring cases" process.
So I'm a bit indecisive and I decided to ask for advice here, what would you do in my situation? I don't want my code to look like that of Yandere Simulator TwT