Add base `Weapon` class

This commit is contained in:
Louis Hobbs 2022-12-15 22:04:51 +00:00
parent 35b6736e0a
commit 14bb9eef74
2 changed files with 157 additions and 0 deletions

View File

@ -0,0 +1,67 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "Weapon.h"
// Sets default values
AWeapon::AWeapon()
{
}
// Called when the game starts or when spawned
void AWeapon::BeginPlay()
{
Super::BeginPlay();
}
USkeletalMeshComponent* AWeapon::GetSkeletalMesh()
{
return WeaponSkeletalMesh;
}
void AWeapon::SetSkeletalMesh(USkeletalMeshComponent* USkeletalMeshComponent)
{
WeaponSkeletalMesh = USkeletalMeshComponent;
}
TEnumAsByte<WeaponState>* AWeapon::GetCurrentWeaponStatus()
{
return &CurrentWeaponStatus;
}
void AWeapon::SetCurrentWeaponStatus(TEnumAsByte<WeaponState> NewWeaponStatus)
{
CurrentWeaponStatus = NewWeaponStatus;
}
FWeaponProperties* AWeapon::GetWeaponProperties()
{
return &WeaponProperties;
}
void AWeapon::SetWeaponProperties(FWeaponProperties FWeaponProperties)
{
WeaponProperties = FWeaponProperties;
}
ANakatomiCharacter* AWeapon::GetParentPawn()
{
return ParentPawn;
}
void AWeapon::SetParentPawn(ANakatomiCharacter* ANakatomiCharacter)
{
ParentPawn = ANakatomiCharacter;
}
USoundBase* AWeapon::GetFireSound()
{
return FireSound;
}
void AWeapon::SetFireSound(USoundBase* USoundBase)
{
FireSound = USoundBase;
}

90
Source/Nakatomi/Weapon.h Normal file
View File

@ -0,0 +1,90 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "Weapon.generated.h"
class ANakatomiCharacter;
UENUM()
enum WeaponState
{
Idle,
Firing,
Cooldown,
Swapping
};
USTRUCT()
struct FWeaponProperties
{
GENERATED_USTRUCT_BODY()
float WeaponCooldown = 1.0f;
int WeaponDamage = 10;
float WeaponChangeTime = 2.0f;
int ProjectilesPerShot = 1;
float ProjectileRange = 10000.0f;
float WeaponSpread = 2.5f;
bool IsAutomatic = true;
};
UCLASS(Abstract, Blueprintable)
class NAKATOMI_API AWeapon : public AActor
{
GENERATED_BODY()
protected:
UPROPERTY(EditDefaultsOnly)
USkeletalMeshComponent* WeaponSkeletalMesh;
UPROPERTY(EditDefaultsOnly)
TEnumAsByte<WeaponState> CurrentWeaponStatus;
UPROPERTY(EditDefaultsOnly)
FWeaponProperties WeaponProperties;
UPROPERTY(VisibleAnywhere)
ANakatomiCharacter* ParentPawn;
UPROPERTY(EditDefaultsOnly)
USoundBase* FireSound;
public:
// Sets default values for this actor's properties
AWeapon();
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
USkeletalMeshComponent* GetSkeletalMesh();
void SetSkeletalMesh(USkeletalMeshComponent* USkeletalMeshComponent);
TEnumAsByte<WeaponState>* GetCurrentWeaponStatus();
void SetCurrentWeaponStatus(TEnumAsByte<WeaponState> NewWeaponStatus);
FWeaponProperties* GetWeaponProperties();
void SetWeaponProperties(FWeaponProperties FWeaponProperties);
ANakatomiCharacter* GetParentPawn();
void SetParentPawn(ANakatomiCharacter* ANakatomiCharacter);
USoundBase* GetFireSound();
void SetFireSound(USoundBase* USoundBase);
};