Space Plunder
Loading...
Searching...
No Matches
AAutoTurret Class Reference

#include <AutoTurret.h>

Inheritance diagram for AAutoTurret:
ADefenseSystemPawn AInteractablePawn IDefencePawnAnim ICharacterInterface IBaseInterface ISaveLoad

Public Member Functions

 AAutoTurret ()
 
- Public Member Functions inherited from ADefenseSystemPawn
 ADefenseSystemPawn ()
 
virtual ETeamAttitude::Type GetTeamAttitudeTowards (const AActor &Other) const override
 
virtual void SetGenericTeamId (const FGenericTeamId &NewTeamID) override
 
virtual FGenericTeamId GetGenericTeamId () const override
 
virtual FRotator GetTargetRotation () const override
 
bool GetActive () const
 
void SetActive (const bool bValue)
 
void OnActivated (const bool bValue)
 
virtual void OnActivated_Implementation (const bool bValue)
 
- Public Member Functions inherited from AInteractablePawn
 AInteractablePawn ()
 
virtual void ReceiveStartFocus (AActor *Caller)
 
virtual void ReceiveEndFocus (AActor *Caller)
 
virtual void ReceiveOnInteract (AActor *Caller, const EInteractionType InteractionType)
 
virtual void ReceiveOnEndInteract (AActor *Caller)
 
virtual void ReceiveOnOverlap (AActor *Caller)
 
virtual void ReceiveOnEndOverlap (AActor *Caller)
 
virtual void ReceiveToggleSwitch (AActor *Caller, const bool bOn)
 
virtual void InteractionDataUpdated ()
 
virtual void SetupPlayerInputComponent (class UInputComponent *PlayerInputComponent) override
 
- Public Member Functions inherited from ICharacterInterface
virtual USkeletalMeshComponent * GetCharacterSecondaryMesh () const
 
virtual void StartThreatIndication (AActor *PawnThreat)
 
virtual void UpdateThreatIndication (const FVector &Location, const float DetectionAmount)
 
virtual void StopThreatIndication ()
 

Protected Member Functions

virtual void BeginPlay () override
 
virtual void GetActorEyesViewPoint (FVector &OutLocation, FRotator &OutRotation) const override
 
virtual bool GetIsUpsideDown () const override
 
virtual void EnemySeen () override
 
virtual void LostAllTargets () override
 
virtual void WeaponFire ()
 
void OnWeaponFire ()
 
virtual void RotateToTarget () override
 
virtual void OnDeath (AActor *OwningActor, EDeathType DeathType, AActor *DeathCauser, AController *DeathInstigator) override
 
- Protected Member Functions inherited from ADefenseSystemPawn
int32 GetTeamID () const
 
virtual ECharacterType GetCharacterType () const override
 
virtual EFactionType GetCharacterFaction () const override
 
virtual bool GetIsDead () const override
 
virtual void SetCharacterVehicleMode (const EVehicleMode Mode) override
 
void OnNewTargetSeen (APawn *Pawn)
 
void OnTargetSeen (APawn *Pawn)
 
void OnHostileSeen ()
 
void OnHostileSeenUpdate ()
 
void OnTargetLost ()
 
void OnLostAllTargets ()
 
void OnAlertChange (const float CurrentAlertLevel, const float MaxAlertLevel)
 
virtual bool GetIsCharacter () const override
 
virtual void PointDamageTaken (AActor *DamagedActor, float Damage, class AController *InstigatedBy, FVector HitLocation, class UPrimitiveComponent *HitComponent, FName BoneName, FVector ShotFromDirection, const class UDamageType *DamageType, AActor *DamageCauser)
 
bool CanStillSeePawn (APawn *Pawn) const
 
bool IsPawnAlive (APawn *Pawn) const
 
bool GetCurrentTarget (APawn *&Pawn) const
 
TArray< APawn * > & GetTargets ()
 
float GetDistanceToPawn (const APawn *Pawn) const
 
float GetTotalDistanceScoreToAllTargets () const
 
virtual FRotator GetRotationToTarget (const FVector &StartLocation)
 
virtual void TargetSeen (APawn *Pawn)
 
virtual void NewTargetSeen (APawn *Pawn)
 
- Protected Member Functions inherited from AInteractablePawn
virtual bool SaveGame () override
 
virtual bool LoadGame () override
 
FVector GetCustomInteractionLocation () const
 
void LogDebugError (const FString &Message) const
 
void LogDebugError (const FString &Message, const int32 Value) const
 
void LogDebugError (const FString &Message, const float Value) const
 
void LogDebugWarning (const FString &Message) const
 
void LogDebugWarning (const FString &Message, const int32 Value) const
 
