Good luck!
I made this, which seems to be similar to what you are making:
So I kind of know what you are dealing with.
This sounds to me like you risk overcomplicating things. I don’t do any prototype swapping in Void Scrappers.
If you have bullets with very similar behaviours (e.g. just varying in terms of speed, damage, visual, etc) I would actually just use one single factory. I would create a table of bullet properties:
local bullet_types = {
regular = {speed = 200, flipbook = "reg", damage = 1},
large = {speed = 100, flipbook = "lrg", damage = 3},
}
When spawning I get the data from the bullet types table and apply it as required, then store the produced bullet in another table:
local function spawn_bullet(bullet_type)
local bullet_data = bullet_types[bullet_type]
local object = factory.create("#bullet_factory")
--play the appropriate flipbook based on bullet_data.flipbook
--insert the bullet into a table to track it
table.insert(active_bullets, {
object = object,
speed = bullet_data.speed,
damage = bullet_data.damage,
})
end
Then to process bullets:
local function process_bullets(dt)
for i, bullet in ipairs(active_bullets) do
--update position based on bullet.speed
--check for collision maybe? depends how you do it!
--if collision, then apply damage based on bullet.damage
end
end
There is a lot more to it than this of course, but I just want to give a rough idea of how I handle something like this. Would love to hear other people’s opinions as well.