本文整理汇总了C++中TWeakObjectPtr::GetAbility方法的典型用法代码示例。如果您正苦于以下问题:C++ TWeakObjectPtr::GetAbility方法的具体用法?C++ TWeakObjectPtr::GetAbility怎么用?C++ TWeakObjectPtr::GetAbility使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TWeakObjectPtr
的用法示例。
在下文中一共展示了TWeakObjectPtr::GetAbility方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnTaskTick
void UAblRayCastQueryTask::OnTaskTick(const TWeakObjectPtr<const UAblAbilityContext>& Context, float deltaTime) const
{
Super::OnTaskTick(Context, deltaTime);
if (IsAsyncFriendly() && UAbleSettings::IsAsyncEnabled())
{
UAblRayCastQueryTaskScratchPad* ScratchPad = Cast<UAblRayCastQueryTaskScratchPad>(Context->GetScratchPadForTask(this));
check(ScratchPad);
if (!ScratchPad->AsyncProcessed && ScratchPad->AsyncHandle._Handle != 0)
{
AActor* SourceActor = m_QueryLocation.GetSourceActor(*Context.Get());
check(SourceActor);
UWorld* World = SourceActor->GetWorld();
FTraceDatum Datum;
if (World->QueryTraceData(ScratchPad->AsyncHandle, Datum))
{
if (m_CopyResultsToContext)
{
CopyResultsToContext(Datum.OutHits, Context);
}
if (m_FireEvent)
{
Context->GetAbility()->OnRaycastEvent(Context.Get(), m_Name, Datum.OutHits);
}
ScratchPad->AsyncProcessed = true;
}
}
}
}
示例2: Validate
void UAblAbilityTaskDependencyValidator::Validate(const TWeakObjectPtr<UAblAbilityTaskValidatorContext>& Context, const TWeakObjectPtr<const UAblAbilityTask>& Task) const
{
const TArray<UAblAbilityTask*>& AllTasks = Context->GetAbility()->GetTasks();
for (const UAblAbilityTask* CurrentTask : AllTasks)
{
HasCircularDependency(Context, CurrentTask, CurrentTask);
}
}
示例3: OnTaskStart
void UAblSetShaderParameterTask::OnTaskStart(const TWeakObjectPtr<const UAblAbilityContext>& Context) const
{
Super::OnTaskStart(Context);
if (!m_Value)
{
UE_LOG(LogAble, Warning, TEXT("No Value set for SetShaderParameter in Ability [%s]"), *Context->GetAbility()->GetDisplayName());
return;
}
// We need to convert our Actors to primitive components.
TArray<TWeakObjectPtr<AActor>> TargetArray;
GetActorsForTask(Context, TargetArray);
TArray<TWeakObjectPtr<UPrimitiveComponent>> PrimitiveComponents;
for (TWeakObjectPtr<AActor>& Target : TargetArray)
{
for (UActorComponent* Component : Target->GetComponentsByClass(UPrimitiveComponent::StaticClass()))
{
PrimitiveComponents.Add(Cast<UPrimitiveComponent>(Component));
}
}
UAblSetShaderParameterTaskScratchPad* ScratchPad = Cast<UAblSetShaderParameterTaskScratchPad>(Context->GetScratchPadForTask(this));
check(ScratchPad);
ScratchPad->BlendIn = m_BlendIn;
ScratchPad->BlendIn.Reset();
ScratchPad->BlendOut = m_BlendOut;
ScratchPad->BlendOut.Reset();
UAblSetParameterValue* CachedValue = nullptr;
for (TWeakObjectPtr<UPrimitiveComponent>& PrimitiveComponent : PrimitiveComponents)
{
if (PrimitiveComponent.IsValid())
{
for (int32 i = 0; i < PrimitiveComponent->GetNumMaterials(); ++i)
{
UMaterialInterface* MaterialInterface = PrimitiveComponent->GetMaterial(i);
UMaterialInstanceDynamic* DynamicMaterial = Cast<UMaterialInstanceDynamic>(MaterialInterface);
// If our material currently isn't dynamic, but we have the parameter we're looking for - instantiate a dynamic version.
if (!DynamicMaterial && CheckMaterialHasParameter(MaterialInterface))
{
DynamicMaterial = PrimitiveComponent->CreateDynamicMaterialInstance(i, MaterialInterface);
}
if (DynamicMaterial)
{
CachedValue = CacheShaderValue(ScratchPad, DynamicMaterial);
if (CachedValue)
{
ScratchPad->DynamicMaterials.Add(DynamicMaterial);
ScratchPad->PreviousValues.Add(CachedValue);
if (ScratchPad->BlendIn.IsComplete())
{
// If there isn't any blend. Just set it here since we won't be ticking.
InternalSetShaderValue(DynamicMaterial, m_Value, CachedValue, ScratchPad->BlendIn.GetAlpha());
}
}
}
}
}
}
}
示例4: OnTaskStart
void UAblRayCastQueryTask::OnTaskStart(const TWeakObjectPtr<const UAblAbilityContext>& Context) const
{
Super::OnTaskStart(Context);
AActor* SourceActor = m_QueryLocation.GetSourceActor(*Context.Get());
check(SourceActor);
UWorld* World = SourceActor->GetWorld();
FTransform QueryTransform;
m_QueryLocation.GetTransform(*Context.Get(), QueryTransform);
const FVector RayStart = QueryTransform.GetLocation();
const FVector RayEnd = RayStart + QueryTransform.GetRotation().GetForwardVector() * m_Length;
if (m_UseAsyncQuery && UAbleSettings::IsAsyncEnabled())
{
UAblRayCastQueryTaskScratchPad* ScratchPad = Cast<UAblRayCastQueryTaskScratchPad>(Context->GetScratchPadForTask(this));
check(ScratchPad);
if (m_OnlyReturnBlockingHit)
{
ScratchPad->AsyncHandle = World->AsyncLineTraceByChannel(EAsyncTraceType::Single, RayStart, RayEnd, m_CollisionChannel);
}
else
{
ScratchPad->AsyncHandle = World->AsyncLineTraceByChannel(EAsyncTraceType::Multi, RayStart, RayEnd, m_CollisionChannel);
}
}
else
{
TArray<FHitResult> HitResults;
FHitResult TraceResult;
if (m_OnlyReturnBlockingHit)
{
if (World->LineTraceSingleByChannel(TraceResult, RayStart, RayEnd, m_CollisionChannel))
{
HitResults.Add(TraceResult);
}
}
else
{
World->LineTraceMultiByChannel(HitResults, RayStart, RayEnd, m_CollisionChannel);
}
#if !(UE_BUILD_SHIPPING)
if (IsVerbose())
{
PrintVerbose(FString::Printf(TEXT("Raycast found %d results."), HitResults.Num()));
}
#endif
if (HitResults.Num())
{
#if !(UE_BUILD_SHIPPING)
if (IsVerbose())
{
// Quick distance print help to see if we hit ourselves.
float DistanceToBlocker = HitResults[HitResults.Num() - 1].Distance;
PrintVerbose(FString::Printf(TEXT("Raycast blocking hit distance: %4.2f."), DistanceToBlocker));
}
#endif
if (m_CopyResultsToContext)
{
#if !(UE_BUILD_SHIPPING)
if (IsVerbose())
{
PrintVerbose(FString::Printf(TEXT("Copying %d results into Context."), HitResults.Num()));
}
#endif
CopyResultsToContext(HitResults, Context);
}
if (m_FireEvent)
{
#if !(UE_BUILD_SHIPPING)
if (IsVerbose())
{
PrintVerbose(FString::Printf(TEXT("Firing Raycast Event %s with %d results."), *m_Name.ToString(), HitResults.Num()));
}
#endif
Context->GetAbility()->OnRaycastEvent(Context.Get(), m_Name, HitResults);
}
}
}
#if !UE_BUILD_SHIPPING
if (FAblAbilityDebug::ShouldDrawQueries())
{
FAblAbilityDebug::DrawRaycastQuery(World, QueryTransform, m_Length);
}
#endif
}