-
Notifications
You must be signed in to change notification settings - Fork 220
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
Component Grouping #201
Conversation
1173116
to
993ba09
Compare
specs/README.md
Outdated
@@ -0,0 +1,71 @@ | |||
# specs |
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.
It seems your rebase wasn't quite correct, this is the old README.
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.
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.
specs_derive/src/component_group.rs
Outdated
#[allow(unused_mut)] | ||
let mut list = #name::local_components(); | ||
#( | ||
for component in #subgroup_ty::components() { |
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.
Can't this use extend
instead of manual loop?
specs/src/group.rs
Outdated
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. |
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.
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.
Can we have the restructurization PR separate from the new functionality please? |
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. |
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). |
@Aceeri Maybe you could structure it the same way @ebkalderon did in their PR? |
@torkleyy I feel it makes more sense to use a workspace given this is exactly the usecase for it (multiple crates in one repo). |
@Aceeri They also implemented it as a workspace, see https://github.com/slide-rs/specs/pull/192/files |
905620a
to
6524127
Compare
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.
The syntax in the example looks nice! IIRC it's a great improvement over the current serialize
example.
specs_derive/README.md
Outdated
@@ -0,0 +1,107 @@ | |||
# Specs |
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 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> { |
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.
Do we really need a struct for this?
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.
Yeah, if I implemented Serialize
or Deserialize
on the World
itself, then it would make a new copy of the world.
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 was talking about just a function actually.
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.
Well, it ties in better with serde
s traits and such this way rather than just have some special methods for it.
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 don't really mind either way since it would still be possible if it was a function instead of a struct.
d0a6153
to
377d248
Compare
Well uh, I have made a mistake so please ignore this for the next couple hours while I go get my backup. |
a730839
to
0376ecf
Compare
2a0277d
to
3fd2365
Compare
@torkleyy For the |
/// 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> { |
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 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.
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.
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.
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 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.
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.
What if you want to put in multiple prefabs for a single entity though?
@Aceeri I see. It's up to you how you implement it then. |
1137f3a
to
f96b221
Compare
Closing this for now since I'm not sure if it is worth the complexity yet. |
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 <azriel91@gmail.com>
fixes #155
Restrutures into a workspace of
specs
andspecs_derive
.