// Fill out your copyright notice in the Description page of Project Settings. #pragma once #include "CoreMinimal.h" #include "Components/ActorComponent.h" #include #include "Interfaces/Damageable.h" #include "ShootingComponent.generated.h" UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) ) class EXO_API UShootingComponent : public UActorComponent { GENERATED_BODY() public: // Sets default values for this component's properties UShootingComponent(); UPROPERTY(EditAnywhere, Category = "Shooting") float MaxRange = 2000.0f; UPROPERTY(EditAnywhere, Category = "Shooting") float DamageValue = 100.0f; UPROPERTY(EditAnywhere, Category = "Shooting") float FireRateCooldown = 1.0f; UPROPERTY(EditAnywhere, Category = "Shooting") float RecoilForce = 50.0f; UPROPERTY(EditAnywhere, Category = "Shooting") float ReloadTime = 3.0f; UPROPERTY(EditAnywhere, Category = "Ammo") int32 CurrentAmmo = 10; UPROPERTY(EditAnywhere, Category = "Ammo") int32 MaxAmmo = 10; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Debug") bool bShowDebugLine = true; UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Character") TObjectPtr PlayerCharacter; protected: // Called when the game starts virtual void BeginPlay() override; public: // Called every frame virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override; UFUNCTION(Category = "Shooting") void Shoot(); UFUNCTION(Category = "Shooting") void Reload(); private: void ResetFireCooldown(); void ReloadCompleted(); FTimerHandle ShootCooldownTimer; FTimerHandle ReloadTimer; UPROPERTY(EditAnywhere, Category = "Shooting") bool bCanShoot = true; UPROPERTY(EditAnywhere, Category = "Reloading") bool bIsReloading = false; };