You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
99 lines
4.2 KiB
C++
99 lines
4.2 KiB
C++
/*
|
|
* Copyright (c) Contributors to the Open 3D Engine Project.
|
|
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
|
*
|
|
*/
|
|
#ifndef AZFRAMEWORK_GAMEENTITYCONTEXTCOMPONENT_H
|
|
#define AZFRAMEWORK_GAMEENTITYCONTEXTCOMPONENT_H
|
|
|
|
#include <AzCore/Math/Uuid.h>
|
|
#include <AzCore/Math/Transform.h>
|
|
#include <AzCore/std/containers/unordered_set.h>
|
|
#include <AzCore/Component/Component.h>
|
|
#include <AzFramework/Entity/GameEntityContextBus.h>
|
|
#include <AzFramework/Entity/SliceGameEntityOwnershipService.h>
|
|
#include <AzFramework/Visibility/EntityVisibilityBoundsUnionSystem.h>
|
|
|
|
#include "EntityContext.h"
|
|
|
|
namespace AzFramework
|
|
{
|
|
/**
|
|
* System component responsible for owning the game entity context.
|
|
*
|
|
* The game entity context owns entities in the game runtime, as well as during play-in-editor.
|
|
* These entities typically own game/runtime components, *not* inheriting from EditorComponentBase.
|
|
*/
|
|
class GameEntityContextComponent
|
|
: public AZ::Component
|
|
, public EntityContext
|
|
, private GameEntityContextRequestBus::Handler
|
|
{
|
|
public:
|
|
|
|
AZ_COMPONENT(GameEntityContextComponent, "{DA235454-DD9C-468C-AE70-404E415BAA6C}");
|
|
|
|
GameEntityContextComponent();
|
|
~GameEntityContextComponent() override;
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
// Component overrides
|
|
void Init() override;
|
|
void Activate() override;
|
|
void Deactivate() override;
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
// 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;
|
|
void AddGameEntity(AZ::Entity* entity) override;
|
|
void DestroyGameEntity(const AZ::EntityId&) override;
|
|
void DestroyGameEntityAndDescendants(const AZ::EntityId&) override;
|
|
void ActivateGameEntity(const AZ::EntityId&) override;
|
|
void DeactivateGameEntity(const AZ::EntityId&) override;
|
|
bool LoadFromStream(AZ::IO::GenericStream& stream, bool remapIds) override;
|
|
AZStd::string GetEntityName(const AZ::EntityId& id) override;
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
void DestroyGameEntityInternal(const AZ::EntityId&, bool destroyChildren);
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
// EntityContext
|
|
AZ::Entity* CreateEntity(const char* name) override;
|
|
void OnRootEntityReloaded() override;
|
|
void OnContextEntitiesAdded(const EntityList& entities) override;
|
|
void OnContextReset() override;
|
|
bool ValidateEntitiesAreValidForContext(const EntityList& entities) override;
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
static void Reflect(AZ::ReflectContext* context);
|
|
|
|
static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
|
|
{
|
|
provided.push_back(AZ_CRC("GameEntityContextService", 0xa6f2c885));
|
|
}
|
|
static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
|
|
{
|
|
incompatible.push_back(AZ_CRC("GameEntityContextService", 0xa6f2c885));
|
|
}
|
|
static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
|
|
{
|
|
required.push_back(AZ_CRC("SliceSystemService", 0x1a5b7aad));
|
|
}
|
|
|
|
private:
|
|
|
|
AzFramework::EntityVisibilityBoundsUnionSystem m_entityVisibilityBoundsUnionSystem;
|
|
};
|
|
} // namespace AzFramework
|
|
|
|
#endif // AZFRAMEWORK_GAMEENTITYCONTEXTCOMPONENT_H
|