void LogDebugWarning (const FString &Message, const float Value) const
 
void LogDebugMessage (const FString &Message, const bool bWarning=false, const bool bError=false) const
 
void LogDebugMessage (const FString &Message, const int32 Value, const bool bWarning=false, const bool bError=false) const
 
void LogDebugMessage (const FString &Message, const float Value, const bool bWarning=false, const bool bError=false) const
 
void LogDebugMessage (const FString &Message, const bool bValue, const bool bWarning, const bool bError) const
 
void LogOnScreenMessage (const int32 Key, const FString &Message, FColor Color=FColor::Green) const
 
void SetCategoryName (const FLogCategoryBase &Category)
 

Protected Attributes

FName RootBoneName = FName("SK_Prop_Turret_Small_Pivot_Ceiling_01")
 
FName GunBoneName = FName("SK_Prop_Turret_Small_Gun_Ceiling_01")
 
USkeletalMeshComponent * MeshComponent
 
UCapsuleComponent * CapsuleComponent
 
UChildActorComponent * CurrentWeapon
 
float WeaponFireFrequency = 0.1
 
- Protected Attributes inherited from ADefenseSystemPawn
FGenericTeamId TeamID
 
ECharacterType CharacterType = ECharacterType::Defence
 
EFactionType OwnerFaction = EFactionType::Alliance
 
FRotator StartRotation = FRotator::ZeroRotator
 
FRotator TargetRotation = FRotator::ZeroRotator
 
float AlertUpdateFrequency = 0.2f
 
float AlertLevelIncrease = 0.1f
 
float AlertLevelDecrease = 0.1f
 
float AlertLevelThreshold = 100.0f
 
float AlertLevel = 0.0f
 
bool bAlert = false
 
float VisibilityCheckFrequency = 2.0f
 
bool bInstantResetOnLostTarget = false
 
float LostTargetResetTime = 2.0f
 
bool bDead = false
 
bool bAutoActivate = true
 
UHealthComponentBase * HealthComponent
 
UAdvancedPawnSensingComponentPawnSensingComponent
 
- Protected Attributes inherited from AInteractablePawn
class UAudioReactionComponent * AudioReactionComponent
 
class UInteractableActorComponent * InteractableActorComponent
 
class UAIPerceptionStimuliSourceComponent * PerceptionStimuliComponent
 
bool bDebuggingMode = false
 

Private Attributes

FTimerHandle WeaponFireTimerHandle
 

Constructor & Destructor Documentation

◆ AAutoTurret()

AAutoTurret::AAutoTurret ( )
9{
10 PrimaryActorTick.bCanEverTick = false;
11 CapsuleComponent = CreateDefaultSubobject<UCapsuleComponent>(TEXT("Capsule"));
12 RootComponent = CapsuleComponent;
13
14 MeshComponent = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("Skeletal Mesh"));
15 MeshComponent->SetupAttachment(CapsuleComponent);
16
17 //- Weapon //
18 CurrentWeapon = CreateDefaultSubobject<UChildActorComponent>("Weapon Actor");
19 CurrentWeapon->SetIsReplicated(true);
20 CurrentWeapon->SetupAttachment(MeshComponent, FName("Barrel"));
21 CurrentWeapon->SetChildActorClass(AActor::StaticClass());
22}
UChildActorComponent * CurrentWeapon
Definition AutoTurret.h:38
UCapsuleComponent * CapsuleComponent
Definition AutoTurret.h:36
USkeletalMeshComponent * MeshComponent
Definition AutoTurret.h:34

Member Function Documentation

◆ BeginPlay()

void AAutoTurret::BeginPlay ( )
overrideprotectedvirtual

Reimplemented from ADefenseSystemPawn.

26{
27 Super::BeginPlay();
28 if(MeshComponent != nullptr)
29 {
30 StartRotation.Yaw = MeshComponent->GetSocketRotation(RootBoneName).Yaw - GetActorRotation().Yaw;
31 StartRotation.Pitch = MeshComponent->GetSocketRotation(GunBoneName).Pitch - GetActorRotation().Pitch;
32 StartRotation = FRotator::ZeroRotator;
33 }
34 if(CurrentWeapon != nullptr && CurrentWeapon->GetChildActor() != nullptr)
35 {
36 CurrentWeapon->GetChildActor()->SetOwner(this);
37 }
38}
FName GunBoneName
Definition AutoTurret.h:31
FName RootBoneName
Definition AutoTurret.h:29
FRotator StartRotation
Definition DefenseSystemPawn.h:87

◆ EnemySeen()

void AAutoTurret::EnemySeen ( )
overrideprotectedvirtual

Reimplemented from ADefenseSystemPawn.

