Skip to content
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

Insert prototype data on existing entities #10

Merged
merged 1 commit into from
Feb 24, 2022
Merged

Insert prototype data on existing entities #10

merged 1 commit into from
Feb 24, 2022

Conversation

MrGVSV
Copy link
Owner

@MrGVSV MrGVSV commented Feb 24, 2022

Objective

Add ability to insert prototype data on existing entities.

Solution

Added default trait method to Prototypical called insert, which takes an EntityCommands object. Its usage looks something like:

fn attach_components(entity: &mut EntityCommands, data: &ProtoData, asset_server: &AssetServer) {
  let proto = data.get_prototype("My Prototype").expect("Should exist!");
  proto.insert(entity, data, asset_server).insert(SomeOtherComponent);
}

@MrGVSV MrGVSV self-assigned this Feb 24, 2022
@MrGVSV MrGVSV merged commit 11b3373 into main Feb 24, 2022
@MrGVSV MrGVSV deleted the insertion branch February 24, 2022 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant