[박치영] c++ 포팅 작업 중

main
PCYPC\pcy35 2023-07-26 21:31:37 +09:00
parent b2fdfd6724
commit da1657869e
23 changed files with 402 additions and 1 deletions

View File

@ -7,7 +7,10 @@
{
"Name": "D1",
"Type": "Runtime",
"LoadingPhase": "Default"
"LoadingPhase": "Default",
"AdditionalDependencies": [
"Engine"
]
}
],
"Plugins": [

View File

@ -0,0 +1,48 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "Actor/BaseEquippable.h"
#include "GameFramework/Character.h"
//#include "SkeletalMesh.h"
// Sets default values
ABaseEquippable::ABaseEquippable()
{
// 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;
}
void ABaseEquippable::AttachActor(const FName SocketName)
{
ACharacter* character = Cast<ACharacter>(GetOwner());
if (character)
{
USkeletalMeshComponent* mesh = character->GetMesh();
AttachToComponent(mesh, FAttachmentTransformRules::SnapToTargetNotIncludingScale, SocketName);
}
}
void ABaseEquippable::OnEquipped()
{
bIsEquipped = true;
AttachToActor(this, FAttachmentTransformRules::SnapToTargetNotIncludingScale, AttachSocketName);
}
void ABaseEquippable::OnUnequipped()
{
if (bIsEquipped)
bIsEquipped = false;
}
void ABaseEquippable::SetIsEquipped(bool IsEquipped)
{
bIsEquipped = IsEquipped;
}
bool ABaseEquippable::GetIsEquipped()
{
return bIsEquipped;
}

View File

@ -0,0 +1,31 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "BaseEquippable.generated.h"
UCLASS()
class D1_API ABaseEquippable : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
ABaseEquippable();
public:
UFUNCTION(BlueprintCallable)
virtual void AttachActor(const FName SocketName);
virtual void OnEquipped();
virtual void OnUnequipped();
virtual void SetIsEquipped(bool IsEquipped);
virtual bool GetIsEquipped();
protected:
UPROPERTY(VisibleAnywhere, BlueprintReadWrite)
bool bIsEquipped;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Initialization")
FName AttachSocketName;
};

View File

@ -0,0 +1,26 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "Actor/BaseWeapon.h"
#include "Components/CombatComponent.h"
ABaseWeapon::ABaseWeapon()
{
}
void ABaseWeapon::OnEquipped()
{
SetIsEquipped(true);
AActor* owner = GetOwner();
UCombatComponent* component = owner->GetComponentByClass<UCombatComponent>();
if (component->GetCombatEnabled())
AttachActor(HandSocketName);
else
AttachActor(AttachSocketName);
CombatComponent->SetMainWeapon(this);
//TODO Update Combat Type
}

View File

@ -0,0 +1,37 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Actor/BaseEquippable.h"
#include "Enums/CombatType.h"
#include "BaseWeapon.generated.h"
/**
*
*/
UCLASS()
class D1_API ABaseWeapon : public ABaseEquippable
{
GENERATED_BODY()
public:
ABaseWeapon();
public:
void OnEquipped() override;
protected:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Initialization")
FName HandSocketName;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Initialization")
ECombatType CombatType;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category="Components")
TObjectPtr<class UCombatComponent> CombatComponent;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Animations")
TObjectPtr<class UAnimMontage> EnterCombat;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Animations")
TObjectPtr<class UAnimMontage> ExitCombat;
};

View File

@ -0,0 +1,14 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "Actor/PickupActor.h"
// Sets default values
APickupActor::APickupActor()
{
// 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;
}

View File

@ -0,0 +1,20 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "PickupActor.generated.h"
UCLASS()
class D1_API APickupActor : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
APickupActor();
private:
};

View File

@ -0,0 +1,40 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "Animation/CombatAnimInstance.h"
#include "GameFramework/Character.h"
#include "GameFramework/CharacterMovementComponent.h"
#include "Kismet/KismetMathLibrary.h"
void UCombatAnimInstance::NativeInitializeAnimation()
{
Super::NativeInitializeAnimation();
Character = Cast<ACharacter>(TryGetPawnOwner());
if (Character)
CharacterMovementComponent = Character->GetCharacterMovement();
}
void UCombatAnimInstance::NativeUpdateAnimation(float DeltaSeconds)
{
Super::NativeUpdateAnimation(DeltaSeconds);
Velocity = CharacterMovementComponent->Velocity;
FVector2D vel = { Velocity.X, Velocity.Y };
GroundSpeed = vel.Length();
ShouldMove = (GroundSpeed > 3.f) && (CharacterMovementComponent->GetCurrentAcceleration().Length() != 0);
IsFalling = CharacterMovementComponent->IsFalling();
}
void UCombatAnimInstance::UpdateCombatType(ECombatType combatType)
{
CombatType = combatType;
}
void UCombatAnimInstance::UpdateCombatEnabled(bool combatEnabled)
{
CombatEnabled = combatEnabled;
}

