Files
UnrealEngineUWP/Engine/Source/Runtime/AIModule/Private/EnvironmentQuery/EnvQueryInstanceBlueprintWrapper.cpp

174 lines
4.4 KiB
C++
Raw Normal View History

// Copyright Epic Games, Inc. All Rights Reserved.
#include "EnvironmentQuery/EnvQueryInstanceBlueprintWrapper.h"
#include "EnvironmentQuery/Items/EnvQueryItemType_ActorBase.h"
#include "EnvironmentQuery/EnvQueryManager.h"
UEnvQueryInstanceBlueprintWrapper::UEnvQueryInstanceBlueprintWrapper(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
, QueryID(INDEX_NONE)
{
}
void UEnvQueryInstanceBlueprintWrapper::OnQueryFinished(TSharedPtr<FEnvQueryResult> Result)
{
check(Result.IsValid());
QueryResult = Result;
ItemType = Result->ItemType;
OptionIndex = Result->OptionIndex;
OnQueryFinishedEvent.Broadcast(this, Result->GetRawStatus());
Copying up to CL#2909284 //UE4/Fortnite-Staging to //UE4/Main This is CL#2904759 from //Fortnite/Main #lockdown Nick.Penwarden ========================== MAJOR FEATURES + CHANGES ========================== Change 2904398 on 2016/03/10 by Bob.Tellez #UE4 OnlineBeaconClients are now destroyed when net cleanup happens instead of normal destruction time so the behave more like PlayerControllers. Also added some low level protection from closing already closed beacons. #rb Josh.Markiewicz #codreview Josh.Markiewicz #JIRA FORT-20703 Change 2904339 on 2016/03/10 by Daniel.Broder Added support for allowing an actor to determine whether it is selectable or not (rather than relying purely on editor modes). One example use-case is a Transient actor created by WorldSettings for Fortnite which can otherwise be selected, edited, and even copied and pasted to a non-Transient form (which can be done accidentally and cause bugs). Change made after discussion with Bob. #CodeReview Bob.Tellez #UE4 Change 2903020 on 2016/03/10 by John.Abercrombie Added blueprint function to set named params for use when running an EQS query from BP - Phil is going to test this out for me. #rb me (Mieszko wrote this) #codereview Phil.Cole, Mieszko.Zielinski Change 2902440 on 2016/03/09 by Ben.Zeigler #Jira FORT-20149 Fix package map issue where if the client package map received a reference to a package that was already in the async loading queue due to an unrelated async load call, it would not register it correctly, which would lead to error messages and actors potentially not being initialized. #codereview john.pollard #RB bob.tellez Change 2900138 on 2016/03/08 by Bob.Tellez #UE4 Updated the following Parameter value functions to respect the bOverride flag GetStaticSwitchParameterValue GetStaticComponentMaskParameterValue GetTerrainLayerWeightParameterValue #rb Nick.Penwarden Change 2899839 on 2016/03/08 by Lukasz.Furman fixed navmesh projection on actors with overlap response to world channels #rb Mieszko.Zielinski #codereview Zak.Middleton Change 2899743 on 2016/03/08 by Lukasz.Furman fixed handling multiple blocking hits in navwalking's geometry conforming blocking response was used in previous implementation accepting first hit, scoring mutliple points requires getting them all with overlap response #fortnite FORT-21546 #rb Mieszko.Zielinski #codereview Zak.Middleton Change 2898194 on 2016/03/07 by Chris.Gagnon Added the ability to filter DataTable Assets by their row using the metadata. meta = (RowType=MyRowName) #RB Saad.Nader #codereview Saad.Nader, Jamie.Dale Change 2895102 on 2016/03/04 by Ben.Zeigler #JIRA FORT-20290 Fix issue where if a server received a 408 on a verify auth call, it would get stuck in the "in progress" state, and would never try to verify auth again until the auth timed out Add additional logging to auth queries, to track this and other issues. The new log lines are permanent, but StartExtraLogging should be disabled before merging back to main #codereview josh.markiewicz Change 2891302 on 2016/03/02 by Bob.Tellez #UE4 The spawned NavGraph actors in CreateNavigationDataInstance were getting immediately marked pending kill due to the existance of the FortNavGraph actors placed in the NavMeshBounds map. Marking an actor pending kill instead of calling destroy actor is dangerous since DestroyActor does many other things including removing the actor from the networked actors list. Failure to remove from this list caused FORT-21458. This change both removes the existing FortNavGraph actors from the registered list and better handles cleaning up NavigationData removed for this reason. #rb Ben.Zeigler #codereview Lukasz.Furman Change 2887908 on 2016/03/01 by Chris.Gagnon Added Event Track to UMG Sequencer. Added PlayTo functionality for targeting the end point of a played animation. #RB Frank.Fella #codereview Frank.Fella, Nick.Darnell Change 2887686 on 2016/03/01 by Joel.Crabbe Fixed issue with replication comparison object not necessarily being the correct, blueprint-defined, defaults-edited version. Changed GetClass()->GetDefaultObject to GetArchetype() for comparison value. #codereview Ben.Zeigler Change 2886847 on 2016/02/29 by Bob.Tellez #UE4 Fixed a bug where pasting multiple lines of text into the property matrix would leave the \\r character in the string in windows platforms. #codereview Richard.TalbotWatkin Change 2886414 on 2016/02/29 by Lukasz.Furman fixed start point of composite path's update #fortnite FORT-21380 #rb Mieszko.Zielinski Change 2886250 on 2016/02/29 by Bob.Tellez #UE4 Adding !IsInSlateThread to assert in SuspendLoading/ResumeLoading. I suspect this may be the cause of a race condition involving flushing async loading during startup. #codereview Robert.Manuszewski Change 2885942 on 2016/02/29 by Bob.Tellez #UE4 Disabling per-instance mesh painting on instanced static mesh components. #rb Jack.Porter [CL 2909292 by Bob Tellez in Main branch]
2016-03-14 21:21:09 -04:00
// remove our reference to the query instance
QueryInstance = nullptr;
// unregister self, no longer shielded from GC
UEnvQueryManager* EnvQueryManager = Cast<UEnvQueryManager>(GetOuter());
if (ensure(EnvQueryManager))
{
EnvQueryManager->UnregisterActiveWrapper(*this);
}
}
float UEnvQueryInstanceBlueprintWrapper::GetItemScore(int32 ItemIndex) const
{
return QueryResult.IsValid() ? QueryResult->GetItemScore(ItemIndex) : -1.f;
}
bool UEnvQueryInstanceBlueprintWrapper::GetQueryResultsAsActors(TArray<AActor*>& ResultActors) const
{
ResultActors.Empty();
if (QueryResult.IsValid() &&
(QueryResult->GetRawStatus() == EEnvQueryStatus::Success) &&
(ItemType.Get() != nullptr) &&
ItemType->IsChildOf(UEnvQueryItemType_ActorBase::StaticClass()))
{
if (RunMode != EEnvQueryRunMode::AllMatching)
{
ResultActors.Add(QueryResult->GetItemAsActor(0));
}
else
{
QueryResult->GetAllAsActors(ResultActors);
}
return (ResultActors.Num() > 0);
}
return false;
}
TArray<AActor*> UEnvQueryInstanceBlueprintWrapper::GetResultsAsActors() const
{
TArray<AActor*> Results;
if (QueryResult.IsValid() &&
(ItemType.Get() != nullptr) &&
ItemType->IsChildOf(UEnvQueryItemType_ActorBase::StaticClass()))
{
if (RunMode != EEnvQueryRunMode::AllMatching)
{
Results.Add(QueryResult->GetItemAsActor(0));
}
else
{
QueryResult->GetAllAsActors(Results);
}
}
return Results;
}
bool UEnvQueryInstanceBlueprintWrapper::GetQueryResultsAsLocations(TArray<FVector>& ResultLocations) const
{
ResultLocations.Empty();
if (QueryResult.IsValid() &&
(QueryResult->GetRawStatus() == EEnvQueryStatus::Success))
{
if (RunMode != EEnvQueryRunMode::AllMatching)
{
ResultLocations.Add(QueryResult->GetItemAsLocation(0));
}
else
{
QueryResult->GetAllAsLocations(ResultLocations);
}
return (ResultLocations.Num() > 0);
}
return false;
}
TArray<FVector> UEnvQueryInstanceBlueprintWrapper::GetResultsAsLocations() const
{
TArray<FVector> Results;
if (QueryResult.IsValid())
{
if (RunMode != EEnvQueryRunMode::AllMatching)
{
Results.Add(QueryResult->GetItemAsLocation(0));
}
else
{
QueryResult->GetAllAsLocations(Results);
}
}
return Results;
}
void UEnvQueryInstanceBlueprintWrapper::RunQuery(const EEnvQueryRunMode::Type InRunMode, FEnvQueryRequest& QueryRequest)
{
RunMode = InRunMode;
QueryID = QueryRequest.Execute(RunMode, this, &UEnvQueryInstanceBlueprintWrapper::OnQueryFinished);
if (QueryID != INDEX_NONE)
{
// register self as a wrapper needing shielding from GC
UEnvQueryManager* EnvQueryManager = Cast<UEnvQueryManager>(GetOuter());
if (ensure(EnvQueryManager))
{
EnvQueryManager->RegisterActiveWrapper(*this);
Copying up to CL#2909284 //UE4/Fortnite-Staging to //UE4/Main This is CL#2904759 from //Fortnite/Main #lockdown Nick.Penwarden ========================== MAJOR FEATURES + CHANGES ========================== Change 2904398 on 2016/03/10 by Bob.Tellez #UE4 OnlineBeaconClients are now destroyed when net cleanup happens instead of normal destruction time so the behave more like PlayerControllers. Also added some low level protection from closing already closed beacons. #rb Josh.Markiewicz #codreview Josh.Markiewicz #JIRA FORT-20703 Change 2904339 on 2016/03/10 by Daniel.Broder Added support for allowing an actor to determine whether it is selectable or not (rather than relying purely on editor modes). One example use-case is a Transient actor created by WorldSettings for Fortnite which can otherwise be selected, edited, and even copied and pasted to a non-Transient form (which can be done accidentally and cause bugs). Change made after discussion with Bob. #CodeReview Bob.Tellez #UE4 Change 2903020 on 2016/03/10 by John.Abercrombie Added blueprint function to set named params for use when running an EQS query from BP - Phil is going to test this out for me. #rb me (Mieszko wrote this) #codereview Phil.Cole, Mieszko.Zielinski Change 2902440 on 2016/03/09 by Ben.Zeigler #Jira FORT-20149 Fix package map issue where if the client package map received a reference to a package that was already in the async loading queue due to an unrelated async load call, it would not register it correctly, which would lead to error messages and actors potentially not being initialized. #codereview john.pollard #RB bob.tellez Change 2900138 on 2016/03/08 by Bob.Tellez #UE4 Updated the following Parameter value functions to respect the bOverride flag GetStaticSwitchParameterValue GetStaticComponentMaskParameterValue GetTerrainLayerWeightParameterValue #rb Nick.Penwarden Change 2899839 on 2016/03/08 by Lukasz.Furman fixed navmesh projection on actors with overlap response to world channels #rb Mieszko.Zielinski #codereview Zak.Middleton Change 2899743 on 2016/03/08 by Lukasz.Furman fixed handling multiple blocking hits in navwalking's geometry conforming blocking response was used in previous implementation accepting first hit, scoring mutliple points requires getting them all with overlap response #fortnite FORT-21546 #rb Mieszko.Zielinski #codereview Zak.Middleton Change 2898194 on 2016/03/07 by Chris.Gagnon Added the ability to filter DataTable Assets by their row using the metadata. meta = (RowType=MyRowName) #RB Saad.Nader #codereview Saad.Nader, Jamie.Dale Change 2895102 on 2016/03/04 by Ben.Zeigler #JIRA FORT-20290 Fix issue where if a server received a 408 on a verify auth call, it would get stuck in the "in progress" state, and would never try to verify auth again until the auth timed out Add additional logging to auth queries, to track this and other issues. The new log lines are permanent, but StartExtraLogging should be disabled before merging back to main #codereview josh.markiewicz Change 2891302 on 2016/03/02 by Bob.Tellez #UE4 The spawned NavGraph actors in CreateNavigationDataInstance were getting immediately marked pending kill due to the existance of the FortNavGraph actors placed in the NavMeshBounds map. Marking an actor pending kill instead of calling destroy actor is dangerous since DestroyActor does many other things including removing the actor from the networked actors list. Failure to remove from this list caused FORT-21458. This change both removes the existing FortNavGraph actors from the registered list and better handles cleaning up NavigationData removed for this reason. #rb Ben.Zeigler #codereview Lukasz.Furman Change 2887908 on 2016/03/01 by Chris.Gagnon Added Event Track to UMG Sequencer. Added PlayTo functionality for targeting the end point of a played animation. #RB Frank.Fella #codereview Frank.Fella, Nick.Darnell Change 2887686 on 2016/03/01 by Joel.Crabbe Fixed issue with replication comparison object not necessarily being the correct, blueprint-defined, defaults-edited version. Changed GetClass()->GetDefaultObject to GetArchetype() for comparison value. #codereview Ben.Zeigler Change 2886847 on 2016/02/29 by Bob.Tellez #UE4 Fixed a bug where pasting multiple lines of text into the property matrix would leave the \\r character in the string in windows platforms. #codereview Richard.TalbotWatkin Change 2886414 on 2016/02/29 by Lukasz.Furman fixed start point of composite path's update #fortnite FORT-21380 #rb Mieszko.Zielinski Change 2886250 on 2016/02/29 by Bob.Tellez #UE4 Adding !IsInSlateThread to assert in SuspendLoading/ResumeLoading. I suspect this may be the cause of a race condition involving flushing async loading during startup. #codereview Robert.Manuszewski Change 2885942 on 2016/02/29 by Bob.Tellez #UE4 Disabling per-instance mesh painting on instanced static mesh components. #rb Jack.Porter [CL 2909292 by Bob Tellez in Main branch]
2016-03-14 21:21:09 -04:00
QueryInstance = EnvQueryManager->FindQueryInstance(QueryID);
}
}
Copying up to CL#2909284 //UE4/Fortnite-Staging to //UE4/Main This is CL#2904759 from //Fortnite/Main #lockdown Nick.Penwarden ========================== MAJOR FEATURES + CHANGES ========================== Change 2904398 on 2016/03/10 by Bob.Tellez #UE4 OnlineBeaconClients are now destroyed when net cleanup happens instead of normal destruction time so the behave more like PlayerControllers. Also added some low level protection from closing already closed beacons. #rb Josh.Markiewicz #codreview Josh.Markiewicz #JIRA FORT-20703 Change 2904339 on 2016/03/10 by Daniel.Broder Added support for allowing an actor to determine whether it is selectable or not (rather than relying purely on editor modes). One example use-case is a Transient actor created by WorldSettings for Fortnite which can otherwise be selected, edited, and even copied and pasted to a non-Transient form (which can be done accidentally and cause bugs). Change made after discussion with Bob. #CodeReview Bob.Tellez #UE4 Change 2903020 on 2016/03/10 by John.Abercrombie Added blueprint function to set named params for use when running an EQS query from BP - Phil is going to test this out for me. #rb me (Mieszko wrote this) #codereview Phil.Cole, Mieszko.Zielinski Change 2902440 on 2016/03/09 by Ben.Zeigler #Jira FORT-20149 Fix package map issue where if the client package map received a reference to a package that was already in the async loading queue due to an unrelated async load call, it would not register it correctly, which would lead to error messages and actors potentially not being initialized. #codereview john.pollard #RB bob.tellez Change 2900138 on 2016/03/08 by Bob.Tellez #UE4 Updated the following Parameter value functions to respect the bOverride flag GetStaticSwitchParameterValue GetStaticComponentMaskParameterValue GetTerrainLayerWeightParameterValue #rb Nick.Penwarden Change 2899839 on 2016/03/08 by Lukasz.Furman fixed navmesh projection on actors with overlap response to world channels #rb Mieszko.Zielinski #codereview Zak.Middleton Change 2899743 on 2016/03/08 by Lukasz.Furman fixed handling multiple blocking hits in navwalking's geometry conforming blocking response was used in previous implementation accepting first hit, scoring mutliple points requires getting them all with overlap response #fortnite FORT-21546 #rb Mieszko.Zielinski #codereview Zak.Middleton Change 2898194 on 2016/03/07 by Chris.Gagnon Added the ability to filter DataTable Assets by their row using the metadata. meta = (RowType=MyRowName) #RB Saad.Nader #codereview Saad.Nader, Jamie.Dale Change 2895102 on 2016/03/04 by Ben.Zeigler #JIRA FORT-20290 Fix issue where if a server received a 408 on a verify auth call, it would get stuck in the "in progress" state, and would never try to verify auth again until the auth timed out Add additional logging to auth queries, to track this and other issues. The new log lines are permanent, but StartExtraLogging should be disabled before merging back to main #codereview josh.markiewicz Change 2891302 on 2016/03/02 by Bob.Tellez #UE4 The spawned NavGraph actors in CreateNavigationDataInstance were getting immediately marked pending kill due to the existance of the FortNavGraph actors placed in the NavMeshBounds map. Marking an actor pending kill instead of calling destroy actor is dangerous since DestroyActor does many other things including removing the actor from the networked actors list. Failure to remove from this list caused FORT-21458. This change both removes the existing FortNavGraph actors from the registered list and better handles cleaning up NavigationData removed for this reason. #rb Ben.Zeigler #codereview Lukasz.Furman Change 2887908 on 2016/03/01 by Chris.Gagnon Added Event Track to UMG Sequencer. Added PlayTo functionality for targeting the end point of a played animation. #RB Frank.Fella #codereview Frank.Fella, Nick.Darnell Change 2887686 on 2016/03/01 by Joel.Crabbe Fixed issue with replication comparison object not necessarily being the correct, blueprint-defined, defaults-edited version. Changed GetClass()->GetDefaultObject to GetArchetype() for comparison value. #codereview Ben.Zeigler Change 2886847 on 2016/02/29 by Bob.Tellez #UE4 Fixed a bug where pasting multiple lines of text into the property matrix would leave the \\r character in the string in windows platforms. #codereview Richard.TalbotWatkin Change 2886414 on 2016/02/29 by Lukasz.Furman fixed start point of composite path's update #fortnite FORT-21380 #rb Mieszko.Zielinski Change 2886250 on 2016/02/29 by Bob.Tellez #UE4 Adding !IsInSlateThread to assert in SuspendLoading/ResumeLoading. I suspect this may be the cause of a race condition involving flushing async loading during startup. #codereview Robert.Manuszewski Change 2885942 on 2016/02/29 by Bob.Tellez #UE4 Disabling per-instance mesh painting on instanced static mesh components. #rb Jack.Porter [CL 2909292 by Bob Tellez in Main branch]
2016-03-14 21:21:09 -04:00
}
void UEnvQueryInstanceBlueprintWrapper::SetNamedParam(FName ParamName, float Value)
{
FEnvQueryInstance* InstancePtr = QueryInstance.Get();
if (InstancePtr != nullptr)
{
InstancePtr->NamedParams.Add(ParamName, Value);
}
Copying //UE4/Dev-Build to //UE4/Dev-Main (Source: //UE4/Dev-Build @ 3209340) #lockdown Nick.Penwarden #rb none ========================== MAJOR FEATURES + CHANGES ========================== Change 3209340 on 2016/11/23 by Ben.Marsh Convert UE4 codebase to an "include what you use" model - where every header just includes the dependencies it needs, rather than every source file including large monolithic headers like Engine.h and UnrealEd.h. Measured full rebuild times around 2x faster using XGE on Windows, and improvements of 25% or more for incremental builds and full rebuilds on most other platforms. * Every header now includes everything it needs to compile. * There's a CoreMinimal.h header that gets you a set of ubiquitous types from Core (eg. FString, FName, TArray, FVector, etc...). Most headers now include this first. * There's a CoreTypes.h header that sets up primitive UE4 types and build macros (int32, PLATFORM_WIN64, etc...). All headers in Core include this first, as does CoreMinimal.h. * Every .cpp file includes its matching .h file first. * This helps validate that each header is including everything it needs to compile. * No engine code includes a monolithic header such as Engine.h or UnrealEd.h any more. * You will get a warning if you try to include one of these from the engine. They still exist for compatibility with game projects and do not produce warnings when included there. * There have only been minor changes to our internal games down to accommodate these changes. The intent is for this to be as seamless as possible. * No engine code explicitly includes a precompiled header any more. * We still use PCHs, but they're force-included on the compiler command line by UnrealBuildTool instead. This lets us tune what they contain without breaking any existing include dependencies. * PCHs are generated by a tool to get a statistical amount of coverage for the source files using it, and I've seeded the new shared PCHs to contain any header included by > 15% of source files. Tool used to generate this transform is at Engine\Source\Programs\IncludeTool. [CL 3209342 by Ben Marsh in Main branch]
2016-11-23 15:48:37 -05:00
}
void UEnvQueryInstanceBlueprintWrapper::SetInstigator(const UObject* Object)
{
#if !UE_BUILD_SHIPPING
Instigator = Object;
#endif // !UE_BUILD_SHIPPING
}
bool UEnvQueryInstanceBlueprintWrapper::IsSupportedForNetworking() const
{
// this object can't be replicated, but there are dragons in the land of blueprint...
FEnvQueryInstance* InstancePtr = QueryInstance.Get();
FString InstigatorName = TEXT("not available in shipping");
#if !UE_BUILD_SHIPPING
InstigatorName = *GetNameSafe(Instigator.Get());
#endif // !UE_BUILD_SHIPPING
UE_LOG(LogEQS, Warning, TEXT("%s can't be replicated over network!\n- Query: %s\n- Querier:%s\n- Instigator:%s"),
*GetName(),
InstancePtr ? *InstancePtr->QueryName : TEXT("instance not found"),
InstancePtr ? *GetNameSafe(InstancePtr->Owner.Get()) : TEXT("instance not found"),
*InstigatorName);
return false;
}