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`.
This commit is contained in:
Gonçalo Rica Pais da Silva 2024-06-03 18:33:14 +02:00 committed by GitHub
parent e6a0f75a63
commit 36f2542f63
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -3,6 +3,9 @@
//! or other IDs that can be packed and expressed within a `u64` sized type. //! 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 //! [`Identifier`]s cannot be created directly, only able to be converted from other
//! compatible IDs. //! compatible IDs.
#[cfg(feature = "bevy_reflect")]
use bevy_reflect::Reflect;
use self::{error::IdentifierError, kinds::IdKind, masks::IdentifierMask}; use self::{error::IdentifierError, kinds::IdKind, masks::IdentifierMask};
use std::{hash::Hash, num::NonZeroU32}; 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 /// segment, a 31-bit high segment, and the significant bit reserved as type flags to denote
/// entity kinds. /// entity kinds.
#[derive(Debug, Clone, Copy)] #[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 // Alignment repr necessary to allow LLVM to better output
// optimised codegen for `to_bits`, `PartialEq` and `Ord`. // optimised codegen for `to_bits`, `PartialEq` and `Ord`.
#[repr(C, align(8))] #[repr(C, align(8))]