Port Fire Wand to new ProjectileWeapon implementation
This commit is contained in:
parent
43dad6b126
commit
488387767b
@ -23,33 +23,6 @@ void AFireWandWeapon::BeginPlay()
|
|||||||
void AFireWandWeapon::FireWeaponAction_Implementation()
|
void AFireWandWeapon::FireWeaponAction_Implementation()
|
||||||
{
|
{
|
||||||
Super::FireWeaponAction_Implementation();
|
Super::FireWeaponAction_Implementation();
|
||||||
|
|
||||||
if (ProjectileTemplate && OverlappedEnemies.Num() > 0)
|
|
||||||
{
|
|
||||||
AGameModeBase* gamemode = UGameplayStatics::GetGameMode(GetWorld());
|
|
||||||
|
|
||||||
if (UKismetSystemLibrary::DoesImplementInterface(gamemode, UPools::StaticClass()))
|
|
||||||
{
|
|
||||||
if (AObjectPoolManager* objectPoolManager = IPools::Execute_GetProjectileObjectPoolManager(gamemode))
|
|
||||||
{
|
|
||||||
AActor* projectile = objectPoolManager->GetObject();
|
|
||||||
|
|
||||||
if (UKismetSystemLibrary::DoesImplementInterface(projectile, UProjectilable::StaticClass()))
|
|
||||||
{
|
|
||||||
IProjectilable::Execute_LoadDataFromDataAsset(projectile, ProjectileTemplate);
|
|
||||||
projectile->SetOwner(this);
|
|
||||||
|
|
||||||
AActor* target = OverlappedEnemies[FMath::RandRange(0, OverlappedEnemies.Num() - 1)];
|
|
||||||
FVector direction = UKismetMathLibrary::GetDirectionUnitVector(
|
|
||||||
GetActorLocation(), target->GetActorLocation());
|
|
||||||
direction.Z = 0.0;
|
|
||||||
direction.Normalize();
|
|
||||||
|
|
||||||
IProjectilable::Execute_SetTargetDirection(projectile, direction);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AFireWandWeapon::UpgradeWeapon_Implementation()
|
bool AFireWandWeapon::UpgradeWeapon_Implementation()
|
||||||
@ -89,3 +62,35 @@ bool AFireWandWeapon::UpgradeWeapon_Implementation()
|
|||||||
ResetWeaponTimer();
|
ResetWeaponTimer();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AFireWandWeapon::FireProjectile()
|
||||||
|
{
|
||||||
|
if (ProjectileTemplate && OverlappedEnemies.Num() > 0)
|
||||||
|
{
|
||||||
|
AGameModeBase* gamemode = UGameplayStatics::GetGameMode(GetWorld());
|
||||||
|
|
||||||
|
if (UKismetSystemLibrary::DoesImplementInterface(gamemode, UPools::StaticClass()))
|
||||||
|
{
|
||||||
|
if (AObjectPoolManager* objectPoolManager = IPools::Execute_GetProjectileObjectPoolManager(gamemode))
|
||||||
|
{
|
||||||
|
AActor* projectile = objectPoolManager->GetObject();
|
||||||
|
|
||||||
|
if (UKismetSystemLibrary::DoesImplementInterface(projectile, UProjectilable::StaticClass()))
|
||||||
|
{
|
||||||
|
IProjectilable::Execute_LoadDataFromDataAsset(projectile, ProjectileTemplate);
|
||||||
|
projectile->SetOwner(this);
|
||||||
|
|
||||||
|
AActor* target = OverlappedEnemies[FMath::RandRange(0, OverlappedEnemies.Num() - 1)];
|
||||||
|
FVector direction = UKismetMathLibrary::GetDirectionUnitVector(
|
||||||
|
GetActorLocation(), target->GetActorLocation());
|
||||||
|
direction.Z = 0.0;
|
||||||
|
direction.Normalize();
|
||||||
|
|
||||||
|
IProjectilable::Execute_SetTargetDirection(projectile, direction);
|
||||||
|
}
|
||||||
|
|
||||||
|
Super::FireProjectile();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -24,4 +24,7 @@ public:
|
|||||||
virtual void FireWeaponAction_Implementation() override;
|
virtual void FireWeaponAction_Implementation() override;
|
||||||
|
|
||||||
virtual bool UpgradeWeapon_Implementation() override;
|
virtual bool UpgradeWeapon_Implementation() override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void FireProjectile() override;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user