amethyst / amethyst/editor-core

Add new components to entities at runtime

Open
#31 0 comments 0 reactions 0 assignees View on GitHub
enhancement help wanted
Dominant language
Rust
Stars
45
Forks
8
PR merge metrics
No merged PRs in 30d

Description

> ~~This is currently blocked by #27.~~

Add a way for editors to request that a new component be added to an existing entity at runtime. The editor should specify the ID for the component type (i.e. the user-provided name for the type) and the entity it should be attached to. The game should then create the corresponding component in the game world.

Since the editor currently knows nothing about the type definitions for components, it won't know how to create the data for a new component when adding one. Instead, we'll leave it to the game process to use `Default` or similar user-provided logic to create the new component directly within the game.

To do this, add a new variant to `IncomingMessage` called `AddComponent` that specifies the ID for the component type and the entity the component should be added to. We'll also likely have to add `Default` as a bound for `WriteComponentSet`.

Note that it may prove insufficient to use `Default` for some component types, since they may require data from resources or other components when being initialized. If this proves to be the case, we can discuss adding a new trait such as `ComponentDefault` that allows users to access world state when creating default values for a component.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.