Skip to content

Named Queries #2588

Closed
Closed
@lizelive

Description

@lizelive

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

The most simple of systems require a lot of ugly boiler plate code such as:

  1. a for loop
  2. destructing operations
  3. hard to read queries
  4. hard to debug

What solution would you like?

#[derive(Query)]
pub struct PointMassQuery{
    position: &mut Position,
    momentum: &Momentum,
    mass: &Mass
}

pub fn newtons_first_law(point_mass: PointMassQuerry, time: Res<Time>) {
    point_mass.position += time.delta_seconds() * point_mass.momentum / point_mass.mass;
}

fn system_with_queryable(q: Query<PointMassQuery>) {}

What alternative(s) have you considered?

#2252 but that requires all param to be mutable to be useful. it is possible to make a macro to generate an all inclusive named query for early development to address this use case.
The old school for-each sytanx but that is not very flexible

Additional context

Figuring this out will make the relation system way cleaner and more usable.

Metadata

Metadata

Labels

A-ECSEntities, components, systems, and eventsC-DocsAn addition or correction to our documentation

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions