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


C++ UAbilitySystemComponent类代码示例

本文整理汇总了C++中UAbilitySystemComponent的典型用法代码示例。如果您正苦于以下问题:C++ UAbilitySystemComponent类的具体用法?C++ UAbilitySystemComponent怎么用?C++ UAbilitySystemComponent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了UAbilitySystemComponent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ABILITY_LOG

void FAggregator::BroadcastOnDirty()
{
	// If we are batching on Dirty calls (and we actually have dependents registered with us) then early out.
	if (FScopedAggregatorOnDirtyBatch::GlobalBatchCount > 0 && (Dependents.Num() > 0 || OnDirty.IsBound()))
	{
		FScopedAggregatorOnDirtyBatch::DirtyAggregators.Add(this);
		return;
	}

	if (IsBroadcastingDirty)
	{
		// Apologies for the vague warning but its very hard from this spot to call out what data has caused this. If this frequently happens we should improve this.
		ABILITY_LOG(Warning, TEXT("FAggregator detected cyclic attribute dependencies. We are skipping a recursive dirty call. Its possible the resulting attribute values are not what you expect!"));
		return;
	}

	TGuardValue<bool>	Guard(IsBroadcastingDirty, true);
	
	OnDirty.Broadcast(this);


	TArray<FActiveGameplayEffectHandle>	ValidDependents;
	for (FActiveGameplayEffectHandle Handle : Dependents)
	{
		UAbilitySystemComponent* ASC = Handle.GetOwningAbilitySystemComponent();
		if (ASC)
		{
			ASC->OnMagnitudeDependencyChange(Handle, this);
			ValidDependents.Add(Handle);
		}
	}
	Dependents = ValidDependents;

}
开发者ID:amyvmiwei,项目名称:UnrealEngine4,代码行数:34,代码来源:GameplayEffectAggregator.cpp

示例2: EndTask

void UAbilityTask_WaitGameplayEffectRemoved::Activate()
{
    if (Handle.IsValid() == false)
    {
        InvalidHandle.Broadcast();
        EndTask();
        return;;
    }

    UAbilitySystemComponent* EffectOwningAbilitySystemComponent = Handle.GetOwningAbilitySystemComponent();

    if (EffectOwningAbilitySystemComponent)
    {
        FOnActiveGameplayEffectRemoved* DelPtr = EffectOwningAbilitySystemComponent->OnGameplayEffectRemovedDelegate(Handle);
        if (DelPtr)
        {
            OnGameplayEffectRemovedDelegateHandle = DelPtr->AddUObject(this, &UAbilityTask_WaitGameplayEffectRemoved::OnGameplayEffectRemoved);
            Registered = true;
        }
    }

    if (!Registered)
    {
        // GameplayEffect was already removed, treat this as a warning? Could be cases of immunity or chained gameplay rules that would instant remove something
        OnGameplayEffectRemoved();
    }
}
开发者ID:xiangyuan,项目名称:Unreal4,代码行数:27,代码来源:AbilityTask_WaitGameplayEffectRemoved.cpp

示例3: check

