[박치영] C++ 기본구조 작업

main
PCYPC\pcy35 2023-07-27 20:47:58 +09:00
parent e35ed0a933
commit e2d1c17b96
33 changed files with 267 additions and 43 deletions

View File

@ -68,3 +68,60 @@ ConnectionType=USBOnly
bUseManualIPAddress=False bUseManualIPAddress=False
ManualIPAddress= ManualIPAddress=
[/Script/Engine.CollisionProfile]
-Profiles=(Name="NoCollision",CollisionEnabled=NoCollision,ObjectTypeName="WorldStatic",CustomResponses=((Channel="Visibility",Response=ECR_Ignore),(Channel="Camera",Response=ECR_Ignore)),HelpMessage="No collision",bCanModify=False)
-Profiles=(Name="BlockAll",CollisionEnabled=QueryAndPhysics,ObjectTypeName="WorldStatic",CustomResponses=,HelpMessage="WorldStatic object that blocks all actors by default. All new custom channels will use its own default response. ",bCanModify=False)
-Profiles=(Name="OverlapAll",CollisionEnabled=QueryOnly,ObjectTypeName="WorldStatic",CustomResponses=((Channel="WorldStatic",Response=ECR_Overlap),(Channel="Pawn",Response=ECR_Overlap),(Channel="Visibility",Response=ECR_Overlap),(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. ",bCanModify=False)
-Profiles=(Name="BlockAllDynamic",CollisionEnabled=QueryAndPhysics,ObjectTypeName="WorldDynamic",CustomResponses=,HelpMessage="WorldDynamic object that blocks all actors by default. All new custom channels will use its own default response. ",bCanModify=False)
-Profiles=(Name="OverlapAllDynamic",CollisionEnabled=QueryOnly,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="WorldStatic",Response=ECR_Overlap),(Channel="Pawn",Response=ECR_Overlap),(Channel="Visibility",Response=ECR_Overlap),(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="WorldDynamic object that overlaps all actors by default. All new custom channels will use its own default response. ",bCanModify=False)
-Profiles=(Name="IgnoreOnlyPawn",CollisionEnabled=QueryOnly,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="Pawn",Response=ECR_Ignore),(Channel="Vehicle",Response=ECR_Ignore)),HelpMessage="WorldDynamic object that ignores Pawn and Vehicle. All other channels will be set to default.",bCanModify=False)
-Profiles=(Name="OverlapOnlyPawn",CollisionEnabled=QueryOnly,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="Pawn",Response=ECR_Overlap),(Channel="Vehicle",Response=ECR_Overlap),(Channel="Camera",Response=ECR_Ignore)),HelpMessage="WorldDynamic object that overlaps Pawn, Camera, and Vehicle. All other channels will be set to default. ",bCanModify=False)
-Profiles=(Name="Pawn",CollisionEnabled=QueryAndPhysics,ObjectTypeName="Pawn",CustomResponses=((Channel="Visibility",Response=ECR_Ignore)),HelpMessage="Pawn object. Can be used for capsule of any playerable character or AI. ",bCanModify=False)
-Profiles=(Name="Spectator",CollisionEnabled=QueryOnly,ObjectTypeName="Pawn",CustomResponses=((Channel="WorldStatic",Response=ECR_Block),(Channel="Pawn",Response=ECR_Ignore),(Channel="Visibility",Response=ECR_Ignore),(Channel="WorldDynamic",Response=ECR_Ignore),(Channel="Camera",Response=ECR_Ignore),(Channel="PhysicsBody",Response=ECR_Ignore),(Channel="Vehicle",Response=ECR_Ignore),(Channel="Destructible",Response=ECR_Ignore)),HelpMessage="Pawn object that ignores all other actors except WorldStatic.",bCanModify=False)
-Profiles=(Name="CharacterMesh",CollisionEnabled=QueryOnly,ObjectTypeName="Pawn",CustomResponses=((Channel="Pawn",Response=ECR_Ignore),(Channel="Vehicle",Response=ECR_Ignore),(Channel="Visibility",Response=ECR_Ignore)),HelpMessage="Pawn object that is used for Character Mesh. All other channels will be set to default.",bCanModify=False)
-Profiles=(Name="PhysicsActor",CollisionEnabled=QueryAndPhysics,ObjectTypeName="PhysicsBody",CustomResponses=,HelpMessage="Simulating actors",bCanModify=False)
-Profiles=(Name="Destructible",CollisionEnabled=QueryAndPhysics,ObjectTypeName="Destructible",CustomResponses=,HelpMessage="Destructible actors",bCanModify=False)
-Profiles=(Name="InvisibleWall",CollisionEnabled=QueryAndPhysics,ObjectTypeName="WorldStatic",CustomResponses=((Channel="Visibility",Response=ECR_Ignore)),HelpMessage="WorldStatic object that is invisible.",bCanModify=False)
-Profiles=(Name="InvisibleWallDynamic",CollisionEnabled=QueryAndPhysics,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="Visibility",Response=ECR_Ignore)),HelpMessage="WorldDynamic object that is invisible.",bCanModify=False)
-Profiles=(Name="Trigger",CollisionEnabled=QueryOnly,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="WorldStatic",Response=ECR_Overlap),(Channel="Pawn",Response=ECR_Overlap),(Channel="Visibility",Response=ECR_Ignore),(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="WorldDynamic object that is used for trigger. All other channels will be set to default.",bCanModify=False)
-Profiles=(Name="Ragdoll",CollisionEnabled=QueryAndPhysics,ObjectTypeName="PhysicsBody",CustomResponses=((Channel="Pawn",Response=ECR_Ignore),(Channel="Visibility",Response=ECR_Ignore)),HelpMessage="Simulating Skeletal Mesh Component. All other channels will be set to default.",bCanModify=False)
-Profiles=(Name="Vehicle",CollisionEnabled=QueryAndPhysics,ObjectTypeName="Vehicle",CustomResponses=,HelpMessage="Vehicle object that blocks Vehicle, WorldStatic, and WorldDynamic. All other channels will be set to default.",bCanModify=False)
-Profiles=(Name="UI",CollisionEnabled=QueryOnly,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="WorldStatic",Response=ECR_Overlap),(Channel="Pawn",Response=ECR_Overlap),(Channel="Visibility",Response=ECR_Block),(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. ",bCanModify=False)
+Profiles=(Name="NoCollision",CollisionEnabled=NoCollision,bCanModify=False,ObjectTypeName="WorldStatic",CustomResponses=((Channel="Visibility",Response=ECR_Ignore),(Channel="Camera",Response=ECR_Ignore)),HelpMessage="No collision")
+Profiles=(Name="BlockAll",CollisionEnabled=QueryAndPhysics,bCanModify=False,ObjectTypeName="WorldStatic",CustomResponses=,HelpMessage="WorldStatic object that blocks all actors by default. All new custom channels will use its own default response. ")
+Profiles=(Name="OverlapAll",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="WorldStatic",CustomResponses=((Channel="WorldStatic",Response=ECR_Overlap),(Channel="Pawn",Response=ECR_Overlap),(Channel="Visibility",Response=ECR_Overlap),(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. ")
+Profiles=(Name="BlockAllDynamic",CollisionEnabled=QueryAndPhysics,bCanModify=False,ObjectTypeName="WorldDynamic",CustomResponses=,HelpMessage="WorldDynamic object that blocks all actors by default. All new custom channels will use its own default response. ")
+Profiles=(Name="OverlapAllDynamic",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="WorldStatic",Response=ECR_Overlap),(Channel="Pawn",Response=ECR_Overlap),(Channel="Visibility",Response=ECR_Overlap),(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="WorldDynamic object that overlaps all actors by default. All new custom channels will use its own default response. ")
+Profiles=(Name="IgnoreOnlyPawn",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="Pawn",Response=ECR_Ignore),(Channel="Vehicle",Response=ECR_Ignore)),HelpMessage="WorldDynamic object that ignores Pawn and Vehicle. All other channels will be set to default.")
+Profiles=(Name="OverlapOnlyPawn",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="Pawn",Response=ECR_Overlap),(Channel="Vehicle",Response=ECR_Overlap),(Channel="Camera",Response=ECR_Ignore)),HelpMessage="WorldDynamic object that overlaps Pawn, Camera, and Vehicle. All other channels will be set to default. ")
+Profiles=(Name="Pawn",CollisionEnabled=QueryAndPhysics,bCanModify=False,ObjectTypeName="Pawn",CustomResponses=((Channel="Visibility",Response=ECR_Ignore)),HelpMessage="Pawn object. Can be used for capsule of any playerable character or AI. ")
+Profiles=(Name="Spectator",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="Pawn",CustomResponses=((Channel="WorldStatic"),(Channel="Pawn",Response=ECR_Ignore),(Channel="Visibility",Response=ECR_Ignore),(Channel="WorldDynamic",Response=ECR_Ignore),(Channel="Camera",Response=ECR_Ignore),(Channel="PhysicsBody",Response=ECR_Ignore),(Channel="Vehicle",Response=ECR_Ignore),(Channel="Destructible",Response=ECR_Ignore)),HelpMessage="Pawn object that ignores all other actors except WorldStatic.")
+Profiles=(Name="CharacterMesh",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="Pawn",CustomResponses=((Channel="Pawn",Response=ECR_Ignore),(Channel="Vehicle",Response=ECR_Ignore),(Channel="Visibility",Response=ECR_Ignore)),HelpMessage="Pawn object that is used for Character Mesh. All other channels will be set to default.")
+Profiles=(Name="PhysicsActor",CollisionEnabled=QueryAndPhysics,bCanModify=False,ObjectTypeName="PhysicsBody",CustomResponses=,HelpMessage="Simulating actors")
+Profiles=(Name="Destructible",CollisionEnabled=QueryAndPhysics,bCanModify=False,ObjectTypeName="Destructible",CustomResponses=,HelpMessage="Destructible actors")
+Profiles=(Name="InvisibleWall",CollisionEnabled=QueryAndPhysics,bCanModify=False,ObjectTypeName="WorldStatic",CustomResponses=((Channel="Visibility",Response=ECR_Ignore)),HelpMessage="WorldStatic object that is invisible.")
+Profiles=(Name="InvisibleWallDynamic",CollisionEnabled=QueryAndPhysics,bCanModify=False,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="Visibility",Response=ECR_Ignore)),HelpMessage="WorldDynamic object that is invisible.")
+Profiles=(Name="Trigger",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="WorldStatic",Response=ECR_Overlap),(Channel="Pawn",Response=ECR_Overlap),(Channel="Visibility",Response=ECR_Ignore),(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="WorldDynamic object that is used for trigger. All other channels will be set to default.")
+Profiles=(Name="Ragdoll",CollisionEnabled=QueryAndPhysics,bCanModify=False,ObjectTypeName="PhysicsBody",CustomResponses=((Channel="Pawn",Response=ECR_Ignore),(Channel="Visibility",Response=ECR_Ignore)),HelpMessage="Simulating Skeletal Mesh Component. All other channels will be set to default.")
+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")
-ProfileRedirects=(OldName="BlockingVolume",NewName="InvisibleWall")
-ProfileRedirects=(OldName="InterpActor",NewName="IgnoreOnlyPawn")
-ProfileRedirects=(OldName="StaticMeshComponent",NewName="BlockAllDynamic")
-ProfileRedirects=(OldName="SkeletalMeshActor",NewName="PhysicsActor")
-ProfileRedirects=(OldName="InvisibleActor",NewName="InvisibleWallDynamic")
+ProfileRedirects=(OldName="BlockingVolume",NewName="InvisibleWall")
+ProfileRedirects=(OldName="InterpActor",NewName="IgnoreOnlyPawn")
+ProfileRedirects=(OldName="StaticMeshComponent",NewName="BlockAllDynamic")
+ProfileRedirects=(OldName="SkeletalMeshActor",NewName="PhysicsActor")
+ProfileRedirects=(OldName="InvisibleActor",NewName="InvisibleWallDynamic")
-CollisionChannelRedirects=(OldName="Static",NewName="WorldStatic")
-CollisionChannelRedirects=(OldName="Dynamic",NewName="WorldDynamic")
-CollisionChannelRedirects=(OldName="VehicleMovement",NewName="Vehicle")
-CollisionChannelRedirects=(OldName="PawnMovement",NewName="Pawn")
+CollisionChannelRedirects=(OldName="Static",NewName="WorldStatic")
+CollisionChannelRedirects=(OldName="Dynamic",NewName="WorldDynamic")
+CollisionChannelRedirects=(OldName="VehicleMovement",NewName="Vehicle")
+CollisionChannelRedirects=(OldName="PawnMovement",NewName="Pawn")

View File

@ -3,7 +3,6 @@
#include "Actor/BaseEquippable.h" #include "Actor/BaseEquippable.h"
#include "GameFramework/Character.h" #include "GameFramework/Character.h"
//#include "SkeletalMesh.h"
// Sets default values // Sets default values
ABaseEquippable::ABaseEquippable() ABaseEquippable::ABaseEquippable()
@ -11,6 +10,15 @@ ABaseEquippable::ABaseEquippable()
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it. // Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true; PrimaryActorTick.bCanEverTick = true;
DefaultSceneRoot = CreateDefaultSubobject<USceneComponent>(TEXT("DefaultSceneRoot"));
RootComponent = DefaultSceneRoot;
ItemSkeletalMesh = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("ItemSkeletalMesh"));
ItemSkeletalMesh->SetupAttachment(RootComponent);
ItemStaticMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("ItemStaticMesh"));
ItemStaticMesh->SetupAttachment(RootComponent);
ItemStaticMesh->SetCollisionEnabled(ECollisionEnabled::NoCollision);
} }
void ABaseEquippable::AttachActor(const FName SocketName) void ABaseEquippable::AttachActor(const FName SocketName)

View File

@ -22,6 +22,14 @@ public:
virtual void OnUnequipped(); virtual void OnUnequipped();
virtual void SetIsEquipped(bool IsEquipped); virtual void SetIsEquipped(bool IsEquipped);
virtual bool GetIsEquipped(); virtual bool GetIsEquipped();
protected:
UPROPERTY(EditAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"))
class USceneComponent* DefaultSceneRoot;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Mesh, meta = (AllowPrivateAccess = "true"))
class USkeletalMeshComponent* ItemSkeletalMesh;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Mesh, meta = (AllowPrivateAccess = "true"))
class UStaticMeshComponent* ItemStaticMesh;
protected: protected:
UPROPERTY(VisibleAnywhere, BlueprintReadWrite) UPROPERTY(VisibleAnywhere, BlueprintReadWrite)
bool bIsEquipped; bool bIsEquipped;

View File

@ -3,6 +3,8 @@
#include "Actor/BaseWeapon.h" #include "Actor/BaseWeapon.h"
#include "Components/CombatComponent.h" #include "Components/CombatComponent.h"
#include "GameFramework/Character.h"
#include "Animation/CombatAnimInstance.h"
ABaseWeapon::ABaseWeapon() ABaseWeapon::ABaseWeapon()
{ {
@ -13,14 +15,20 @@ void ABaseWeapon::OnEquipped()
{ {
SetIsEquipped(true); SetIsEquipped(true);
AActor* owner = GetOwner(); AActor* owner = GetOwner();
UCombatComponent* component = owner->GetComponentByClass<UCombatComponent>(); CombatComponent = owner->GetComponentByClass<UCombatComponent>();
if (component->GetCombatEnabled()) if (CombatComponent->GetCombatEnabled())
AttachActor(HandSocketName); AttachActor(HandSocketName);
else else
AttachActor(AttachSocketName); AttachActor(AttachSocketName);
CombatComponent->SetMainWeapon(this); CombatComponent->SetMainWeapon(this);
//TODO Update Combat Type ACharacter* character = Cast<ACharacter>(owner);
if (character)
{
UCombatAnimInstance* animInstance = Cast<UCombatAnimInstance>(character->GetMesh()->GetAnimInstance());
animInstance->UpdateCombatType(CombatType);
}
} }

View File

@ -10,6 +10,8 @@
/** /**
* *
*/ */
class UAnimMontage;
UCLASS() UCLASS()
class D1_API ABaseWeapon : public ABaseEquippable class D1_API ABaseWeapon : public ABaseEquippable
{ {
@ -21,6 +23,9 @@ public:
public: public:
void OnEquipped() override; void OnEquipped() override;
public:
FORCEINLINE UAnimMontage* GetEnterCombat() const { return EnterCombat; }
FORCEINLINE UAnimMontage* GetExitCombat() const { return ExitCombat; }
protected: protected:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Initialization") UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Initialization")
FName HandSocketName; FName HandSocketName;
@ -31,7 +36,7 @@ protected:
TObjectPtr<class UCombatComponent> CombatComponent; TObjectPtr<class UCombatComponent> CombatComponent;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Animations") UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Animations")
TObjectPtr<class UAnimMontage> EnterCombat; TObjectPtr<UAnimMontage> EnterCombat;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Animations") UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Animations")
TObjectPtr<class UAnimMontage> ExitCombat; TObjectPtr<UAnimMontage> ExitCombat;
}; };

