diff --git a/Config/DefaultEngine.ini b/Config/DefaultEngine.ini index 694bbe3a..a767fe5a 100644 --- a/Config/DefaultEngine.ini +++ b/Config/DefaultEngine.ini @@ -107,6 +107,8 @@ ManualIPAddress= +Profiles=(Name="Vehicle",CollisionEnabled=QueryAndPhysics,bCanModify=False,ObjectTypeName="Vehicle",CustomResponses=,HelpMessage="Vehicle object that blocks Vehicle, WorldStatic, and WorldDynamic. All other channels will be set to default.") +Profiles=(Name="UI",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="WorldStatic",Response=ECR_Overlap),(Channel="Pawn",Response=ECR_Overlap),(Channel="Visibility"),(Channel="WorldDynamic",Response=ECR_Overlap),(Channel="Camera",Response=ECR_Overlap),(Channel="PhysicsBody",Response=ECR_Overlap),(Channel="Vehicle",Response=ECR_Overlap),(Channel="Destructible",Response=ECR_Overlap)),HelpMessage="WorldStatic object that overlaps all actors by default. All new custom channels will use its own default response. ") +DefaultChannelResponses=(Channel=ECC_GameTraceChannel1,DefaultResponse=ECR_Block,bTraceType=False,bStaticObject=False,Name="Interactable") ++EditProfiles=(Name="Pawn",CustomResponses=((Channel="Camera",Response=ECR_Ignore))) ++EditProfiles=(Name="CharacterMesh",CustomResponses=((Channel="Camera",Response=ECR_Ignore))) -ProfileRedirects=(OldName="BlockingVolume",NewName="InvisibleWall") -ProfileRedirects=(OldName="InterpActor",NewName="IgnoreOnlyPawn") -ProfileRedirects=(OldName="StaticMeshComponent",NewName="BlockAllDynamic") @@ -126,18 +128,21 @@ ManualIPAddress= +CollisionChannelRedirects=(OldName="VehicleMovement",NewName="Vehicle") +CollisionChannelRedirects=(OldName="PawnMovement",NewName="Pawn") - [CoreRedirects] +FunctionRedirects=(OldName="/Script/D1.CollisionComponent.EnableCollision",NewName="/Script/D1.CollisionComponent.ActivateCollision") +FunctionRedirects=(OldName="/Script/D1.CollisionComponent.DisableCollision",NewName="/Script/D1.CollisionComponent.DeactivateCollision") +PropertyRedirects=(OldName="/Script/D1.BaseDualWeapon.RightFoot",NewName="/Script/D1.BaseDualWeapon.RightFootCollisionComponent") -+PropertyRedirects=(OldName="/Script/D1.CombatCharacter.ToogleLockOnAction",NewName="/Script/D1.CombatCharacter.ToggleLockOnAction") ++PropertyRedirects=(OldName="/Script/D1.CombatCharacter.ToogleLockOnAction",NewName="/Script/D1.CombatPlayerCharacter.ToggleLockOnAction") +ClassRedirects=(OldName="/Script/D1.UI_LockOnComponent",NewName="/Script/D1.LockOnWidgetComponent") +PropertyRedirects=(OldName="/Script/D1.MasterAI.TargetingWidget",NewName="/Script/D1.MasterAI.TargetingWidgetComponent") +PropertyRedirects=(OldName="/Script/D1.HumanoidEnemy.HealthBar",NewName="/Script/D1.HumanoidEnemy.HealthBarComponent") +PropertyRedirects=(OldName="/Script/D1.T_FindNextPatrolPoint.TargetLocation",NewName="/Script/D1.T_FindNextPatrolPoint.BlackboardKey_TargetLocation") +PropertyRedirects=(OldName="/Script/D1.T_FindNextPatrolPoint.PatrolIndex",NewName="/Script/D1.T_FindNextPatrolPoint.BlackboardKey_PatrolIndex") -+PropertyRedirects=(OldName="/Script/D1.CombatCharacter.ToggleCombatAction",NewName="/Script/D1.CombatCharacter.ToggleCombatInputAction") ++PropertyRedirects=(OldName="/Script/D1.CombatCharacter.ToggleCombatAction",NewName="/Script/D1.CombatPlayerCharacter.ToggleCombatInputAction") +FunctionRedirects=(OldName="/Script/D1.BaseWeapon.ToggleCombat",NewName="/Script/D1.BaseWeapon.ToggleWeaponCombat") +PropertyRedirects=(OldName="/Script/D1.S_UpdateBehavior.AttackingRange",NewName="/Script/D1.S_UpdateBehavior.TotalAttackingDistance") -+PropertyRedirects=(OldName="/Script/D1.S_UpdateBehavior.TotalAttackingDistanceRange",NewName="/Script/D1.S_UpdateBehavior.TotalAttackingDistance") \ No newline at end of file ++PropertyRedirects=(OldName="/Script/D1.S_UpdateBehavior.TotalAttackingDistanceRange",NewName="/Script/D1.S_UpdateBehavior.TotalAttackingDistance") ++ClassRedirects=(OldName="/Script/D1.CombatCharacter",NewName="/Script/D1.CombatPlayerCharacter") ++FunctionRedirects=(OldName="/Script/D1.ICombatInterface.PerformCombatAction",NewName="/Script/D1.ICombatInterface.PerformAction") ++FunctionRedirects=(OldName="/Script/D1.ICombatInterface.PerformCombatAttack",NewName="/Script/D1.ICombatInterface.PerformAttack") + diff --git a/Content/CombatSystem/Blueprints/Animnotifies/ToggleCombat_AN.uasset b/Content/CombatSystem/Blueprints/Animnotifies/ToggleCombat_AN.uasset index 9cab9dea..87cc86bd 100644 Binary files a/Content/CombatSystem/Blueprints/Animnotifies/ToggleCombat_AN.uasset and b/Content/CombatSystem/Blueprints/Animnotifies/ToggleCombat_AN.uasset differ diff --git a/Content/CombatSystem/Blueprints/BP_CombatCharacter.uasset b/Content/CombatSystem/Blueprints/BP_CombatCharacter.uasset index fbdf8366..1f2aeae1 100644 Binary files a/Content/CombatSystem/Blueprints/BP_CombatCharacter.uasset and b/Content/CombatSystem/Blueprints/BP_CombatCharacter.uasset differ diff --git a/Source/D1/AI/BehaviorTreeNodes/T_PerformAction.cpp b/Source/D1/AI/BehaviorTreeNodes/T_PerformAction.cpp index 841b65f1..3cfeb6e3 100644 --- a/Source/D1/AI/BehaviorTreeNodes/T_PerformAction.cpp +++ b/Source/D1/AI/BehaviorTreeNodes/T_PerformAction.cpp @@ -19,7 +19,7 @@ EBTNodeResult::Type UT_PerformAction::ExecuteTask(UBehaviorTreeComponent& OwnerC if(!CombatInterface) return EBTNodeResult::Failed; - float actionDuration = CombatInterface->PerformCombatAction(ActionTag, StateTag, MontageIndex, RandomIndex); + float actionDuration = CombatInterface->PerformAction(ActionTag, StateTag, MontageIndex, RandomIndex); actionDuration += ActionDurationModifier; FTimerHandle ActionTimer; GetWorld()->GetTimerManager().SetTimer(ActionTimer, FTimerDelegate::CreateLambda([&]() diff --git a/Source/D1/AI/BehaviorTreeNodes/T_PerformAttack.cpp b/Source/D1/AI/BehaviorTreeNodes/T_PerformAttack.cpp index 7e3d9375..2c92d300 100644 --- a/Source/D1/AI/BehaviorTreeNodes/T_PerformAttack.cpp +++ b/Source/D1/AI/BehaviorTreeNodes/T_PerformAttack.cpp @@ -19,7 +19,7 @@ EBTNodeResult::Type UT_PerformAttack::ExecuteTask(UBehaviorTreeComponent& OwnerC if(!CombatInterface) return EBTNodeResult::Failed; - float actionDuration = CombatInterface->PerformCombatAttack(AttackTypeTag, AttackIndex, RandomIndex); + float actionDuration = CombatInterface->PerformAttack(AttackTypeTag, AttackIndex, RandomIndex); actionDuration += ActionDurationModifier; FTimerHandle ActionTimer; GetWorld()->GetTimerManager().SetTimer(ActionTimer, FTimerDelegate::CreateLambda([&]() diff --git a/Source/D1/AI/BossEnemy.cpp b/Source/D1/AI/BossEnemy.cpp index 9ccb13b5..8eab5019 100644 --- a/Source/D1/AI/BossEnemy.cpp +++ b/Source/D1/AI/BossEnemy.cpp @@ -9,7 +9,6 @@ #include "Components/CombatComponent.h" #include "DamageType/AttackDamageType.h" #include "Kismet/GameplayStatics.h" -#include "UI/UI_BossHealth.h" #include "UI/UI_HealthBar.h" ABossEnemy::ABossEnemy() diff --git a/Source/D1/AI/BossEnemy.h b/Source/D1/AI/BossEnemy.h index 5fb0c951..372e6c19 100644 --- a/Source/D1/AI/BossEnemy.h +++ b/Source/D1/AI/BossEnemy.h @@ -48,9 +48,5 @@ private: UPROPERTY(EditAnywhere, Blueprintable, Category="Initialization", meta=(AllowPrivateAccess="true")) FName WeaponHandSocketName; UPROPERTY(VisibleAnywhere, BlueprintReadWrite, meta=(AllowPrivateAccess="true")) - TObjectPtr BossHealthWidget; - UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(AllowPrivateAccess="true")) - TSubclassOf BossHealthClass; - - + TObjectPtr BossHealthWidget; }; diff --git a/Source/D1/AI/MasterAI.cpp b/Source/D1/AI/MasterAI.cpp index cc3b750b..3e1e7c4b 100644 --- a/Source/D1/AI/MasterAI.cpp +++ b/Source/D1/AI/MasterAI.cpp @@ -195,14 +195,7 @@ void AMasterAI::DeactivateCollision_Implementation(ECollisionPart CollisionPart) MainWeaponCollisionComponent->DeactivateCollision(); } -void AMasterAI::ToggleCombat_Implementation() -{ - if (!IsValid(CombatComponent)) - return; - CombatComponent->SetCombatEnabled(!CombatComponent->GetCombatEnabled()); -} - -float AMasterAI::PerformCombatAction(FGameplayTag ActionTag, FGameplayTag StateTag, int32 MontageIndex, bool bRandomIndex) +float AMasterAI::PerformAction(FGameplayTag ActionTag, FGameplayTag StateTag, int32 MontageIndex, bool bRandomIndex) { TArray montages = GetActionMontage(ActionTag); int32 montageIdx = MontageIndex; @@ -232,7 +225,7 @@ float AMasterAI::PerformCombatAction(FGameplayTag ActionTag, FGameplayTag StateT return actionDuration; } -float AMasterAI::PerformCombatAttack(FGameplayTag AttackType, int32 AttackIndex, bool bRandomIndex) +float AMasterAI::PerformAttack(FGameplayTag AttackType, int32 AttackIndex, bool bRandomIndex) { TArray montages = GetActionMontage(AttackType); int32 attackIdx = AttackIndex; @@ -353,7 +346,7 @@ void AMasterAI::AttackEvent() return; if (CombatComponent->GetCombatEnabled()) - PerformCombatAttack(GetDesiredAttackType(), CombatComponent->GetAttackCount(), false); + PerformAttack(GetDesiredAttackType(), CombatComponent->GetAttackCount(), false); } void AMasterAI::ApplyHitReactionPhysicsVelocity(float InitialSpeed) diff --git a/Source/D1/AI/MasterAI.h b/Source/D1/AI/MasterAI.h index edd12168..a4f1ab26 100644 --- a/Source/D1/AI/MasterAI.h +++ b/Source/D1/AI/MasterAI.h @@ -63,13 +63,10 @@ public: UFUNCTION(BlueprintCallable, BlueprintNativeEvent) void DeactivateCollision(ECollisionPart CollisionPart); virtual void DeactivateCollision_Implementation(ECollisionPart CollisionPart) override; - UFUNCTION(BlueprintCallable, BlueprintNativeEvent) - void ToggleCombat(); - virtual void ToggleCombat_Implementation() override; virtual EMovementSpeedMode GetCombatMovementSpeedMode() override { return GetMovementSpeedMode(); } - virtual float PerformCombatAction(FGameplayTag ActionTag, FGameplayTag StateTag, int32 MontageIndex, bool bRandomIndex); - virtual float PerformCombatAttack(FGameplayTag AttackType, int32 AttackIndex, bool bRandomIndex); + virtual float PerformAction(FGameplayTag ActionTag, FGameplayTag StateTag, int32 MontageIndex, bool bRandomIndex); + virtual float PerformAttack(FGameplayTag AttackType, int32 AttackIndex, bool bRandomIndex); // Inherited via ITargetingInterface virtual bool CanBeTargeted() override; diff --git a/Source/D1/Actor/BaseWeapon.cpp b/Source/D1/Actor/BaseWeapon.cpp index 47a5695f..0d6cd9b8 100644 --- a/Source/D1/Actor/BaseWeapon.cpp +++ b/Source/D1/Actor/BaseWeapon.cpp @@ -51,6 +51,8 @@ void ABaseWeapon::OnEquipped() if (!owner) return; CombatComponent = owner->GetComponentByClass(); + CombatComponent->OnCombatToggled.AddUObject(this, &ABaseWeapon::ToggleWeaponCombat); + OwnerStateManager = owner->GetComponentByClass(); if (CombatComponent->GetCombatEnabled()) @@ -117,10 +119,6 @@ void ABaseWeapon::DeactivateCollision(ECollisionPart CollsionPart) void ABaseWeapon::ToggleWeaponCombat(bool EnableCombat) { - if(!CombatComponent) - return; - - CombatComponent->SetCombatEnabled(EnableCombat); if(EnableCombat) AttachActor(HandSocketName); else diff --git a/Source/D1/CombatCharacter.cpp b/Source/D1/CombatPlayerCharacter.cpp similarity index 69% rename from Source/D1/CombatCharacter.cpp rename to Source/D1/CombatPlayerCharacter.cpp index 41b01894..11c89028 100644 --- a/Source/D1/CombatCharacter.cpp +++ b/Source/D1/CombatPlayerCharacter.cpp @@ -1,6 +1,6 @@ // Copyright Epic Games, Inc. All Rights Reserved. -#include "CombatCharacter.h" +#include "CombatPlayerCharacter.h" #include "Camera/CameraComponent.h" #include "Components/CapsuleComponent.h" #include "Components/InputComponent.h" @@ -16,7 +16,6 @@ #include "Definitions/CombatGameplayTags.h" #include "Engine/DamageEvents.h" #include "NiagaraFunctionLibrary.h" -#include "NiagaraComponent.h" #include "DamageType/AttackDamageType.h" #include "Kismet/KismetSystemLibrary.h" #include "Kismet/KismetMathLibrary.h" @@ -25,7 +24,7 @@ ////////////////////////////////////////////////////////////////////////// // ACombatCharacter -ACombatCharacter::ACombatCharacter() +ACombatPlayerCharacter::ACombatPlayerCharacter() { // Set size for collision capsule GetCapsuleComponent()->InitCapsuleSize(42.f, 96.0f); @@ -70,19 +69,24 @@ ACombatCharacter::ACombatCharacter() // Setting CombatComponent CombatComponent = CreateDefaultSubobject(TEXT("CombatComponent")); - CombatComponent->OnCombatToggled.AddUObject(this, &ACombatCharacter::CharacterCombatToggled); + CombatComponent->OnCombatToggled.AddUObject(this, &ACombatPlayerCharacter::CharacterCombatToggled); // Setting StateManagerComponent StateManagerComponent = CreateDefaultSubobject(TEXT("StateManagerComponent")); - StateManagerComponent->OnStateBegin.AddUObject(this, &ACombatCharacter::CharacterStateBegin); - StateManagerComponent->OnStateEnd.AddUObject(this, &ACombatCharacter::CharacterStateEnd); - StateManagerComponent->OnActionBegin.AddUObject(this, &ACombatCharacter::CharacterActionBegin); - StateManagerComponent->OnActionEnd.AddUObject(this, &ACombatCharacter::CharacterActionEnd); + StateManagerComponent->OnStateBegin.AddUObject(this, &ACombatPlayerCharacter::CharacterStateBegin); + StateManagerComponent->OnStateEnd.AddUObject(this, &ACombatPlayerCharacter::CharacterStateEnd); // Setting StatsComponent StatsComponent = CreateDefaultSubobject(TEXT("StatsComponent")); - StatsComponent->OnCurrentStatValueUpdated.AddUObject(this, &ACombatCharacter::CharacterCurrentStatValueUpdated); - + StatsComponent->OnCurrentStatValueUpdated.AddUObject(this, &ACombatPlayerCharacter::CharacterCurrentStatValueUpdated); + StatsComponent->SetBaseStatValue(EStats::Health, 100.f); + StatsComponent->SetMaxStatValue(EStats::Health, 100.f); + StatsComponent->SetBaseStatValue(EStats::Stamina, 100.f); + StatsComponent->SetMaxStatValue(EStats::Stamina, 100.f); + StatsComponent->SetBaseStatValue(EStats::Armor, 0.f); + StatsComponent->SetMaxStatValue(EStats::Armor, 100.f); + StatsComponent->InitializeStats(); + //Setting TargetComponent TargetingComponent = CreateDefaultSubobject(TEXT("TargetingComponent")); @@ -100,7 +104,7 @@ ACombatCharacter::ACombatCharacter() } -void ACombatCharacter::BeginPlay() +void ACombatPlayerCharacter::BeginPlay() { // Call the base class Super::BeginPlay(); @@ -121,11 +125,9 @@ void ACombatCharacter::BeginPlay() ABaseEquippable* SpawnItem = Cast(GetWorld()->SpawnActor(Weapon, &GetActorTransform(), spawnParam)); if (SpawnItem) SpawnItem->OnEquipped(); - - StatsComponent->InitializeStats(); } -float ACombatCharacter::TakeDamage(float Damage, FDamageEvent const& DamageEvent, AController* EventInstigator, AActor* DamageCauser) +float ACombatPlayerCharacter::TakeDamage(float Damage, FDamageEvent const& DamageEvent, AController* EventInstigator, AActor* DamageCauser) { float fDamage = Super::TakeDamage(Damage, DamageEvent, EventInstigator, DamageCauser); @@ -153,7 +155,7 @@ float ACombatCharacter::TakeDamage(float Damage, FDamageEvent const& DamageEvent return fDamage; } -void ACombatCharacter::ContinueAttack_Implementation() +void ACombatPlayerCharacter::ContinueAttack_Implementation() { if (CombatComponent->GetIsAttackSaved()) { @@ -164,19 +166,19 @@ void ACombatCharacter::ContinueAttack_Implementation() } } -void ACombatCharacter::ResetAttack_Implementation() +void ACombatPlayerCharacter::ResetAttack_Implementation() { CombatComponent->ResetAttack(); } -void ACombatCharacter::ResetCombat_Implementation() +void ACombatPlayerCharacter::ResetCombat_Implementation() { CombatComponent->ResetAttack(); StateManagerComponent->ResetState(); StateManagerComponent->SetCurrentAction(FGameplayTag::EmptyTag); } -FRotator ACombatCharacter::GetDesiredRotation_Implementation() +FRotator ACombatPlayerCharacter::GetDesiredRotation_Implementation() { FVector InputVector = GetCharacterMovement()->GetLastInputVector(); if (InputVector.Equals(FVector(0, 0, 0), 0.001f)) @@ -185,7 +187,7 @@ FRotator ACombatCharacter::GetDesiredRotation_Implementation() return UKismetMathLibrary::MakeRotFromX(GetLastMovementInputVector()); } -bool ACombatCharacter::CanReceiveDamage_Implementation() +bool ACombatPlayerCharacter::CanReceiveDamage_Implementation() { bool result; result = (StateManagerComponent->GetCurrentState() != FCombatGameplayTags::Get().Character_State_Dead); @@ -195,78 +197,70 @@ bool ACombatCharacter::CanReceiveDamage_Implementation() ////////////////////////////////////////////////////////////////////////// // Input -void ACombatCharacter::SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) +void ACombatPlayerCharacter::SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) { // Set up action bindings if (UEnhancedInputComponent* EnhancedInputComponent = CastChecked(PlayerInputComponent)) { //Jumping - EnhancedInputComponent->BindAction(JumpAction, ETriggerEvent::Triggered, this, &ACombatCharacter::Jumping); + EnhancedInputComponent->BindAction(JumpAction, ETriggerEvent::Triggered, this, &ACombatPlayerCharacter::Jumping); EnhancedInputComponent->BindAction(JumpAction, ETriggerEvent::Completed, this, &ACharacter::StopJumping); //Moving - EnhancedInputComponent->BindAction(MoveAction, ETriggerEvent::Triggered, this, &ACombatCharacter::Move); + EnhancedInputComponent->BindAction(MoveAction, ETriggerEvent::Triggered, this, &ACombatPlayerCharacter::Move); //Looking - EnhancedInputComponent->BindAction(LookAction, ETriggerEvent::Triggered, this, &ACombatCharacter::Look); + EnhancedInputComponent->BindAction(LookAction, ETriggerEvent::Triggered, this, &ACombatPlayerCharacter::Look); //Interact - EnhancedInputComponent->BindAction(InteractAction, ETriggerEvent::Started, this, &ACombatCharacter::Interact); + EnhancedInputComponent->BindAction(InteractAction, ETriggerEvent::Started, this, &ACombatPlayerCharacter::Interact); //ToggleCombat - EnhancedInputComponent->BindAction(ToggleCombatInputAction, ETriggerEvent::Started, this, &ACombatCharacter::ToggleCombatAction); + EnhancedInputComponent->BindAction(ToggleCombatInputAction, ETriggerEvent::Started, this, &ACombatPlayerCharacter::ToggleCombatAction); //LightAttack - EnhancedInputComponent->BindAction(LightAttackAction, ETriggerEvent::Triggered, this, &ACombatCharacter::LightChargeAttack); - EnhancedInputComponent->BindAction(LightAttackAction, ETriggerEvent::Completed, this, &ACombatCharacter::LightAttack); + EnhancedInputComponent->BindAction(LightAttackAction, ETriggerEvent::Triggered, this, &ACombatPlayerCharacter::LightChargeAttack); + EnhancedInputComponent->BindAction(LightAttackAction, ETriggerEvent::Completed, this, &ACombatPlayerCharacter::LightAttack); //HeavyAttack - EnhancedInputComponent->BindAction(HeavyAttackAction, ETriggerEvent::Started, this, &ACombatCharacter::HeavyAttack); + EnhancedInputComponent->BindAction(HeavyAttackAction, ETriggerEvent::Started, this, &ACombatPlayerCharacter::HeavyAttack); //Dodge - EnhancedInputComponent->BindAction(DodgeAction, ETriggerEvent::Started, this, &ACombatCharacter::Dodge); + EnhancedInputComponent->BindAction(DodgeAction, ETriggerEvent::Started, this, &ACombatPlayerCharacter::Dodge); //ToggleWalk - EnhancedInputComponent->BindAction(ToggleWalkAction, ETriggerEvent::Started, this, &ACombatCharacter::ToggleWalk); + EnhancedInputComponent->BindAction(ToggleWalkAction, ETriggerEvent::Started, this, &ACombatPlayerCharacter::ToggleWalk); //Sprint - EnhancedInputComponent->BindAction(SprintAction, ETriggerEvent::Started, this, &ACombatCharacter::StartSprint); - EnhancedInputComponent->BindAction(SprintAction, ETriggerEvent::Completed, this, &ACombatCharacter::StopSprint); + EnhancedInputComponent->BindAction(SprintAction, ETriggerEvent::Started, this, &ACombatPlayerCharacter::StartSprint); + EnhancedInputComponent->BindAction(SprintAction, ETriggerEvent::Completed, this, &ACombatPlayerCharacter::StopSprint); //ToggleLockOn - EnhancedInputComponent->BindAction(ToggleLockOnAction, ETriggerEvent::Started, this, &ACombatCharacter::ToggleLockOn); + EnhancedInputComponent->BindAction(ToggleLockOnAction, ETriggerEvent::Started, this, &ACombatPlayerCharacter::ToggleLockOn); } } -void ACombatCharacter::SetCanMove_Implementation(bool inputCanMove) +void ACombatPlayerCharacter::SetCanMove_Implementation(bool inputCanMove) { bCanMove = inputCanMove; } -void ACombatCharacter::ActivateCollision_Implementation(ECollisionPart CollisionPart) +void ACombatPlayerCharacter::ActivateCollision_Implementation(ECollisionPart CollisionPart) { ABaseWeapon* weapon = CombatComponent->GetMainWeapon(); if(IsValid(weapon)) weapon->ActivateCollision(CollisionPart); } -void ACombatCharacter::DeactivateCollision_Implementation(ECollisionPart CollisionPart) +void ACombatPlayerCharacter::DeactivateCollision_Implementation(ECollisionPart CollisionPart) { ABaseWeapon* weapon = CombatComponent->GetMainWeapon(); if(IsValid(weapon)) weapon->DeactivateCollision(CollisionPart); } -void ACombatCharacter::ToggleCombat_Implementation() +float ACombatPlayerCharacter::PerformAction(FGameplayTag ActionTag, FGameplayTag StateTag, int32 MontageIndex, bool bRandomIndex) { - ABaseWeapon* weapon = CombatComponent->GetMainWeapon(); - if (IsValid(weapon)) - weapon->ToggleWeaponCombat(!CombatComponent->GetCombatEnabled()); -} - -float ACombatCharacter::PerformCombatAction(FGameplayTag ActionTag, FGameplayTag StateTag, int32 MontageIndex, bool bRandomIndex) -{ - //TODO : 나중에 이 함수로 바꿔서 쓰기 혹시 몰라 구현만 해놓음 ABaseWeapon* CurrentWeapon = CombatComponent->GetMainWeapon(); if (!CurrentWeapon) return false; @@ -299,9 +293,8 @@ float ACombatCharacter::PerformCombatAction(FGameplayTag ActionTag, FGameplayTag return actionDuration; } -float ACombatCharacter::PerformCombatAttack(FGameplayTag AttackType, int32 AttackIndex, bool bRandomIndex) +float ACombatPlayerCharacter::PerformAttack(FGameplayTag AttackType, int32 AttackIndex, bool bRandomIndex) { - //TODO : 나중에 이 함수로 바꿔서 쓰기 혹시 몰라 구현만 해놓음 if(!CombatComponent->GetCombatEnabled()) return 0.f; @@ -343,7 +336,7 @@ float ACombatCharacter::PerformCombatAttack(FGameplayTag AttackType, int32 Attac return attackDuration; } -void ACombatCharacter::SetMovementSpeedMode(EMovementSpeedMode NewSpeedMode) +void ACombatPlayerCharacter::SetMovementSpeedMode(EMovementSpeedMode NewSpeedMode) { if (NewSpeedMode == MovementSpeedMode) return; @@ -367,7 +360,7 @@ void ACombatCharacter::SetMovementSpeedMode(EMovementSpeedMode NewSpeedMode) } } -void ACombatCharacter::Move(const FInputActionValue& Value) +void ACombatPlayerCharacter::Move(const FInputActionValue& Value) { if(!bCanMove) //Value changes SetCanMove Func Call to Animnotify return; @@ -393,7 +386,7 @@ void ACombatCharacter::Move(const FInputActionValue& Value) } } -void ACombatCharacter::Look(const FInputActionValue& Value) +void ACombatPlayerCharacter::Look(const FInputActionValue& Value) { // input is a Vector2D FVector2D LookAxisVector = Value.Get(); @@ -411,7 +404,7 @@ void ACombatCharacter::Look(const FInputActionValue& Value) } } -void ACombatCharacter::Jumping(const FInputActionValue& Value) +void ACombatPlayerCharacter::Jumping(const FInputActionValue& Value) { if (!CanJumping()) return; @@ -422,7 +415,7 @@ void ACombatCharacter::Jumping(const FInputActionValue& Value) Super::Jump(); } -void ACombatCharacter::Interact(const FInputActionValue& Value) +void ACombatPlayerCharacter::Interact(const FInputActionValue& Value) { bool bInput = Value.Get(); @@ -440,14 +433,14 @@ void ACombatCharacter::Interact(const FInputActionValue& Value) } } -void ACombatCharacter::ToggleCombatAction(const FInputActionValue& Value) +void ACombatPlayerCharacter::ToggleCombatAction(const FInputActionValue& Value) { bool bInput = Value.Get(); ToggleCombatEvent(); } -void ACombatCharacter::LightAttack(const FInputActionValue& Value) +void ACombatPlayerCharacter::LightAttack(const FInputActionValue& Value) { if (!ResetChargeAttack()) return; @@ -460,7 +453,7 @@ void ACombatCharacter::LightAttack(const FInputActionValue& Value) } //누르고 있는 시간을 받기 위해서 FInputActionValue가 아니라 FInputActionInstance로 인자값을 받음 -void ACombatCharacter::LightChargeAttack(const FInputActionInstance& Instance) +void ACombatPlayerCharacter::LightChargeAttack(const FInputActionInstance& Instance) { AttackHeldTime = Instance.GetElapsedTime(); bAttackCharged = (AttackHeldTime >= ChargeAttackTime); @@ -468,7 +461,7 @@ void ACombatCharacter::LightChargeAttack(const FInputActionInstance& Instance) ChargeAttackEvent(); } -void ACombatCharacter::HeavyAttack(const FInputActionValue& Value) +void ACombatPlayerCharacter::HeavyAttack(const FInputActionValue& Value) { if (bAttackCharged) return; @@ -479,11 +472,11 @@ void ACombatCharacter::HeavyAttack(const FInputActionValue& Value) AttackEvent(); } -void ACombatCharacter::Dodge(const FInputActionValue& Value) +void ACombatPlayerCharacter::Dodge(const FInputActionValue& Value) { if (CanPerformDodge()) { - PerformDodge(); + PerformAction(FCombatGameplayTags::Get().Character_Action_Dodge, FCombatGameplayTags::Get().Character_State_Dodging, 0); ABaseWeapon* pBaseWeapon = CombatComponent->GetMainWeapon(); if (IsValid(pBaseWeapon)) { @@ -493,7 +486,7 @@ void ACombatCharacter::Dodge(const FInputActionValue& Value) } -void ACombatCharacter::ToggleWalk(const FInputActionValue& Value) +void ACombatPlayerCharacter::ToggleWalk(const FInputActionValue& Value) { if (GetCombatMovementSpeedMode() != EMovementSpeedMode::Walking) SetMovementSpeedMode(EMovementSpeedMode::Walking); @@ -502,30 +495,28 @@ void ACombatCharacter::ToggleWalk(const FInputActionValue& Value) } -void ACombatCharacter::StartSprint(const FInputActionValue& Value) +void ACombatPlayerCharacter::StartSprint(const FInputActionValue& Value) { if (CanPerformSprint()) { SetMovementSpeedMode(EMovementSpeedMode::Sprinting); UWorld* World = GEngine->GetWorldFromContextObjectChecked(this); if (World) - World->GetTimerManager().SetTimer(StaminaTimerHandle, this, &ACombatCharacter::SprintStaminaCost, 0.1f, true); + World->GetTimerManager().SetTimer(StaminaTimerHandle, this, &ACombatPlayerCharacter::SprintStaminaCost, 0.1f, true); } } -void ACombatCharacter::StopSprint(const FInputActionValue& Value) +void ACombatPlayerCharacter::StopSprint(const FInputActionValue& Value) { DisableSprint(); } -void ACombatCharacter::ToggleLockOn(const FInputActionValue& Value) +void ACombatPlayerCharacter::ToggleLockOn(const FInputActionValue& Value) { - if(!CombatComponent->GetCombatEnabled() && !TargetingComponent->GetIsTargeting()) - return; TargetingComponent->ToggleLockOn(); } -void ACombatCharacter::CharacterStateBegin(FGameplayTag CharState) +void ACombatPlayerCharacter::CharacterStateBegin(FGameplayTag CharState) { if (FGameplayTag::EmptyTag == CharState) {/*None*/} @@ -543,7 +534,7 @@ void ACombatCharacter::CharacterStateBegin(FGameplayTag CharState) {/*None*/} } -void ACombatCharacter::CharacterStateEnd(FGameplayTag CharState) +void ACombatPlayerCharacter::CharacterStateEnd(FGameplayTag CharState) { if (FGameplayTag::EmptyTag == CharState) {/*None*/} @@ -559,55 +550,7 @@ void ACombatCharacter::CharacterStateEnd(FGameplayTag CharState) {/*None*/} } -void ACombatCharacter::CharacterActionBegin(FGameplayTag CharAction) -{ - if(FGameplayTag::EmptyTag == CharAction) - {/*None*/ } - else if(FCombatGameplayTags::Get().Character_Action_GeneralAction == CharAction) - {/*None*/ } - else if(FCombatGameplayTags::Get().Character_Action_Dodge == CharAction) - {/*None*/ } - else if(FCombatGameplayTags::Get().Character_Action_EnterCombat == CharAction) - {/*None*/ } - else if(FCombatGameplayTags::Get().Character_Action_ExitCombat == CharAction) - {/*None*/ } - else if(FCombatGameplayTags::Get().Character_Action_Attack_LightAttack == CharAction) - {/*None*/ } - else if(FCombatGameplayTags::Get().Character_Action_Attack_HeavyAttack == CharAction) - {/*None*/ } - else if(FCombatGameplayTags::Get().Character_Action_Attack_ChargedAttack == CharAction) - {/*None*/ } - else if(FCombatGameplayTags::Get().Character_Action_Attack_FallingAttack == CharAction) - {/*None*/ } - else if(FCombatGameplayTags::Get().Character_Action_Attack_SprintAttack == CharAction) - {/*None*/ } -} - -void ACombatCharacter::CharacterActionEnd(FGameplayTag CharAction) -{ - if(FGameplayTag::EmptyTag == CharAction) - {/*None*/ } - else if(FCombatGameplayTags::Get().Character_Action_GeneralAction == CharAction) - {/*None*/ } - else if(FCombatGameplayTags::Get().Character_Action_Dodge == CharAction) - {/*None*/ } - else if(FCombatGameplayTags::Get().Character_Action_EnterCombat == CharAction) - {/*None*/ } - else if(FCombatGameplayTags::Get().Character_Action_ExitCombat == CharAction) - {/*None*/ } - else if(FCombatGameplayTags::Get().Character_Action_Attack_LightAttack == CharAction) - {/*None*/ } - else if(FCombatGameplayTags::Get().Character_Action_Attack_HeavyAttack == CharAction) - {/*None*/ } - else if(FCombatGameplayTags::Get().Character_Action_Attack_ChargedAttack == CharAction) - {/*None*/ } - else if(FCombatGameplayTags::Get().Character_Action_Attack_FallingAttack == CharAction) - {/*None*/ } - else if(FCombatGameplayTags::Get().Character_Action_Attack_SprintAttack == CharAction) - {/*None*/ } -} - -void ACombatCharacter::CharacterCurrentStatValueUpdated(EStats statType, float value) +void ACombatPlayerCharacter::CharacterCurrentStatValueUpdated(EStats statType, float value) { if (!(statType == EStats::Health) || value > 0.f) return; @@ -615,13 +558,13 @@ void ACombatCharacter::CharacterCurrentStatValueUpdated(EStats statType, float v StateManagerComponent->SetCurrentState(FCombatGameplayTags::Get().Character_State_Dead); } -void ACombatCharacter::CharacterCombatToggled(bool IsCombatEnabled) +void ACombatPlayerCharacter::CharacterCombatToggled(bool IsCombatEnabled) { if(IsValid(TargetingComponent)) TargetingComponent->UpdateRotationMode(); } -void ACombatCharacter::ToggleCombatEvent() +void ACombatPlayerCharacter::ToggleCombatEvent() { ABaseWeapon* baseWeapon = CombatComponent->GetMainWeapon(); if (!baseWeapon) @@ -631,12 +574,12 @@ void ACombatCharacter::ToggleCombatEvent() return; if (!CombatComponent->GetCombatEnabled()) - PerformAction(FCombatGameplayTags::Get().Character_State_GeneralActionState, FCombatGameplayTags::Get().Character_Action_EnterCombat, 0); + PerformAction(FCombatGameplayTags::Get().Character_Action_EnterCombat, FCombatGameplayTags::Get().Character_State_GeneralActionState, 0); else - PerformAction(FCombatGameplayTags::Get().Character_State_GeneralActionState, FCombatGameplayTags::Get().Character_Action_ExitCombat, 0); + PerformAction(FCombatGameplayTags::Get().Character_Action_ExitCombat, FCombatGameplayTags::Get().Character_State_GeneralActionState, 0); } -void ACombatCharacter::AttackEvent() +void ACombatPlayerCharacter::AttackEvent() { if (!CanPerformAttack()) return; @@ -651,7 +594,7 @@ void ACombatCharacter::AttackEvent() ToggleCombatEvent(); } -void ACombatCharacter::ChargeAttackEvent() +void ACombatPlayerCharacter::ChargeAttackEvent() { if (CanPerformAttack()) { @@ -664,7 +607,7 @@ void ACombatCharacter::ChargeAttackEvent() } } -bool ACombatCharacter::ResetChargeAttack() +bool ACombatPlayerCharacter::ResetChargeAttack() { AttackHeldTime = 0.f; if (bAttackCharged) @@ -676,7 +619,7 @@ bool ACombatCharacter::ResetChargeAttack() return true; } -void ACombatCharacter::ApplyHitReactionPhysicsVelocity(float InitialSpeed) +void ACombatPlayerCharacter::ApplyHitReactionPhysicsVelocity(float InitialSpeed) { if (!GetMesh()) return; @@ -684,7 +627,7 @@ void ACombatCharacter::ApplyHitReactionPhysicsVelocity(float InitialSpeed) GetMesh()->SetPhysicsLinearVelocity(GetActorForwardVector() * -InitialSpeed, false, PelvisBoneName); } -void ACombatCharacter::EnableRagdoll() +void ACombatPlayerCharacter::EnableRagdoll() { GetCharacterMovement()->SetMovementMode(EMovementMode::MOVE_None, 0); //movement 더 이상 없게 바꿈 GetCapsuleComponent()->SetCollisionResponseToChannel(ECollisionChannel::ECC_Pawn, ECollisionResponse::ECR_Ignore); //충돌무시 @@ -697,7 +640,7 @@ void ACombatCharacter::EnableRagdoll() GetMesh()->SetAllBodiesBelowPhysicsBlendWeight(PelvisBoneName, 1.f); } -void ACombatCharacter::DisableSprint() +void ACombatPlayerCharacter::DisableSprint() { UWorld* World = GEngine->GetWorldFromContextObjectChecked(this); if (World) @@ -707,7 +650,7 @@ void ACombatCharacter::DisableSprint() SetMovementSpeedMode(EMovementSpeedMode::Jogging); } -void ACombatCharacter::SprintStaminaCost() +void ACombatPlayerCharacter::SprintStaminaCost() { if (!CanPerformSprint()) { @@ -723,7 +666,7 @@ void ACombatCharacter::SprintStaminaCost() } } -void ACombatCharacter::ApplyHitReaction(EDamageType InDamageType) +void ACombatPlayerCharacter::ApplyHitReaction(EDamageType InDamageType) { switch (InDamageType) { @@ -741,7 +684,7 @@ void ACombatCharacter::ApplyHitReaction(EDamageType InDamageType) } } -void ACombatCharacter::ApplyImpactEffect(EDamageType InDamageType) +void ACombatPlayerCharacter::ApplyImpactEffect(EDamageType InDamageType) { //Play Sound UGameplayStatics::PlaySoundAtLocation(this, HitSound, LastHitInfo.Location); @@ -750,103 +693,7 @@ void ACombatCharacter::ApplyImpactEffect(EDamageType InDamageType) UNiagaraFunctionLibrary::SpawnSystemAtLocation(GetWorld(), HitEmitter, LastHitInfo.Location); } -void ACombatCharacter::PerformAttack(FGameplayTag attackType, int32 attackIndex) -{ - if(!CombatComponent->GetCombatEnabled()) - return; - - ABaseWeapon* CurrentWeapon = CombatComponent->GetMainWeapon(); - if (!CurrentWeapon) - return; - - TArray montages = CurrentWeapon->GetActionMontage(attackType); - int32 attackIdx = attackIndex; - - if (montages.Num() <= attackIdx) - attackIdx = 0; - if (!montages.IsValidIndex(attackIdx)) - return; - - UAnimMontage* attackMontage = montages[attackIdx]; - if (!IsValid(attackMontage)) - { - FString debugStr = FString::Printf(TEXT("Index %d Is NOT VALID!!"), attackIdx); - GEngine->AddOnScreenDebugMessage(-1, 3.f, FColor::Red, debugStr); - return; - } - else - { - StateManagerComponent->SetCurrentState(FCombatGameplayTags::Get().Character_State_Attacking); - StateManagerComponent->SetCurrentAction(attackType); - - PlayAnimMontage(attackMontage); - - int idx = attackIdx + 1; - if (idx >= montages.Num()) - idx = 0; - - CombatComponent->SetAttackCount(idx); - } -} - -//인자값은 나중에 필요하면 추가 PerformDodge(int32 dodgeIndex) -void ACombatCharacter::PerformDodge() -{ - ABaseWeapon* CurrentWeapon = CombatComponent->GetMainWeapon(); - if (!CurrentWeapon) - return; - int32 montageIndex = 0; - TArray montages = CurrentWeapon->GetActionMontage(FCombatGameplayTags::Get().Character_Action_Dodge); - if (montages.Num() <= montageIndex) - montageIndex = 0; - if (!montages.IsValidIndex(montageIndex)) - return; - - UAnimMontage* dodgeMontage = montages[montageIndex]; - if (IsValid(dodgeMontage)) - { - StateManagerComponent->SetCurrentState(FCombatGameplayTags::Get().Character_State_Dodging); - StateManagerComponent->SetCurrentAction(FCombatGameplayTags::Get().Character_Action_Dodge); - PlayAnimMontage(dodgeMontage); - } - else - { - FString str = FString::Printf(TEXT("Dodge Index %n is NOT VALID!!"), montageIndex); - GEngine->AddOnScreenDebugMessage(-1, 3.f, FColor::Red, str); - } -} - -bool ACombatCharacter::PerformAction(FGameplayTag characterState, FGameplayTag characterAction, int32 montageIndex) -{ - ABaseWeapon* CurrentWeapon = CombatComponent->GetMainWeapon(); - if (!CurrentWeapon) - return false; - - TArray montages = CurrentWeapon->GetActionMontage(characterAction); - int32 montageIdx = montageIndex; - - if (montages.Num() <= montageIdx) - montageIdx = 0; - if (!montages.IsValidIndex(montageIdx)) - return false; - - UAnimMontage* actionMontage = montages[montageIdx]; - if (IsValid(actionMontage)) - { - StateManagerComponent->SetCurrentState(characterState); - StateManagerComponent->SetCurrentAction(characterAction); - PlayAnimMontage(actionMontage); - return true; - } - else - { - FString str = FString::Printf(TEXT("Dodge Index %n is NOT VALID!!"), montageIdx); - GEngine->AddOnScreenDebugMessage(-1, 3.f, FColor::Red, str); - return false; - } -} - -void ACombatCharacter::PerformDeath() +void ACombatPlayerCharacter::PerformDeath() { EnableRagdoll(); ApplyHitReactionPhysicsVelocity(2000.f); //충돌을 좀 더 그럴싸하게 하기 위해서 뒷방향으로 충격 @@ -863,7 +710,7 @@ void ACombatCharacter::PerformDeath() }), 4.f, false); // 4초 후에 object 삭제 } -bool ACombatCharacter::PerformHitStun() +bool ACombatPlayerCharacter::PerformHitStun() { UAnimMontage* hitMontage = nullptr; if(bHitFront) @@ -879,7 +726,7 @@ bool ACombatCharacter::PerformHitStun() return true; } -bool ACombatCharacter::PerformKnockdown() +bool ACombatPlayerCharacter::PerformKnockdown() { UAnimMontage* hitMontage = nullptr; if(bHitFront) @@ -895,7 +742,7 @@ bool ACombatCharacter::PerformKnockdown() return true; } -bool ACombatCharacter::CanPerformToggleCombat() +bool ACombatPlayerCharacter::CanPerformToggleCombat() { bool ReturnValue = true; @@ -911,7 +758,7 @@ bool ACombatCharacter::CanPerformToggleCombat() return ReturnValue; } -bool ACombatCharacter::CanPerformAttack() +bool ACombatPlayerCharacter::CanPerformAttack() { bool ReturnValue = true; @@ -928,7 +775,7 @@ bool ACombatCharacter::CanPerformAttack() return ReturnValue; } -bool ACombatCharacter::CanPerformDodge() +bool ACombatPlayerCharacter::CanPerformDodge() { bool ReturnValue = true; @@ -944,7 +791,7 @@ bool ACombatCharacter::CanPerformDodge() return ReturnValue; } -bool ACombatCharacter::CanJumping() +bool ACombatPlayerCharacter::CanJumping() { bool ReturnValue = true; @@ -959,7 +806,7 @@ bool ACombatCharacter::CanJumping() return ReturnValue; } -bool ACombatCharacter::CanReceiveHitReaction() +bool ACombatPlayerCharacter::CanReceiveHitReaction() { bool ReturnValue = true; @@ -970,12 +817,12 @@ bool ACombatCharacter::CanReceiveHitReaction() return ReturnValue; } -bool ACombatCharacter::CanPerformSprint() +bool ACombatPlayerCharacter::CanPerformSprint() { return (FMath::IsNearlyEqual(GetVelocity().Length(), 0.f)) == false; } -FGameplayTag ACombatCharacter::GetDesiredAttackType() +FGameplayTag ACombatPlayerCharacter::GetDesiredAttackType() { if (GetCharacterMovement()->IsFalling()) return FCombatGameplayTags::Get().Character_Action_Attack_FallingAttack; diff --git a/Source/D1/CombatCharacter.h b/Source/D1/CombatPlayerCharacter.h similarity index 92% rename from Source/D1/CombatCharacter.h rename to Source/D1/CombatPlayerCharacter.h index e3b52877..a4057266 100644 --- a/Source/D1/CombatCharacter.h +++ b/Source/D1/CombatPlayerCharacter.h @@ -12,11 +12,11 @@ #include "Components/StatsComponent.h" #include "Components/TargetingComponent.h" #include "Definitions/GameEnums.h" -#include "CombatCharacter.generated.h" +#include "CombatPlayerCharacter.generated.h" UCLASS(config=Game) -class ACombatCharacter : public ACharacter, public ICombatInterface, public IGameplayTagAssetInterface +class ACombatPlayerCharacter : public ACharacter, public ICombatInterface, public IGameplayTagAssetInterface { GENERATED_BODY() @@ -73,7 +73,7 @@ class ACombatCharacter : public ACharacter, public ICombatInterface, public IGam UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Input, meta = (AllowPrivateAccess = "true")) float ChargeAttackTime; public: - ACombatCharacter(); + ACombatPlayerCharacter(); public: /** Returns CameraBoom subobject **/ @@ -113,13 +113,10 @@ public: UFUNCTION(BlueprintCallable, BlueprintNativeEvent) void DeactivateCollision(ECollisionPart CollisionPart); virtual void DeactivateCollision_Implementation(ECollisionPart CollisionPart) override; - UFUNCTION(BlueprintCallable, BlueprintNativeEvent) - void ToggleCombat(); - virtual void ToggleCombat_Implementation() override; virtual EMovementSpeedMode GetCombatMovementSpeedMode() override { return GetMovementSpeedMode(); } - virtual float PerformCombatAction(FGameplayTag ActionTag, FGameplayTag StateTag, int32 MontageIndex, bool bRandomIndex); - virtual float PerformCombatAttack(FGameplayTag AttackType, int32 AttackIndex, bool bRandomIndex); + virtual float PerformAction(FGameplayTag ActionTag, FGameplayTag StateTag, int32 MontageIndex, bool bRandomIndex = false); + virtual float PerformAttack(FGameplayTag AttackType, int32 AttackIndex, bool bRandomIndex = false); // Inherited via IGameplayTagAssetInterface virtual void GetOwnedGameplayTags(FGameplayTagContainer& TagContainer) const override { TagContainer = OwnedGameplayTags; } @@ -146,8 +143,6 @@ protected: private://Delegate void CharacterStateBegin(FGameplayTag CharState); void CharacterStateEnd(FGameplayTag CharState); - void CharacterActionBegin(FGameplayTag CharAction); - void CharacterActionEnd(FGameplayTag CharAction); void CharacterCurrentStatValueUpdated(EStats statType, float value); void CharacterCombatToggled(bool IsCombatEnabled); @@ -164,9 +159,6 @@ private: void ApplyImpactEffect(EDamageType InDamageType); private: - void PerformAttack(FGameplayTag attackType, int32 attackIndex); - void PerformDodge(); - bool PerformAction(FGameplayTag characterState, FGameplayTag characterAction, int32 montageIndex); void PerformDeath(); bool PerformHitStun(); bool PerformKnockdown(); diff --git a/Source/D1/Components/CollisionComponent.cpp b/Source/D1/Components/CollisionComponent.cpp index 27d4c191..c10a727e 100644 --- a/Source/D1/Components/CollisionComponent.cpp +++ b/Source/D1/Components/CollisionComponent.cpp @@ -3,6 +3,8 @@ #include "Components/CollisionComponent.h" +#include "GameplayTagAssetInterface.h" + // Sets default values for this component's properties UCollisionComponent::UCollisionComponent() @@ -61,3 +63,12 @@ void UCollisionComponent::ActivateCollision() bCollisionEnabled = true; } +bool UCollisionComponent::CanHitActor(AActor* InActor) +{ + IGameplayTagAssetInterface* tagInterface = Cast(InActor); + if(tagInterface) + { + + } +} + diff --git a/Source/D1/Components/CollisionComponent.h b/Source/D1/Components/CollisionComponent.h index 3c83ded4..f309bac9 100644 --- a/Source/D1/Components/CollisionComponent.h +++ b/Source/D1/Components/CollisionComponent.h @@ -54,6 +54,7 @@ public: UFUNCTION(BlueprintCallable) FORCEINLINE void DeactivateCollision() { bCollisionEnabled = false; } bool IsCollisionEnabled() { return bCollisionEnabled; } + bool CanHitActor(AActor* InActor); private: UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category="Initialization", meta=(AllowPrivateAccess="true")) float TraceRadius; diff --git a/Source/D1/D1GameMode.cpp b/Source/D1/D1GameMode.cpp index beefad7f..b42b569a 100644 --- a/Source/D1/D1GameMode.cpp +++ b/Source/D1/D1GameMode.cpp @@ -1,7 +1,7 @@ // Copyright Epic Games, Inc. All Rights Reserved. #include "D1GameMode.h" -#include "CombatCharacter.h" +#include "CombatPlayerCharacter.h" #include "UObject/ConstructorHelpers.h" AD1GameMode::AD1GameMode() diff --git a/Source/D1/Interface/CombatInterface.cpp b/Source/D1/Interface/CombatInterface.cpp index 31e7e481..b7f151d2 100644 --- a/Source/D1/Interface/CombatInterface.cpp +++ b/Source/D1/Interface/CombatInterface.cpp @@ -4,13 +4,13 @@ #include "Interface/CombatInterface.h" // Add default functionality here for any ICombatInterface functions that are not pure virtual. -float ICombatInterface::PerformCombatAction(FGameplayTag ActionTag, FGameplayTag StateTag, int32 MontageIndex, +float ICombatInterface::PerformAction(FGameplayTag ActionTag, FGameplayTag StateTag, int32 MontageIndex, bool bRandomIndex) { return 0.f; } -float ICombatInterface::PerformCombatAttack(FGameplayTag AttackType, int32 AttackIndex, bool bRandomIndex) +float ICombatInterface::PerformAttack(FGameplayTag AttackType, int32 AttackIndex, bool bRandomIndex) { return 0.f; } diff --git a/Source/D1/Interface/CombatInterface.h b/Source/D1/Interface/CombatInterface.h index dc757f32..0402268a 100644 --- a/Source/D1/Interface/CombatInterface.h +++ b/Source/D1/Interface/CombatInterface.h @@ -40,15 +40,13 @@ public: void ActivateCollision(ECollisionPart CollisionPart); UFUNCTION(BlueprintCallable, BlueprintNativeEvent) void DeactivateCollision(ECollisionPart CollisionPart); - UFUNCTION(BlueprintCallable, BlueprintNativeEvent) - void ToggleCombat(); UFUNCTION() virtual EMovementSpeedMode GetCombatMovementSpeedMode() = 0; UFUNCTION(Category="CombatActions") - virtual float PerformCombatAction(FGameplayTag ActionTag, FGameplayTag StateTag, int32 MontageIndex, bool bRandomIndex); + virtual float PerformAction(FGameplayTag ActionTag, FGameplayTag StateTag, int32 MontageIndex, bool bRandomIndex = false); UFUNCTION(Category="CombatActions") - virtual float PerformCombatAttack(FGameplayTag AttackType, int32 AttackIndex, bool bRandomIndex); + virtual float PerformAttack(FGameplayTag AttackType, int32 AttackIndex, bool bRandomIndex = false); }; diff --git a/Source/D1/UI/CombatHUD.cpp b/Source/D1/UI/CombatHUD.cpp index c0bd59b7..185ca6eb 100644 --- a/Source/D1/UI/CombatHUD.cpp +++ b/Source/D1/UI/CombatHUD.cpp @@ -3,7 +3,6 @@ #include "UI/CombatHUD.h" -#include "UI_BossHealth.h" #include "UI/UI_MainHUD.h" void ACombatHUD::BeginPlay() @@ -19,11 +18,5 @@ void ACombatHUD::BeginPlay() UUI_MainHUD* outputUI = CreateWidget(Contorller, MainUI); outputUI->AddToViewport(); } - - UUI_BossHealth* BossHealthRef = CreateWidget(Contorller, UUI_BossHealth::StaticClass()); - if (BossHealthRef) //ExposeOnSpawn 대용으로 사용 - { - BossHealthRef->AddToViewport(); - } } } diff --git a/Source/D1/UI/UI_HealthBar.cpp b/Source/D1/UI/UI_HealthBar.cpp index eec2c076..f5f46ba0 100644 --- a/Source/D1/UI/UI_HealthBar.cpp +++ b/Source/D1/UI/UI_HealthBar.cpp @@ -9,7 +9,7 @@ void UUI_HealthBar::NativeConstruct() { Super::NativeConstruct(); - if(bUsePlayerStatsComponent) + if(!IsValid(StatsComponent)) { if(const APlayerController* playerController = GetOwningPlayer()) StatsComponent = playerController->GetComponentByClass(); diff --git a/Source/D1/UI/UI_HealthBar.h b/Source/D1/UI/UI_HealthBar.h index 57c786d3..f3932029 100644 --- a/Source/D1/UI/UI_HealthBar.h +++ b/Source/D1/UI/UI_HealthBar.h @@ -26,8 +26,6 @@ private: UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Initialization" , meta=(AllowPrivateAccess="true")) EStats StatType; - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Initialization" , meta=(AllowPrivateAccess="true")) - bool bUsePlayerStatsComponent; public: UFUNCTION(BlueprintCallable) diff --git a/Source/D1/UI/UI_StatBar.cpp b/Source/D1/UI/UI_StatBar.cpp index eebb332a..6912a1e2 100644 --- a/Source/D1/UI/UI_StatBar.cpp +++ b/Source/D1/UI/UI_StatBar.cpp @@ -6,13 +6,7 @@ void UUI_StatBar::NativeConstruct() { - APawn* pplayer = GetOwningPlayerPawn(); - if (pplayer) - { - StatsComponent = pplayer->GetComponentByClass(); - if (IsValid(StatsComponent)) - StatsComponent->OnCurrentStatValueUpdated.AddUObject(this, &UUI_StatBar::StatBarStatValueUpdated); - } + InitializeStatBar(nullptr); } void UUI_StatBar::StatBarStatValueUpdated(EStats stat, float value) @@ -26,3 +20,17 @@ void UUI_StatBar::StatBarStatValueUpdated(EStats stat, float value) float fPercent = value / StatsComponent->GetMaxStatValue(StatType); StatBar->SetPercent(fPercent); } + +void UUI_StatBar::InitializeStatBar(UStatsComponent* InputStatsComponent) +{ + if(IsValid(InputStatsComponent)) + StatsComponent = InputStatsComponent; + else if(!IsValid(StatsComponent)) + { + APawn* pplayer = GetOwningPlayerPawn(); + if (pplayer) + StatsComponent = pplayer->GetComponentByClass(); + } + StatsComponent->OnCurrentStatValueUpdated.AddUObject(this, &UUI_StatBar::StatBarStatValueUpdated); + StatBarStatValueUpdated(StatType, StatsComponent->GetCurrentStatValue(StatType)); +} diff --git a/Source/D1/UI/UI_StatBar.h b/Source/D1/UI/UI_StatBar.h index 3dcbf40e..c37bcc3c 100644 --- a/Source/D1/UI/UI_StatBar.h +++ b/Source/D1/UI/UI_StatBar.h @@ -19,6 +19,8 @@ protected: virtual void NativeConstruct() override; public: //Delegate void StatBarStatValueUpdated(EStats stat, float value); +public: + void InitializeStatBar(UStatsComponent* InputStatsComponent); public: UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (BindWidget)) TObjectPtr StatBar;