void AGameplayAbilityTargetActor::BindToConfirmCancelInputs()
{
	check(OwningAbility);

	UAbilitySystemComponent* ASC = OwningAbility->GetCurrentActorInfo()->AbilitySystemComponent.Get();
	if (ASC)
	{
		const FGameplayAbilityActorInfo* Info = OwningAbility->GetCurrentActorInfo();

		if (Info->IsLocallyControlled())
		{
			// We have to wait for the callback from the AbilitySystemComponent. Which will always be instigated locally
			ASC->GenericLocalConfirmCallbacks.AddDynamic(this, &AGameplayAbilityTargetActor::ConfirmTargeting);	// Tell me if the confirm input is pressed
			ASC->GenericLocalCancelCallbacks.AddDynamic(this, &AGameplayAbilityTargetActor::CancelTargeting);	// Tell me if the cancel input is pressed
		}
		else
		{	
			FGameplayAbilitySpecHandle Handle = OwningAbility->GetCurrentAbilitySpecHandle();
			FPredictionKey PredKey = OwningAbility->GetCurrentActivationInfo().GetActivationPredictionKey();

			GenericConfirmHandle = ASC->AbilityReplicatedEventDelegate(EAbilityGenericReplicatedEvent::GenericConfirm, Handle, PredKey ).AddUObject(this, &AGameplayAbilityTargetActor::ConfirmTargeting);
			GenericCancelHandle = ASC->AbilityReplicatedEventDelegate(EAbilityGenericReplicatedEvent::GenericCancel, Handle, PredKey ).AddUObject(this, &AGameplayAbilityTargetActor::CancelTargeting);
			
			if (ASC->CallReplicatedEventDelegateIfSet(EAbilityGenericReplicatedEvent::GenericConfirm, Handle, PredKey))
			{
				return;
			}
			
			if (ASC->CallReplicatedEventDelegateIfSet(EAbilityGenericReplicatedEvent::GenericCancel, Handle, PredKey))
			{
				return;
			}
		}
	}
}
开发者ID:colwalder,项目名称:unrealengine,代码行数:35,代码来源:GameplayAbilityTargetActor.cpp

示例4: GetActiveAbilitiesDebugDataForActor

void FGameplayAbilitiesModule::GetActiveAbilitiesDebugDataForActor(AActor* Actor, FString& AbilityString, bool& bIsUsingAbilities)
{
	UAbilitySystemComponent* AbilityComp = Actor->FindComponentByClass<UAbilitySystemComponent>();
	bIsUsingAbilities = (AbilityComp != nullptr);
	  
	int32 NumActive = 0;
	if (AbilityComp)
	{
		AbilityString = TEXT("");
	  
		for (const FGameplayAbilitySpec& AbilitySpec : AbilityComp->GetActivatableAbilities())
		{
	  		if (AbilitySpec.Ability && AbilitySpec.IsActive())
	  		{
	  			if (NumActive)
	  			{
					AbilityString += TEXT(", ");
	  			}
	  
	  			UClass* AbilityClass = AbilitySpec.Ability->GetClass();
	  			FString AbClassName = GetNameSafe(AbilityClass);
	  			AbClassName.RemoveFromEnd(TEXT("_c"));
	  
				AbilityString += AbClassName;
	  			NumActive++;
	  		}
		}
	}
	  
	if (NumActive == 0)
	{
		AbilityString = TEXT("None");
	}
}
开发者ID:didixp,项目名称:Ark-Dev-Kit,代码行数:34,代码来源:GameplayAbilitiesModule.cpp

示例5: CancelTargeting

/** Outside code is saying 'stop everything and just forget about it' */
void AGameplayAbilityTargetActor::CancelTargeting()
{
	UAbilitySystemComponent* ASC = OwningAbility->GetCurrentActorInfo()->AbilitySystemComponent.Get();
	ASC->AbilityReplicatedEventDelegate(EAbilityGenericReplicatedEvent::GenericCancel, OwningAbility->GetCurrentAbilitySpecHandle(), OwningAbility->GetCurrentActivationInfo().GetActivationPredictionKey() ).Remove(GenericCancelHandle);

	CanceledDelegate.Broadcast(FGameplayAbilityTargetDataHandle());
	Destroy();
}
开发者ID:colwalder,项目名称:unrealengine,代码行数:9,代码来源:GameplayAbilityTargetActor.cpp

示例6: GetActiveGameplayEffectStackCount

int32 UAbilitySystemBlueprintLibrary::GetActiveGameplayEffectStackCount(FActiveGameplayEffectHandle ActiveHandle)
{
	UAbilitySystemComponent* ASC = ActiveHandle.GetOwningAbilitySystemComponent();
	if (ASC)
	{
		return ASC->GetCurrentStackCount(ActiveHandle);
	}
	return 0;
}
开发者ID:amyvmiwei,项目名称:UnrealEngine4,代码行数:9,代码来源:AbilitySystemBlueprintLibrary.cpp

示例7: GetActiveGameplayEffectDebugString

FString UAbilitySystemBlueprintLibrary::GetActiveGameplayEffectDebugString(FActiveGameplayEffectHandle ActiveHandle)
{
	FString Str;
	UAbilitySystemComponent* ASC = ActiveHandle.GetOwningAbilitySystemComponent();
	if (ASC)
	{
		Str = ASC->GetActiveGEDebugString(ActiveHandle);
	}
	return Str;
}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:10,代码来源:AbilitySystemBlueprintLibrary.cpp

示例8: GetActiveGameplayEffectStackLimitCount

int32 UAbilitySystemBlueprintLibrary::GetActiveGameplayEffectStackLimitCount(FActiveGameplayEffectHandle ActiveHandle)
{
	UAbilitySystemComponent* ASC = ActiveHandle.GetOwningAbilitySystemComponent();
	if (ASC)
	{
		const UGameplayEffect* ActiveGE = ASC->GetGameplayEffectDefForHandle(ActiveHandle);
		if (ActiveGE)
		{
			return ActiveGE->StackLimitCount;
		}
	}
	return 0;
}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:13,代码来源:AbilitySystemBlueprintLibrary.cpp

示例9: ConfirmTargeting

void AGameplayAbilityTargetActor::ConfirmTargeting()
{
	UAbilitySystemComponent* ASC = OwningAbility->GetCurrentActorInfo()->AbilitySystemComponent.Get();
	ASC->AbilityReplicatedEventDelegate(EAbilityGenericReplicatedEvent::GenericConfirm, OwningAbility->GetCurrentAbilitySpecHandle(), OwningAbility->GetCurrentActivationInfo().GetActivationPredictionKey() ).Remove(GenericConfirmHandle);

	if (IsConfirmTargetingAllowed())
	{
		ConfirmTargetingAndContinue();
		if (bDestroyOnConfirmation)
		{
			Destroy();
		}
	}
}
开发者ID:colwalder,项目名称:unrealengine,代码行数:14,代码来源:GameplayAbilityTargetActor.cpp

示例10: OnDestroy

void UAbilityTask_WaitGameplayEffectStackChange::OnDestroy(bool AbilityIsEnding)
{
	UAbilitySystemComponent* EffectOwningAbilitySystemComponent = Handle.GetOwningAbilitySystemComponent();
	if (EffectOwningAbilitySystemComponent && OnGameplayEffectStackChangeDelegateHandle.IsValid())
	{
		FOnActiveGameplayEffectRemoved* DelPtr = EffectOwningAbilitySystemComponent->OnGameplayEffectRemovedDelegate(Handle);
		if (DelPtr)
		{
			DelPtr->Remove(OnGameplayEffectStackChangeDelegateHandle);
		}
	}

	Super::OnDestroy(AbilityIsEnding);
}
开发者ID:RandomDeveloperM,项目名称:UE4_Hairworks,代码行数:14,代码来源:AbilityTask_WaitGameplayEffectStackChange.cpp

示例11: GetTargetASC

void UAbilityTask_WaitGameplayTagRemoved::Activate()
{
	UAbilitySystemComponent* ASC = GetTargetASC();
	if (ASC && ASC->HasMatchingGameplayTag(Tag) == false)
	{			
		Removed.Broadcast();
		if(OnlyTriggerOnce)
		{
			EndTask();
			return;
		}
	}

	Super::Activate();
}
开发者ID:amyvmiwei,项目名称:UnrealEngine4,代码行数:15,代码来源:AbilityTask_WaitGameplayTag.cpp

示例12: SendGameplayEventToActor

void UAbilitySystemBlueprintLibrary::SendGameplayEventToActor(AActor* Actor, FGameplayTag EventTag, FGameplayEventData Payload)
{
	if (Actor && !Actor->IsPendingKill())
	{
		IAbilitySystemInterface* AbilitySystemInterface = Cast<IAbilitySystemInterface>(Actor);
		if (AbilitySystemInterface != NULL)
		{
			UAbilitySystemComponent* AbilitySystemComponent = AbilitySystemInterface->GetAbilitySystemComponent();
			if (AbilitySystemComponent != NULL)
			{
				FScopedPredictionWindow NewScopedWindow(AbilitySystemComponent, true);
				AbilitySystemComponent->HandleGameplayEvent(EventTag, &Payload);
			}
		}
	}
}
开发者ID:amyvmiwei,项目名称:UnrealEngine4,代码行数:16,代码来源:AbilitySystemBlueprintLibrary.cpp

示例13: CancelTargeting

/** Outside code is saying 'stop everything and just forget about it' */
void AGameplayAbilityTargetActor::CancelTargeting()
{
	const FGameplayAbilityActorInfo* ActorInfo = (OwningAbility ? OwningAbility->GetCurrentActorInfo() : nullptr);
	UAbilitySystemComponent* ASC = (ActorInfo ? ActorInfo->AbilitySystemComponent.Get() : nullptr);
	if (ASC)
	{
		ASC->AbilityReplicatedEventDelegate(EAbilityGenericReplicatedEvent::GenericCancel, OwningAbility->GetCurrentAbilitySpecHandle(), OwningAbility->GetCurrentActivationInfo().GetActivationPredictionKey() ).Remove(GenericCancelHandle);
	}
	else
	{
		ABILITY_LOG(Warning, TEXT("AGameplayAbilityTargetActor::CancelTargeting called with null ASC! Actor %s"), *GetName());
	}

	CanceledDelegate.Broadcast(FGameplayAbilityTargetDataHandle());
	Destroy();
}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:17,代码来源:GameplayAbilityTargetActor.cpp

示例14: SendGameplayEvent

// TODO: polymorphic payload
void UGameplayAbility::SendGameplayEvent(FGameplayTag EventTag, FGameplayEventData Payload)
{
	if (NetExecutionPolicy == EGameplayAbilityNetExecutionPolicy::Predictive)
	{
		Payload.PredictionKey = CurrentActivationInfo.GetPredictionKeyForNewAction();
	}

	AActor *OwnerActor = Cast<AActor>(GetOuter());
	if (OwnerActor)
	{
		UAbilitySystemComponent* AbilitySystemComponent = OwnerActor->FindComponentByClass<UAbilitySystemComponent>();
		if (ensure(AbilitySystemComponent))
		{
			AbilitySystemComponent->HandleGameplayEvent(EventTag, &Payload);
		}
	}
}
开发者ID:1vanK,项目名称:AHRUnrealEngine,代码行数:18,代码来源:GameplayAbility.cpp

示例15: PreActivate

void UGameplayAbility::PreActivate(const FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo* ActorInfo, const FGameplayAbilityActivationInfo ActivationInfo, FOnGameplayAbilityEnded* OnGameplayAbilityEndedDelegate)
{
	UAbilitySystemComponent* Comp = ActorInfo->AbilitySystemComponent.Get();

	bIsActive = true;

	Comp->CancelAbilities(&CancelAbilitiesWithTag, nullptr, this);
	Comp->BlockAbilitiesWithTags(BlockAbilitiesWithTag);


	if (OnGameplayAbilityEndedDelegate)
	{
		OnGameplayAbilityEnded = *OnGameplayAbilityEndedDelegate;
	}

	Comp->NotifyAbilityActivated(Handle, this);
}
开发者ID:1vanK,项目名称:AHRUnrealEngine,代码行数:17,代码来源:GameplayAbility.cpp


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