Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Add a way to flag entities for removal by engine #598

Open
FlorentP42 opened this issue Jun 27, 2024 · 1 comment
Open

[Feature] Add a way to flag entities for removal by engine #598

FlorentP42 opened this issue Jun 27, 2024 · 1 comment
Labels
dev/informed issue forwarded to dev team for consideration feature request A request to implement a feature.

Comments

@FlorentP42
Copy link

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

@FlorentP42 FlorentP42 added the feature request A request to implement a feature. label Jun 27, 2024
@Gregory-Gregory Gregory-Gregory added the dev/informed issue forwarded to dev team for consideration label Jul 9, 2024
@Gregory-Gregory
Copy link

@FlorentP42 thank you for this suggestion and the additional details!

The information has been forwarded to the team.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dev/informed issue forwarded to dev team for consideration feature request A request to implement a feature.
Projects
None yet
Development

No branches or pull requests

2 participants