bevyengine / bevyengine/bevy

Constant/Lifetime components

Open
#20,029 0 comments 0 reactions 0 assignees View on GitHub
A-ECS C-Feature
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?

There are some components that don't make sense to change at all over the lifetime of the game, such as the name of an item.

It might make sense to disallow removing such components

## What solution would you like?

```rust
#[derive(Component)]
#[component(constant)]
pub struct ItemName(String);

// Throws a compiler error
commands.entity(entity).remove::();
```

I have no idea how, or even if this would work, this is mostly just a random thought I had.

## What alternative(s) have you considered?

Same as before, but keep in mind you shouldn't be changing them.

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the `#[derive(Component)]` and `#[component(constant)]` entry points, along with `commands.entity(entity).remove::()`. Determine whether constant components and compile-time removal prevention are feasible, then seek an agreed design. Done means the behavior and implementation scope are decided, with the requested restriction covered by tests.

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
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.