feather icon indicating copy to clipboard operation
feather copied to clipboard

DynamicBundle

Open Defman opened this issue 4 years ago • 4 comments

Might need some documentation, I'm not familiar with the that @caelunshun is using. Resolves #375

Defman avatar Mar 04 '21 11:03 Defman

The Game::spawn could also be optimized to not use entity builder and reduce the number of host calls required. Which in turn could also be used to improve the EntityBuilder.

Defman avatar Mar 04 '21 11:03 Defman

I would like to have a single spawn function on game, that can take PiglinBundle, Component, and or any combination of components and bundles. Without specialisation there is no way to make a blank ComponentBundle implementation for Components, I suggest that Component: ComponentBundle such that a Component is also a bundle, but it only adds it self to the entity.

Defman avatar Mar 06 '21 09:03 Defman

If this is an acceptable solution, the next step for me would be to create bundles for all EntityInit variants. Maybe update the EntityBuilder to only require one host call, instead of a host call to initialize the builder and for each added component.

The bundles would look something like

struct PiglinBundle {
  piglin: Piglin,
  uuid: Uuid,
  position: Position,
}

Should I manually implement these or add an derive ComponentBundle (maybe rename ComponentBundle to Bundle)?

Defman avatar Mar 06 '21 10:03 Defman

@caelunshun where did we land on this. Right now I have moved bundles into common such that I can make a blanket ComponentBundle implementation for Component. Should the function still be renamed to spawn_bundle or should we move to exclusively use bundles?

Defman avatar Mar 08 '21 10:03 Defman