merging latest origin
This commit is contained in:
@@ -18,6 +18,8 @@
|
||||
#include <AzCore/Component/TickBus.h>
|
||||
#include <AzCore/Debug/Profiler.h>
|
||||
#include <AzCore/std/containers/stack.h>
|
||||
#include <AzFramework/Scene/Scene.h>
|
||||
#include <AzFramework/Scene/SceneSystemInterface.h>
|
||||
|
||||
#include "EntityContext.h"
|
||||
|
||||
@@ -37,6 +39,30 @@ namespace AzFramework
|
||||
}
|
||||
}
|
||||
|
||||
AZStd::shared_ptr<Scene> EntityContext::FindContainingScene(const EntityContextId& contextId)
|
||||
{
|
||||
auto sceneSystem = SceneSystemInterface::Get();
|
||||
AZ_Assert(sceneSystem, "Attempting to retrieve the scene containing a entity context before the scene system is available.");
|
||||
|
||||
AZStd::shared_ptr<Scene> result;
|
||||
sceneSystem->IterateActiveScenes([&result, &contextId](const AZStd::shared_ptr<Scene>& scene)
|
||||
{
|
||||
EntityContext** entityContext = scene->FindSubsystemInScene<EntityContext::SceneStorageType>();
|
||||
if (entityContext && (*entityContext)->GetContextId() == contextId)
|
||||
{
|
||||
result = scene;
|
||||
// Result found, returning.
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// No match, continuing to search for containing scene.
|
||||
return true;
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
// EntityContext ctor
|
||||
//=========================================================================
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <AzCore/Component/EntityBus.h>
|
||||
#include <AzCore/Serialization/ObjectStream.h>
|
||||
#include <AzCore/Serialization/IdUtils.h>
|
||||
#include <AzCore/std/smart_ptr/shared_ptr.h>
|
||||
#include <AzFramework/Entity/EntityContextBus.h>
|
||||
#include <AzFramework/Entity/SliceEntityOwnershipService.h>
|
||||
|
||||
@@ -27,7 +28,7 @@ namespace AZ
|
||||
|
||||
namespace AzFramework
|
||||
{
|
||||
class EntityContext;
|
||||
class Scene;
|
||||
|
||||
/**
|
||||
* Provides services for a group of entities under the umbrella of a given context.
|
||||
@@ -47,9 +48,11 @@ namespace AzFramework
|
||||
, public EntityOwnershipServiceNotificationBus::Handler
|
||||
{
|
||||
public:
|
||||
|
||||
AZ_TYPE_INFO(EntityContext, "{4F98A6B9-C7B5-450E-8A8A-30EEFC411EF5}");
|
||||
|
||||
/// The type used to store entity in AzFramework::Scene.
|
||||
using SceneStorageType = EntityContext*;
|
||||
|
||||
EntityContext(AZ::SerializeContext* serializeContext = nullptr);
|
||||
EntityContext(const EntityContextId& contextId, AZ::SerializeContext* serializeContext = nullptr);
|
||||
EntityContext(const EntityContextId& contextId, AZStd::unique_ptr<EntityOwnershipService> entityOwnershipService,
|
||||
@@ -75,6 +78,7 @@ namespace AzFramework
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static void Reflect(AZ::ReflectContext* context);
|
||||
static AZStd::shared_ptr<Scene> FindContainingScene(const EntityContextId& contextId);
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
@@ -66,6 +66,8 @@ namespace AzFramework
|
||||
*/
|
||||
virtual EntityContextId GetGameEntityContextId() = 0;
|
||||
|
||||
virtual EntityContext* GetGameEntityContextInstance() = 0;
|
||||
|
||||
/**
|
||||
* Creates an entity in the game context.
|
||||
* @param name A name for the new entity.
|
||||
|
||||
@@ -52,6 +52,7 @@ namespace AzFramework
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// GameEntityContextRequestBus
|
||||
AZ::Uuid GetGameEntityContextId() override { return GetContextId(); }
|
||||
EntityContext* GetGameEntityContextInstance() override { return this; }
|
||||
void ResetGameContext() override;
|
||||
AZ::Entity* CreateGameEntity(const char* name) override;
|
||||
BehaviorEntity CreateGameEntityForBehaviorContext(const char* name) override;
|
||||
|
||||
Reference in New Issue
Block a user