[박치영] Blocking 사전작업

main
PCYPC\pcy35 2023-11-13 21:06:59 +09:00
parent 835e265d42
commit 1af7482513
15 changed files with 105 additions and 23 deletions

View File

@ -46,7 +46,7 @@ ABossEnemy::ABossEnemy()
//Setting CombatComponent
//Setting others is Parents
CombatComponent->OnCombatToggled.AddUObject(this, &ABossEnemy::OnCombatToggled);
CombatComponent->OnCombatToggled.BindUObject(this, &ABossEnemy::OnCombatToggled);
}
void ABossEnemy::BeginPlay()

View File

@ -45,7 +45,7 @@ void ACombatAIController::OnPossess(APawn* InPawn)
MasterAI = AIpawn;
UCombatComponent* combatComponent = MasterAI->GetComponentByClass<UCombatComponent>();
combatComponent->OnCombatToggled.AddUObject(this, &ACombatAIController::OnCombatToggle);
combatComponent->OnCombatToggled.BindUObject(this, &ACombatAIController::OnCombatToggle);
RunBehaviorTree(MasterAI->GetBeHaviorTree());

View File

@ -44,7 +44,7 @@ AGruntlingEnemy::AGruntlingEnemy()
//Setting CombatComponent
//Setting others is Parents
CombatComponent->OnCombatToggled.AddUObject(this, &AGruntlingEnemy::OnCombatToggled);
CombatComponent->OnCombatToggled.BindUObject(this, &AGruntlingEnemy::OnCombatToggled);
}
void AGruntlingEnemy::BeginPlay()

View File

@ -44,7 +44,7 @@ AHeavyMobEnemy::AHeavyMobEnemy()
//Setting CombatComponent
//Setting others is Parents
CombatComponent->OnCombatToggled.AddUObject(this, &AHeavyMobEnemy::OnCombatToggled);
CombatComponent->OnCombatToggled.BindUObject(this, &AHeavyMobEnemy::OnCombatToggled);
}
void AHeavyMobEnemy::BeginPlay()

View File

@ -38,7 +38,7 @@ AMobEnemy::AMobEnemy()
//Setting CombatComponent
//Setting others is Parents
CombatComponent->OnCombatToggled.AddUObject(this, &AMobEnemy::OnCombatToggled);
CombatComponent->OnCombatToggled.BindUObject(this, &AMobEnemy::OnCombatToggled);
}
void AMobEnemy::BeginPlay()

View File

@ -0,0 +1,5 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "Actor/BaseShield.h"

View File

@ -0,0 +1,17 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Actor/BaseWeapon.h"
#include "BaseShield.generated.h"
/**
*
*/
UCLASS()
class D1_API ABaseShield : public ABaseWeapon
{
GENERATED_BODY()
};

View File

@ -51,7 +51,7 @@ void ABaseWeapon::OnEquipped()
if (!owner)
return;
CombatComponent = owner->GetComponentByClass<UCombatComponent>();
CombatComponent->OnCombatToggled.AddUObject(this, &ABaseWeapon::ToggleWeaponCombat);
CombatComponent->OnCombatToggled.BindUObject(this, &ABaseWeapon::ToggleWeaponCombat);
OwnerStateManager = owner->GetComponentByClass<UStateManagerComponent>();

View File

@ -20,7 +20,7 @@ void UCombatAnimInstance::NativeInitializeAnimation()
UCombatComponent* CombatComponent = Character->GetComponentByClass<UCombatComponent>();
ensure(CombatComponent);
if(IsValid(CombatComponent))
CombatComponent->OnCombatToggled.AddUObject(this, &UCombatAnimInstance::UpdateCombatEnabled);
CombatComponent->OnCombatToggled.BindUObject(this, &UCombatAnimInstance::UpdateCombatEnabled);
}
}

View File

