268 lines
11 KiB
C++
268 lines
11 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#pragma once
|
|
|
|
#include "CoreMinimal.h"
|
|
#include "GameplayTagAssetInterface.h"
|
|
#include "GameFramework/Character.h"
|
|
#include "InputActionValue.h"
|
|
#include "InputAction.h"
|
|
#include "Interface/CombatInterface.h"
|
|
#include "Components/StateManagerComponent.h"
|
|
#include "Components/StatsComponent.h"
|
|
#include "Components/TargetingComponent.h"
|
|
#include "Components/TimelineComponent.h"
|
|
#include "Definitions/GameEnums.h"
|
|
#include "CombatPlayerCharacter.generated.h"
|
|
|
|
class UInputMappingContext;
|
|
class UInputAction;
|
|
|
|
UCLASS(config=Game)
|
|
class ACombatPlayerCharacter : public ACharacter, public ICombatInterface, public IGameplayTagAssetInterface
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
/** Camera boom positioning the camera behind the character */
|
|
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true"))
|
|
class USpringArmComponent* CameraBoom;
|
|
|
|
/** Follow camera */
|
|
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true"))
|
|
class UCameraComponent* FollowCamera;
|
|
|
|
/** MappingContext */
|
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
|
|
UInputMappingContext* DefaultMappingContext;
|
|
|
|
/** Jump Input Action */
|
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
|
|
UInputAction* JumpAction;
|
|
|
|
/** Move Input Action */
|
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
|
|
UInputAction* MoveAction;
|
|
|
|
/** Look Input Action */
|
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
|
|
UInputAction* LookAction;
|
|
|
|
/* Interact Input Action */
|
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
|
|
UInputAction* InteractAction;
|
|
|
|
/* ToggleCombat Input Action */
|
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
|
|
UInputAction* ToggleCombatInputAction;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
|
|
UInputAction* LightAttackAction;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
|
|
UInputAction* HeavyAttackAction;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
|
|
UInputAction* DodgeAction;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
|
|
UInputAction* ToggleWalkAction;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
|
|
UInputAction* SprintAction;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
|
|
UInputAction* ToggleLockOnAction;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
|
|
UInputAction* BlockAction;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
|
|
UInputAction* UseItemAction;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Input, meta = (AllowPrivateAccess = "true"))
|
|
float ChargeAttackTime;
|
|
public:
|
|
ACombatPlayerCharacter();
|
|
|
|
public:
|
|
/** Returns CameraBoom subobject **/
|
|
FORCEINLINE class USpringArmComponent* GetCameraBoom() const { return CameraBoom; }
|
|
/** Returns FollowCamera subobject **/
|
|
FORCEINLINE class UCameraComponent* GetFollowCamera() const { return FollowCamera; }
|
|
|
|
protected:
|
|
// APawn interface
|
|
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
|
|
virtual void BeginPlay() override;
|
|
virtual void Tick(float DeltaSeconds) override;
|
|
virtual float TakeDamage(float Damage, struct FDamageEvent const& DamageEvent, AController* EventInstigator, AActor* DamageCauser) override;
|
|
|
|
public:
|
|
// Inherited via ICombatInterface
|
|
UFUNCTION(BlueprintCallable, BlueprintNativeEvent)
|
|
void ContinueAttack();
|
|
virtual void ContinueAttack_Implementation() override;
|
|
UFUNCTION(BlueprintCallable, BlueprintNativeEvent)
|
|
void ResetAttack();
|
|
virtual void ResetAttack_Implementation() override;
|
|
UFUNCTION(BlueprintCallable, BlueprintNativeEvent)
|
|
void ResetCombat();
|
|
virtual void ResetCombat_Implementation() override;
|
|
UFUNCTION(BlueprintCallable, BlueprintNativeEvent)
|
|
FRotator GetDesiredRotation();
|
|
virtual FRotator GetDesiredRotation_Implementation() override;
|
|
UFUNCTION(BlueprintCallable, BlueprintNativeEvent)
|
|
bool CanReceiveDamage();
|
|
virtual bool CanReceiveDamage_Implementation() override;
|
|
UFUNCTION(BlueprintCallable, BlueprintNativeEvent)
|
|
void SetCanMove(bool inputCanMove);
|
|
virtual void SetCanMove_Implementation(bool inputCanMove) override;
|
|
UFUNCTION(BlueprintCallable, BlueprintNativeEvent)
|
|
void ActivateCollision(ECollisionPart CollisionPart);
|
|
virtual void ActivateCollision_Implementation(ECollisionPart CollisionPart) override;
|
|
UFUNCTION(BlueprintCallable, BlueprintNativeEvent)
|
|
void DeactivateCollision(ECollisionPart CollisionPart);
|
|
virtual void DeactivateCollision_Implementation(ECollisionPart CollisionPart) override;
|
|
UFUNCTION(BlueprintCallable, BlueprintNativeEvent)
|
|
void SetIFrame(bool InputEnableIFrame);
|
|
virtual void SetIFrame_Implementation(bool InputEnableIFrame) override;
|
|
|
|
virtual EMovementSpeedMode GetCombatMovementSpeedMode() override { return GetMovementSpeedMode(); }
|
|
virtual float PerformAction(FGameplayTag ActionTag, FGameplayTag StateTag, int32 MontageIndex, bool bRandomIndex = false);
|
|
virtual float PerformAttack(FGameplayTag AttackType, int32 AttackIndex, bool bRandomIndex = false);
|
|
virtual bool PerformCustomAction(FGameplayTag ActionTag, FGameplayTag StateTag, UAnimMontage* InMontage, float fMontagePlayRate, bool bAutoReset) override;
|
|
|
|
// Inherited via IGameplayTagAssetInterface
|
|
virtual void GetOwnedGameplayTags(FGameplayTagContainer& TagContainer) const override { TagContainer = OwnedGameplayTags; }
|
|
public:
|
|
void SetMovementSpeedMode(EMovementSpeedMode NewSpeedMode);
|
|
FORCEINLINE EMovementSpeedMode GetMovementSpeedMode() const { return MovementSpeedMode; }
|
|
void SetPotionUI(UUserWidget* potionUI);
|
|
|
|
protected:
|
|
//Input Funcs
|
|
void Move(const FInputActionValue& Value);
|
|
void Look(const FInputActionValue& Value);
|
|
void Jumping(const FInputActionValue& Value);
|
|
void Interact(const FInputActionValue& Value);
|
|
void ToggleCombatAction(const FInputActionValue& Value);
|
|
void LightAttack(const FInputActionValue& Value);
|
|
void LightChargeAttack(const FInputActionInstance& Instance);
|
|
void HeavyAttack(const FInputActionValue& Value);
|
|
void Dodge(const FInputActionValue& Value);
|
|
void ToggleWalk(const FInputActionValue& Value);
|
|
void StartSprint(const FInputActionValue& Value);
|
|
void StopSprint(const FInputActionValue& Value);
|
|
void ToggleLockOn(const FInputActionValue& Value);
|
|
void Blocking(const FInputActionValue& Value);
|
|
void StopBlocking(const FInputActionValue& Value);
|
|
void UseItem(const FInputActionValue& Value);
|
|
|
|
private://Delegate
|
|
void CharacterStateBegin(FGameplayTag CharState);
|
|
void CharacterStateEnd(FGameplayTag CharState);
|
|
void CharacterCurrentStatValueUpdated(EStats statType, float value);
|
|
|
|
void CharacterCombatToggled(bool IsCombatEnabled);
|
|
private:
|
|
void ToggleCombatEvent();
|
|
void AttackEvent();
|
|
void ChargeAttackEvent();
|
|
bool ResetChargeAttack();
|
|
void ApplyHitReactionPhysicsVelocity(float InitialSpeed);
|
|
void EnableRagdoll();
|
|
void DisableSprint();
|
|
void SprintStaminaCost();
|
|
void ApplyHitReaction(EDamageType InDamageType);
|
|
void ApplyImpactEffect(EDamageType InDamageType);
|
|
|
|
void ReceiveDamage(float Damage, const FPointDamageEvent* pointDamageEvent, const class UAttackDamageType* damageTypeClass, AController* eventInstigator);
|
|
void ReceiveDamage(float Damage, const FRadialDamageEvent* radialDamageEvent, const class UAttackDamageType* damageTypeClass, AController* eventInstigator);
|
|
|
|
//Timeline
|
|
void RotateToTarget();
|
|
void StopRotateToTarget();
|
|
UFUNCTION()
|
|
void RotateToTargetUpdate(float Value);
|
|
|
|
private:
|
|
void PerformDeath();
|
|
bool PerformHitStun();
|
|
bool PerformKnockdown();
|
|
bool PerformBlock();
|
|
|
|
protected: //Check Func
|
|
bool CanPerformToggleCombat();
|
|
bool CanPerformAttack();
|
|
bool CanPerformDodge();
|
|
bool CanJumping();
|
|
bool CanReceiveHitReaction();
|
|
bool CanPerformSprint();
|
|
bool CanPerformBlock();
|
|
bool CanUseItem();
|
|
FGameplayTag GetDesiredAttackType();
|
|
bool WasHitBlocked();
|
|
|
|
public:
|
|
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category="Components", meta=(AllowPrivateAccess="true"))
|
|
TObjectPtr<class UCombatComponent> CombatComponent;
|
|
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category="Components", meta=(AllowPrivateAccess="true"))
|
|
TObjectPtr<UStateManagerComponent> StateManagerComponent;
|
|
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category="Components", meta=(AllowPrivateAccess="true"))
|
|
TObjectPtr<UStatsComponent> StatsComponent;
|
|
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category="Components", meta=(AllowPrivateAccess="true"))
|
|
TObjectPtr<UTargetingComponent> TargetingComponent;
|
|
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category="Components", meta=(AllowPrivateAccess="true"))
|
|
TObjectPtr<class UEquipmentComponent> EquipmentComponent;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Hit", meta = (AllowPrivateAccess = "true"))
|
|
FName PelvisBoneName;
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Hit", meta = (AllowPrivateAccess = "true"))
|
|
TObjectPtr<class USoundBase> HitSound;
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Hit", meta = (AllowPrivateAccess = "true"))
|
|
TObjectPtr<class UNiagaraSystem> HitEmitter;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "MovementSpeed", meta = (AllowPrivateAccess = "true"))
|
|
EMovementSpeedMode MovementSpeedMode;
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "MovementSpeed", meta = (AllowPrivateAccess = "true"))
|
|
float WalkingSpeed;
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "MovementSpeed", meta = (AllowPrivateAccess = "true"))
|
|
float JoggingSpeed;
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "MovementSpeed", meta = (AllowPrivateAccess = "true"))
|
|
float SprintSpeed;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Montage", meta = (AllowPrivateAccess = "true"))
|
|
TObjectPtr<UAnimMontage> HitStunFrontMontage;
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Montage", meta = (AllowPrivateAccess = "true"))
|
|
TObjectPtr<UAnimMontage> HitStunBackMontage;
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Montage", meta = (AllowPrivateAccess = "true"))
|
|
TObjectPtr<UAnimMontage> KnockdownFrontMontage;
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Montage", meta = (AllowPrivateAccess = "true"))
|
|
TObjectPtr<UAnimMontage> KnockdownBackMontage;
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Montage|Death", meta = (AllowPrivateAccess = "true"))
|
|
TArray<TObjectPtr<UAnimMontage>> DeathAnimations;
|
|
|
|
TObjectPtr<class UUserWidget> PotionUI;
|
|
|
|
private: //Timeline
|
|
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Timeline", meta = (AllowPrivateAccess = "true"))
|
|
TObjectPtr<UTimelineComponent> RotateToTargetTimeLineComponent;
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Timeline", meta = (AllowPrivateAccess = "true"))
|
|
TObjectPtr<UCurveFloat> CurveFloatTimeline;
|
|
const float RotateToTargetInterpSpeed = 9.f;
|
|
|
|
private:
|
|
FTimerHandle StaminaTimerHandle;
|
|
|
|
private:
|
|
bool IsHeavyAttack;
|
|
float AttackHeldTime;
|
|
bool bAttackCharged;
|
|
bool bCanMove = true;
|
|
bool bHitFront;
|
|
bool bEnableIFrame;
|
|
bool bIsBlockPressed;
|
|
FHitResult LastHitInfo;
|
|
FGameplayTagContainer OwnedGameplayTags;
|
|
};
|