[Feature] Add a way to flag entities for removal by engine #598
Labels
dev/informed
issue forwarded to dev team for consideration
feature request
A request to implement a feature.
Is your feature request related to a problem (if not, explain why you think this feature should be added)? Please describe.
I am looking for a practical and safe way to delete scripts at runtime.
Why? Because when a mod spawns endless waves of enemies with a script attached to each, on the long run the accumulation of scripts starts to have an impact on performances, even when the enemies are "dead" and the scripts are put in "idle mode" (returning immediately at the beginning of
tick()
,update()
,draw()
, etc.)Currently a script cannot
Delete()
itself without crashing the game (which make sense), so if you want to do that you need an external manager script that will find all the dead scripts and delete them for you. But as @YuLun-bili mentioned here this method also has some unwanted side effect as apparently deleting a script at runtime this way would also skip this tick for the scripts that comes after it in the engine list.Describe the solution you'd like
So having a way to flag an entity for deletion (through a tag maybe?) so that the engine can safely delete it at the most appropriate moment looks like the right answer to this problem.
And if there is a way to do it for scripts, why not do it in a generic way for all entities?
Describe alternatives you've considered
As mentioned above I already made some manager scripts that I can report scripts to be deleted to and that would delete them from an external standpoint, but that is a quite hacky solution and it requires an extra copy of that manager each time a mod needs such cleanup feature.
Additional context
This is a follow up to discussions in the comments of this thread: #591
The text was updated successfully, but these errors were encountered: