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

Adding derive Reflect for tick structs #11641

Merged
merged 6 commits into from
Feb 1, 2024

Conversation

cBournhonesque
Copy link
Contributor

Objective

  • Deriving Reflect for some public ChangeDetection/Tick structs in bevy_ecs

@cBournhonesque cBournhonesque added C-Usability A simple quality-of-life change that makes Bevy easier to use A-Reflection Runtime information about types labels Feb 1, 2024
@alice-i-cecile alice-i-cecile added the A-ECS Entities, components, systems, and events label Feb 1, 2024
@@ -286,7 +287,7 @@ impl ComponentInfo {
/// Given a type `T` which implements [`Component`], the `ComponentId` for `T` can be retrieved
/// from a `World` using [`World::component_id()`] or via [`Components::component_id()`]. Access
/// to the `ComponentId` for a [`Resource`] is available via [`Components::resource_id()`].
#[derive(Debug, Copy, Clone, Hash, Ord, PartialOrd, Eq, PartialEq)]
#[derive(Debug, Copy, Clone, Hash, Ord, PartialOrd, Eq, PartialEq, Reflect)]
Copy link
Member

Choose a reason for hiding this comment

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

Could you also add the appropriate registrations (e.g. #[reflect(Hash, PartialEq)])?

Same for the other items.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, should i add Clone as well?

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 there is one for Clone 🤔

Copy link
Member

@MrGVSV MrGVSV Feb 1, 2024

Choose a reason for hiding this comment

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

We should probably also register these types into the App (although I’m not sure if the bevy_ecs has a plugin or anything that would make sense to hold that logic)

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, there's no great spot to do this. Maybe bevy_core?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added them in bevy core, seems like a good place for it

Copy link
Member

@MrGVSV MrGVSV left a comment

Choose a reason for hiding this comment

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

LGTM!

@MrGVSV MrGVSV added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Feb 1, 2024
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Feb 1, 2024
github-merge-queue bot pushed a commit that referenced this pull request Feb 1, 2024
# Objective

- Deriving `Reflect` for some public ChangeDetection/Tick structs in
bevy_ecs

---------

Co-authored-by: Charles Bournhonesque <cbournhonesque@snapchat.com>
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 1, 2024
@alice-i-cecile
Copy link
Member

Looks like this wasn't feature-flagged correctly.

@alice-i-cecile alice-i-cecile removed the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Feb 1, 2024
@cBournhonesque
Copy link
Contributor Author

Looks like this wasn't feature-flagged correctly.

Sorry about that, I think it should work now?
I'm not 100% sure if the multiple conditional attributes work.
It generates something like this

/// Records when a component was added and when it was last mutably dereferenced (or added).
    #[reflect(Debug)]
    pub struct ComponentTicks {
        pub(crate) added: Tick,
        pub(crate) changed: Tick,
    }
    const _: () = {
        #[allow(unused_mut)]
        impl bevy_reflect::GetTypeRegistration for ComponentTicks
        where
            Self: ::core::any::Any + ::core::marker::Send + ::core::marker::Sync,
            Tick: bevy_reflect::FromReflect + bevy_reflect::TypePath,
            Tick: bevy_reflect::FromReflect + bevy_reflect::TypePath,
        {
            fn get_type_registration() -> bevy_reflect::TypeRegistration {

@alice-i-cecile alice-i-cecile added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Feb 1, 2024
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Feb 1, 2024
Merged via the queue into bevyengine:main with commit e618426 Feb 1, 2024
24 checks passed
tjamaan pushed a commit to tjamaan/bevy that referenced this pull request Feb 6, 2024
# Objective

- Deriving `Reflect` for some public ChangeDetection/Tick structs in
bevy_ecs

---------

Co-authored-by: Charles Bournhonesque <cbournhonesque@snapchat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ECS Entities, components, systems, and events A-Reflection Runtime information about types C-Usability A simple quality-of-life change that makes Bevy easier to use S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants