MCPcopy Create free account
hub / github.com/arnaud-jamin/Cog / Server_Hit

Method Server_Hit

Source/CogSample/CogSampleProjectileComponent.cpp:545–597  ·  view source on GitHub ↗

--------------------------------------------------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

543
544//--------------------------------------------------------------------------------------------------------------------------
545void UCogSampleProjectileComponent::Server_Hit(const FHitResult& HitResult)
546{
547 COG_LOG_OBJECT(LogCogProjectile, ELogVerbosity::Verbose, Creator.Get(), TEXT("Projectile:%s | Role:%s | Other:%s | Comp:%s | Bone:%s"),
548 *GetNameSafe(GetOwner()),
549 *GetRoleName(),
550 *GetNameSafe(HitResult.GetActor()),
551 *GetNameSafe(HitResult.GetComponent()),
552 *HitResult.BoneName.ToString());
553
554#if ENABLE_COG
555 DrawDebugCurrentState(FColor::White, false);
556 DrawDebugHitResult(HitResult);
557#endif //ENABLE_COG
558
559 AActor* HitActor = HitResult.GetActor();
560
561 UAbilitySystemComponent* TargetAbilitySystem = UAbilitySystemGlobals::GetAbilitySystemComponentFromActor(HitActor);
562 if (TargetAbilitySystem == nullptr)
563 {
564 return;
565 }
566
567 for (const FCogSampleProjectileEffectConfig& EffectConfig : Effects)
568 {
569 for (TSubclassOf<UGameplayEffect> EffectClass : EffectConfig.Effects)
570 {
571 if (UCogSampleFunctionLibrary_Team::MatchAllegiance(GetOwner(), HitActor, EffectConfig.Allegiance) == false)
572 {
573 continue;
574 }
575
576 FGameplayEffectSpecHandle* Handle = EffectsMap.Find(EffectClass);
577 if (Handle == nullptr)
578 {
579 continue;
580 }
581
582 FGameplayEffectSpec* Spec = Handle->Data.Get();
583 if (Spec == nullptr)
584 {
585 continue;
586 }
587
588 if (UCogSampleFunctionLibrary_Gameplay::IsDead(HitActor) && EffectConfig.AffectDead == false)
589 {
590 continue;
591 }
592
593 Spec->GetContext().AddHitResult(HitResult, true);
594 TargetAbilitySystem->ApplyGameplayEffectSpecToSelf(*Spec);
595 }
596 }
597}

Calls 2

GetOwnerFunction · 0.85
ToStringMethod · 0.80

Tested by

no test coverage detected