Skip to content

Resources as Components Tracking Issue #19731

@Trashtalk217

Description

@Trashtalk217

This issue does not exist to argue the merits of Resources as Components, for some of the rationale we refer to this HackMD (this really should've been an RFC, huh?). This issue exists to track the progress on implementation and to reference in code when it is only partially working. If there are steps you feel like should be added, or if there are problems with this approach, please let me know.

Implementation Plan

This is a tracking issue for the Resources as Components. This outline is roughly copied from #17485.

  • Introduce Internal Entities, entities that are difficult to query, with the intend to make resource entities internal (Internal Entities #20204).
  • Test robustness, to be less reliant on specific entity counts (Improve test robustness #20248, Adjust benches to be more robust #20207) . We deprecate world.iter_entities() and world._iter_entities_mut() as part of that effort Deprecate iter_entities and iter_entities_mut #20260.
  • Define marker components IsResource and ResourceEntity and spawn them alongside resources. (in progress: Add entities alongside resources #19711)
  • Add a cache that links Resources to their respective entities (in progress: Add entities alongside resources #19711)
  • Change the API of world.clear_entities() and assorted other methods to ignore resource entities.
  • Make Resource a Component, and change the derive macro to derive a Component also.
  • Remove or shrink ReflectResource
  • Store the actual resource data on the resource entities. Note that at this point, the usual resource infrastructure exists alongside the entities, which are spawned and respawned alongside Resources.
  • Make sure the caller information can be passed into entity spawning.
  • Move resource access over from the old storage to the entities. Think Query<Res<Example>>, world.iter_resources(), and so on.
  • Remove all of the resource internals (before this, they're marked with expect(dead_code)).

I'm guessing that I could split out several of these items into smaller things, but this suffices as a rough outline for now.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ECSEntities, components, systems, and eventsC-Tracking-IssueAn issue that collects information about a broad development initiativeX-BlessedHas a large architectural impact or tradeoffs, but the design has been endorsed by decision makers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions