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

Parameters
[in]AimLocationDesired Aiming Location in FVector

◆ BeginPlay()

virtual void UMortarAimingComponent::BeginPlay ( )
overrideprotectedvirtual

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

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

◆ GetFiringCount()

int32 UMortarAimingComponent::GetFiringCount ( ) const

Gets The Current Firing Count Left

Returns
Firing Count Left

◆ GetReloadTimeInSeconds()

int32 UMortarAimingComponent::GetReloadTimeInSeconds ( ) const

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

Returns
Float variable containing reload time in seconds

◆ GetShotsSpreadDegree()

float UMortarAimingComponent::GetShotsSpreadDegree ( ) const

Gets Shots Spread Range which is used while Firing.

Returns
Float Variable Containing Shot spread in degree

◆ GetValidSubSystem()

class UMortarResourceManager* UMortarAimingComponent::GetValidSubSystem ( )
private

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

Returns
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

Parameters
[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

Returns
True if Barrel is moving false otherwise

◆ MoveBarrelTowards()

void UMortarAimingComponent::MoveBarrelTowards ( const FVector &  AimDirection)
private

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)
private

◆ ResetFiring()

void UMortarAimingComponent::ResetFiring ( )

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

◆ SetBarrelState()

void UMortarAimingComponent::SetBarrelState ( )
private

Sets State of Barrel like Moving,locked etc

◆ SetFiringLeft()

void UMortarAimingComponent::SetFiringLeft ( const int32 &  FiringLeft)

Sets Firing Left

Parameters
[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)
virtual

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

Parameters
[in]ProjectileToSetProjectile to spawn of Class Projectile

◆ SetReloadTimeInSeconds()

void UMortarAimingComponent::SetReloadTimeInSeconds ( const float &  ReloadTime)

Sets Time Delay between each shots

Parameters
[in]ReloadTimeFloat variable containing reload Time

◆ SetShotsSpreadDegree()

void UMortarAimingComponent::SetShotsSpreadDegree ( const float &  ShotsSpread)

Sets Shots Spread Range

Parameters
[in]ShotsSpreadShots Spread In Degree

◆ TickComponent()

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

Function Called on Every Tick

Member Data Documentation

◆ Barrel

class UMortarBarrel* UMortarAimingComponent::Barrel = nullptr
protected

Barrel/Gun Class to Use Moves Vertically

◆ bCanShoot

uint32 UMortarAimingComponent::bCanShoot
private

Whether Mortar Can Shoot or not

◆ bUnlimitedAmmo

bool UMortarAimingComponent::bUnlimitedAmmo = true
private

Allow Unlimited Firing

◆ CurrentAimDirection

FVector UMortarAimingComponent::CurrentAimDirection
private

Current Aim Direction of the mortar gun

◆ CurrentFiringState

EMortarFiringState UMortarAimingComponent::CurrentFiringState
private

Stores Current Firing state used by BP

◆ DefaultAimLocation

FVector UMortarAimingComponent::DefaultAimLocation
private

Default Aim Locatin of Barrel

◆ FireSound

class USoundBase* UMortarAimingComponent::FireSound
protected

Sound Played on Each Mortar Firing

◆ FiringLeft

int32 UMortarAimingComponent::FiringLeft = 1000
private

Allow to use Firing Left Only if Unlimited Ammo is off

◆ LastFireTime

float UMortarAimingComponent::LastFireTime = 0
private

Stores Last Firing Time

◆ OnFireEvent

FMortarFireEvent UMortarAimingComponent::OnFireEvent

Event Called Just Before Spawning a Projectile actor

◆ OriginalFiringLeft

int32 UMortarAimingComponent::OriginalFiringLeft = 1000
private

Original Firing Left Count

◆ OriginalReloadTimeInSeconds

float UMortarAimingComponent::OriginalReloadTimeInSeconds = 0.5f
private

Original Reload Time In Seconds

◆ ProjectileSpawnSockets

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

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

Note
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
private

Time Delay Between each shots

◆ ShotsSpreadDegree

float UMortarAimingComponent::ShotsSpreadDegree = 2.f
private

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

◆ Turret

class UMortarTurret* UMortarAimingComponent::Turret = nullptr
protected

Turret Class to Use Moves Horizontally

◆ VectorThresholdComparision

float UMortarAimingComponent::VectorThresholdComparision = 0.1f
private

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: