diff --git a/Content/CombatSystem/Input/Actions/IA_Block.uasset b/Content/CombatSystem/Input/Actions/IA_Block.uasset new file mode 100644 index 00000000..e8db4a70 Binary files /dev/null and b/Content/CombatSystem/Input/Actions/IA_Block.uasset differ diff --git a/Content/CombatSystem/Input/IMC_Default.uasset b/Content/CombatSystem/Input/IMC_Default.uasset index 7e0d2264..9480ed8d 100644 Binary files a/Content/CombatSystem/Input/IMC_Default.uasset and b/Content/CombatSystem/Input/IMC_Default.uasset differ diff --git a/Source/D1/AI/BossEnemy.cpp b/Source/D1/AI/BossEnemy.cpp index 75d552af..6dae1b2f 100644 --- a/Source/D1/AI/BossEnemy.cpp +++ b/Source/D1/AI/BossEnemy.cpp @@ -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() diff --git a/Source/D1/AI/CombatAIController.cpp b/Source/D1/AI/CombatAIController.cpp index 0ecd75a5..0ad601fe 100644 --- a/Source/D1/AI/CombatAIController.cpp +++ b/Source/D1/AI/CombatAIController.cpp @@ -45,7 +45,7 @@ void ACombatAIController::OnPossess(APawn* InPawn) MasterAI = AIpawn; UCombatComponent* combatComponent = MasterAI->GetComponentByClass(); - combatComponent->OnCombatToggled.AddUObject(this, &ACombatAIController::OnCombatToggle); + combatComponent->OnCombatToggled.BindUObject(this, &ACombatAIController::OnCombatToggle); RunBehaviorTree(MasterAI->GetBeHaviorTree()); diff --git a/Source/D1/AI/GruntlingEnemy.cpp b/Source/D1/AI/GruntlingEnemy.cpp index 9ef06868..1169983e 100644 --- a/Source/D1/AI/GruntlingEnemy.cpp +++ b/Source/D1/AI/GruntlingEnemy.cpp @@ -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() diff --git a/Source/D1/AI/HeavyMobEnemy.cpp b/Source/D1/AI/HeavyMobEnemy.cpp index 868ebc70..5f70c8aa 100644 --- a/Source/D1/AI/HeavyMobEnemy.cpp +++ b/Source/D1/AI/HeavyMobEnemy.cpp @@ -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() diff --git a/Source/D1/AI/MobEnemy.cpp b/Source/D1/AI/MobEnemy.cpp index 2278e8b7..faea9711 100644 --- a/Source/D1/AI/MobEnemy.cpp +++ b/Source/D1/AI/MobEnemy.cpp @@ -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() diff --git a/Source/D1/Actor/BaseShield.cpp b/Source/D1/Actor/BaseShield.cpp new file mode 100644 index 00000000..7414d334 --- /dev/null +++ b/Source/D1/Actor/BaseShield.cpp @@ -0,0 +1,5 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "Actor/BaseShield.h" + diff --git a/Source/D1/Actor/BaseShield.h b/Source/D1/Actor/BaseShield.h new file mode 100644 index 00000000..3895a216 --- /dev/null +++ b/Source/D1/Actor/BaseShield.h @@ -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() + +}; diff --git a/Source/D1/Actor/BaseWeapon.cpp b/Source/D1/Actor/BaseWeapon.cpp index 0d6cd9b8..4839c578 100644 --- a/Source/D1/Actor/BaseWeapon.cpp +++ b/Source/D1/Actor/BaseWeapon.cpp @@ -51,7 +51,7 @@ void ABaseWeapon::OnEquipped() if (!owner) return; CombatComponent = owner->GetComponentByClass(); - CombatComponent->OnCombatToggled.AddUObject(this, &ABaseWeapon::ToggleWeaponCombat); + CombatComponent->OnCombatToggled.BindUObject(this, &ABaseWeapon::ToggleWeaponCombat); OwnerStateManager = owner->GetComponentByClass(); diff --git a/Source/D1/Animation/CombatAnimInstance.cpp b/Source/D1/Animation/CombatAnimInstance.cpp index eff29d5f..40d96355 100644 --- a/Source/D1/Animation/CombatAnimInstance.cpp +++ b/Source/D1/Animation/CombatAnimInstance.cpp @@ -20,7 +20,7 @@ void UCombatAnimInstance::NativeInitializeAnimation() UCombatComponent* CombatComponent = Character->GetComponentByClass(); ensure(CombatComponent); if(IsValid(CombatComponent)) - CombatComponent->OnCombatToggled.AddUObject(this, &UCombatAnimInstance::UpdateCombatEnabled); + CombatComponent->OnCombatToggled.BindUObject(this, &UCombatAnimInstance::UpdateCombatEnabled); } } diff --git a/Source/D1/CombatPlayerCharacter.cpp b/Source/D1/CombatPlayerCharacter.cpp index 39f0645d..99f7fe80 100644 --- a/Source/D1/CombatPlayerCharacter.cpp +++ b/Source/D1/CombatPlayerCharacter.cpp @@ -69,7 +69,7 @@ ACombatPlayerCharacter::ACombatPlayerCharacter() // Setting CombatComponent CombatComponent = CreateDefaultSubobject(TEXT("CombatComponent")); - CombatComponent->OnCombatToggled.AddUObject(this, &ACombatPlayerCharacter::CharacterCombatToggled); + CombatComponent->OnCombatToggled.BindUObject(this, &ACombatPlayerCharacter::CharacterCombatToggled); // Setting StateManagerComponent StateManagerComponent = CreateDefaultSubobject(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()) diff --git a/Source/D1/CombatPlayerCharacter.h b/Source/D1/CombatPlayerCharacter.h index ee1c508b..3d7b111b 100644 --- a/Source/D1/CombatPlayerCharacter.h +++ b/Source/D1/CombatPlayerCharacter.h @@ -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: diff --git a/Source/D1/Components/CombatComponent.cpp b/Source/D1/Components/CombatComponent.cpp index 9b4fba61..f7b2285e 100644 --- a/Source/D1/Components/CombatComponent.cpp +++ b/Source/D1/Components/CombatComponent.cpp @@ -19,7 +19,7 @@ void UCombatComponent::SetCombatEnabled(bool bInputCombat) { bCombatEnabled = bInputCombat; - OnCombatToggled.Broadcast(bInputCombat); + OnCombatToggled.Execute(bInputCombat); // ACharacter* character = Cast(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 : 이거 맞나? +} + diff --git a/Source/D1/Components/CombatComponent.h b/Source/D1/Components/CombatComponent.h index fda44bc9..9e3b2e2b 100644 --- a/Source/D1/Components/CombatComponent.h +++ b/Source/D1/Components/CombatComponent.h @@ -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 MainWeapon; @@ -45,10 +50,17 @@ private: UPROPERTY(VisibleAnywhere, BlueprintReadWrite, meta=(AllowPrivateAccess="true")) bool bIsAttackSaved; - + UPROPERTY(VisibleAnywhere, BlueprintReadWrite, meta=(AllowPrivateAccess="true")) int32 AttackCount; + UPROPERTY(VisibleAnywhere, BlueprintReadWrite, meta=(AllowPrivateAccess="true")) + TObjectPtr EquippedShield; + + UPROPERTY(VisibleAnywhere, BlueprintReadWrite, meta=(AllowPrivateAccess="true")) + bool bIsBlocking; + public: //Delegate FOnCombatToggled OnCombatToggled; + FOnBlockingSet onBlockingSet; };