Skip to content

Allow for Resource - Component relationships #19690

Open
@Freyja-moth

Description

@Freyja-moth

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

There may be times where we want a Resource to store an entity where it would not make sense to do so for components.

// It wouldn't make sense for this to be a component as there can only be one.
#[derive(Resource)]
pub struct CurrentPlayer(Entity);

pub struct Player;

Currently there is no way to ensure that the entity is valid such as in the case of Component relationships.

What solution would you like?

Allow resources to be specified in relationships

#[derive(Resource)]
#[relationship_target(relationship = Player)]
pub struct CurrentPlayer(Entity);

#[derive(Component)]
#[relationship(relationship_target = CurrentPlayer)]
pub struct Player(Entity);

What alternative(s) have you considered?

Same as before but check if the entity is valid each time it is used.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-FeatureA new feature, making something new possibleS-Needs-TriageThis issue needs to be labelled

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions