当前位置: 首页>>代码示例>>C++>>正文


C++ TWeakObjectPtr::GetAbility方法代码示例

本文整理汇总了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;
			}

		}
	}
}
开发者ID:zpzsoft,项目名称:zpzsoft.github.io,代码行数:34,代码来源:ablRayCastQueryTask.cpp

示例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);
	}
}
开发者ID:zpzsoft,项目名称:zpzsoft.github.io,代码行数:8,代码来源:ablAbilityTaskValidator.cpp

示例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());
						}
					}
				}
			}
		}
	}

}
开发者ID:zpzsoft,项目名称:zpzsoft.github.io,代码行数:69,代码来源:ablSetShaderParameterTask.cpp

示例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
}
开发者ID:zpzsoft,项目名称:zpzsoft.github.io,代码行数:93,代码来源:ablRayCastQueryTask.cpp


注:本文中的TWeakObjectPtr::GetAbility方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。