You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.3 KiB
49 lines
1.3 KiB
|
|
|
|
|
|
#include "MAIEnemyShooter.h"
|
|
#include "MWeapon.h"
|
|
#include "MHealthComponent.h"
|
|
#include "NavigationSystem.h"
|
|
#include "Components/CapsuleComponent.h"
|
|
|
|
AMAIEnemyShooter::AMAIEnemyShooter()
|
|
{
|
|
WeaponSocketName = "WeaponSocket";
|
|
|
|
bCanIdle = true;
|
|
PatrolRadius = 500;
|
|
}
|
|
|
|
void AMAIEnemyShooter::BeginPlay()
|
|
{
|
|
Super::BeginPlay();
|
|
|
|
StartingLocation = GetActorLocation();
|
|
|
|
//Spawn Default Weapon
|
|
FActorSpawnParameters SpawnParameters;
|
|
SpawnParameters.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
|
|
CurrentWeapon = GetWorld()->SpawnActor<AMWeapon>(StarterWeaponClass, FVector::ZeroVector, FRotator::ZeroRotator, SpawnParameters);
|
|
if(CurrentWeapon)
|
|
{
|
|
CurrentWeapon->AttachToComponent(GetMesh(), FAttachmentTransformRules::SnapToTargetNotIncludingScale, WeaponSocketName);
|
|
CurrentWeapon->SetOwner(this);
|
|
}
|
|
}
|
|
|
|
UShapeComponent* AMAIEnemyShooter::GetSafeZoneOverlappingShape()
|
|
{
|
|
return GetCapsuleComponent();
|
|
}
|
|
|
|
FVector AMAIEnemyShooter::PickNextPartrolDestination()
|
|
{
|
|
FNavLocation ResultLocation;
|
|
UNavigationSystemV1* NavigationSystem = UNavigationSystemV1::GetNavigationSystem(GetController());
|
|
if(NavigationSystem && NavigationSystem->GetRandomPointInNavigableRadius(StartingLocation, PatrolRadius, ResultLocation))
|
|
{
|
|
return ResultLocation.Location;
|
|
}
|
|
return FVector();
|
|
}
|
|
|