Nakatomi/Source/Nakatomi/PlayerCharacter.h

148 lines
3.3 KiB
C
Raw Normal View History

2022-12-13 04:11:56 +00:00
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "Camera/CameraComponent.h"
#include "CoreMinimal.h"
#include "GameFramework/SpringArmComponent.h"
#include "InputActionValue.h"
#include "EnhancedInputComponent.h"
#include "NakatomiCharacter.h"
2023-01-01 23:59:59 +00:00
#include "Weapon.h"
2022-12-13 04:11:56 +00:00
#include "PlayerCharacter.generated.h"
class UInputAction;
class UInputMappingContext;
//class UEnhancedInputComponent;
/**
*
*/
UCLASS()
class NAKATOMI_API APlayerCharacter : public ANakatomiCharacter
{
GENERATED_BODY()
public:
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
2023-01-13 19:45:40 +00:00
UInputAction* MovementAction;
2022-12-13 04:11:56 +00:00
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
2023-01-13 19:45:40 +00:00
UInputAction* LookAction;
2022-12-13 04:11:56 +00:00
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
2023-01-13 19:45:40 +00:00
UInputAction* JumpAction;
2022-12-13 04:11:56 +00:00
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
2023-01-13 19:45:40 +00:00
UInputAction* FireAction;
2022-12-13 04:11:56 +00:00
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
2023-01-13 19:45:40 +00:00
UInputAction* QuitAction;
2022-12-13 04:11:56 +00:00
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
2023-01-13 19:45:40 +00:00
UInputAction* SprintAction;
2022-12-13 04:11:56 +00:00
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
2023-01-13 19:45:40 +00:00
TSoftObjectPtr<UInputMappingContext> InputMappingContext;
2022-12-13 04:11:56 +00:00
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
2023-01-13 19:45:40 +00:00
int MappingPriority = 0;
2022-12-13 04:11:56 +00:00
2023-01-01 23:59:59 +00:00
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
2023-01-13 19:45:40 +00:00
TArray<TSubclassOf<class AWeapon>> DefaultWeaponInventory;
2023-01-01 23:59:59 +00:00
UPROPERTY()
2023-01-13 19:45:40 +00:00
TArray<AWeapon*> WeaponInventory;
2023-01-01 23:59:59 +00:00
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
2023-01-13 19:45:40 +00:00
UInputAction* WeaponSwitchingAction;
2023-01-01 23:59:59 +00:00
protected:
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
2023-01-13 19:45:40 +00:00
float SprintSpeedMultiplier = 2.0f;
2023-01-01 23:59:59 +00:00
private:
UPROPERTY()
2023-01-13 19:45:40 +00:00
USpringArmComponent* CameraBoom = nullptr;
2023-01-01 23:59:59 +00:00
UPROPERTY()
2023-01-13 19:45:40 +00:00
UCameraComponent* CameraComponent = nullptr;
2023-01-01 23:59:59 +00:00
float DefaultMovementSpeed;
int CurrentInventorySlot = 0;
UPROPERTY()
AWeapon* CurrentWeapon = nullptr;
2023-01-13 21:11:07 +00:00
FTimerHandle FireTimerHandle;
FTimerHandle CooldownTimerHandle;
bool IsFiring = false;
2023-01-01 23:59:59 +00:00
public:
// Sets default values for this character's properties
APlayerCharacter();
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
// Called to bind functionality to input
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
2022-12-13 04:11:56 +00:00
void MovementCallback(const FInputActionInstance& Instance);
void LookCallback(const FInputActionInstance& Instance);
void JumpCallback(const FInputActionInstance& Instance);
2023-01-13 21:11:07 +00:00
void BeginFireCallback(const FInputActionInstance& Instance);
void EndFireCallback(const FInputActionInstance& Instance);
2022-12-13 04:11:56 +00:00
void QuitCallback(const FInputActionInstance& Instance);
void SetSprintingCallback(const FInputActionInstance& Instance);
void SetWalkingCallback(const FInputActionInstance& Instance);
void CalculateHits(TArray<FHitResult>* hits);
2023-01-01 23:59:59 +00:00
void SetInventoryToDefault();
void SelectInventorySlot(int slot);
void WeaponSwitchingCallback(const FInputActionInstance& Instance);
void InventoryIncrement();
2023-01-01 23:59:59 +00:00
void InventoryDecrement();
2023-01-01 23:59:59 +00:00
AWeapon* InitializeWeapon(TSubclassOf<class AWeapon> weapon);
AWeapon* GetCurrentWeapon();
void SetCurrentWeapon(AWeapon* weapon);
void AddWeaponToInventory(TSubclassOf<class AWeapon> weapon);
void RemoveWeaponFromInventory(int i);
void RemoveCurrentWeaponFromInventory();
2023-01-13 21:11:07 +00:00
void OnFire();
void WeaponCooldownHandler();
void ClearAllTimers();
2022-12-13 04:11:56 +00:00
};