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

Component Grouping #201

Closed
wants to merge 11 commits into from
Closed

Component Grouping #201

wants to merge 11 commits into from

Conversation

Aceeri
Copy link
Member

@Aceeri Aceeri commented Jun 18, 2017

fixes #155

Restrutures into a workspace of specs and specs_derive.

@Aceeri Aceeri force-pushed the group branch 2 times, most recently from 1173116 to 993ba09 Compare June 18, 2017 04:22
specs/README.md Outdated
@@ -0,0 +1,71 @@
# specs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems your rebase wasn't quite correct, this is the old README.

Copy link
Member

@WaDelma WaDelma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The call macro being limited to certain maximum recursion is unfortunate, but as we discussed there isn't really way to make it better. Otherwise looking good.

#[allow(unused_mut)]
let mut list = #name::local_components();
#(
for component in #subgroup_ty::components() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't this use extend instead of manual loop?

pub trait SerializeGroup: ComponentGroup {
/// Serializes the group of components from the world.
fn serialize_group<S: Serializer>(world: &World, serializer: S) -> Result<S::Ok, S::Error>;
/// Helper method for serializing the world.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to expose these helpers in the trait or are they only called in trait implementation? If they are not needed anywhere else then these helpers are just implementation detail and should probably removed.

@kvark
Copy link
Member

kvark commented Jun 19, 2017

Can we have the restructurization PR separate from the new functionality please?

@WaDelma
Copy link
Member

WaDelma commented Jun 19, 2017

You have to use workspace to include the custom derive as it needs to be it's own crate. Dunno if splitting it to it's own PR would be possible.

@Aceeri
Copy link
Member Author

Aceeri commented Jun 21, 2017

I mean, I could have another PR for it if we want, but it would either just be a workspace of "specs" and "specs_derive" (without functionality).

@torkleyy
Copy link
Member

@Aceeri Maybe you could structure it the same way @ebkalderon did in their PR?

@Aceeri
Copy link
Member Author

Aceeri commented Jun 21, 2017

@torkleyy I feel it makes more sense to use a workspace given this is exactly the usecase for it (multiple crates in one repo).

@torkleyy
Copy link
Member

@Aceeri They also implemented it as a workspace, see https://github.com/slide-rs/specs/pull/192/files

@Aceeri Aceeri force-pushed the group branch 7 times, most recently from 905620a to 6524127 Compare July 2, 2017 15:11
Copy link
Member

@torkleyy torkleyy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The syntax in the example looks nice! IIRC it's a great improvement over the current serialize example.

@@ -0,0 +1,107 @@
# Specs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need a second readme here (or at least, don't copy the specs README and just show a small example of component groups).


#[cfg(feature="serialize")]
/// Structure used to serialize a world using a component group.
pub struct WorldSerializer<'a, G> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need a struct for this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, if I implemented Serialize or Deserialize on the World itself, then it would make a new copy of the world.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was talking about just a function actually.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, it ties in better with serdes traits and such this way rather than just have some special methods for it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really mind either way since it would still be possible if it was a function instead of a struct.

@Aceeri Aceeri force-pushed the group branch 4 times, most recently from d0a6153 to 377d248 Compare July 7, 2017 21:41
@Aceeri
Copy link
Member Author

Aceeri commented Jul 7, 2017

Well uh, I have made a mistake so please ignore this for the next couple hours while I go get my backup.

@Aceeri Aceeri force-pushed the group branch 6 times, most recently from a730839 to 0376ecf Compare July 8, 2017 01:45
@Aceeri Aceeri force-pushed the group branch 16 times, most recently from 2a0277d to 3fd2365 Compare July 8, 2017 18:23
@Aceeri
Copy link
Member Author

Aceeri commented Jul 8, 2017

@torkleyy For the WorldSerializer, I just realized why I originally had it. Some serde libraries don't expose Serializer in their interfaces which is annoying, but the only way to serialize with them is to pass in a type that implements Serialize.

/// Creates a new world deserializer out of a world and a list of entities.
///
/// The list of entities will be used to merge into the component storages.
pub fn new(world: &'a mut World, entities: &'a [Entity]) -> WorldDeserializer<'a, G> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it really makes sense to pass a slice of entities. Is there any case where you want to deserialize components and insert them for existing entities? I mean can you really ensure this works reliable? Which brings me to the question if it should be allowed for an entity to not have a component of the component group.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any case where you want to deserialize components and insert them for existing entities?

I was mainly thinking stuff like prefabs here, so a prefab could be deserialized into an existing entity.

Which brings me to the question if it should be allowed for an entity to not have a component of the component group.

Well, if we disallowed that then every entity would have to have every component in that component group if we wanted to serialize the world properly.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was mainly thinking stuff like prefabs here, so a prefab could be deserialized into an existing entity.

Exactly, so a new entity has to be created.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if you want to put in multiple prefabs for a single entity though?

@torkleyy
Copy link
Member

torkleyy commented Jul 8, 2017

@Aceeri I see. It's up to you how you implement it then.

@Aceeri
Copy link
Member Author

Aceeri commented Oct 20, 2017

Closing this for now since I'm not sure if it is worth the complexity yet.

@Aceeri Aceeri closed this Oct 20, 2017
xMAC94x pushed a commit to xMAC94x/specs that referenced this pull request Mar 10, 2021
201: Add `ci.yml` github actions workflow. r=azriel91 a=azriel91

Switch CI to use github actions, as bors isn't getting past travis (always times out).

Co-authored-by: Azriel Hoh <[email protected]>
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.

Component/System/Resource Grouping
4 participants