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

Add and remove plugins at runtime #11083

Open
Fidius-jko opened this issue Dec 24, 2023 · 4 comments
Open

Add and remove plugins at runtime #11083

Fidius-jko opened this issue Dec 24, 2023 · 4 comments
Labels
A-App Bevy apps and plugins A-ECS Entities, components, systems, and events C-Feature A new feature, making something new possible D-Complex Quite challenging from either a design or technical perspective. Ask for help!

Comments

@Fidius-jko
Copy link

Fidius-jko commented Dec 24, 2023

What problem does this solve or what need does it fill?

I want to add mods at runtime so I don't have to reload the game to add a mod. Replacing system for mod can change game logic.

What solution would you like?

Plugins

Add Plugin parameter ModPlugin.with_label(ModLabel("ModName")) or with_label(ModPlugin, ModLabel("ModName"));
If there is the same plugin with the same label, then panic.
Label varies by ParticalEq.
Add App function: remove_plugin::<T: PluginType, L: PluginLabel>(label: L), and it removes plugin with all its configurated systems, resources, states, etc.
And add resource AppCommands<Label> for change App with label. And resource AppSettings for get current settings.
Example:

...
fn add_mods(mut app_cmd: ResMut<AppCommands>, app_cfg: Res<AppSettings>) {
     // Check mods folder
    if app_cfg.is_exist::<ModPlugin>(ModLabel("MOD_NAME")) {
         app_cmd.remove_plugin::<ModPlugin>(ModLabel("MOD_NAME"));
    }
    app_cmd.add_plugins(ModPlugin.with_label(ModLabel("MOD_NAME"));
} 
...

App commands runs after all system.

System replace

Make passage to get SystemId and replacing by SystemId. For example:

let mut schelude = ...// getting schelude
let sys_id = schelude.get_system_ids(my_system).get(0).unwrap();
schelude.replace_system(sys_id, my_another_system);

What alternative(s) have you considered?

Plugins

Create your own plugin system for the runtime, but it will be limited (for example, no SubApp).

System replace

Make run_if condition for disable it.

@Fidius-jko Fidius-jko added C-Feature A new feature, making something new possible S-Needs-Triage This issue needs to be labelled labels Dec 24, 2023
@Fidius-jko Fidius-jko changed the title Add plugins at runtime. And remove it by label. Add plugins at runtime. And remove it by label. Replacing systems Dec 24, 2023
@matiqo15 matiqo15 added A-ECS Entities, components, systems, and events and removed S-Needs-Triage This issue needs to be labelled labels Dec 24, 2023
@alice-i-cecile alice-i-cecile added A-App Bevy apps and plugins D-Complex Quite challenging from either a design or technical perspective. Ask for help! labels Dec 25, 2023
@alice-i-cecile alice-i-cecile changed the title Add plugins at runtime. And remove it by label. Replacing systems Add and remove plugins at runtime Dec 25, 2023
@alice-i-cecile
Copy link
Member

This is an extension of #279, which does this for systems. It's closely related to #2160, which proposes tools to work with plugins as a meaningful unit of organization, rather than just a trivial mutating function on App.

@Fidius-jko
Copy link
Author

@alice-i-cecile
How i can help with #2160 and #279?

@badcodecat
Copy link

Maybe this should remain open if it isn't covered directly by the other mentioned issues?
I'm just interested in these types of features so feel free to disregard this if its inappropriate.

@elifry
Copy link

elifry commented Mar 25, 2024

I am also interested in this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-App Bevy apps and plugins A-ECS Entities, components, systems, and events C-Feature A new feature, making something new possible D-Complex Quite challenging from either a design or technical perspective. Ask for help!
Projects
None yet
Development

No branches or pull requests

5 participants