1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- /*
- * 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_CE("GameEntityContextService"));
- }
- static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
- {
- incompatible.push_back(AZ_CRC_CE("GameEntityContextService"));
- }
- static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
- {
- required.push_back(AZ_CRC_CE("SliceSystemService"));
- }
- private:
- AzFramework::EntityVisibilityBoundsUnionSystem m_entityVisibilityBoundsUnionSystem;
- };
- } // namespace AzFramework
- #endif // AZFRAMEWORK_GAMEENTITYCONTEXTCOMPONENT_H
|