Should I make a new module for each ability or should I put them all into 1 module?
I really have no idea which would be better and if there’s any performance impact that would make one method better than the other, or if it’s just opinion which is better.
Technically having more of anything could be considered ‘less efficient’ but let’s also talk from a developing perspective.
having all your code in one script can make it hard to navigate as a developer
having multiple modules can make it hard to navigate between instances
sharing variables is way easier in one module than multiple, if necessary
Ultimately, it’s your decision. I always preferred having multiple items when developing, but for a finished product you might want to centralize all your scripts for ease of access.
Instead you can do both, which mean creating sections
I do it with VFX, but abilities are almost the same thing, only different logic Example:
In our game there are 4 characters to choose, and each of them have abilities object assigned to them, to create abbility object, they need to call module called CharacterAbbilities, in this module there are 5 functions, that handle abilities logic, one of them is:
function Character1Abbilities.fireball(Origin: Vector3, Direction: Vector3)
local Fireball = __Fireball.new(Origin, Direction)
Fireball:simulate()
print("Fireball was used")
end
Now, imagine that this is our character class
function __Character1:useAbbility(Abbility: Abbility, ...: any)
local Callback = CharacterAbbilities[Abbility]
if not Callback then
return
end
Callback(...)
end
This way you can have let’s say, 5 modules per 5 characters, and each module will contain abbilities connected to it
If you want, you can add shared module, that will simply have some abbilities that two characters can use