diff --git a/Config/DefaultEngine.ini b/Config/DefaultEngine.ini index 698bc190..b1c2dcf5 100644 --- a/Config/DefaultEngine.ini +++ b/Config/DefaultEngine.ini @@ -151,4 +151,6 @@ ManualIPAddress= +PropertyRedirects=(OldName="/Script/D1.MasterAI.RightWeaponCollisionComponent",NewName="/Script/D1.MasterAI.MainCollisionComponent") +PropertyRedirects=(OldName="/Script/D1.MasterAI.LeftWeaponCollisionComponent",NewName="/Script/D1.MasterAI.SubCollisionComponent") +PropertyRedirects=(OldName="/Script/D1.CombatPlayerCharacter.Weapon",NewName="/Script/D1.CombatPlayerCharacter.StartingEquipment") ++PropertyRedirects=(OldName="/Script/D1.CombatPlayerCharacter.StartingEquipment",NewName="/Script/D1.CombatPlayerCharacter.EquippedItems") ++PropertyRedirects=(OldName="/Script/D1.CombatPlayerCharacter.EquippedItems",NewName="/Script/D1.CombatPlayerCharacter.StartingEquipments") diff --git a/Content/CombatSystem/Input/Actions/IA_UseItem.uasset b/Content/CombatSystem/Input/Actions/IA_UseItem.uasset new file mode 100644 index 00000000..49473cae Binary files /dev/null and b/Content/CombatSystem/Input/Actions/IA_UseItem.uasset differ diff --git a/Content/CombatSystem/Input/IMC_Default.uasset b/Content/CombatSystem/Input/IMC_Default.uasset index 9480ed8d..174a13f3 100644 Binary files a/Content/CombatSystem/Input/IMC_Default.uasset and b/Content/CombatSystem/Input/IMC_Default.uasset differ diff --git a/Source/D1/Actor/BaseConsumable.cpp b/Source/D1/Actor/BaseConsumable.cpp new file mode 100644 index 00000000..d4150710 --- /dev/null +++ b/Source/D1/Actor/BaseConsumable.cpp @@ -0,0 +1,5 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "Actor/BaseConsumable.h" + diff --git a/Source/D1/Actor/BaseConsumable.h b/Source/D1/Actor/BaseConsumable.h new file mode 100644 index 00000000..bc97e057 --- /dev/null +++ b/Source/D1/Actor/BaseConsumable.h @@ -0,0 +1,17 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "Actor/BaseEquippable.h" +#include "BaseConsumable.generated.h" + +/** + * + */ +UCLASS() +class D1_API ABaseConsumable : public ABaseEquippable +{ + GENERATED_BODY() + +}; diff --git a/Source/D1/Actor/BaseEquippable.cpp b/Source/D1/Actor/BaseEquippable.cpp index 9996f4bf..8786a0ac 100644 --- a/Source/D1/Actor/BaseEquippable.cpp +++ b/Source/D1/Actor/BaseEquippable.cpp @@ -61,4 +61,8 @@ bool ABaseEquippable::GetIsEquipped() return bIsEquipped; } +void ABaseEquippable::UseItem() +{ +} + diff --git a/Source/D1/Actor/BaseEquippable.h b/Source/D1/Actor/BaseEquippable.h index fad5949f..d2a23240 100644 --- a/Source/D1/Actor/BaseEquippable.h +++ b/Source/D1/Actor/BaseEquippable.h @@ -3,11 +3,12 @@ #pragma once #include "CoreMinimal.h" +#include "GameplayTagAssetInterface.h" #include "GameFramework/Actor.h" #include "BaseEquippable.generated.h" UCLASS() -class D1_API ABaseEquippable : public AActor +class D1_API ABaseEquippable : public AActor, public IGameplayTagAssetInterface { GENERATED_BODY() @@ -23,6 +24,12 @@ public: virtual void OnUnequipped(); virtual void SetIsEquipped(bool IsEquipped); virtual bool GetIsEquipped(); + virtual void UseItem(); + +protected: + // Inherited via IGameplayTagAssetInterface + virtual void GetOwnedGameplayTags(FGameplayTagContainer& TagContainer) const override { TagContainer = OwnedGameplayTags; } + protected: UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (AllowPrivateAccess = "true")) TObjectPtr DefaultSceneRoot; @@ -37,4 +44,7 @@ protected: UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Initialization") FName AttachSocketName; +private: + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "GameplayTags", meta = (AllowPrivateAccess = "true")) + FGameplayTagContainer OwnedGameplayTags; }; diff --git a/Source/D1/CombatPlayerCharacter.cpp b/Source/D1/CombatPlayerCharacter.cpp index 73c53924..7784d55c 100644 --- a/Source/D1/CombatPlayerCharacter.cpp +++ b/Source/D1/CombatPlayerCharacter.cpp @@ -124,7 +124,7 @@ void ACombatPlayerCharacter::BeginPlay() FActorSpawnParameters spawnParam; spawnParam.Owner = this; spawnParam.Instigator = this; - for (auto Equipment : StartingEquipment) + for (auto Equipment : StartingEquipments) { ABaseEquippable* SpawnItem = Cast(GetWorld()->SpawnActor(Equipment, &GetActorTransform(), spawnParam)); if (SpawnItem) @@ -255,6 +255,9 @@ void ACombatPlayerCharacter::SetupPlayerInputComponent(class UInputComponent* Pl //Block EnhancedInputComponent->BindAction(BlockAction, ETriggerEvent::Triggered, this, &ACombatPlayerCharacter::Blocking); EnhancedInputComponent->BindAction(BlockAction, ETriggerEvent::Completed, this, &ACombatPlayerCharacter::StopBlocking); + + //Use Item + EnhancedInputComponent->BindAction(UseItemAction, ETriggerEvent::Started, this, &ACombatPlayerCharacter::UseItem); } } @@ -362,6 +365,25 @@ float ACombatPlayerCharacter::PerformAttack(FGameplayTag AttackType, int32 Attac return attackDuration; } +bool ACombatPlayerCharacter::UseItemByTag(FGameplayTag ItemTag) +{ + for (auto Item : EquippedItems) + { + if(IsValid(Item)) + { + IGameplayTagAssetInterface* TagItem = Cast(Item); + if(!TagItem) + continue; + if(TagItem->HasMatchingGameplayTag(ItemTag)) + { + Item->UseItem(); + return true; + } + } + } + return false; +} + void ACombatPlayerCharacter::SetMovementSpeedMode(EMovementSpeedMode NewSpeedMode) { if (NewSpeedMode == MovementSpeedMode) @@ -557,6 +579,11 @@ void ACombatPlayerCharacter::StopBlocking(const FInputActionValue& Value) CombatComponent->SetBlockingState(false); } +void ACombatPlayerCharacter::UseItem(const FInputActionValue& Value) +{ + +} + void ACombatPlayerCharacter::CharacterStateBegin(FGameplayTag CharState) { if (FGameplayTag::EmptyTag == CharState) diff --git a/Source/D1/CombatPlayerCharacter.h b/Source/D1/CombatPlayerCharacter.h index b7ce4f15..19c9ad87 100644 --- a/Source/D1/CombatPlayerCharacter.h +++ b/Source/D1/CombatPlayerCharacter.h @@ -76,6 +76,9 @@ class ACombatPlayerCharacter : public ACharacter, public ICombatInterface, publi 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; @@ -128,6 +131,7 @@ public: 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 UseItemByTag(FGameplayTag ItemTag) override; // Inherited via IGameplayTagAssetInterface virtual void GetOwnedGameplayTags(FGameplayTagContainer& TagContainer) const override { TagContainer = OwnedGameplayTags; } @@ -152,6 +156,7 @@ protected: 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); @@ -206,11 +211,12 @@ public: TObjectPtr StatsComponent; UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category="Components", meta=(AllowPrivateAccess="true")) TObjectPtr TargetingComponent; - - //TODO : 방패 착용 후 Toggle Event 시 Weapon의 소켓이 안바뀌는 버그 + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Equipment", meta = (AllowPrivateAccess = "true")) - TArray> StartingEquipment; - + TArray> StartingEquipments; + UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category="Equipment", meta = (AllowPrivateAccess = "true")) + TArray> EquippedItems; + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Hit", meta = (AllowPrivateAccess = "true")) FName PelvisBoneName; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Hit", meta = (AllowPrivateAccess = "true")) diff --git a/Source/D1/Interface/CombatInterface.cpp b/Source/D1/Interface/CombatInterface.cpp index b7f151d2..486649de 100644 --- a/Source/D1/Interface/CombatInterface.cpp +++ b/Source/D1/Interface/CombatInterface.cpp @@ -14,3 +14,8 @@ float ICombatInterface::PerformAttack(FGameplayTag AttackType, int32 AttackIndex { return 0.f; } + +bool ICombatInterface::UseItemByTag(FGameplayTag ItemTag) +{ + return false; +} diff --git a/Source/D1/Interface/CombatInterface.h b/Source/D1/Interface/CombatInterface.h index e896eec6..97205534 100644 --- a/Source/D1/Interface/CombatInterface.h +++ b/Source/D1/Interface/CombatInterface.h @@ -52,6 +52,7 @@ public: virtual float PerformAction(FGameplayTag ActionTag, FGameplayTag StateTag = FCombatGameplayTags::Get().Character_State_GeneralActionState, int32 MontageIndex = 0, bool bRandomIndex = false); UFUNCTION(Category="CombatActions") virtual float PerformAttack(FGameplayTag AttackType, int32 AttackIndex, bool bRandomIndex = false); - + UFUNCTION(Category="CombatActions") + virtual bool UseItemByTag(FGameplayTag ItemTag); };