本文整理汇总了C++中FGameplayEffectContextHandle类的典型用法代码示例。如果您正苦于以下问题:C++ FGameplayEffectContextHandle类的具体用法?C++ FGameplayEffectContextHandle怎么用?C++ FGameplayEffectContextHandle使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FGameplayEffectContextHandle类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetActors
TArray<FActiveGameplayEffectHandle> FGameplayAbilityTargetData::ApplyGameplayEffectSpec(FGameplayEffectSpec& InSpec, FPredictionKey PredictionKey)
{
TArray<FActiveGameplayEffectHandle> AppliedHandles;
if (!ensure(InSpec.GetContext().IsValid() && InSpec.GetContext().GetInstigatorAbilitySystemComponent()))
{
return AppliedHandles;
}
TArray<TWeakObjectPtr<AActor> > Actors = GetActors();
AppliedHandles.Reserve(Actors.Num());
for (TWeakObjectPtr<AActor> TargetActor : Actors)
{
UAbilitySystemComponent* TargetComponent = UAbilitySystemBlueprintLibrary::GetAbilitySystemComponent(TargetActor.Get());
if (TargetComponent)
{
// We have to make a new effect spec and context here, because otherwise the targeting info gets accumulated and things take damage multiple times
FGameplayEffectSpec SpecToApply(InSpec);
FGameplayEffectContextHandle EffectContext = SpecToApply.GetContext().Duplicate();
SpecToApply.SetContext(EffectContext);
AddTargetDataToContext(EffectContext, false);
AppliedHandles.Add(EffectContext.GetInstigatorAbilitySystemComponent()->ApplyGameplayEffectSpecToTarget(SpecToApply, TargetComponent, PredictionKey));
}
}
return AppliedHandles;
}
示例2: check
FGameplayEffectContextHandle UGameplayAbility::GetEffectContext(const FGameplayAbilityActorInfo *ActorInfo) const
{
check(ActorInfo);
FGameplayEffectContextHandle Context = FGameplayEffectContextHandle(UAbilitySystemGlobals::Get().AllocGameplayEffectContext());
// By default use the owner and avatar as the instigator and causer
Context.AddInstigator(ActorInfo->OwnerActor.Get(), ActorInfo->AvatarActor.Get());
return Context;
}
示例3: EffectContextGetOrigin
FVector UAbilitySystemBlueprintLibrary::EffectContextGetOrigin(FGameplayEffectContextHandle EffectContext)
{
if (EffectContext.HasOrigin())
{
return EffectContext.GetOrigin();
}
return FVector::ZeroVector;
}
示例4: EffectContextGetHitResult
FHitResult UAbilitySystemBlueprintLibrary::EffectContextGetHitResult(FGameplayEffectContextHandle EffectContext)
{
if (EffectContext.GetHitResult())
{
return *EffectContext.GetHitResult();
}
return FHitResult();
}
示例5: GameplayCueActivated
void FGameplayCueHandler::GameplayCueActivated(const FGameplayTagContainer& GameplayCueTags, float NormalizedMagnitude, const FGameplayEffectContextHandle& EffectContext)
{
check(Owner);
bool InstigatorLocal = EffectContext.IsLocallyControlled();
bool TargetLocal = OwnerIsLocallyControlled();
for (auto TagIt = GameplayCueTags.CreateConstIterator(); TagIt; ++TagIt)
{
if (FGameplayCueViewInfo* View = GetBestMatchingView(EGameplayCueEvent::OnActive, *TagIt, InstigatorLocal, TargetLocal))
{
View->SpawnViewEffects(Owner, NULL, EffectContext);
}
FName MatchedTag;
UFunction *Func = UAbilitySystemGlobals::Get().GetGameplayCueFunction(*TagIt, Owner->GetClass(), MatchedTag);
if (Func)
{
FGameplayCueParameters Params;
Params.NormalizedMagnitude = NormalizedMagnitude;
Params.EffectContext = EffectContext;
IGameplayCueInterface::DispatchBlueprintCustomHandler(Owner, Func, EGameplayCueEvent::OnActive, Params);
}
}
}
示例6: AddTargetDataToContext
void FGameplayAbilityTargetData::AddTargetDataToContext(FGameplayEffectContextHandle& Context, bool bIncludeActorArray) const
{
if (bIncludeActorArray && (GetActors().Num() > 0))
{
Context.AddActors(GetActors());
}
if (HasHitResult() && !Context.GetHitResult())
{
Context.AddHitResult(*GetHitResult());
}
if (HasOrigin())
{
Context.AddOrigin(GetOrigin().GetLocation());
}
}
示例7: GameplayCueExecuted
void FGameplayCueHandler::GameplayCueExecuted(const FGameplayTagContainer& GameplayCueTags, float NormalizedMagnitude, const FGameplayEffectContextHandle& EffectContext)
{
check(Owner);
bool InstigatorLocal = EffectContext.IsLocallyControlled();
bool TargetLocal = OwnerIsLocallyControlled();
for (auto TagIt = GameplayCueTags.CreateConstIterator(); TagIt; ++TagIt)
{
if (FGameplayCueViewInfo* View = GetBestMatchingView(EGameplayCueEvent::Executed, *TagIt, InstigatorLocal, TargetLocal))
{
View->SpawnViewEffects(Owner, NULL, EffectContext);
}
}
}
示例8: GameplayCueAdded
void FGameplayCueHandler::GameplayCueAdded(const FGameplayTagContainer& GameplayCueTags, float NormalizedMagnitude, const FGameplayEffectContextHandle& EffectContext)
{
check(Owner);
bool InstigatorLocal = EffectContext.IsLocallyControlled();
bool TargetLocal = OwnerIsLocallyControlled();
for (auto TagIt = GameplayCueTags.CreateConstIterator(); TagIt; ++TagIt)
{
TArray<TSharedPtr<FGameplayCueViewEffects> > &Effects = SpawnedViewEffects.FindOrAdd(*TagIt);
// Clear old effects if they existed? This will vary case to case. Removing old effects is the easiest approach
ClearEffects(Effects);
check(Effects.Num() == 0);
if (FGameplayCueViewInfo * View = GetBestMatchingView(EGameplayCueEvent::WhileActive, *TagIt, InstigatorLocal, TargetLocal))
{
TSharedPtr<FGameplayCueViewEffects> SpawnedEffects = View->SpawnViewEffects(Owner, &SpawnedObjects, EffectContext);
Effects.Add(SpawnedEffects);
}
}
}
示例9: EffectContextHasHitResult
bool UAbilitySystemBlueprintLibrary::EffectContextHasHitResult(FGameplayEffectContextHandle EffectContext)
{
return EffectContext.GetHitResult() != NULL;
}
示例10: EffectContextIsInstigatorLocallyControlled
bool UAbilitySystemBlueprintLibrary::EffectContextIsInstigatorLocallyControlled(FGameplayEffectContextHandle EffectContext)
{
return EffectContext.IsLocallyControlled();
}
示例11: EffectContextSetOrigin
void UAbilitySystemBlueprintLibrary::EffectContextSetOrigin(FGameplayEffectContextHandle EffectContext, FVector Origin)
{
EffectContext.AddOrigin(Origin);
}
示例12: EffectContextAddHitResult
void UAbilitySystemBlueprintLibrary::EffectContextAddHitResult(FGameplayEffectContextHandle EffectContext, FHitResult HitResult, bool bReset)
{
EffectContext.AddHitResult(HitResult, bReset);
}
示例13: EffectContextIsValid
bool UAbilitySystemBlueprintLibrary::EffectContextIsValid(FGameplayEffectContextHandle EffectContext)
{
return EffectContext.IsValid();
}
示例14: if
TSharedPtr<FGameplayCueViewEffects> FGameplayCueViewInfo::SpawnViewEffects(AActor *Owner, TArray<UObject*> *SpawnedObjects, const FGameplayEffectContextHandle& EffectContext) const
{
check(Owner);
TSharedPtr<FGameplayCueViewEffects> SpawnedEffects = TSharedPtr<FGameplayCueViewEffects>(new FGameplayCueViewEffects());
if (Sound)
{
SpawnedEffects->AudioComponent = UGameplayStatics::PlaySoundAttached(Sound, Owner->GetRootComponent());
if (SpawnedObjects)
{
SpawnedObjects->Add(SpawnedEffects->AudioComponent.Get());
}
}
if (ParticleSystem)
{
if (EffectContext.GetHitResult())
{
const FHitResult &HitResult = *EffectContext.GetHitResult();
if (AttachParticleSystem)
{
SpawnedEffects->ParticleSystemComponent = UGameplayStatics::SpawnEmitterAttached(ParticleSystem, Owner->GetRootComponent(), NAME_None, HitResult.Location,
HitResult.Normal.Rotation(), EAttachLocation::KeepWorldPosition);
}
else
{
bool AutoDestroy = SpawnedObjects == nullptr;
SpawnedEffects->ParticleSystemComponent = UGameplayStatics::SpawnEmitterAtLocation(Owner->GetWorld(), ParticleSystem, HitResult.Location, HitResult.Normal.Rotation(), AutoDestroy);
}
}
else
{
if (AttachParticleSystem)
{
SpawnedEffects->ParticleSystemComponent = UGameplayStatics::SpawnEmitterAttached(ParticleSystem, Owner->GetRootComponent());
}
else
{
bool AutoDestroy = SpawnedObjects == nullptr;
SpawnedEffects->ParticleSystemComponent = UGameplayStatics::SpawnEmitterAtLocation(Owner->GetWorld(), ParticleSystem, Owner->GetActorLocation(), Owner->GetActorRotation(), AutoDestroy);
}
}
if (SpawnedObjects)
{
SpawnedObjects->Add(SpawnedEffects->ParticleSystemComponent.Get());
}
else if (SpawnedEffects->ParticleSystemComponent.IsValid())
{
for (int32 EmitterIndx = 0; EmitterIndx < SpawnedEffects->ParticleSystemComponent->EmitterInstances.Num(); EmitterIndx++)
{
if (SpawnedEffects->ParticleSystemComponent->EmitterInstances[EmitterIndx] &&
SpawnedEffects->ParticleSystemComponent->EmitterInstances[EmitterIndx]->CurrentLODLevel &&
SpawnedEffects->ParticleSystemComponent->EmitterInstances[EmitterIndx]->CurrentLODLevel->RequiredModule &&
SpawnedEffects->ParticleSystemComponent->EmitterInstances[EmitterIndx]->CurrentLODLevel->RequiredModule->EmitterLoops == 0)
{
ABILITY_LOG(Warning, TEXT("%s - particle system has a looping emitter. This should not be used in a executed GameplayCue!"), *SpawnedEffects->ParticleSystemComponent->GetName());
break;
}
}
}
}
if (ActorClass)
{
FVector Location = Owner->GetActorLocation();
FRotator Rotation = Owner->GetActorRotation();
SpawnedEffects->SpawnedActor = Cast<AGameplayCueActor>(Owner->GetWorld()->SpawnActor(ActorClass, &Location, &Rotation));
if (SpawnedObjects)
{
SpawnedObjects->Add(SpawnedEffects->SpawnedActor.Get());
}
}
return SpawnedEffects;
}