--------------------------------------------------------------------------------------------------------------------------
| 543 | |
| 544 | //-------------------------------------------------------------------------------------------------------------------------- |
| 545 | void 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 | } |
no test coverage detected