Modular Turret C++ Plugin  Version 3
Turret C++ Unreal engine 4 plugin
UMortarAimingComponent Class Reference
+ Inheritance diagram for UMortarAimingComponent:
+ Collaboration diagram for UMortarAimingComponent:

Public Member Functions

void AimAt (const FVector &AimLocation)
void Fire ()
EMortarFiringState GetCurrentState () const
int32 GetFiringCount () const
int32 GetReloadTimeInSeconds () const
float GetShotsSpreadDegree () const
bool HasUnlimitedAmmo () const
void InitializeAiming (class UMortarTurret *TurretToSet, UMortarBarrel *BarrelToSet)
bool IsBarrelMoving ()
void ResetFiring ()
void SetFiringLeft (const int32 &FiringLeft)
void SetIdle ()
virtual void SetProjectile (const TMap< FName, TSubclassOf< class AActor >> &ProjectileToSet)
void SetReloadTimeInSeconds (const float &ReloadTime)
void SetShotsSpreadDegree (const float &ShotsSpread)
 UMortarAimingComponent ()

Public Attributes

FMortarFireEvent OnFireEvent

Protected Member Functions

virtual void BeginPlay () override
virtual void TickComponent (float DeltaTime, ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction) override

Protected Attributes

class UMortarBarrelBarrel = nullptr
class USoundBase * FireSound
TMap< FName, TSubclassOf< class AActor > > ProjectileSpawnSockets
class UMortarTurretTurret = nullptr

Private Member Functions

class UMortarResourceManagerGetValidSubSystem ()
void MoveBarrelTowards (const FVector &AimDirection)
void ProjectileDestoryed (AActor *DestroyedActor)
void SetBarrelState ()

Private Attributes

uint32 bCanShoot: 1
bool bUnlimitedAmmo = true
FVector CurrentAimDirection
EMortarFiringState CurrentFiringState
FVector DefaultAimLocation
int32 FiringLeft = 1000
float LastFireTime = 0
int32 OriginalFiringLeft = 1000
float OriginalReloadTimeInSeconds = 0.5f
float ReloadTimeInSeconds = 0.5f
float ShotsSpreadDegree = 2.f
float VectorThresholdComparision = 0.1f

Detailed Description

Mortar Aiming Component All Rotation ,Aiming And Firing Will be controlled by this class

Constructor & Destructor Documentation

◆ UMortarAimingComponent()

UMortarAimingComponent::UMortarAimingComponent ( )

Member Function Documentation

◆ AimAt()

void UMortarAimingComponent::AimAt ( const FVector &  AimLocation)

Checks if Mortar is able to aim and then moves mortar at the Desired Location

[in]AimLocationDesired Aiming Location in FVector

◆ BeginPlay()

virtual void UMortarAimingComponent::BeginPlay ( )

Called when the game starts

◆ Fire()

void UMortarAimingComponent::Fire ( )

Spawns A projectile at the desired socket location after checking mortar is in locked state

◆ GetCurrentState()

EMortarFiringState UMortarAimingComponent::GetCurrentState ( ) const

Gets The Current State of Gun

Enum of Firing State which can be Reloading,Aiming,Locked,OutOfAmmo

◆ GetFiringCount()

int32 UMortarAimingComponent::GetFiringCount ( ) const

Gets The Current Firing Count Left

Firing Count Left

◆ GetReloadTimeInSeconds()

int32 UMortarAimingComponent::GetReloadTimeInSeconds ( ) const

Gets Reload Time for The Mortar Gun i.e Time Delay between each shot

Float variable containing reload time in seconds

◆ GetShotsSpreadDegree()

float UMortarAimingComponent::GetShotsSpreadDegree ( ) const

Gets Shots Spread Range which is used while Firing.

Float Variable Containing Shot spread in degree

◆ GetValidSubSystem()

class UMortarResourceManager* UMortarAimingComponent::GetValidSubSystem ( )

Returns A Valid Subsystem Which has the resourcemanaging Part This also ensures that the subsystem is the blueprint one and not the cpp one return Pointer To SubSystem if valid nullptr otherwise

◆ HasUnlimitedAmmo()

bool UMortarAimingComponent::HasUnlimitedAmmo ( ) const

Provides information whether there is limit on ammo

True if unlimited ammo that is no limit and false if limited ammo

◆ InitializeAiming()

