Benign crates 4,317,144 installs Download

bevy_hierarchy 0.8.1

“Provides hierarchy functionality for Bevy Engine”

Rust test marker or harnessimports bevy_ecs::reflect::ReflectComponent
SHA-2565eb1ec76099ea5a716de08ea42ff41f036ebe2502df1d569168b58f16458a85e

Evidence

imports bevy_ecs::system::Commands child_builder.rs · lines 1–15
1use crate::{
2 prelude::{Children, Parent},
3 HierarchyEvent,
4};
5use bevy_ecs::{
6 bundle::Bundle,
7 entity::Entity,
8 event::Events,
9 system::{Command, Commands, EntityCommands},
10 world::{EntityMut, World},
11};
12use smallvec::SmallVec;
13
14fn push_events(world: &mut World, events: SmallVec<[HierarchyEvent; 8]>) {
15 if let Some(mu …
English function-word token "for" child_builder.rs · lines 15–22
15:43… ource_mut::<Events<HierarchyEvent>>() {
16 for evt in events {
17 moved.send(evt);
18 }
⋯4 lines
imports bevy_ecs::component::Component child_builder.rs · lines 510–535
510:14… e_children(parent, children, self.world);
511 self
512 }
513}
514
515#[cfg(test)]
516mod tests {
517 use super::{BuildChildren, BuildWorldChildren};
518 use crate::prelude::{Children, Parent};
519 use smallvec::{smallvec, SmallVec};
520
521 use bevy_ecs::{
522 component::Component,
523 entity::Entity,
524 system::{CommandQueue, Commands},
525 world::World,
526 };
527
528 #[derive(Component)]
529 struct C(u32);
530
531 #[test]
532 fn build_children() {
533 let mut world = World::default();
534 let mut queue = CommandQueue::default();
535 le …
Rust synchronous or async test attribute hierarchy.rs · lines 156–163
156:31… PartialEq, Eq, Ord, PartialOrd, Debug)]
157 struct N(String);
158
159 #[test]
160 fn despawn_recursive() {
161 let mut world = World::default();
162 let mut queue = CommandQueue::default();
163 …
imports bevy_ecs::reflect::ReflectComponent parent.rs · lines 1–48
1use bevy_ecs::{
2 component::Component,
3 entity::{Entity, EntityMap, MapEntities, MapEntitiesError},
4 reflect::{ReflectComponent, ReflectMapEntities},
5 world::{FromWorld, World},
6};
7use bevy_reflect::Reflect;
8use std::ops::Deref;
9
10/// Holds a reference to the parent entity of this entity.
11/// This component should only be present on entities that actually have a parent entity.
12#[derive(Component, Debug, Eq, PartialEq, Reflect)]
13#[reflect(Component, MapEntities, PartialEq)]
⋯7 lines
21}
22
23// TODO: We need to impl either FromWorld or Default so Parent can be registered as Reflect.
24// This is because Reflect deserialize by creating an instance and apply a patch on top.
25// However Parent should only ever be set with a real user-defined entity. Its worth looking into
26// better ways to handle cases like this.
27impl FromWorld for Parent {
28 fn from_world(_world: &mut World) -> Self {
29 Parent(Entity::from_raw(u32::MAX))
⋯5 lines
35 // Parent of an entity in the new world can be in outside world, in which case it
36 // should not be mapped.
37 if let Ok(mapped_entity) = entity_map.get(self.0) {
38 self.0 = mapped_entity;
39 }
⋯9 lines

No evidence locations were recorded for this file. Raw result

Keyboard shortcuts on this page: j for the next sample, k for the previous one, x to go back to the feed, d to download the original bytes, r to re-queue the sample for analysis.