Skip to content

Unnecessary dependence #43

Description

@S1yGus

Remove unnecessary dependency on the player's mesh in the cubes' inheritance chain:

UStaticMeshComponent* ACGBaseCubeActor::GetPlayerMesh() const
{
if (const auto* PC = GetWorld() ? GetWorld()->GetFirstPlayerController() : nullptr)
{
if (const auto* Pawn = PC->GetPawn())
{
return Pawn->FindComponentByClass<UStaticMeshComponent>();
}
}
return nullptr;
}

void ACGAttachedBonusActor::AttachToPlayerMesh()
{
if (UStaticMeshComponent* PlayerMesh = GetPlayerMesh())
{
AttachToComponent(PlayerMesh, FAttachmentTransformRules::SnapToTargetNotIncludingScale);
}
}

void ACGShieldBonusActor::SetPlayerMeshCollisionEnabled(bool bEnabled)
{
if (UStaticMeshComponent* PlayerMesh = GetPlayerMesh())
{
PlayerMesh->SetCollisionEnabled(bEnabled ? ECollisionEnabled::QueryOnly : ECollisionEnabled::NoCollision);
}
}

CollectNiagaraComponent->SetVectorParameter(NiagaraTargetPositionParamName, PlayerMesh->GetComponentLocation());

Metadata

Metadata

Assignees

Labels

invalidThis doesn't seem right

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions