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::scene::graph::Graph;
24use crate::scene::{
25    self,
26    animation::{absm::AnimationBlendingStateMachine, AnimationPlayer},
27    camera::Camera,
28    decal::Decal,
29    dim2::{self, rectangle::Rectangle},
30    light::{directional::DirectionalLight, point::PointLight, spot::SpotLight},
31    mesh::Mesh,
32    navmesh::NavigationalMesh,
33    node::Node,
34    particle_system::ParticleSystem,
35    pivot::Pivot,
36    ragdoll::Ragdoll,
37    sound::{listener::Listener, Sound},
38    sprite::Sprite,
39    terrain::Terrain,
40    tilemap::TileMap,
41};
42use fyrox_graph::constructor::{GraphNodeConstructor, GraphNodeConstructorContainer};
43
44/// Node constructor creates scene nodes in various states.
45pub type NodeConstructor = GraphNodeConstructor<Node, Graph>;
46
47/// A special container that is able to create nodes by their type UUID.
48pub type NodeConstructorContainer = GraphNodeConstructorContainer<Node, Graph>;
49
50/// Creates default node constructor container with constructors for built-in engine nodes.
51pub fn new_node_constructor_container() -> NodeConstructorContainer {
52    let container = NodeConstructorContainer::default();
53
54    container.add::<dim2::collider::Collider>();
55    container.add::<dim2::joint::Joint>();
56    container.add::<Rectangle>();
57    container.add::<dim2::rigidbody::RigidBody>();
58    container.add::<DirectionalLight>();
59    container.add::<PointLight>();
60    container.add::<SpotLight>();
61    container.add::<Mesh>();
62    container.add::<ParticleSystem>();
63    container.add::<Sound>();
64    container.add::<Listener>();
65    container.add::<Camera>();
66    container.add::<scene::collider::Collider>();
67    container.add::<Decal>();
68    container.add::<scene::joint::Joint>();
69    container.add::<Pivot>();
70    container.add::<scene::rigidbody::RigidBody>();
71    container.add::<Sprite>();
72    container.add::<Terrain>();
73    container.add::<AnimationPlayer>();
74    container.add::<AnimationBlendingStateMachine>();
75    container.add::<NavigationalMesh>();
76    container.add::<Ragdoll>();
77    container.add::<TileMap>();
78
79    container
80}