Finality Engine
Toggle main menu visibility
Loading...
Searching...
No Matches
Prefab.h
Go to the documentation of this file.
1
6
#pragma once
7
#include <
Finality.h
>
8
#include <set>
9
10
namespace
FINALITY
11
{
12
inline
bool
SavePrefab
(
Scene
& source, entt::entity root,
const
std::filesystem::path& path)
13
{
14
if
(!source.
GetRegistry
().valid(root))
return
false
;
15
EmptyScene
copy;
16
if
(!copy.
InstantiateHierarchy
(source, root).
IsValid
())
return
false
;
17
std::filesystem::create_directories(path.parent_path());
18
SceneSerializer
(copy, path.stem().string()).Serialize(path.string());
19
AssetRegistry::Scan
();
20
return
std::filesystem::is_regular_file(path);
21
}
22
23
inline
Entity
InstantiatePrefab
(
Scene
& destination,
const
std::filesystem::path& path)
24
{
25
EmptyScene
source;
26
if
(!
SceneSerializer
(source).DeSerialize(path.string()))
return
{};
27
for
(
auto
entity : source.
GetRegistry
().view<
RelationshipComponent
>())
28
if
(source.
GetRegistry
().get<
RelationshipComponent
>(entity).
Parent
== entt::null)
29
return
destination.
InstantiateHierarchy
(source, entity);
30
return
{};
31
}
32
}
Finality.h
FINALITY::AssetRegistry::Scan
static void Scan()
FINALITY::EmptyScene
Definition
Scene.h:106
FINALITY::Entity
Provides a scene-bound handle for component and hierarchy operations.
Definition
Entity.h:34
FINALITY::Entity::IsValid
bool IsValid() const
Checks that the scene still exists and the entity handle is valid.
Definition
Entity.h:67
FINALITY::Scene
Owns entities and dispatches script simulation.
Definition
Scene.h:36
FINALITY::Scene::InstantiateHierarchy
Entity InstantiateHierarchy(const Scene &source, entt::entity handle)
FINALITY::Scene::GetRegistry
const entt::registry & GetRegistry() const
Definition
Scene.h:82
FINALITY::SceneSerializer::SceneSerializer
SceneSerializer(const Scene &scene, const std::string &name="Untitled Scene")
FINALITY
Definition
Asset.h:12
FINALITY::InstantiatePrefab
Entity InstantiatePrefab(Scene &destination, const std::filesystem::path &path)
Definition
Prefab.h:23
FINALITY::SavePrefab
bool SavePrefab(Scene &source, entt::entity root, const std::filesystem::path &path)
Definition
Prefab.h:12
FINALITY::RelationshipComponent
Intrusive hierarchy links using EnTT handles; entt::null denotes a missing link.
Definition
Entity.h:84
FINALITY::RelationshipComponent::Parent
entt::entity Parent
Definition
Entity.h:85
FinalityEditor
src
Editor
Prefab.h
Generated by
1.18.0