2022-04-29 22:26:35 +00:00
|
|
|
// 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"),
|
2022-04-30 11:09:28 +00:00
|
|
|
|
2022-04-29 22:26:35 +00:00
|
|
|
EWS_MAX UMETA(DisplayName = "DefaultMAX")
|
|
|
|
};
|
|
|
|
|
|
|
|
UCLASS()
|
|
|
|
class BLASTER_API AWeapon : public AActor
|
|
|
|
{
|
|
|
|
GENERATED_BODY()
|
2022-04-29 23:19:55 +00:00
|
|
|
|
|
|
|
public:
|
2022-04-29 22:26:35 +00:00
|
|
|
AWeapon();
|
2022-04-30 14:08:00 +00:00
|
|
|
virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
|
2022-04-30 10:26:25 +00:00
|
|
|
void ShowPickupWidget(bool bShowWidget);
|
2022-05-05 10:51:14 +00:00
|
|
|
virtual void Fire(const FVector& HitTarget);
|
2022-05-08 17:31:58 +00:00
|
|
|
void Dropped();
|
2022-04-30 10:26:25 +00:00
|
|
|
|
2022-05-05 15:57:57 +00:00
|
|
|
// 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;
|
2022-05-05 19:56:31 +00:00
|
|
|
|
|
|
|
// Zoom FOV while aiming
|
|
|
|
UPROPERTY(EditAnywhere)
|
|
|
|
float ZoomedFOV = 30.f;
|
|
|
|
|
|
|
|
UPROPERTY(EditAnywhere)
|
|
|
|
float ZoomInterpSpeed = 20.f;
|
2022-05-06 20:54:23 +00:00
|
|
|
|
|
|
|
// Automatic fire
|
|
|
|
|
|
|
|
UPROPERTY(EditAnywhere, Category = Combat)
|
|
|
|
bool bAutomatic = true;
|
|
|
|
|
|
|
|
UPROPERTY(EditAnywhere, Category = Combat)
|
|
|
|
float FireDelay = .15f;
|
2022-05-05 15:57:57 +00:00
|
|
|
|
2022-04-29 22:26:35 +00:00
|
|
|
protected:
|
|
|
|
virtual void BeginPlay() override;
|
|
|
|
|
2022-04-29 23:19:55 +00:00
|
|
|
UFUNCTION()
|
|
|
|
virtual void OnSphereOverlap(
|
|
|
|
UPrimitiveComponent* OverlappedComponent,
|
|
|
|
AActor* OtherActor,
|
|
|
|
UPrimitiveComponent* OtherComp,
|
|
|
|
int32 OtherBodyIndex,
|
|
|
|
bool bFromSweep,
|
|
|
|
const FHitResult& SweepResult
|
|
|
|
);
|
2022-04-30 10:26:25 +00:00
|
|
|
|
|
|
|
UFUNCTION()
|
|
|
|
virtual void OnSphereEndOverlap(
|
|
|
|
UPrimitiveComponent* OverlappedComponent,
|
|
|
|
AActor* OtherActor,
|
|
|
|
UPrimitiveComponent* OtherComp,
|
|
|
|
int32 OtherBodyIndex
|
|
|
|
);
|
2022-04-29 23:19:55 +00:00
|
|
|
|
|
|
|
private:
|
2022-04-29 22:26:35 +00:00
|
|
|
UPROPERTY(VisibleAnywhere, Category="Weapon Properties")
|
|
|
|
USkeletalMeshComponent* WeaponMesh;
|
|
|
|
|
|
|
|
UPROPERTY(VisibleAnywhere, Category="Weapon Properties")
|
|
|
|
class USphereComponent* AreaSphere;
|
|
|
|
|
2022-04-30 14:08:00 +00:00
|
|
|
UPROPERTY(ReplicatedUsing = OnRep_WeaponState, VisibleAnywhere, Category="Weapon Properties")
|
2022-04-29 22:26:35 +00:00
|
|
|
EWeaponState WeaponState;
|
|
|
|
|
2022-04-30 14:08:00 +00:00
|
|
|
UFUNCTION()
|
|
|
|
void OnRep_WeaponState();
|
|
|
|
|
2022-04-29 23:19:55 +00:00
|
|
|
UPROPERTY(VisibleAnywhere, Category="Weapon Properties")
|
|
|
|
class UWidgetComponent* PickupWidget;
|
2022-04-29 22:26:35 +00:00
|
|
|
|
2022-05-04 20:27:26 +00:00
|
|
|
UPROPERTY(EditAnywhere, Category= "Weapon Properties")
|
|
|
|
class UAnimationAsset* FireAnimation;
|
2022-05-05 13:49:24 +00:00
|
|
|
|
|
|
|
UPROPERTY(EditAnywhere, Category= "Weapon Properties")
|
|
|
|
TSubclassOf<class ACasing> CasingClass;
|
2022-05-05 15:57:57 +00:00
|
|
|
|
|
|
|
|
2022-04-29 23:19:55 +00:00
|
|
|
public:
|
2022-04-30 14:08:00 +00:00
|
|
|
void SetWeaponState(EWeaponState State);
|
|
|
|
FORCEINLINE USphereComponent* GetAreaSphere() const { return AreaSphere; }
|
2022-05-03 22:43:10 +00:00
|
|
|
FORCEINLINE USkeletalMeshComponent* GetWeaponMesh() const { return WeaponMesh; };
|
2022-05-05 19:56:31 +00:00
|
|
|
FORCEINLINE float GetZoomedFOV() const { return ZoomedFOV; };
|
|
|
|
FORCEINLINE float GetZoomInterpSpeed() const { return ZoomInterpSpeed; };
|
|
|
|
|
2022-04-29 22:26:35 +00:00
|
|
|
};
|