Nebula
Nebula copied to clipboard
Make ammo magazines lazy-initialize
Description of changes
Do not merge, needs additional testing and maintainer consensus on if this is something we even want to do. Could also make it a config or compile option if desired.
Most ammo magazines will now wait until their first interaction (with their contents, not necessarily by players) to create their contents. Chambering/consuming a round from an uninitialized magazine will lower the initial ammo count by one and create exactly one round, further delaying initialization where possible.
Why and what will this PR improve
Cuts off a decent amount of init time by waiting to create objects that functionally don't exist until interacted with already.
Changelog
:cl: experiment: Ammo magazines will not initialize their contents until first interacted with, which makes startup faster but could cause bugs. Report any issues on the issue tracker! /:cl:
I almost feel like it would be preferable for mags to never instantiate their full contents - outside of people manually loading in shells, we only ever care about the same time 50 times or whatever, which could be factored into worth and matter calc pretty easily without creating the full set.
It should only generate them all when you dump out the magazine or do other things that access all of them, iirc? I was pretty careful to delay instantiation as much as possible.