Skip to content

Class list

LinuxCat edited this page Jul 10, 2024 · 6 revisions

This page's goal is to provide a comprehensive list of the useful C++ classes within this project.
Please do note that every function and property in this page is declared as public in the code, unless explicitly stated.
This does not have every single property or function from every class, redundant stuff is excluded and built-in functions (like Tick, BeginPlay, etc) are excluded as well, unless heavy logic is done in them.

Structures

FWord was made to simply hold a single word in a DataTable row and allow it to be manipulated by other classes later.

Properties

FString Word

The word held by the FWord struct. Default is "".

FWordList, as its name suggests, is made to hold multiple FWords, however it should only hold FWords of the same length.

Properties

UDataTable* WordList

The data table holding the FWords. No check is made to ensure this Data Table actually holds FWords.

int WordLength

The length of all the FWords in WordList. Again, no check is made to ensure this - such an operation would be quite expensive anyways.

FWave represents a pre-entered Wave of enemies, meaning this structure is only used when data is manually entered and insterted in a data table.

Properties

TArray<TSubclassOf<Ak3ShooterEnemyBase>> Enemies

The enemies that will spawn in the wave, in order.

float MinimumTimeToSpawn

and

float MaximumTimeToSpawn

are used to determine the time between enemies spawn.

This class is used as a "wrapper" to EnemyBase to allow an arbitrary points value on an enemy, which will be used in the procedural wave generation once the pre-entered FWaves run out.

Properties

TSubclassOf<Ak3ShooterEnemyBase> Enemy

The enemy to spawn in the wave.

float Points

How much points the enemy is worth. This is not used at all when calculating score, only when doing calculations for procedural wave generation.

Classes

The base class for the Game Instance. It allows easy access to the word database by other classes.

Functions

void PopulateList(TArray<FWordList> ListOfFWordList)

Fills up the database from a list of FWordList, which is most likely going to be a DataTable.\

FString GetRandomWordOfLength(int length)

Returns a random word in the database with the corresponding length.

Properties

TArray<FWordList> WordLists

The word database itself. While freely accessible, it's recommended to use GetRandomWordOfLength instead.
Other properties are values that need to be preserved through level transitions.

The class responsible for handling everything around the main character - typing, health, money, shooting animation, etc.

Functions

void Hurt(float DamageTaken)

This function is called whenever the player needs to lose damage, so it can be called by itself or by any enemies.

void OnAnyKeyPress(FKey key)

This is a protected function, however it needs to be explained due to its involvement in everything.
This function checks if the key pressed is alphabetical, and if so, it compares the letter typed to the next letter in the target word.
Depending on the context, this might be different. As an example, this does not happen if we are in the shop, and handling the key press is left to the shop itself.
Another example is when you complete a word : then the word resets and the gun fire animation starts.

void Fire()

This function starts the gun animation and deals damage to the nearest enemy. For more information on how damage is dealt, please check this page.

void GetNewTargetWord()

As the name suggests, this resets the target word using the function provided by the game instance.

void ToggleShop()

Rotates the player around so the camera is facing the shop.

Actor* GetNearestEnemy()

This is a protected function. It is used by Fire and returns the nearest enemy, or nullptr if no suitable actor was found.

FString GetCurrentWordProgress()

This function is used by the User Interface Widget to show colored text on successful/missed letters.

Properties

FString TargetWord

The word that the player has to type.

FString Typed

The word that the player currently typed. Will never exceed the length of TargetWord.

int Health

float Money

The health points (HP) and money the player currently has. The player dies if HP is equal to or under 0, after which the scene changes to a leaderboard.

float MoneyGain

A multiplier on money won by killing enemies.

float DamagePerLetter

A multiplier on damage dealt on enemies per correct letter.

Recoil

Recoil is done in the Tick function, so an explanation is needed. When Fire() executes, it sets RecoilAmount to the value corresponding to the number of correct letters.
Then, Tick moves the model of the gun in space using and modifying the variables RecoilMovementCurrent and RecoilMovementMult.
The calculation can be found in detail here

