// Fill out your copyright notice in the Description page of Project Settings. #pragma once #include "CoreMinimal.h" #include "Item.h" #include "AmmoType.h" #include "Engine/DataTable.h" #include "WeaponType.h" #include "Weapon.generated.h" class USoundCue; class UWidgetComponent; USTRUCT(BlueprintType) struct FWeaponDataTable : public FTableRowBase { GENERATED_BODY() UPROPERTY(EditAnywhere, BlueprintReadWrite) EAmmoType AmmoType; UPROPERTY(EditAnywhere, BlueprintReadWrite) int32 WeaponAmmo; UPROPERTY(EditAnywhere, BlueprintReadWrite) int32 MagazineCapacity; UPROPERTY(EditAnywhere, BlueprintReadWrite) USoundCue* PickupSound; UPROPERTY(EditAnywhere, BlueprintReadWrite) USoundCue* EquipSound; UPROPERTY(EditAnywhere, BlueprintReadWrite) USkeletalMesh* ItemMesh; UPROPERTY(EditAnywhere, BlueprintReadWrite) FString ItemName; UPROPERTY(EditAnywhere, BlueprintReadWrite) UTexture2D* InventoryIcon; UPROPERTY(EditAnywhere, BlueprintReadWrite) UTexture2D* AmmoIcon; UPROPERTY(EditAnywhere, BlueprintReadWrite) UMaterialInstance* MaterialInstance; UPROPERTY(EditAnywhere, BlueprintReadWrite) int32 MaterialIndex; UPROPERTY(EditAnywhere, BlueprintReadWrite) FName ClipBoneName; UPROPERTY(EditAnywhere, BlueprintReadWrite) FName ReloadMontageSection; UPROPERTY(EditAnywhere, BlueprintReadWrite) TSubclassOf AnimBP; UPROPERTY(EditAnywhere, BlueprintReadWrite) UTexture2D* CrosshairsMiddle; UPROPERTY(EditAnywhere, BlueprintReadWrite) UTexture2D* CrosshairsLeft; UPROPERTY(EditAnywhere, BlueprintReadWrite) UTexture2D* CrosshairsRight; UPROPERTY(EditAnywhere, BlueprintReadWrite) UTexture2D* CrosshairsBottom; UPROPERTY(EditAnywhere, BlueprintReadWrite) UTexture2D* CrosshairsTop; }; /** * */ UCLASS() class SHOOTER_API AWeapon : public AItem { GENERATED_BODY() public: AWeapon(); virtual void Tick(float DeltaTime) override; protected: void StopFalling(); virtual void OnConstruction(const FTransform& Transform) override; private: FTimerHandle ThrowWeaponTimer; float ThrowWeaponTime; bool bFalling; /** Ammo count for this weapon */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weapon Properties", meta = (AllowPrivateAccess = "true")) int32 Ammo; /** Max ammo that our weapon can hold */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weapon Properties", meta = (AllowPrivateAccess = "true")) int32 MagazineCapacity; /** Type of weapon */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weapon Properties", meta = (AllowPrivateAccess = "true")) EWeaponType WeaponType; /** Type of ammo for this weapon */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weapon Properties", meta = (AllowPrivateAccess = "true")) EAmmoType AmmoType; /** FName for the reload montage section */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weapon Properties", meta = (AllowPrivateAccess = "true")) FName ReloadMontageSection; /** True when moving the clip while reloading */ UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Weapon Properties", meta = (AllowPrivateAccess = "true")) bool bMovingClip; /** FName for the clip bone */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weapon Properties", meta = (AllowPrivateAccess = "true")) FName ClipBoneName; /** Data table for weapon properties */ UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = DataTable, meta = (AllowPrivateAccess = "true")) UDataTable* WeaponDataTable; int32 PreviousMaterialIndex; /** Textures for the weapon crosshairs */ UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = DataTable, meta = (AllowPrivateAccess = "true")) UTexture2D* CrosshairsMiddle; UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = DataTable, meta = (AllowPrivateAccess = "true")) UTexture2D* CrosshairsLeft; UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = DataTable, meta = (AllowPrivateAccess = "true")) UTexture2D* CrosshairsRight; UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = DataTable, meta = (AllowPrivateAccess = "true")) UTexture2D* CrosshairsBottom; UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = DataTable, meta = (AllowPrivateAccess = "true")) UTexture2D* CrosshairsTop; public: /** Adds an impulse to the weapon */ void ThrowWeapon(); FORCEINLINE int32 GetAmmo() const { return Ammo; } /** Called from Character class when firing weapon */ void DecrementAmmo(); FORCEINLINE EWeaponType GetWeaponType() const { return WeaponType; } FORCEINLINE EAmmoType GetAmmoType() const { return AmmoType; } FORCEINLINE int32 GetMagazineCapacity() const { return MagazineCapacity; } FORCEINLINE FName GetReloadMontageSection() const { return ReloadMontageSection; } FORCEINLINE FName GetClipBoneName() const { return ClipBoneName; } void ReloadAmmo(int32 Amount); FORCEINLINE void SetMovingClip(bool Move) { bMovingClip = Move; }; bool ClipIsFull(); };