rename add_archetype to add_entity

This commit is contained in:
Carter Anderson 2020-03-09 02:02:17 -07:00
parent a790332505
commit 8eec5653b6
8 changed files with 38 additions and 38 deletions

View file

@ -80,7 +80,7 @@ fn setup(world: &mut World, resources: &mut Resources) {
world
.build()
// cube
.add_archetype(MeshMaterialEntity::<MyMaterial> {
.add_entity(MeshMaterialEntity::<MyMaterial> {
mesh: cube_handle,
renderable: Renderable {
pipelines: vec![Handle::new(2)], // TODO: make this pipeline assignment cleaner
@ -94,7 +94,7 @@ fn setup(world: &mut World, resources: &mut Resources) {
..Default::default()
})
// cube
.add_archetype(MeshMaterialEntity::<MyMaterial> {
.add_entity(MeshMaterialEntity::<MyMaterial> {
mesh: cube_handle,
renderable: Renderable {
pipelines: vec![Handle::new(2)], // TODO: make this pipeline assignment cleaner
@ -108,7 +108,7 @@ fn setup(world: &mut World, resources: &mut Resources) {
..Default::default()
})
// camera
.add_archetype(CameraEntity {
.add_entity(CameraEntity {
camera: Camera::new(CameraType::Projection {
fov: std::f32::consts::PI / 4.0,
near: 1.0,

View file

@ -122,7 +122,7 @@ fn create_entities_builder_archetype(
world
.build()
// plane
.add_archetype(MeshEntity {
.add_entity(MeshEntity {
mesh: plane_handle,
material: StandardMaterial {
albedo: math::vec4(0.1, 0.2, 0.1, 1.0).into(),
@ -130,7 +130,7 @@ fn create_entities_builder_archetype(
..Default::default()
})
// cube
.add_archetype(MeshEntity {
.add_entity(MeshEntity {
mesh: cube_handle,
material: StandardMaterial {
albedo: math::vec4(0.5, 0.3, 0.3, 1.0).into(),
@ -138,12 +138,12 @@ fn create_entities_builder_archetype(
..Default::default()
})
// light
.add_archetype(LightEntity {
.add_entity(LightEntity {
translation: Translation::new(4.0, -4.0, 5.0),
..Default::default()
})
// camera
.add_archetype(CameraEntity {
.add_entity(CameraEntity {
camera: Camera::new(CameraType::Projection {
fov: std::f32::consts::PI / 4.0,
near: 1.0,

View file

@ -29,7 +29,7 @@ fn setup(world: &mut World, resources: &mut Resources) {
world
.build()
// parent cube
.add_archetype(MeshEntity {
.add_entity(MeshEntity {
mesh: cube_handle,
material: StandardMaterial {
albedo: math::vec4(0.5, 0.4, 0.3, 1.0).into(),
@ -40,7 +40,7 @@ fn setup(world: &mut World, resources: &mut Resources) {
.add(Rotator)
.add_children(|child_builder| {
// cube
child_builder.add_archetype(MeshEntity {
child_builder.add_entity(MeshEntity {
mesh: cube_handle,
material: StandardMaterial {
albedo: math::vec4(0.5, 0.4, 0.3, 1.0).into(),
@ -50,13 +50,13 @@ fn setup(world: &mut World, resources: &mut Resources) {
})
})
// light
.add_archetype(LightEntity {
.add_entity(LightEntity {
translation: Translation::new(4.0, -4.0, 5.0),
rotation: Rotation::from_euler_angles(0.0, 0.0, 0.0),
..Default::default()
})
// camera
.add_archetype(CameraEntity {
.add_entity(CameraEntity {
camera: Camera::new(CameraType::Projection {
fov: std::f32::consts::PI / 4.0,
near: 1.0,

View file

@ -12,7 +12,7 @@ fn setup(world: &mut World, resources: &mut Resources) {
world
.build()
// plane
.add_archetype(MeshEntity {
.add_entity(MeshEntity {
mesh: plane_handle,
material: StandardMaterial {
albedo: math::vec4(0.1, 0.2, 0.1, 1.0).into(),
@ -20,7 +20,7 @@ fn setup(world: &mut World, resources: &mut Resources) {
..Default::default()
})
// cube
.add_archetype(MeshEntity {
.add_entity(MeshEntity {
mesh: cube_handle,
material: StandardMaterial {
albedo: math::vec4(0.5, 0.4, 0.3, 1.0).into(),
@ -29,13 +29,13 @@ fn setup(world: &mut World, resources: &mut Resources) {
..Default::default()
})
// light
.add_archetype(LightEntity {
.add_entity(LightEntity {
translation: Translation::new(4.0, -4.0, 5.0),
rotation: Rotation::from_euler_angles(0.0, 0.0, 0.0),
..Default::default()
})
// camera
.add_archetype(CameraEntity {
.add_entity(CameraEntity {
camera: Camera::new(CameraType::Projection {
fov: std::f32::consts::PI / 4.0,
near: 1.0,

View file

@ -69,7 +69,7 @@ fn setup(world: &mut World, resources: &mut Resources) {
let mut builder = world
.build()
// plane
.add_archetype(MeshEntity {
.add_entity(MeshEntity {
mesh: plane_handle,
material: StandardMaterial {
albedo: math::vec4(0.1, 0.2, 0.1, 1.0).into(),
@ -77,7 +77,7 @@ fn setup(world: &mut World, resources: &mut Resources) {
..Default::default()
})
// cube
.add_archetype(MeshEntity {
.add_entity(MeshEntity {
mesh: cube_handle,
material: StandardMaterial {
albedo: math::vec4(1.0, 1.0, 1.0, 1.0).into(),
@ -85,7 +85,7 @@ fn setup(world: &mut World, resources: &mut Resources) {
translation: Translation::new(0.0, 0.0, 1.0),
..Default::default()
})
.add_archetype(MeshEntity {
.add_entity(MeshEntity {
mesh: cube_handle,
material: StandardMaterial {
albedo: math::vec4(0.0, 1.0, 0.0, 1.0).into(),
@ -94,12 +94,12 @@ fn setup(world: &mut World, resources: &mut Resources) {
..Default::default()
})
// light
.add_archetype(LightEntity {
.add_entity(LightEntity {
translation: Translation::new(4.0, -4.0, 5.0),
..Default::default()
})
// camera
.add_archetype(CameraEntity {
.add_entity(CameraEntity {
camera: Camera::new(CameraType::Projection {
fov: std::f32::consts::PI / 4.0,
near: 1.0,
@ -116,7 +116,7 @@ fn setup(world: &mut World, resources: &mut Resources) {
let mut rng = StdRng::from_entropy();
for _ in 0..10000 {
builder = builder.add_archetype(MeshEntity {
builder = builder.add_entity(MeshEntity {
mesh: cube_handle,
material: StandardMaterial {
albedo: math::vec4(

View file

@ -17,7 +17,7 @@ fn setup(world: &mut World, resources: &mut Resources) {
world
.build()
// cube
.add_archetype(MeshEntity {
.add_entity(MeshEntity {
mesh: cube_handle,
material: StandardMaterial {
albedo: texture_handle.into(),
@ -26,12 +26,12 @@ fn setup(world: &mut World, resources: &mut Resources) {
..Default::default()
})
// light
.add_archetype(LightEntity {
.add_entity(LightEntity {
translation: Translation::new(4.0, 4.0, 5.0),
..Default::default()
})
// camera
.add_archetype(CameraEntity {
.add_entity(CameraEntity {
camera: Camera::new(CameraType::Projection {
fov: std::f32::consts::PI / 4.0,
near: 1.0,

View file

@ -11,7 +11,7 @@ fn setup(world: &mut World, resources: &mut Resources) {
world
.build()
// cube
.add_archetype(MeshEntity {
.add_entity(MeshEntity {
mesh: cube_handle,
material: StandardMaterial {
albedo: math::vec4(0.5, 0.3, 0.3, 1.0).into(),
@ -20,12 +20,12 @@ fn setup(world: &mut World, resources: &mut Resources) {
..Default::default()
})
// light
.add_archetype(LightEntity {
.add_entity(LightEntity {
translation: Translation::new(4.0, -4.0, 5.0),
..Default::default()
})
// 3d camera
.add_archetype(CameraEntity {
.add_entity(CameraEntity {
camera: Camera::new(CameraType::Projection {
fov: std::f32::consts::PI / 4.0,
near: 1.0,
@ -40,7 +40,7 @@ fn setup(world: &mut World, resources: &mut Resources) {
)),
})
// 2d camera
.add_archetype(Camera2dEntity {
.add_entity(Camera2dEntity {
camera: Camera::new(CameraType::Orthographic {
left: 0.0,
right: 0.0,
@ -52,7 +52,7 @@ fn setup(world: &mut World, resources: &mut Resources) {
active_camera_2d: ActiveCamera2d,
})
// bottom left anchor with vertical fill
.add_archetype(UiEntity {
.add_entity(UiEntity {
node: Node::new(
math::vec2(0.0, 0.0),
Anchors::new(0.0, 0.0, 0.0, 1.0),
@ -61,7 +61,7 @@ fn setup(world: &mut World, resources: &mut Resources) {
),
})
// top right anchor with vertical fill
.add_archetype(UiEntity {
.add_entity(UiEntity {
node: Node::new(
math::vec2(0.0, 0.0),
Anchors::new(1.0, 1.0, 0.0, 1.0),
@ -70,7 +70,7 @@ fn setup(world: &mut World, resources: &mut Resources) {
),
})
// render order test: reddest in the back, whitest in the front
.add_archetype(UiEntity {
.add_entity(UiEntity {
node: Node::new(
math::vec2(75.0, 75.0),
Anchors::new(0.5, 0.5, 0.5, 0.5),
@ -78,7 +78,7 @@ fn setup(world: &mut World, resources: &mut Resources) {
math::vec4(1.0, 0.1, 0.1, 1.0),
),
})
.add_archetype(UiEntity {
.add_entity(UiEntity {
node: Node::new(
math::vec2(50.0, 50.0),
Anchors::new(0.5, 0.5, 0.5, 0.5),
@ -86,7 +86,7 @@ fn setup(world: &mut World, resources: &mut Resources) {
math::vec4(1.0, 0.3, 0.3, 1.0),
),
})
.add_archetype(UiEntity {
.add_entity(UiEntity {
node: Node::new(
math::vec2(100.0, 100.0),
Anchors::new(0.5, 0.5, 0.5, 0.5),
@ -94,7 +94,7 @@ fn setup(world: &mut World, resources: &mut Resources) {
math::vec4(1.0, 0.5, 0.5, 1.0),
),
})
.add_archetype(UiEntity {
.add_entity(UiEntity {
node: Node::new(
math::vec2(150.0, 150.0),
Anchors::new(0.5, 0.5, 0.5, 0.5),
@ -103,7 +103,7 @@ fn setup(world: &mut World, resources: &mut Resources) {
),
})
// parenting
.add_archetype(UiEntity {
.add_entity(UiEntity {
node: Node::new(
math::vec2(300.0, 300.0),
Anchors::new(0.0, 0.0, 0.0, 0.0),
@ -112,7 +112,7 @@ fn setup(world: &mut World, resources: &mut Resources) {
),
})
.add_children(|child_builder| {
child_builder.add_archetype(UiEntity {
child_builder.add_entity(UiEntity {
node: Node::new(
math::vec2(0.0, 0.0),
Anchors::new(0.0, 1.0, 0.0, 1.0),
@ -122,7 +122,7 @@ fn setup(world: &mut World, resources: &mut Resources) {
})
})
// alpha test
.add_archetype(UiEntity {
.add_entity(UiEntity {
node: Node::new(
math::vec2(200.0, 200.0),
Anchors::new(0.5, 0.5, 0.5, 0.5),

View file

@ -65,7 +65,7 @@ impl<'a> WorldBuilder<'a> {
self
}
pub fn add_archetype(mut self, entity_archetype: impl EntityArchetype) -> Self {
pub fn add_entity(mut self, entity_archetype: impl EntityArchetype) -> Self {
let current_entity = entity_archetype.insert(self.world);
self.current_entity = Some(current_entity);
self.add_parent_to_current_entity();