// Fill out your copyright notice in the Description page of Project Settings. #pragma once #include "CoreMinimal.h" #include "WeaponTypes.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& OutLifetimeProps) const override; virtual void OnRep_Owner() override; void SetHUDAmmo(); void ShowPickupWidget(bool bShowWidget); virtual void Fire(const FVector& HitTarget); void Dropped(); void AddAmmo(int32 Amount); // 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) class USoundCue* EquipSound; 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 CasingClass; UPROPERTY(EditAnywhere, ReplicatedUsing=OnRep_Ammo) int32 Ammo; UFUNCTION() void OnRep_Ammo(); void SpendRound(); UPROPERTY(EditAnywhere) int32 MagCapacity; UPROPERTY() class ABlasterCharacter* OwnerCharacter; UPROPERTY() class ABlasterPlayerController* OwnerController; UPROPERTY(EditAnywhere) EWeaponType WeaponType; 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; }; FORCEINLINE EWeaponType GetWeaponType() const { return WeaponType; } FORCEINLINE int32 GetAmmo() const { return Ammo; } FORCEINLINE int32 GetMagCapacity() const { return MagCapacity; } bool IsEmpty(); };