-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add BRP method to mutate a component #16940
base: main
Are you sure you want to change the base?
Conversation
@@ -48,6 +48,9 @@ pub const BRP_REPARENT_METHOD: &str = "bevy/reparent"; | |||
/// The method path for a `bevy/list` request. | |||
pub const BRP_LIST_METHOD: &str = "bevy/list"; | |||
|
|||
/// The method path for a `bevy/reparent` request. | |||
pub const BRP_MUTATE_COMPONENT_METHOD: &str = "bevy/mutate_component"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what the convention is for multiple words in a method name is. Should the method be named differently? I'm trying to consider future methods for modifying other things like Resource's.
I had a few other ideas for methods:
bevy/modify/component
bevy/mutate/component
bevy/component_mut
this feels too Rusty in this context
pub fn process_remote_mutate_component_request( | ||
In(params): In<Option<Value>>, | ||
world: &mut World, | ||
) -> BrpResult { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like the method handler could probably be done better or maybe in less steps. Any pointers here would be appreciated.
Objective
Add a method to mutate components with BRP.
Currently the only way to modify a component on an entity with BRP is to insert a new one with the new values. This isn't ideal for several reasons, one reason being that the client has to know what all the fields are of the component and stay in sync with the server.
Solution
Add a new BRP method called
bevy/mutate_component
to mutate a single field in a component on an entity.Testing
Transform
andName
fields.Showcase
Example JSON-RPC request to change the
Name
of an entity to "New name!"