64{
65 Super::EnemySeen();
66 GetWorld()->GetTimerManager().SetTimer(WeaponFireTimerHandle, this, &AAutoTurret::WeaponFire, WeaponFireFrequency, true);
67}
virtual void WeaponFire()
Definition AutoTurret.cpp:69
float WeaponFireFrequency
Definition AutoTurret.h:44
FTimerHandle WeaponFireTimerHandle
Definition AutoTurret.h:58

◆ GetActorEyesViewPoint()

void AAutoTurret::GetActorEyesViewPoint ( FVector & OutLocation,
FRotator & OutRotation ) const
overrideprotectedvirtual

Reimplemented from ADefenseSystemPawn.

41{
42 if(MeshComponent != nullptr && MeshComponent->DoesSocketExist(FName("Eyes")))
43 {
44 OutLocation = MeshComponent->GetSocketLocation(FName("Eyes"));
45 OutRotation = MeshComponent->GetSocketRotation(FName("Eyes"));
46 return;
47 }
48 Super::GetActorEyesViewPoint(OutLocation, OutRotation);
49}

◆ GetIsUpsideDown()

bool AAutoTurret::GetIsUpsideDown ( ) const
overrideprotectedvirtual

See if the Eye socket is above the Gun

Reimplemented from ADefenseSystemPawn.

52{
53 if(MeshComponent != nullptr)
54 {
56 const FVector EyeLocation = MeshComponent->GetSocketLocation(FName("Eyes"));
57 const FVector RootLocation = MeshComponent->GetSocketLocation(GunBoneName);
58 return (EyeLocation - RootLocation).Z < 0.0f;
59 }
60 return Super::GetIsUpsideDown();
61}

◆ LostAllTargets()

void AAutoTurret::LostAllTargets ( )
overrideprotectedvirtual

Reimplemented from ADefenseSystemPawn.

86{
87 Super::LostAllTargets();
88 GetWorld()->GetTimerManager().ClearTimer(WeaponFireTimerHandle);
89 //@TODO Should Lerp Back
91}
FRotator TargetRotation
Definition DefenseSystemPawn.h:89

◆ OnDeath()

void AAutoTurret::OnDeath ( AActor * OwningActor,
EDeathType DeathType,
AActor * DeathCauser,
AController * DeathInstigator )
overrideprotectedvirtual

Reimplemented from ADefenseSystemPawn.

94{
95 Super::OnDeath(OwningActor, DeathType, DeathCauser, DeathInstigator);
96 if(MeshComponent != nullptr)
97 {
98 MeshComponent->SetAllBodiesBelowSimulatePhysics(GunBoneName ,true);
99 }
100 if(GetWorld() != nullptr)
101 {
102 GetWorld()->GetTimerManager().ClearTimer(WeaponFireTimerHandle);
103 }
104
105}

◆ OnWeaponFire()

void AAutoTurret::OnWeaponFire ( )
protected

◆ RotateToTarget()

void AAutoTurret::RotateToTarget ( )
overrideprotectedvirtual

Reimplemented from ADefenseSystemPawn.

76{
77 if(MeshComponent == nullptr){return;}
78 //@TODO Should Lerp To Target
79 // UKismetMathLibrary::RLerp()
80 FRotator NewRotation = GetRotationToTarget(MeshComponent->GetSocketLocation(GunBoneName));
81 NewRotation.Yaw -= GetActorRotation().Yaw;
82 TargetRotation = NewRotation;
83}
virtual FRotator GetRotationToTarget(const FVector &StartLocation)
Definition DefenseSystemPawn.cpp:392

◆ WeaponFire()

void AAutoTurret::WeaponFire ( )
protectedvirtual
70{
73}
void OnWeaponFire()
virtual void RotateToTarget() override
Definition AutoTurret.cpp:75

Member Data Documentation

◆ CapsuleComponent

UCapsuleComponent* AAutoTurret::CapsuleComponent
protected

◆ CurrentWeapon

UChildActorComponent* AAutoTurret::CurrentWeapon
protected

◆ GunBoneName

FName AAutoTurret::GunBoneName = FName("SK_Prop_Turret_Small_Gun_Ceiling_01")
protected

◆ MeshComponent

USkeletalMeshComponent* AAutoTurret::MeshComponent
protected

◆ RootBoneName

FName AAutoTurret::RootBoneName = FName("SK_Prop_Turret_Small_Pivot_Ceiling_01")
protected

◆ WeaponFireFrequency

float AAutoTurret::WeaponFireFrequency = 0.1
protected

◆ WeaponFireTimerHandle

FTimerHandle AAutoTurret::WeaponFireTimerHandle
private

The documentation for this class was generated from the following files: