#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(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(); }