1//************************************ bs::framework - Copyright 2018 Marko Pintera **************************************//
2//*********** Licensed under the MIT license. See LICENSE.md for full terms. This notice is not to be removed. ***********//
3#pragma once
4
5#include "BsCorePrerequisites.h"
6#include "Reflection/BsRTTIType.h"
7
8namespace bs
9{
10 class GameObjectDeserializationState;
11
12 /** @addtogroup Utility-Core-Internal
13 * @{
14 */
15
16 /** Contains information about a resource dependency, including the dependant resource and number of references to it. */
17 struct ResourceDependency
18 {
19 ResourceDependency() = default;
20
21 HResource resource;
22 UINT32 numReferences = 0;
23 };
24
25 /** Static class containing various utility methods that do not fit anywhere else. */
26 class BS_CORE_EXPORT Utility
27 {
28 public:
29 /**
30 * Finds all resources referenced by the specified object.
31 *
32 * @param[in] object Object to search for resource dependencies.
33 * @param[in] recursive Determines whether or not child objects will also be searched (if the object has any
34 * children).
35 * @return A list of unique, non-null resources.
36 */
37 static Vector<ResourceDependency> findResourceDependencies(IReflectable& object, bool recursive = true);
38
39 /**
40 * Finds all components of a specific type on a scene object and any of its children.
41 *
42 * @param[in] object Object which to search for components. All children will be searched as well.
43 * @param[in] typeId RTTI type ID of the component type to search for.
44 * @return A list of all components of the specified type.
45 */
46 static Vector<HComponent> findComponents(const HSceneObject& object, UINT32 typeId);
47
48 /** Calculates how deep in the scene object hierarchy is the provided object. Zero means root. */
49 static UINT32 getSceneObjectDepth(const HSceneObject& so);
50 };
51
52 /** Provides extra information and maintains state during serialization of various RTTI types in the core. */
53 struct BS_CORE_EXPORT CoreSerializationContext : SerializationContext
54 {
55 SPtr<GameObjectDeserializationState> goState;
56 bool goDeserializationActive = false;
57
58 static RTTITypeBase* getRTTIStatic();
59 RTTITypeBase* getRTTI() const override;
60 };
61
62 /** @} */
63}
64