Skip to main content

fyrox_impl/scene/node/
constructor.rs

1// Copyright (c) 2019-present Dmitry Stepanov and Fyrox Engine contributors.
2//
3// Permission is hereby granted, free of charge, to any person obtaining a copy
4// of this software and associated documentation files (the "Software"), to deal
5// in the Software without restriction, including without limitation the rights
6// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7// copies of the Software, and to permit persons to whom the Software is
8// furnished to do so, subject to the following conditions:
9//
10// The above copyright notice and this permission notice shall be included in all
11// copies or substantial portions of the Software.
12//
13// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19// SOFTWARE.
20
21//! A special container that is able to create nodes by their type UUID.
22
23use crate::{
24    graph::constructor::{GraphNodeConstructor, GraphNodeConstructorContainer},
25    scene::{
26        self,
27        animation::{absm::AnimationBlendingStateMachine, AnimationPlayer},
28        camera::Camera,
29        decal::Decal,
30        dim2::{self, rectangle::Rectangle},
31        graph::Graph,
32        light::{directional::DirectionalLight, point::PointLight, spot::SpotLight},
33        mesh::Mesh,
34        navmesh::NavigationalMesh,
35        node::Node,
36        particle_system::ParticleSystem,
37        pivot::Pivot,
38        probe::ReflectionProbe,
39        ragdoll::Ragdoll,
40        sound::{listener::Listener, Sound},
41        sprite::Sprite,
42        terrain::Terrain,
43        tilemap::TileMap,
44    },
45};
46
47/// Node constructor creates scene nodes in various states.
48pub type NodeConstructor = GraphNodeConstructor<Node, Graph>;
49
50/// A special container that is able to create nodes by their type UUID.
51pub type NodeConstructorContainer = GraphNodeConstructorContainer<Node, Graph>;
52
53/// Creates default node constructor container with constructors for built-in engine nodes.
54pub fn new_node_constructor_container() -> NodeConstructorContainer {
55    let container = NodeConstructorContainer::default();
56
57    container.add::<dim2::collider::Collider>();
58    container.add::<dim2::joint::Joint>();
59    container.add::<Rectangle>();
60    container.add::<dim2::rigidbody::RigidBody>();
61    container.add::<DirectionalLight>();
62    container.add::<PointLight>();
63    container.add::<SpotLight>();
64    container.add::<Mesh>();
65    container.add::<ParticleSystem>();
66    container.add::<Sound>();
67    container.add::<Listener>();
68    container.add::<Camera>();
69    container.add::<scene::collider::Collider>();
70    container.add::<Decal>();
71    container.add::<scene::joint::Joint>();
72    container.add::<Pivot>();
73    container.add::<scene::rigidbody::RigidBody>();
74    container.add::<Sprite>();
75    container.add::<Terrain>();
76    container.add::<AnimationPlayer>();
77    container.add::<AnimationBlendingStateMachine>();
78    container.add::<NavigationalMesh>();
79    container.add::<Ragdoll>();
80    container.add::<TileMap>();
81    container.add::<ReflectionProbe>();
82
83    container
84}