View File

@ -0,0 +1,46 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Animation/AnimInstance.h"
#include "Interface/IAnimInstance.h"
#include "Enums/CombatType.h"
#include "CombatAnimInstance.generated.h"
/**
*
*/
UCLASS()
class D1_API UCombatAnimInstance : public UAnimInstance, public IIAnimInstance
{
GENERATED_BODY()
public:
virtual void NativeInitializeAnimation() override;
virtual void NativeUpdateAnimation(float DeltaSeconds) override;
public:
virtual void UpdateCombatType(ECombatType combatType) override;
virtual void UpdateCombatEnabled(bool combatEnabled) override;
private:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="References", meta=(AllowPrivateAccess="true"))
TObjectPtr<class ACharacter> Character;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="References", meta = (AllowPrivateAccess = "true"))
TObjectPtr<class UCharacterMovementComponent> CharacterMovementComponent;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="EssentialMovementData", meta = (AllowPrivateAccess = "true"))
FVector Velocity;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="EssentialMovementData", meta = (AllowPrivateAccess = "true"))
float GroundSpeed;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="EssentialMovementData", meta = (AllowPrivateAccess = "true"))
bool ShouldMove;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="EssentialMovementData", meta = (AllowPrivateAccess = "true"))
bool IsFalling;
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (AllowPrivateAccess = "true"))
ECombatType CombatType;
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (AllowPrivateAccess = "true"))
bool CombatEnabled;
};

View File

@ -0,0 +1,52 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "Components/CombatComponent.h"
#include "Actor/BaseWeapon.h"
#include "Enums/CombatType.h"
#include "GameFramework/Character.h"
// Sets default values for this component's properties
UCombatComponent::UCombatComponent()
{
// Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features
// off to improve performance if you don't need them.
PrimaryComponentTick.bCanEverTick = true;
// ...
}
void UCombatComponent::SetMainWeapon(ABaseWeapon* NewWeapon)
{
if (IsValid(MainWeapon))
{
MainWeapon->OnUnequipped();
MainWeapon->Destroy();
}
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

@ -0,0 +1,31 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "CombatComponent.generated.h"
class ABaseWeapon;
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class D1_API UCombatComponent : public UActorComponent
{
GENERATED_BODY()
public:
// Sets default values for this component's properties
UCombatComponent();
public:
void SetMainWeapon(ABaseWeapon* NewWeapon);
ABaseWeapon* GetMainWeapon();
void SetCombatEnabled(bool bInputCombat);
bool GetCombatEnabled();
private:
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, meta=(AllowPrivateAccess="true"))
TObjectPtr<ABaseWeapon> MainWeapon;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, meta=(AllowPrivateAccess="true"))
bool bCombatEnabled;
};

View File

@ -9,5 +9,7 @@ public class D1 : ModuleRules
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "HeadMountedDisplay", "EnhancedInput" });
PublicIncludePaths.AddRange(new string[] { "D1" });
}
}

View File

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

View File

@ -0,0 +1,15 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
UENUM(BlueprintType)
enum class ECombatType : uint8
{
NONE UMETA(DisplayName = "NONE"),
LIGHTSWORD UMETA(DisplayName = "LIGHTSWORD"),
GREATSWORD UMETA(DisplayName = "GREATSWORD")
};

View File

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

View File

@ -0,0 +1,28 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "UObject/Interface.h"
#include "Enums/CombatType.h"
#include "IAnimInstance.generated.h"
// This class does not need to be modified.
UINTERFACE(MinimalAPI)
class UIAnimInstance : public UInterface
{
GENERATED_BODY()
};
/**
*
*/
class D1_API IIAnimInstance
{
GENERATED_BODY()
// Add interface functions to this class. This is the class that will be inherited to implement this interface.
public:
virtual void UpdateCombatType(ECombatType combatType) = 0;
virtual void UpdateCombatEnabled(bool combatEnabled) = 0;
};