ExoWest/Source/Exo/Public/Characters/Components/ShootingComponent.h

141 lines
3.4 KiB
C
Raw Normal View History

// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include <Characters/ExoPlayerCharacter.h>
#include "GameFramework/CharacterMovementComponent.h"
#include <Items/GunBase.h>
#include "Interfaces/Damageable.h"
#include "ShootingComponent.generated.h"
class AThrowableBase;
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class EXO_API UShootingComponent : public UActorComponent
{
GENERATED_BODY()
public:
UShootingComponent();
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Debug")
bool bShowDebugLine = true;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Character")
TObjectPtr<AExoPlayerCharacter> PlayerCharacter;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Camera")
TObjectPtr<APlayerCameraManager> CameraManager;
protected:
virtual void BeginPlay() override;
public:
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
UFUNCTION(Category = "Shooting")
void Shoot();
UFUNCTION(Category = "Mele Attack")
void MeleAttack();
UFUNCTION(Category = "Ammo")
void Reload();
UFUNCTION(Category = "Ammo")
bool AddAmmo(EAmmoType CheckingAmmo, int AddValue);
UFUNCTION(BlueprintCallable, Category = "Shooting")
void PickUpGun(UStaticMeshComponent* PickedGunMesh);
UFUNCTION(BlueprintCallable, Category = "Shooting")
bool PickUpThrow(AThrowableBase* ThrowItem);
UFUNCTION(Category = "Shooting")
void DropGun();
UFUNCTION(Category = "Shooting")
void DropThrow();
2025-03-23 21:47:10 +01:00
UFUNCTION(Category = "Shooting")
void SwitchGun();
UFUNCTION(Category = "Shooting")
void SelectGun(bool bSelectFirstSlot);
UFUNCTION(Category = "Shooting")
void StartAiming();
UFUNCTION(Category = "Shooting")
void StopAiming();
UFUNCTION(Category = "Shooting")
void Throw();
UFUNCTION(BlueprintCallable, Category = "Shooting")
bool IsHoldingGun();
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Aiming")
float AimingAnimationSpeed = 30.0f;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Aiming")
float AimingMoveSpeedScale = 0.70f;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Shooting")
float DropGunRange = 20.0f;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Mele Attack")
float MeleRange = 75.f;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Shooting")
bool bHasRifle = false;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Shooting")
AThrowableBase* ThrowableItem = nullptr;
AGunBase* CurrentGunBase = nullptr;
UStaticMeshComponent* CurrentGunMesh = nullptr;
AGunBase* SecondaryGunBase = nullptr;
UStaticMeshComponent* SecondaryGunMesh = nullptr;
2025-03-23 21:47:10 +01:00
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnADSEventSignature);
FOnADSEventSignature OnStartedADS;
FOnADSEventSignature OnStoppedADS;
private:
void ResetFireCooldown();
void ReloadCompleted();
AActor* ExecuteLineTrace(float LineRange);
// Cover logic - ToQly
//
FTimerHandle ShootCooldownTimer;
FTimerHandle ReloadTimer;
bool bCanShoot = true;
bool bIsReloading = false;
2025-03-23 21:47:10 +01:00
float DefaultFOV;
float TargetFOV;
2025-03-23 21:47:10 +01:00
bool bIsFirstGunSelected = true;
float MeleDamageValue = 50.f;
2025-05-15 19:15:32 +02:00
float BreathingTimer = 0.0f;
float PitchFrequency = 0.25f;
float YawFrequency = 0.22f;
float PitchAmplitude = 0.003f;
float YawAmplitude = 0.002f;
float YawPhaseOffset = PI / 3.0f;
};