bevyengine / bevyengine/bevy

Immutable relationships

Open
#20,385 1 comment 0 reactions 0 assignees View on GitHub
A-ECS C-Feature C-Usability S-Needs-Design
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 16h
Merged PRs (30d)
171

Description

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

Currently when trying to implement relationships on immutable components bevy will complain that the components need to be mutable

## What solution would you like?

It'd be nice to have a way to implement relationships on immutable components, especially for one to one relationships.

I don't know if this is possible or not, someone who knows more about relationships will probably have to check.

```rust
#[derive(Component)]
#[component(immutable)]
#[relationship_target(relationship = RelationshipThingy)]
pub struct ThingyRelationship(Entity);

#[derive(Component)]
#[component(immutable)]
#[relationship(relationship_target = ThingyRelationship)]
pub struct RelationshipThingy(Entity);
```

## What alternative(s) have you considered?

The current solution of not doing this, however this does mean that relationships miss out on a lot of the benefits of immutable components.

Contributor guide

Open the contributing guide

Research direction

The issue names no files, tests, or entry points. Start by reproducing the shown immutable relationship declarations and tracing the relationship and immutable-component validation; done would mean relationships can be declared on immutable components, especially the one-to-one case, with coverage for the supported behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
game-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.