Keyd relationships
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 161
Description
## What problem does this solve or what need does it fill?
I've had some situations where i had to create multiple 1:1 relationships because the relationship itself had some semantic to it, like `BodyPart(Entity)` with `T` being `Hand`, `Head`, `Foot`. Having a type of `RelationshipSource` that can take a key would centralize all of these variants into one 1:N relationship.
## What solution would you like?
A `HashMap` (or similar) `RelationshipSource` where you could do
```rust
#[derive(Component)]
#[relationship_target(relationship=BodyPart)]
struct Body {
parts: HashMap,
}
#[derive(Component)]
#[relationship(relationship_target=Body)]
struct BodyPart {
part: Part,
body: Entity
}
enum Part {
Head,
Hand,
Foot,
...
}
```
## What alternative(s) have you considered?
Keep the multiple 1:1 relationships
## Additional context
I use this to have a quick access to bones in a armature to easily attach items to the bone
Contributor guide
Assessment
This issue has not been assessed yet.