void UMortarAimingComponent::InitializeAiming ( class UMortarTurret TurretToSet,
UMortarBarrel BarrelToSet 

Initializes Turret and Barrel

[in]TurretToSetTurret That will be used while Aiming
[in]BarrelToSetBarrel that will be used while aiming

◆ IsBarrelMoving()

bool UMortarAimingComponent::IsBarrelMoving ( )

returns true if the barrel is moving compares the barrel/Gun forward vector

True if Barrel is moving false otherwise

◆ MoveBarrelTowards()

void UMortarAimingComponent::MoveBarrelTowards ( const FVector &  AimDirection)

Move the Barrel at the given Direction And also Rotates turret param[in] AimDirection Direction to aim. It is the direction which we estimated

◆ ProjectileDestoryed()

void UMortarAimingComponent::ProjectileDestoryed ( AActor *  DestroyedActor)

◆ ResetFiring()

void UMortarAimingComponent::ResetFiring ( )

Resets Firing Parameters like count,speed etc can be used after powerup

◆ SetBarrelState()

void UMortarAimingComponent::SetBarrelState ( )

Sets State of Barrel like Moving,locked etc

◆ SetFiringLeft()

void UMortarAimingComponent::SetFiringLeft ( const int32 &  FiringLeft)

Sets Firing Left

[in]FiringLeftFiring Count Left

◆ SetIdle()

void UMortarAimingComponent::SetIdle ( )

Sets Turret and Barrel at Idle Position

◆ SetProjectile()

virtual void UMortarAimingComponent::SetProjectile ( const TMap< FName, TSubclassOf< class AActor >> &  ProjectileToSet)

Sets Projectile Class that needs to be spawned.On special event Mortar Can have different projectile

[in]ProjectileToSetProjectile to spawn of Class Projectile

◆ SetReloadTimeInSeconds()

void UMortarAimingComponent::SetReloadTimeInSeconds ( const float &  ReloadTime)

Sets Time Delay between each shots

[in]ReloadTimeFloat variable containing reload Time

◆ SetShotsSpreadDegree()

void UMortarAimingComponent::SetShotsSpreadDegree ( const float &  ShotsSpread)

Sets Shots Spread Range

[in]ShotsSpreadShots Spread In Degree

◆ TickComponent()

virtual void UMortarAimingComponent::TickComponent ( float  DeltaTime,
ELevelTick  TickType,
FActorComponentTickFunction *  ThisTickFunction 

Function Called on Every Tick

Member Data Documentation

◆ Barrel

class UMortarBarrel* UMortarAimingComponent::Barrel = nullptr

Barrel/Gun Class to Use Moves Vertically

◆ bCanShoot

uint32 UMortarAimingComponent::bCanShoot

Whether Mortar Can Shoot or not

◆ bUnlimitedAmmo

bool UMortarAimingComponent::bUnlimitedAmmo = true

Allow Unlimited Firing

◆ CurrentAimDirection

FVector UMortarAimingComponent::CurrentAimDirection

Current Aim Direction of the mortar gun

◆ CurrentFiringState

EMortarFiringState UMortarAimingComponent::CurrentFiringState

Stores Current Firing state used by BP

◆ DefaultAimLocation

FVector UMortarAimingComponent::DefaultAimLocation

Default Aim Locatin of Barrel

◆ FireSound

class USoundBase* UMortarAimingComponent::FireSound

Sound Played on Each Mortar Firing

◆ FiringLeft

int32 UMortarAimingComponent::FiringLeft = 1000

Allow to use Firing Left Only if Unlimited Ammo is off

◆ LastFireTime

float UMortarAimingComponent::LastFireTime = 0

Stores Last Firing Time

◆ OnFireEvent

FMortarFireEvent UMortarAimingComponent::OnFireEvent

Event Called Just Before Spawning a Projectile actor

◆ OriginalFiringLeft

int32 UMortarAimingComponent::OriginalFiringLeft = 1000

Original Firing Left Count

◆ OriginalReloadTimeInSeconds

float UMortarAimingComponent::OriginalReloadTimeInSeconds = 0.5f

Original Reload Time In Seconds

◆ ProjectileSpawnSockets

TMap<FName, TSubclassOf<class AActor> > UMortarAimingComponent::ProjectileSpawnSockets

This is a map of Socket Name To Projectile Telling Which socket has to Fire which projectile

We can Use Projectile Class but this will force users to Use Projectile as base class which We don't want so better to use AActor class

◆ ReloadTimeInSeconds

float UMortarAimingComponent::ReloadTimeInSeconds = 0.5f

Time Delay Between each shots

◆ ShotsSpreadDegree

float UMortarAimingComponent::ShotsSpreadDegree = 2.f

How much shorts can Be Spread in Degrees Shots Spread Range between -ShotsSpreadDegree to ShotsSpreadDegree inclusive

◆ Turret

class UMortarTurret* UMortarAimingComponent::Turret = nullptr

Turret Class to Use Moves Horizontally

◆ VectorThresholdComparision

float UMortarAimingComponent::VectorThresholdComparision = 0.1f

This is used to for comparing Aim Direction and Forward Vector of Gun To check if they are in same direction

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