bevyengine / bevyengine/bevy

Resources as Components Tracking Issue

Open
#19,731 1 comment 3 reactions 0 assignees View on GitHub
A-ECS C-Tracking-Issue X-Blessed
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 16h
Merged PRs (30d)
171

Description

This issue does not exist to argue the merits of Resources as Components, for some of the rationale we refer to [this HackMD](https://hackmd.io/_uB08OiAT4GqOXPE-X76eQ) (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.
- [x] Test robustness, to be less reliant on specific entity counts (#20248, #20207) . We deprecate `world.iter_entities()` and `world._iter_entities_mut()` as part of that effort #20260.
- [x] Reintroduce `iter_entities()` #22864.
- [x] Implement resources as components through a custom `#[derive(Resource)]` macro #20934.
- [x] Gut `ReflectResource` #20934.
- [x] Rename non-send resources to non-send data #20934.
- [x] Remove resource/component redundancies in component registration #22930.
- [x] Add component features to the resource macro, #24164.
- [x] Change `clear_all` to also remove non-send data #22911 .
- [x] Eliminate `resources` from `Access`, #22910 .
- [ ] Speed up resource lookup, #24077, #22919, #23988, #24058.
- [ ] Remove resources from `bevy_scene` #22968 .
- [ ] Create a cleaner `component_scope` / `resource_scope` implementation.

## Issues

- #24686 Manually implementing `Resource` on top of `Component` causes unexpected behaviour.
- #24592 Resources can no longer be used as Components, which can be usefull.
- #24591 Using the component API on resources can cause confusing behaviour.
+ Example from Discord: `world.spawn((ResourceA::default(), ResourceB::default())`
- Components that are added to resource entities, are not serialized (bevy_world_serialization), as per #22968.

Contributor guide

Open the contributing guide

Research direction

This is an implementation tracking issue; start by reviewing the unchecked plan items: speeding up resource lookup (#24077, #22919, #23988, #24058), removing resources from bevy_scene (#22968), and cleaning up component_scope/resource_scope. Read the linked issues and the referenced rationale before selecting a task. Done means completing a specific remaining item and updating its tracking status; confirm the scope with maintainers first.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
game-dev
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.