void UGameplayDebuggingControllerComponent::OnActivationKeyPressed()
{
#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
	if (GetDebuggingReplicator() && PlayerOwner.IsValid())
	{
		if (!bToolActivated)
		{
			Activate();
			SetComponentTickEnabled(true);

			BindAIDebugViewKeys(AIDebugViewInputComponent);
			if (PlayerOwner.IsValid())
			{
				PlayerOwner->PushInputComponent(AIDebugViewInputComponent);
			}

			GetDebuggingReplicator()->EnableDraw(true);
			GetDebuggingReplicator()->ServerReplicateMessage(nullptr, EDebugComponentMessage::ActivateReplication, EAIDebugDrawDataView::Empty);
		}

		ControlKeyPressedTime = GetWorld()->GetTimeSeconds();
		EnableTargetSelection(true);
	}
#endif //!(UE_BUILD_SHIPPING || UE_BUILD_TEST)
}
void UGameplayDebuggingControllerComponent::OnActivationKeyPressed()
{
	if (GetDebuggingReplicator() && PlayerOwner.IsValid())
	{
		if (!bToolActivated)
		{
			Activate();
			SetComponentTickEnabled(true);

			BindAIDebugViewKeys();
			GetDebuggingReplicator()->EnableDraw(true);
			GetDebuggingReplicator()->ServerReplicateMessage(NULL, EDebugComponentMessage::ActivateReplication, EAIDebugDrawDataView::Empty);
		}

		ControlKeyPressedTime = GetWorld()->GetTimeSeconds();
		EnableTargetSelection(true);
	}
}
void UGameplayDebuggingControllerComponent::OnActivationKeyReleased()
{
	const float KeyPressedTime = GetWorld()->GetTimeSeconds() - ControlKeyPressedTime;

	EnableTargetSelection(false);
	if (GetDebuggingReplicator() && bToolActivated)
	{
		if (KeyPressedTime < KeyPressActivationTime)
		{
			CloseDebugTool();
		}
		else
		{
			APawn* TargetPawn = GetDebuggingReplicator()->GetDebugComponent() ? Cast<APawn>(GetDebuggingReplicator()->GetDebugComponent()->GetSelectedActor()) : NULL;
			if (TargetPawn != NULL)
			{
				FBehaviorTreeDelegates::OnDebugLocked.Broadcast(TargetPawn);
			}
		}
	}
}
void UGameplayDebuggingControllerComponent::OnActivationKeyReleased()
{
#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
	const float KeyPressedTime = GetWorld()->GetTimeSeconds() - ControlKeyPressedTime;

	EnableTargetSelection(false);
	if (GetDebuggingReplicator() && bToolActivated)
	{
		if (KeyPressedTime < KeyPressActivationTime && DebugCameraController.IsValid() == false)
		{
			CloseDebugTool();
		}
		else
		{
			APawn* TargetPawn = GetDebuggingReplicator()->GetDebugComponent() ? Cast<APawn>(GetDebuggingReplicator()->GetDebugComponent()->GetSelectedActor()) : nullptr;
			if (TargetPawn != nullptr)
			{
				FBehaviorTreeDelegates::OnDebugLocked.Broadcast(TargetPawn);
			}
		}
	}
#endif //!(UE_BUILD_SHIPPING || UE_BUILD_TEST)
}