@ -69,7 +69,7 @@ ACombatPlayerCharacter::ACombatPlayerCharacter()
// Setting CombatComponent
CombatComponent = CreateDefaultSubobject<UCombatComponent>(TEXT("CombatComponent"));
CombatComponent->OnCombatToggled.AddUObject(this, &ACombatPlayerCharacter::CharacterCombatToggled);
CombatComponent->OnCombatToggled.BindUObject(this, &ACombatPlayerCharacter::CharacterCombatToggled);
// Setting StateManagerComponent
StateManagerComponent = CreateDefaultSubobject<UStateManagerComponent>(TEXT("StateManagerComponent"));
@ -246,6 +246,9 @@ void ACombatPlayerCharacter::SetupPlayerInputComponent(class UInputComponent* Pl
//ToggleLockOn
EnhancedInputComponent->BindAction(ToggleLockOnAction, ETriggerEvent::Started, this, &ACombatPlayerCharacter::ToggleLockOn);
//Block
EnhancedInputComponent->BindAction(ToggleLockOnAction, ETriggerEvent::Started, this, &ACombatPlayerCharacter::ToggleLockOn);
}
}
@ -533,6 +536,18 @@ void ACombatPlayerCharacter::ToggleLockOn(const FInputActionValue& Value)
TargetingComponent->ToggleLockOn();
}
void ACombatPlayerCharacter::Blocking(const FInputActionValue& Value)
{
if(CanPerformBlock())
{
CombatComponent->SetBlockingState(true);
}
else
{
CombatComponent->SetBlockingState(false);
}
}
void ACombatPlayerCharacter::CharacterStateBegin(FGameplayTag CharState)
{
if (FGameplayTag::EmptyTag == CharState)
@ -918,6 +933,22 @@ bool ACombatPlayerCharacter::CanPerformSprint()
return (FMath::IsNearlyEqual(GetVelocity().Length(), 0.f)) == false;
}
bool ACombatPlayerCharacter::CanPerformBlock()
{
bool ReturnValue = true;
FGameplayTagContainer inputContainer;
inputContainer.AddTag(FCombatGameplayTags::Get().Character_State_Attacking);
inputContainer.AddTag(FCombatGameplayTags::Get().Character_State_Dodging);
inputContainer.AddTag(FCombatGameplayTags::Get().Character_State_Dead);
inputContainer.AddTag(FCombatGameplayTags::Get().Character_State_Disable);
inputContainer.AddTag(FCombatGameplayTags::Get().Character_State_GeneralActionState);
ReturnValue &= !StateManagerComponent->IsCurrentStateEqualToAny(inputContainer);
return ReturnValue;
}
FGameplayTag ACombatPlayerCharacter::GetDesiredAttackType()
{
if (GetCharacterMovement()->IsFalling())

View File

@ -16,6 +16,9 @@
#include "CombatPlayerCharacter.generated.h"
class UInputMappingContext;
class UInputAction;
UCLASS(config=Game)
class ACombatPlayerCharacter : public ACharacter, public ICombatInterface, public IGameplayTagAssetInterface
{
@ -31,45 +34,48 @@ class ACombatPlayerCharacter : public ACharacter, public ICombatInterface, publi
/** MappingContext */
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
class UInputMappingContext* DefaultMappingContext;
UInputMappingContext* DefaultMappingContext;
/** Jump Input Action */
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
class UInputAction* JumpAction;
UInputAction* JumpAction;
/** Move Input Action */
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
class UInputAction* MoveAction;
UInputAction* MoveAction;
/** Look Input Action */
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
class UInputAction* LookAction;
UInputAction* LookAction;
/* Interact Input Action */
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
class UInputAction* InteractAction;
UInputAction* InteractAction;
/* ToggleCombat Input Action */
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
class UInputAction* ToggleCombatInputAction;
UInputAction* ToggleCombatInputAction;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
class UInputAction* LightAttackAction;
UInputAction* LightAttackAction;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
class UInputAction* HeavyAttackAction;
UInputAction* HeavyAttackAction;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
class UInputAction* DodgeAction;
UInputAction* DodgeAction;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
class UInputAction* ToggleWalkAction;
UInputAction* ToggleWalkAction;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
class UInputAction* SprintAction;
UInputAction* SprintAction;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
class UInputAction* ToggleLockOnAction;
UInputAction* ToggleLockOnAction;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
UInputAction* BlockAction;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Input, meta = (AllowPrivateAccess = "true"))
float ChargeAttackTime;
@ -144,6 +150,7 @@ protected:
void StartSprint(const FInputActionValue& Value);
void StopSprint(const FInputActionValue& Value);
void ToggleLockOn(const FInputActionValue& Value);
void Blocking(const FInputActionValue& Value);
private://Delegate
void CharacterStateBegin(FGameplayTag CharState);
@ -184,6 +191,7 @@ protected: //Check Func
bool CanJumping();
bool CanReceiveHitReaction();
bool CanPerformSprint();
bool CanPerformBlock();
FGameplayTag GetDesiredAttackType();
public:

View File

@ -19,7 +19,7 @@ void UCombatComponent::SetCombatEnabled(bool bInputCombat)
{
bCombatEnabled = bInputCombat;
OnCombatToggled.Broadcast(bInputCombat);
OnCombatToggled.Execute(bInputCombat);
// ACharacter* character = Cast<ACharacter>(GetOwner());
// if (character)
@ -52,3 +52,12 @@ ABaseWeapon* UCombatComponent::GetMainWeapon() const
return MainWeapon;
}
void UCombatComponent::SetBlockingState(bool enableBlocking)
{
if(enableBlocking != bIsBlocking)
{
bIsBlocking = enableBlocking;
}
onBlockingSet.Execute(bIsBlocking); // TODO : 이거 맞나?
}

View File

@ -6,7 +6,8 @@
#include "Components/ActorComponent.h"
#include "CombatComponent.generated.h"
DECLARE_MULTICAST_DELEGATE_OneParam(FOnCombatToggled, bool);
DECLARE_DELEGATE_OneParam(FOnCombatToggled, bool);
DECLARE_DELEGATE_OneParam(FOnBlockingSet, bool);
class ABaseWeapon;
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
@ -36,6 +37,10 @@ public:
FORCEINLINE void SetAttackCount(int32 count) { AttackCount = count; }
FORCEINLINE int32 GetAttackCount() { return AttackCount; }
void SetBlockingState(bool enableBlocking);
FORCEINLINE void SetShieldWeapon(ABaseWeapon* inShield) { EquippedShield = inShield; }
FORCEINLINE ABaseWeapon* GetShieldWeapon() { return EquippedShield; }
private:
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, meta=(AllowPrivateAccess="true"))
TObjectPtr<ABaseWeapon> MainWeapon;
@ -49,6 +54,13 @@ private:
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, meta=(AllowPrivateAccess="true"))
int32 AttackCount;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, meta=(AllowPrivateAccess="true"))
TObjectPtr<ABaseWeapon> EquippedShield;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, meta=(AllowPrivateAccess="true"))
bool bIsBlocking;
public: //Delegate
FOnCombatToggled OnCombatToggled;
FOnBlockingSet onBlockingSet;
};