Skip to content

Resources as Components Tracking Issue #19731

Open
@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.

  • 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 APIs of world.iter_entities(), 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. Also 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.
  • Remove or shrink ReflectResource
  • 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