blaster/Source/Blaster/Weapon/Weapon.h

114 lines
2.9 KiB
C++

// 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"
UENUM(BlueprintType)
enum class EWeaponState : uint8
{
EWS_Initial UMETA(DisplayName = "Initial State"),
EWS_Equipped UMETA(DisplayName = "Equipped"),
EWS_Dropped UMETA(DisplayName = "Dropped"),
EWS_MAX UMETA(DisplayName = "DefaultMAX")
};
UCLASS()
class BLASTER_API AWeapon : public AActor
{
GENERATED_BODY()
public:
AWeapon();
virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
void ShowPickupWidget(bool bShowWidget);
virtual void Fire(const FVector& HitTarget);
// Textures for the weapon crosshairs
UPROPERTY(EditAnywhere, Category= Crosshairs)
class UTexture2D* CrosshairsCenter;
UPROPERTY(EditAnywhere, Category= Crosshairs)
class UTexture2D* CrosshairsLeft;
UPROPERTY(EditAnywhere, Category= Crosshairs)
class UTexture2D* CrosshairsRight;
UPROPERTY(EditAnywhere, Category= Crosshairs)
class UTexture2D* CrosshairsTop;
UPROPERTY(EditAnywhere, Category= Crosshairs)
class UTexture2D* CrosshairsBottom;
// Zoom FOV while aiming
UPROPERTY(EditAnywhere)
float ZoomedFOV = 30.f;
UPROPERTY(EditAnywhere)
float ZoomInterpSpeed = 20.f;
// Automatic fire
UPROPERTY(EditAnywhere, Category = Combat)
bool bAutomatic = true;
UPROPERTY(EditAnywhere, Category = Combat)
float FireDelay = .15f;
protected:
virtual void BeginPlay() override;
UFUNCTION()
virtual void OnSphereOverlap(
UPrimitiveComponent* OverlappedComponent,
AActor* OtherActor,
UPrimitiveComponent* OtherComp,
int32 OtherBodyIndex,
bool bFromSweep,
const FHitResult& SweepResult
);
UFUNCTION()
virtual void OnSphereEndOverlap(
UPrimitiveComponent* OverlappedComponent,
AActor* OtherActor,
UPrimitiveComponent* OtherComp,
int32 OtherBodyIndex
);
private:
UPROPERTY(VisibleAnywhere, Category="Weapon Properties")
USkeletalMeshComponent* WeaponMesh;
UPROPERTY(VisibleAnywhere, Category="Weapon Properties")
class USphereComponent* AreaSphere;
UPROPERTY(ReplicatedUsing = OnRep_WeaponState, VisibleAnywhere, Category="Weapon Properties")
EWeaponState WeaponState;
UFUNCTION()
void OnRep_WeaponState();
UPROPERTY(VisibleAnywhere, Category="Weapon Properties")
class UWidgetComponent* PickupWidget;
UPROPERTY(EditAnywhere, Category= "Weapon Properties")
class UAnimationAsset* FireAnimation;
UPROPERTY(EditAnywhere, Category= "Weapon Properties")
TSubclassOf<class ACasing> CasingClass;
public:
void SetWeaponState(EWeaponState State);
FORCEINLINE USphereComponent* GetAreaSphere() const { return AreaSphere; }
FORCEINLINE USkeletalMeshComponent* GetWeaponMesh() const { return WeaponMesh; };
FORCEINLINE float GetZoomedFOV() const { return ZoomedFOV; };
FORCEINLINE float GetZoomInterpSpeed() const { return ZoomInterpSpeed; };
};