[Unreal_C++_DarkSoul]#3_기능 구현, Custom Structure, Custom Enumeration

2022. 11. 23. 11:03· 개인프로젝트
목차
  1.  
  2. [Unreal_C++_DarkSoul]#3_Custom Structure, Custom Enumeration

 

[Unreal_C++_DarkSoul]#3_Custom Structure, Custom Enumeration

 

Unreal C++ 개발 중 "커스텀 구조체 클래스와 커스텀 열거형 클래스"에 대한 내용입니다.

포트폴리오 진행 사항을 기록하기 위한 포스팅입니다.

 

 


 

Overview

 

  1. 임의의 Actor 클래스를 생성합니다.
  2. Actor 클래스의 헤더 파일에 사용자 정의 구조체 클래스와 열거형 클래스를 작성합니다.
  3. 각 타입의 클래스는 Unreal Editor에 Reflection 하기 위해 "USTRUCT()"와 "UENUM()"을 선언합니다.

 

Custom Enum Class

1. Custom_Enums.h

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "Custom_Enums.generated.h"

UCLASS()
class DARKSOUL_API ACustom_Enums : public AActor
{
	GENERATED_BODY()
};

// 0. State Enums					********************************************

UENUM(BlueprintType)
enum class EStateType : uint8
{
	E_Idle = 0 			UMETA(DisplayName = "Idle"),
	E_Attacking 		UMETA(DisplayName = "Attacking"),
	E_Skilling			UMETA(DisplayName = "Skilling"),
	E_Guarding			UMETA(DisplayName = "Guarding"),
	E_Stumbling 		UMETA(DisplayName = "Stumbling"),
	E_Rolling 			UMETA(DisplayName = "Rolling"),
	E_Backstsepping 	UMETA(DisplayName = "Backstepping")
};

UENUM(BlueprintType)
enum class EComboType : uint8
{
	E_ComboType_1 = 0 	UMETA(DisplayName = "First Combo Type"),
	E_ComboType_2 		UMETA(DisplayName = "Second Combo Type"),
};

// 1. Player State Enums			********************************************

UENUM(BlueprintType)
enum class EPlayerCombatType : uint8
{
	E_Unarmed = 0 	UMETA(DisplayName = "Unarmed"),
	E_Fighter 		UMETA(DisplayName = "Fighter"),
	E_SwordMaster 	UMETA(DisplayName = "Sword Master"),
	E_AxeMaster 	UMETA(DisplayName = "Axe Master"),
	E_Samurai		UMETA(DisplayName = "Samurai"),
	E_Warrior		UMETA(DisplayName = "Warrior"),
	E_Wizard 		UMETA(DisplayName = "Wizard"),
	E_Gunner 		UMETA(DisplayName = "Gunner"),
};

// 3. Weapon Type				********************************************

UENUM(BlueprintType)
enum class EWeaponType : uint8
{
	E_Sword = 0			UMETA(DisplayName = "Sword"),
	E_Axe				UMETA(DisplayName = "Axe"),
	E_Fist				UMETA(DisplayName = "Fist"),
	E_Katana			UMETA(DisplayName = "Katana"),
	E_SwordAndShield	UMETA(DisplayName = "SwordAndShield"),
	E_CastleKnight_Axe	UMETA(DisplayName = "CastleKnight_Axe")
};

// 4. Attribute Type			********************************************

UENUM(BlueprintType)
enum class EAttributeType : uint8
{
	E_Steel = 0			UMETA(DisplayName = "Steel"),
	E_Fire				UMETA(DisplayName = "Fire"),
	E_Ice				UMETA(DisplayName = "Ice"),
	E_Electric			UMETA(DisplayName = "Electric"),
	E_Dark				UMETA(DisplayName = "Dark")
};

// 5. Enmey Type				********************************************

UENUM(BlueprintType)
enum class EEnemyType : uint8
{
	E_None = 0				UMETA(DisplayName = "None"),
	E_CastleKnight			UMETA(DisplayName = "Castle Knight"),
};

 

Details

  1. "UENUM()"을 통해 Unreal Editor에서도 활용 가능한 열거형 클래스를 선언합니다.
  2. 이때, "enum"이 아니라 "enum class"를 선언해야합니다.
  3. "UMETA()"를 통해 메타데이터를 작성합니다.

 

Custom Structure Class

