Implemented basic grenade interaction: - Player can pick up, throw, and drop grenades. To-do: - Refine throwing mechanics (e.g. direction, force). - Clean up and refactor related code.
114 lines
2.8 KiB
C++
114 lines
2.8 KiB
C++
// 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:
|
|
// Sets default values for this component's properties
|
|
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:
|
|
// 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 = "Mele Attack")
|
|
void MeleAttack();
|
|
|
|
UFUNCTION(Category = "Shooting")
|
|
void Reload();
|
|
|
|
UFUNCTION(BlueprintCallable, Category = "Shooting")
|
|
void PickUpGun(AGunBase* gunItem);
|
|
|
|
UFUNCTION(BlueprintCallable, Category = "Shooting")
|
|
bool PickUpThrow(AThrowableBase* ThrowItem);
|
|
|
|
UFUNCTION(Category = "Shooting")
|
|
void DropGun();
|
|
|
|
UFUNCTION(Category = "Shooting")
|
|
void DropThrow();
|
|
|
|
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();
|
|
|
|
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(VisibleAnywhere, BlueprintReadOnly, Category = "Shooting")
|
|
AThrowableBase* ThrowableItem = nullptr;
|
|
|
|
AGunBase* CurrentGun = nullptr;
|
|
AGunBase* SecondaryGun = nullptr;
|
|
|
|
private:
|
|
void ResetFireCooldown();
|
|
void ReloadCompleted();
|
|
AActor* ExecuteLineTrace(float LineRange);
|
|
|
|
FTimerHandle ShootCooldownTimer;
|
|
FTimerHandle ReloadTimer;
|
|
|
|
bool bCanShoot = true;
|
|
bool bIsReloading = false;
|
|
|
|
float DefaultFOV;
|
|
float TargetFOV;
|
|
|
|
bool bIsFirstGunSelected = true;
|
|
|
|
float MeleDamageValue = 50.f;
|
|
};
|