bevy
bevy copied to clipboard
Update `App:is_plugin_added` to work inside `Plugin::finish` and `Plugin::clean`
Objective
I have been trying to check for the existing of some plugins via App::is_plugin_added to conditionally run some behaviour in the Plugin::finish part of my plugin, before realizing that the plugin registry is actually not available during this step.
This is because the App::is_plugin_added using the plugin registry to check for previous registration.
Solution
- Switch the
App::is_plugin_addedto use the list of plugin names to check for previous registrations - Add a unit test showcasing that
App::is_plugin_addedworks duringPlugin::finish
instead of documenting it, could we make it work by checking against plugin_name_added in is_plugin_added?
instead of documenting it, could we make it work by checking against
plugin_name_addedinis_plugin_added?
I made the change; if that sounds good, I can update the PR description
Once conflicts are resolved I'll merge this in :)
Once conflicts are resolved I'll merge this in :)
@alice-i-cecile I resolved the conflicts; I had to split the plugin_registry from the plugin_names (since the main idea of the change is that while we call std::mem::take(&mut self.plugin_registry) we still have access to plugin_names to check for is_plugin_added inside Plugin::finish and Plugin::clean