From 36f2542f63f7378b335529eb425d25da957c65a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Rica=20Pais=20da=20Silva?= Date: Mon, 3 Jun 2024 18:33:14 +0200 Subject: [PATCH] feat: Reflection implementations on Identifier (#13648) # Objective - Follow-up on some changes in #11498 - Unblock using `Identifier` to replace `ComponentId` internals. ## Solution - Implement the same `Reflect` impls from `Entity` onto `Identifier` as they share same/similar purposes, ## Testing - No compile errors. Currently `Identifier` has no serialization impls, so there's no need to test a serialization/deserialization roundtrip to ensure correctness. --- ## Changelog ### Added - Reflection implementations on `Identifier`. --- crates/bevy_ecs/src/identifier/mod.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/crates/bevy_ecs/src/identifier/mod.rs b/crates/bevy_ecs/src/identifier/mod.rs index 66ff28af43516..04a93cde45c0c 100644 --- a/crates/bevy_ecs/src/identifier/mod.rs +++ b/crates/bevy_ecs/src/identifier/mod.rs @@ -3,6 +3,9 @@ //! or other IDs that can be packed and expressed within a `u64` sized type. //! [`Identifier`]s cannot be created directly, only able to be converted from other //! compatible IDs. +#[cfg(feature = "bevy_reflect")] +use bevy_reflect::Reflect; + use self::{error::IdentifierError, kinds::IdKind, masks::IdentifierMask}; use std::{hash::Hash, num::NonZeroU32}; @@ -15,6 +18,8 @@ pub(crate) mod masks; /// segment, a 31-bit high segment, and the significant bit reserved as type flags to denote /// entity kinds. #[derive(Debug, Clone, Copy)] +#[cfg_attr(feature = "bevy_reflect", derive(Reflect))] +#[cfg_attr(feature = "bevy_reflect", reflect_value(Debug, Hash, PartialEq))] // Alignment repr necessary to allow LLVM to better output // optimised codegen for `to_bits`, `PartialEq` and `Ord`. #[repr(C, align(8))]