in the unitDef there is always some list like:
Code: Select all
sfxtypes = {
explosiongenerators = {
"custom:smokecloud",
"custom:muzzleflash",
"custom:ejectshell",
...
...
},
},
Code: Select all
local smokecloud = SFX.CEG
local muzzleflash = SFX.CEG+1
local ejectshell = SFX.CEG+2
Now this numbering system with the +1,+2 etc is imo stupid c&p work and supercumbersome if you remove/add effects. Also you end up making the same lists over and over again, in script and unitDef.
So I was thinking to simply add all CEGs to all unitDefs via unitdefs_post.lua like
Code: Select all
for name, ud in pairs(UnitDefs) do
ud.sfxtypes={
explosiongenerators = {
"custom:smokecloud",
"custom:muzzleflash",
"custom:ejectshell",
...
...
},
}
end
Then there would be a file CEGnumbers.lua which holds all the
Code: Select all
smokecloud = SFX.CEG
muzzleflash = SFX.CEG+1
ejectshell = SFX.CEG+2
good/bad? would that be slow or something?
Only limit I think is that SFX.CEG is 1024 and from 2049 or so it continues with projectile numbers instead. (?)
So the number of CEGs would be limited to 1000 but I assume that is guess.
Also I was wondering how CEGnumbers.lua and unitdefs_post.lua could be made to be synced so numbers only need to be changed in one place.
Or maybe just dont use the EmitSfx and use
Spring.GetUnitPiecePosDir & Spring.SpawnCEG?