Plasma Engine  2.0
Loading...
Searching...
No Matches
PrefabResource.h
1#pragma once
2
3#include <Core/ResourceManager/Resource.h>
4#include <Core/WorldSerializer/WorldReader.h>
5#include <Foundation/Containers/ArrayMap.h>
6#include <Foundation/Reflection/PropertyPath.h>
7
9
11{
12};
13
15{
16 plHashedString m_sExposeName;
17 plUInt32 m_uiWorldReaderChildObject : 1; // 0 -> use root object array, 1 -> use child object array
18 plUInt32 m_uiWorldReaderObjectIndex : 31;
19 plHashedString m_sComponentType; // plRTTI type name to identify which component is meant, empty string -> affects game object
20 plHashedString m_sProperty; // which property to override
21 plPropertyPath m_CachedPropertyPath; // cached plPropertyPath to apply a value to the specified property
22
23 void Save(plStreamWriter& inout_stream) const;
24 void Load(plStreamReader& inout_stream);
25};
26
27class PL_CORE_DLL plPrefabResource : public plResource
28{
29 PL_ADD_DYNAMIC_REFLECTION(plPrefabResource, plResource);
30 PL_RESOURCE_DECLARE_COMMON_CODE(plPrefabResource);
31 PL_RESOURCE_DECLARE_CREATEABLE(plPrefabResource, plPrefabResourceDescriptor);
32
33public:
35
36 enum class InstantiateResult : plUInt8
37 {
38 Success,
39 NotYetLoaded,
40 Error,
41 };
42
44 static plPrefabResource::InstantiateResult InstantiatePrefab(const plPrefabResourceHandle& hPrefab, bool bBlockTillLoaded, plWorld& ref_world, const plTransform& rootTransform, plPrefabInstantiationOptions options = {}, const plArrayMap<plHashedString, plVariant>* pExposedParamValues = nullptr);
45
47 void InstantiatePrefab(plWorld& ref_world, const plTransform& rootTransform, plPrefabInstantiationOptions options, const plArrayMap<plHashedString, plVariant>* pExposedParamValues = nullptr);
48
49 void ApplyExposedParameterValues(const plArrayMap<plHashedString, plVariant>* pExposedParamValues, const plDynamicArray<plGameObject*>& createdChildObjects, const plDynamicArray<plGameObject*>& createdRootObjects) const;
50
51private:
52 virtual plResourceLoadDesc UnloadData(Unload WhatToUnload) override;
53 virtual plResourceLoadDesc UpdateContent(plStreamReader* Stream) override;
54 virtual void UpdateMemoryUsage(MemoryUsage& out_NewMemoryUsage) override;
55
56private:
57 plUInt32 FindFirstParamWithName(plUInt64 uiNameHash) const;
58
59 plWorldReader m_WorldReader;
61};
See plArrayMapBase for details.
Definition ArrayMap.h:149
Definition DynamicArray.h:81
This class is optimized to take nearly no memory (sizeof(void*)) and to allow very fast checks whethe...
Definition HashedString.h:25
Definition PrefabResource.h:28
Stores a path from an object of a given type to a property inside of it. Once initialized to a specif...
Definition PropertyPath.h:25
The base class for all resources.
Definition Resource.h:10
Interface for binary in (read) streams.
Definition Stream.h:22
Interface for binary out (write) streams.
Definition Stream.h:107
A world encapsulates a scene graph of game objects and various component managers and their component...
Definition World.h:22
Reads a world description from a stream. Allows to instantiate that world multiple times in different...
Definition WorldReader.h:47
Definition PrefabResource.h:15
Definition WorldReader.h:14
Definition PrefabResource.h:11
Definition Resource.h:34
Describes in which loading state a resource currently is, and how many different quality levels there...
Definition Declarations.h:102