1. Custom_Structs.h

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"

#include "Custom_Enums.h"
#include "GameFramework/Actor.h"
#include "Engine/DataTable.h"
#include "Animation/AnimMontage.h"
#include "Particles/ParticleSystem.h"

#include "Custom_Structs.generated.h"

UCLASS()
class DARKSOUL_API ACustom_Structs : public AActor
{
	GENERATED_BODY()
};

// 0. Weapon				******************************************************

USTRUCT(Atomic, BlueprintType)
struct FNoComboAnimInfo : public FTableRowBase
{
public:
	GENERATED_BODY()

public:
	UPROPERTY(EditAnywhere, BlueprintReadWrite)
		UAnimMontage* AnimMontage;
	UPROPERTY(EditAnywhere, BlueprintReadWrite)
		FName StartSection;
	UPROPERTY(EditAnywhere, BlueprintReadWrite)
		float PlayRate;
	UPROPERTY(EditAnywhere, BlueprintReadWrite)
		bool CanMove;
};

USTRUCT(Atomic, BlueprintType)
struct FComboAnimInfo : public FTableRowBase
{
public:
	GENERATED_BODY()

public:
	UPROPERTY(EditAnywhere, BlueprintReadWrite)
		UAnimMontage* AnimMontage;
	UPROPERTY(EditAnywhere, BlueprintReadWrite)
		FName StartSection;
	UPROPERTY(EditAnywhere, BlueprintReadWrite)
		float PlayRate;
	UPROPERTY(EditAnywhere, BlueprintReadWrite)
		bool CanMove;
};

USTRUCT(Atomic, BlueprintType)
struct FSkillAnimInfo : public FTableRowBase
{
public:
	GENERATED_BODY()

public:
	UPROPERTY(EditAnywhere, BlueprintReadWrite)
		UAnimMontage* AnimMontage;
	UPROPERTY(EditAnywhere, BlueprintReadWrite)
		FName StartSection;
	UPROPERTY(EditAnywhere, BlueprintReadWrite)
		float PlayRate;
	UPROPERTY(EditAnywhere, BlueprintReadWrite)
		bool CanMove;
	UPROPERTY(EditAnywhere, BlueprintReadWrite)
		bool bRadial;		// 단일 스킬 + 광역 스킬
	UPROPERTY(EditAnywhere, BlueprintReadWrite)
		float SphereRadius;	// 광역 스킬 범위
	UPROPERTY(EditAnywhere, BlueprintReadWrite)
		float BaseDamage;	// 스킬 데미지	
	// TODO	:	Hit Effect + Death Effect
	UPROPERTY(EditAnywhere, BlueprintReadWrite)
		UParticleSystem* AttackEffect;
	UPROPERTY(EditAnywhere, BlueprintReadWrite)
		UParticleSystem* ImpactEffect;
};

// 1. Statics				******************************************************

USTRUCT(Atomic, BlueprintType)
struct FSpecInfo : public FTableRowBase
{
public:
	GENERATED_BODY()

public:
	UPROPERTY(EditAnywhere, BlueprintReadWrite)
		float MaxHealth;
	UPROPERTY(EditAnywhere, BlueprintReadWrite)
		float AttackPower;
	UPROPERTY(EditAnywhere, BlueprintReadWrite)
		float DefensePower;
};

// 2. Power					******************************************************

USTRUCT(Atomic, BlueprintType)
struct FPowerInfo : public FTableRowBase
{
public:
	GENERATED_BODY()

public:
	UPROPERTY(EditAnywhere, BlueprintReadWrite)
		EWeaponType Weapon;
	UPROPERTY(EditAnywhere, BlueprintReadWrite)
		EAttributeType Attribute;
	UPROPERTY(EditAnywhere, BlueprintReadWrite)
		float AttackPower;
	UPROPERTY(EditAnywhere, BlueprintReadWrite)
		float AttackRate = 1.f;
	UPROPERTY(EditAnywhere, BlueprintReadWrite)
		float CriticalCount = 10.f;
	UPROPERTY(EditAnywhere, BlueprintReadWrite)
		float CriticalMinRate = 1.f;
	UPROPERTY(EditAnywhere, BlueprintReadWrite)
		float CriticalMaxRate = 5.f;

};

// 3. PlayerCharacter		******************************************************