The base class for all enemies. Contains a handful of functions as well as some properties that will alter the enemy's behavior when set.

Functions

Ak3ShooterCharacter* GetPlayer()

Gets the player. This function is only expensive the first time, as a variable is set and reused for all subsequent calls.

void ResetToDefaultValues()

Resets some properties to default values. This is not done in the base class and has to be implemented in the child classes, if needed. Called on BeginPlay

void OnDeath()

Same as above, this has to be implemented in the child classes if needed, however the base version gives money to the player, so child classes need to call super or implement that another way. Called when the enemy dies, before it's destroyed, so no need to call Destroy() here.

Properties

float CurrentHealth

The enemy's current health. default 10.0

float MovementSpeed

The enemy's movement speed multiplier. This is applied on the Character Movement's movement speed, as this class derives from ACharacter. default 0.0

float MoneyValue

Money gained when defeating the enemy (by default, can be changed in OnDeath). default 0.0

float DamageMultiplier

Multiplier for the damage dealt to the player. default 1.0

A simple AI controller class that will just load a BehaviorTree and run it. In this case, the behavior tree just runs a Uk3ShooterTaskNodeMoveToPlayer node.

Despite being named like so, this task node doesn't actually move to the player and leaves this to the "Move To" tree node. All this does is set a blackboard variable to the player position.

Object used to handle interactions regarding the shop - it acts as a proxy between the player character and the shop items.

Functions

void OnKeyPress(TCHAR key)

Called by Ak3ShooterCharacter, this handles the key presses differently than the player, however checking if the key pressed is alphabetic is done by the character so this is already a guarantee.
After typing a letter, if the word typed corresponds to one of the Shop Items, it tries to buy it.

bool IsWordStart(FString start, FString complete)

A StartsWith implementation for FString, used by OnKeyPress to compare words.

Properties

FString Typed

The currently typed word. It can't be something that isn't the start of an item.

Array<Ak3ShooterShopItem*> Items

The items registered in the shop. This array fills itself with all items in the scene on BeginPlay.

Items that will appear in shop. This is the base class for an item, it shouldn't be used by itself.

Functions

void TryBuy()

Checks if the player has enough money to buy the item, then calls Buy() if so

void Buy()

This is a private function. This doesn't do any checks and runs the effect of the item immediately. This is not implemented in the base class and needs to be in child classes.

Properties

FString Word

The word that needs to be typed to buy the item.

int Price

The price of the item.

This is the enemy spawner object, both in logic and on the map. It's the class that loads pre-entered waves, but it's also the class that procedurally generates waves.

Functions

void Tick(float DeltaTime)

This is an override on the built-in Tick function, all the spawning logic is done in there. For more information on that, you can check the dedicated page, but in short, we check if the player is on a break (= at the end of a wave and all enemies dead), if not, we check if it's time to spawn an enemy yet, and if so we spawn an enemy according to the data.

TSubclassOf<Ak3ShooterEnemyBase> GetRandomEnemyWithRemainingPoints(float* Points)

Used for procedural wave generation. Gets a random enemy from the list, based on how many points are left for enemy spawn. More info on waves available here.

Properties

UDataTable* Waves

The DataTable object with the pre-entered waves info. The waves are FWaves.

UBoxComponent* SpawnZone

The zone in which enemies are allowed to spawn. They will spawn at a random point within the bounds of the box.

bool IsOnBreak

True if we're on a break, else False.

float BreakTime

Time left before the break ends. Decreases in Tick according to DeltaTime.

int WaveNumber

Current wave number.

FWave* CurrentWave

Current wave. Only used when in waves with pre-entered wave data.

float NextSpawnIn

Time until next enemy spawn.

float WavePoints

Current points of this wave, used for procedural generation.

TArray<FEnemy> Enemies

The enemies available to use for procedural wave generation.

Clone this wiki locally