Skip to content

Conversation

@pantaelaman
Copy link

@pantaelaman pantaelaman commented Dec 16, 2025

Objective

I didn't see an issue for something like this made yet, but I ran into a particularly non-ergonomic situation when working on a prototype where I wanted to be able to run a system that normally takes owned input via In with a static, cloneable value. The with_input and with_input_from functions both require the system takes a mutable reference to their input types, so they wouldn't work for my general case.

Solution

I effectively copied the code from the WithInputWrapper and WithInputFromWrapper structs and modified it slightly so that it clones the contained value and passes it as input to the wrapped system.

Testing

The project successfully builds on my machine, and my personal game prototype was built and ran successfully using this extra functionality. Totally possible I missed an edge case though.


Showcase

struct GridCoord {
  location: IVec2,
}

fn spawn_creature(In(location): In<IVec2>, mut commands: Commands) {
  commands.spawn((
    GridCoord { location },
    // some other stuff too...
  ))

  // and maybe some other stuff here...
}

struct CreaturePlugin;

impl Plugin for CreaturePlugin {
  fn build(app: &mut App) {
    app.add_systems(Startup, spawn_creature.with_cloned_input(IVec2::new(0, 0));
  }
}

The idea being that I want to use spawn_creature somewhere else with dynamic input, using run_system_cached_with, but on some schedule (in this case, Startup), I want to give it a constant input.

@github-actions
Copy link
Contributor

Welcome, new contributor!

Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨

@alice-i-cecile alice-i-cecile added C-Feature A new feature, making something new possible A-ECS Entities, components, systems, and events X-Controversial There is active debate or serious implications around merging this PR S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Dec 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-ECS Entities, components, systems, and events C-Feature A new feature, making something new possible S-Needs-Review Needs reviewer attention (from anyone!) to move forward X-Controversial There is active debate or serious implications around merging this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants