Enable destroying game entities spawned with a spawnable
Signed-off-by: srikappa-amzn <srikappa@amazon.com>
This commit is contained in:
@@ -91,15 +91,6 @@ namespace AzFramework
|
||||
*/
|
||||
virtual void DestroyGameEntity(const AZ::EntityId& /*id*/) = 0;
|
||||
|
||||
/**
|
||||
* Destroys an entity only in slice mode (when prefabs are disabled). This request is only added as a stop-gap solution
|
||||
* to prevent the editor from crashing when prefabs are enabled and must only be called through the BehaviorContext binding
|
||||
* for 'DestroyGameEntity'. No code should be written to directly call this method. This will be removed soon.
|
||||
*
|
||||
* @param id The ID of the entity to destroy.
|
||||
*/
|
||||
virtual void DestroyGameEntityOnlyInSliceMode(const AZ::EntityId& /*id*/) = 0;
|
||||
|
||||
/**
|
||||
* Destroys an entity and all of its descendants.
|
||||
* The entity and its descendants are immediately deactivated and will be
|
||||
@@ -108,15 +99,6 @@ namespace AzFramework
|
||||
*/
|
||||
virtual void DestroyGameEntityAndDescendants(const AZ::EntityId& /*id*/) = 0;
|
||||
|
||||
/**
|
||||
* Destroys an entity and its descendants only in slice mode (when prefabs are disabled). This request is only added as a stop-gap
|
||||
* solution to prevent the editor from crashing when prefabs are enabled and must only be called through the BehaviorContext
|
||||
* binding for 'DestroyGameEntityAndDescendants'.No code should be written to directly call this method. This will be removed soon.
|
||||
*
|
||||
* @param id The ID of the entity to destroy.
|
||||
*/
|
||||
virtual void DestroyGameEntityAndDescendantsOnlyInSliceMode(const AZ::EntityId& /*id*/) = 0;
|
||||
|
||||
/**
|
||||
* Activates the game entity.
|
||||
* @param id The ID of the entity to activate.
|
||||
|
||||
@@ -11,9 +11,10 @@
|
||||
#include <AzCore/Serialization/SerializeContext.h>
|
||||
#include <AzCore/Serialization/EditContext.h>
|
||||
#include <AzCore/RTTI/BehaviorContext.h>
|
||||
#include <AzFramework/API/ApplicationAPI.h>
|
||||
#include <AzFramework/Entity/EntityContext.h>
|
||||
#include <AzFramework/Components/TransformComponent.h>
|
||||
#include <AzFramework/API/ApplicationAPI.h>
|
||||
#include <AzFramework/Spawnable/SpawnedEntityTicketMapperInterface.h>
|
||||
|
||||
#include "GameEntityContextComponent.h"
|
||||
|
||||
@@ -47,9 +48,9 @@ namespace AzFramework
|
||||
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common)
|
||||
->Event("CreateGameEntity", &GameEntityContextRequestBus::Events::CreateGameEntityForBehaviorContext)
|
||||
->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::All)
|
||||
->Event("DestroyGameEntity", &GameEntityContextRequestBus::Events::DestroyGameEntityOnlyInSliceMode)
|
||||
->Event("DestroyGameEntity", &GameEntityContextRequestBus::Events::DestroyGameEntity)
|
||||
->Event(
|
||||
"DestroyGameEntityAndDescendants", &GameEntityContextRequestBus::Events::DestroyGameEntityAndDescendantsOnlyInSliceMode)
|
||||
"DestroyGameEntityAndDescendants", &GameEntityContextRequestBus::Events::DestroyGameEntityAndDescendants)
|
||||
->Event("ActivateGameEntity", &GameEntityContextRequestBus::Events::ActivateGameEntity)
|
||||
->Event("DeactivateGameEntity", &GameEntityContextRequestBus::Events::DeactivateGameEntity)
|
||||
->Attribute(AZ::ScriptCanvasAttributes::DeactivatesInputEntity, true)
|
||||
@@ -249,23 +250,6 @@ namespace AzFramework
|
||||
DestroyGameEntityInternal(id, false);
|
||||
}
|
||||
|
||||
void GameEntityContextComponent::DestroyGameEntityOnlyInSliceMode(const AZ::EntityId& id)
|
||||
{
|
||||
bool isPrefabSystemEnabled = false;
|
||||
AzFramework::ApplicationRequests::Bus::BroadcastResult(
|
||||
isPrefabSystemEnabled, &AzFramework::ApplicationRequests::IsPrefabSystemEnabled);
|
||||
if (!isPrefabSystemEnabled)
|
||||
{
|
||||
DestroyGameEntityInternal(id, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
AZ_Error(
|
||||
"GameEntityContextComponent", false,
|
||||
"Destroying a game entity is temporarily disabled until the Spawnable system can support this.");
|
||||
}
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
// GameEntityContextComponent::DestroyGameEntityAndDescendantsById
|
||||
//=========================================================================
|
||||
@@ -274,24 +258,6 @@ namespace AzFramework
|
||||
DestroyGameEntityInternal(id, true);
|
||||
}
|
||||
|
||||
|
||||
void GameEntityContextComponent::DestroyGameEntityAndDescendantsOnlyInSliceMode(const AZ::EntityId& id)
|
||||
{
|
||||
bool isPrefabSystemEnabled = false;
|
||||
AzFramework::ApplicationRequests::Bus::BroadcastResult(
|
||||
isPrefabSystemEnabled, &AzFramework::ApplicationRequests::IsPrefabSystemEnabled);
|
||||
if (!isPrefabSystemEnabled)
|
||||
{
|
||||
DestroyGameEntityInternal(id, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
AZ_Error(
|
||||
"GameEntityContextComponent", false,
|
||||
"Destroying a game entity and its descendants is temporarily disabled until the Spawnable system can support this.");
|
||||
}
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
// GameEntityContextComponent::DestroyGameEntityInternal
|
||||
//=========================================================================
|
||||
@@ -319,6 +285,14 @@ namespace AzFramework
|
||||
EBUS_EVENT_RESULT(currentEntity, AZ::ComponentApplicationBus, FindEntity, *entityIdIter);
|
||||
if (currentEntity)
|
||||
{
|
||||
bool isPrefabSystemEnabled = false;
|
||||
AzFramework::ApplicationRequests::Bus::BroadcastResult(
|
||||
isPrefabSystemEnabled, &AzFramework::ApplicationRequests::IsPrefabSystemEnabled);
|
||||
if (isPrefabSystemEnabled)
|
||||
{
|
||||
AZ::Interface<SpawnedEntityTicketMapperInterface>::Get()->RemoveSpawnedEntity(currentEntity->GetId());
|
||||
}
|
||||
|
||||
if (currentEntity->GetState() == AZ::Entity::State::Active)
|
||||
{
|
||||
// Deactivate the entity, we'll destroy it as soon as it is safe.
|
||||
|
||||
@@ -90,11 +90,6 @@ namespace AzFramework
|
||||
}
|
||||
|
||||
private:
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// GameEntityContextRequestBus
|
||||
void DestroyGameEntityOnlyInSliceMode(const AZ::EntityId&) override;
|
||||
void DestroyGameEntityAndDescendantsOnlyInSliceMode(const AZ::EntityId&) override;
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
||||
AzFramework::EntityVisibilityBoundsUnionSystem m_entityVisibilityBoundsUnionSystem;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user