View File

@ -2,13 +2,40 @@
#include "Actor/PickupActor.h" #include "Actor/PickupActor.h"
#include "Actor/BaseEquippable.h"
#include "Components/SceneComponent.h"
#include "Components/StaticMeshComponent.h"
#include "Components/SphereComponent.h"
// Sets default values // Sets default values
APickupActor::APickupActor() APickupActor::APickupActor()
{ {
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it. // Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true; PrimaryActorTick.bCanEverTick = true;
DefaultSceneRoot = CreateDefaultSubobject<USceneComponent>(TEXT("DefaultSceneRoot"));
RootComponent = DefaultSceneRoot;
Cube = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Cube"));
Cube->SetupAttachment(RootComponent);
Sphere = CreateDefaultSubobject<USphereComponent>(TEXT("Sphere"));
Sphere->SetupAttachment(Cube);
}
void APickupActor::Interact(AActor* Caller)
{
if (Caller == nullptr)
return;
APawn* pawn = Cast<APawn>(Caller);
if (pawn != nullptr)
{
FActorSpawnParameters spawnParam;
spawnParam.Owner = Caller;
spawnParam.Instigator = pawn;
ABaseEquippable* SpawnItem = Cast<ABaseEquippable>(GetWorld()->SpawnActor(Item, &GetActorTransform(),spawnParam));
if(SpawnItem)
SpawnItem->OnEquipped();
}
} }

View File

@ -4,10 +4,11 @@
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "GameFramework/Actor.h" #include "GameFramework/Actor.h"
#include "Interface/Interact.h"
#include "PickupActor.generated.h" #include "PickupActor.generated.h"
UCLASS() UCLASS()
class D1_API APickupActor : public AActor class D1_API APickupActor : public AActor, public IInteract
{ {
GENERATED_BODY() GENERATED_BODY()
@ -15,6 +16,19 @@ public:
// Sets default values for this actor's properties // Sets default values for this actor's properties
APickupActor(); APickupActor();
private: public:
virtual void Interact(AActor* Caller) override;
private:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Components", meta=(AllowPrivateAccess="true"))
TObjectPtr<class USceneComponent> DefaultSceneRoot;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Components", meta=(AllowPrivateAccess="true"))
TObjectPtr<class UStaticMeshComponent> Cube;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Components", meta=(AllowPrivateAccess="true"))
TObjectPtr<class USphereComponent> Sphere;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Components", meta=(AllowPrivateAccess="true"))
TSubclassOf<class ABaseEquippable> Item;
}; };

View File

@ -19,14 +19,16 @@ void UCombatAnimInstance::NativeUpdateAnimation(float DeltaSeconds)
{ {
Super::NativeUpdateAnimation(DeltaSeconds); Super::NativeUpdateAnimation(DeltaSeconds);
if (CharacterMovementComponent == nullptr)
return;
IsFalling = CharacterMovementComponent->IsFalling();
Velocity = CharacterMovementComponent->Velocity; Velocity = CharacterMovementComponent->Velocity;
FVector2D vel = { Velocity.X, Velocity.Y }; FVector2D vel = { Velocity.X, Velocity.Y };
GroundSpeed = vel.Length(); GroundSpeed = vel.Length();
ShouldMove = (GroundSpeed > 3.f) && (CharacterMovementComponent->GetCurrentAcceleration().Length() != 0); ShouldMove = (GroundSpeed > 3.f) && (CharacterMovementComponent->GetCurrentAcceleration().Length() != 0);
IsFalling = CharacterMovementComponent->IsFalling();
} }
void UCombatAnimInstance::UpdateCombatType(ECombatType combatType) void UCombatAnimInstance::UpdateCombatType(ECombatType combatType)

View File

@ -9,7 +9,10 @@
#include "GameFramework/SpringArmComponent.h" #include "GameFramework/SpringArmComponent.h"
#include "EnhancedInputComponent.h" #include "EnhancedInputComponent.h"
#include "EnhancedInputSubsystems.h" #include "EnhancedInputSubsystems.h"
#include "Kismet/KismetSystemLibrary.h"
#include "Interface/Interact.h"
#include "Actor/BaseWeapon.h"
#include "Components//CombatComponent.h"
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// ACombatCharacter // ACombatCharacter
@ -50,6 +53,8 @@ ACombatCharacter::ACombatCharacter()
// Note: The skeletal mesh and anim blueprint references on the Mesh component (inherited from Character) // Note: The skeletal mesh and anim blueprint references on the Mesh component (inherited from Character)
// are set in the derived blueprint asset named ThirdPersonCharacter (to avoid direct content references in C++) // are set in the derived blueprint asset named ThirdPersonCharacter (to avoid direct content references in C++)
CombatComponent = CreateDefaultSubobject<UCombatComponent>(TEXT("CombatComponent"));
} }
void ACombatCharacter::BeginPlay() void ACombatCharacter::BeginPlay()
@ -75,7 +80,7 @@ void ACombatCharacter::SetupPlayerInputComponent(class UInputComponent* PlayerIn
// Set up action bindings // Set up action bindings
if (UEnhancedInputComponent* EnhancedInputComponent = CastChecked<UEnhancedInputComponent>(PlayerInputComponent)) { if (UEnhancedInputComponent* EnhancedInputComponent = CastChecked<UEnhancedInputComponent>(PlayerInputComponent)) {
//Jumping@ //Jumping
EnhancedInputComponent->BindAction(JumpAction, ETriggerEvent::Triggered, this, &ACharacter::Jump); EnhancedInputComponent->BindAction(JumpAction, ETriggerEvent::Triggered, this, &ACharacter::Jump);
EnhancedInputComponent->BindAction(JumpAction, ETriggerEvent::Completed, this, &ACharacter::StopJumping); EnhancedInputComponent->BindAction(JumpAction, ETriggerEvent::Completed, this, &ACharacter::StopJumping);
@ -85,8 +90,12 @@ void ACombatCharacter::SetupPlayerInputComponent(class UInputComponent* PlayerIn
//Looking //Looking
EnhancedInputComponent->BindAction(LookAction, ETriggerEvent::Triggered, this, &ACombatCharacter::Look); EnhancedInputComponent->BindAction(LookAction, ETriggerEvent::Triggered, this, &ACombatCharacter::Look);
} //Interact
EnhancedInputComponent->BindAction(InteractAction, ETriggerEvent::Started, this, &ACombatCharacter::Interact);
//ToggleCombat
EnhancedInputComponent->BindAction(ToggleCombatAction, ETriggerEvent::Started, this, &ACombatCharacter::ToggleCombat);
}
} }
void ACombatCharacter::Move(const FInputActionValue& Value) void ACombatCharacter::Move(const FInputActionValue& Value)
@ -125,6 +134,51 @@ void ACombatCharacter::Look(const FInputActionValue& Value)
} }
} }
void ACombatCharacter::Interact(const FInputActionValue& Value)
{
bool bInput = Value.Get<bool>();
//static bool SphereTraceSingleForObjects(const UObject * WorldContextObject,
// const FVector Start,
// const FVector End,
// float Radius,
// const TArray<TEnumAsByte<EObjectTypeQuery> > &ObjectTypes,
// bool bTraceComplex,
// const TArray<AActor*>&ActorsToIgnore,
// EDrawDebugTrace::Type DrawDebugType,
// FHitResult & OutHit, bool bIgnoreSelf,
// FLinearColor TraceColor = FLinearColor::Red,
// FLinearColor TraceHitColor = FLinearColor::Green,
// float DrawTime = 5.0f);
TArray<TEnumAsByte<EObjectTypeQuery>> ObjectTypes;
TEnumAsByte<EObjectTypeQuery> InteractiveType = UEngineTypes::ConvertToObjectType(ECollisionChannel::ECC_GameTraceChannel1);
ObjectTypes.Add(InteractiveType);
TArray<AActor*> ActorsToIgnore;
FHitResult OutHit;
if (UKismetSystemLibrary::SphereTraceSingleForObjects(GetWorld(), GetActorLocation(), GetActorLocation(), 100.f, ObjectTypes, false, ActorsToIgnore, EDrawDebugTrace::ForDuration, OutHit, true))
{
IInteract* interactObject = Cast<IInteract>(OutHit.GetActor());
if (interactObject)
interactObject->Interact(this);
}
}
void ACombatCharacter::ToggleCombat(const FInputActionValue& Value)
{
bool bInput = Value.Get<bool>();
ABaseWeapon* baseWeapon = CombatComponent->GetMainWeapon();
bool isCombatEnabled = CombatComponent->GetCombatEnabled();
if (!baseWeapon)
return;
if (!isCombatEnabled)
PlayAnimMontage(baseWeapon->GetEnterCombat());
else
PlayAnimMontage(baseWeapon->GetExitCombat());
}

View File

@ -37,19 +37,25 @@ class ACombatCharacter : public ACharacter
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true")) UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
class UInputAction* LookAction; class UInputAction* LookAction;
/* Interact Input Action */
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
class UInputAction* InteractAction;
/* ToggleCombat Input Action */
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
class UInputAction* ToggleCombatAction;
public: public:
ACombatCharacter(); ACombatCharacter();
protected: protected:
/** Called for movement input */ /** Called for movement input */
void Move(const FInputActionValue& Value); void Move(const FInputActionValue& Value);
/** Called for looking input */ /** Called for looking input */
void Look(const FInputActionValue& Value); void Look(const FInputActionValue& Value);
void Interact(const FInputActionValue& Value);
void ToggleCombat(const FInputActionValue& Value);
protected: protected:
// APawn interface // APawn interface
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override; virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
@ -62,5 +68,9 @@ public:
FORCEINLINE class USpringArmComponent* GetCameraBoom() const { return CameraBoom; } FORCEINLINE class USpringArmComponent* GetCameraBoom() const { return CameraBoom; }
/** Returns FollowCamera subobject **/ /** Returns FollowCamera subobject **/
FORCEINLINE class UCameraComponent* GetFollowCamera() const { return FollowCamera; } FORCEINLINE class UCameraComponent* GetFollowCamera() const { return FollowCamera; }
public:
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category="Components", meta=(AllowPrivateAccess="true"))
TObjectPtr<class UCombatComponent> CombatComponent;
}; };

View File

@ -5,6 +5,7 @@
#include "Actor/BaseWeapon.h" #include "Actor/BaseWeapon.h"
#include "Enums/CombatType.h" #include "Enums/CombatType.h"
#include "GameFramework/Character.h" #include "GameFramework/Character.h"
#include "Interface/IAnimInstance.h"
// Sets default values for this component's properties // Sets default values for this component's properties
UCombatComponent::UCombatComponent() UCombatComponent::UCombatComponent()
@ -16,6 +17,24 @@ UCombatComponent::UCombatComponent()
// ... // ...
} }
void UCombatComponent::SetCombatEnabled(bool bInputCombat)
{
bCombatEnabled = bInputCombat;
ACharacter* character = Cast<ACharacter>(GetOwner());
if (character)
{
IIAnimInstance* Animinstance = Cast<IIAnimInstance>(character->GetMesh()->GetAnimInstance());
if (Animinstance)
Animinstance->UpdateCombatEnabled(bInputCombat);
}
}
bool UCombatComponent::GetCombatEnabled()
{
return bCombatEnabled;
}
void UCombatComponent::SetMainWeapon(ABaseWeapon* NewWeapon) void UCombatComponent::SetMainWeapon(ABaseWeapon* NewWeapon)
{ {
if (IsValid(MainWeapon)) if (IsValid(MainWeapon))
@ -25,28 +44,4 @@ void UCombatComponent::SetMainWeapon(ABaseWeapon* NewWeapon)
} }
MainWeapon = NewWeapon; MainWeapon = NewWeapon;
} }
ABaseWeapon* UCombatComponent::GetMainWeapon()
{
return MainWeapon;
}
void UCombatComponent::SetCombatEnabled(bool bInputCombat)
{
bCombatEnabled = bInputCombat;
ACharacter* character = Cast<ACharacter>(GetOwner());
if (character)
{
//TODO : AnimInstance ÈÄ¿¡ ó¸®
//character->GetMesh()->GetAnimInstance();
}
}
bool UCombatComponent::GetCombatEnabled()
{
return bCombatEnabled;
}

View File

@ -18,10 +18,14 @@ public:
UCombatComponent(); UCombatComponent();
public: public:
void SetMainWeapon(ABaseWeapon* NewWeapon); UFUNCTION(BlueprintCallable)
ABaseWeapon* GetMainWeapon();
void SetCombatEnabled(bool bInputCombat); void SetCombatEnabled(bool bInputCombat);
UFUNCTION(BlueprintCallable)
bool GetCombatEnabled(); bool GetCombatEnabled();
void SetMainWeapon(ABaseWeapon* NewWeapon);
FORCEINLINE ABaseWeapon* GetMainWeapon() const { return MainWeapon; }
private: private:
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, meta=(AllowPrivateAccess="true")) UPROPERTY(VisibleAnywhere, BlueprintReadWrite, meta=(AllowPrivateAccess="true"))
TObjectPtr<ABaseWeapon> MainWeapon; TObjectPtr<ABaseWeapon> MainWeapon;

View File

@ -0,0 +1,6 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "Interface/Interact.h"
// Add default functionality here for any IInteract functions that are not pure virtual.

View File

@ -0,0 +1,26 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "UObject/Interface.h"
#include "Interact.generated.h"
// This class does not need to be modified.
UINTERFACE(MinimalAPI)
class UInteract : public UInterface
{
GENERATED_BODY()
};
/**
*
*/
class D1_API IInteract
{
GENERATED_BODY()
// Add interface functions to this class. This is the class that will be inherited to implement this interface.
public:
virtual void Interact(AActor* Caller) = 0;
};