USTRUCT(Atomic, BlueprintType)
struct FCommonAnimInfo : public FTableRowBase
{
public:
	GENERATED_BODY()

public:
	UPROPERTY(EditAnywhere, BlueprintReadWrite)
		UAnimMontage* AnimMontage;
	UPROPERTY(EditAnywhere, BlueprintReadWrite)
		FName StartSection;
	UPROPERTY(EditAnywhere, BlueprintReadWrite)
		float PlayRate;
	UPROPERTY(EditAnywhere, BlueprintReadWrite)
		bool CanMove;
	// TODO	:	Hit Effect + Death Effect
	UPROPERTY(EditAnywhere, BlueprintReadWrite)
		UParticleSystem* Effect;
};

 

Details

  1. "USTRUCT()"를 통해 Unreal Editor에 Reflection 합니다.
  2. "FTableRowBase"를 Public 상속하여, Unreal Editor의 Data Table 자료형과 상호작용합니다!
  3. Unreal이 제공하는 Data Table 자료형을 구조체와 함께 활용하는 방법은 추후에 살펴보겠습니다.

 

 

 

'개인프로젝트' 카테고리의 다른 글

[Unreal_C++_DarkSoul]#6_기능 구현, Targeting 기능  (0) 2022.12.10
[Unreal_C++_DarkSoul]#5_기능 구현, Target Point, Enemy Spawn 위치  (0) 2022.12.10
[Unreal_C++_DarkSoul]#4_문제 해결, Data Table 로드 함수  (0) 2022.11.27
[Unreal_C++_DarkSoul]#2_기능 구현, Custom Log Class  (0) 2022.11.23
[Unreal_C++_DarkSoul]#1_공부, Interaface 클래스  (0) 2022.11.22
  1.  
  2. [Unreal_C++_DarkSoul]#3_Custom Structure, Custom Enumeration
'개인프로젝트' 카테고리의 다른 글
  • [Unreal_C++_DarkSoul]#5_기능 구현, Target Point, Enemy Spawn 위치
  • [Unreal_C++_DarkSoul]#4_문제 해결, Data Table 로드 함수
  • [Unreal_C++_DarkSoul]#2_기능 구현, Custom Log Class
  • [Unreal_C++_DarkSoul]#1_공부, Interaface 클래스
Hardii2
Hardii2
Hardii2
개발 블로그
Hardii2
전체
오늘
어제
  • 분류 전체보기
    • 알고리즘
    • 웹 개발
      • Node.js
      • React
    • 게임개발
      • DirectX12
      • 관련 지식
      • Unreal C++
      • Unreal 블루프린트
    • 언어
      • Effective C++
      • Basic C++
      • 디자인 패턴
      • 자료구조
      • 기술 질문
    • 문제 풀이
      • BOJ 문제 풀이
      • Programmers 문제 풀이
      • geeksForgeeks 문제 풀이
    • 수학
      • 확률과 통계
      • 게임수학
    • 개인프로젝트
    • 그룹프로젝트
      • PM
      • Dev
    • Github

블로그 메뉴

  • 홈
  • 글쓰기

공지사항

인기 글

태그

  • 우선순위 큐
  • 기술 질문
  • 알고리즘
  • unreal
  • BFS
  • Unreal Blueprint
  • C++
  • 개발
  • programmers
  • BOJ
  • 트리
  • DP
  • 최단 경로
  • Effective C++
  • stl
  • 그래프
  • 디자인 패턴
  • set
  • 정렬
  • dfs

최근 댓글

최근 글

hELLO · Designed By 정상우.v4.2.2
Hardii2
[Unreal_C++_DarkSoul]#3_기능 구현, Custom Structure, Custom Enumeration
상단으로

티스토리툴바

개인정보

  • 티스토리 홈
  • 포럼
  • 로그인

단축키

내 블로그

내 블로그 - 관리자 홈 전환
Q
Q
새 글 쓰기
W
W

블로그 게시글

글 수정 (권한 있는 경우)
E
E
댓글 영역으로 이동
C
C

모든 영역

이 페이지의 URL 복사
S
S
맨 위로 이동
T
T
티스토리 홈 이동
H
H
단축키 안내
Shift + /
⇧ + /

* 단축키는 한글/영문 대소문자로 이용 가능하며, 티스토리 기본 도메인에서만 동작합니다.