KLingo Project Documentation 1.0.0
Unreal Engine 5.6 C++ Project Documentation
로딩중...
검색중...
일치하는것 없음
Macro.h
이 파일의 문서화 페이지로 가기
1// Copyright (c) 2025 Doppleddiggong. All rights reserved. Unauthorized copying, modification, or distribution of this file, via any medium is strictly prohibited. Proprietary and confidential.
2
7#pragma once
8
9
10// 공통 선언-구현 매크로
11#define DEFINE_SUBSYSTEM_GETTER_INLINE(ClassName) \
12UFUNCTION(BlueprintPure, Category="CoffeeLibrary|Subsystem", meta=(WorldContext="WorldContextObject")) \
13static ClassName* Get(UObject* WorldContext) \
14{ \
15if (!WorldContext) \
16return nullptr; \
17if (auto* World = WorldContext->GetWorld()) \
18if (auto* GI = World->GetGameInstance()) \
19return GI->GetSubsystem<ClassName>(); \
20return nullptr; \
21}
22
23
24#define DEFINE_LOCALPLAYER_SUBSYSTEM_GETTER_INLINE(ClassName) \
25UFUNCTION(BlueprintPure, Category="CoffeeLibrary|Subsystem", meta=(WorldContext="WorldContextObject")) \
26static ClassName* Get(UObject* WorldContextObject) \
27{ \
28 if (!WorldContextObject) \
29 return nullptr; \
30 if (UWorld* World = WorldContextObject->GetWorld()) \
31 { \
32 if (UGameInstance* GameInstance = World->GetGameInstance()) \
33 { \
34 if (ULocalPlayer* LocalPlayer = GameInstance->GetFirstGamePlayer()) \
35 { \
36 return LocalPlayer->GetSubsystem<ClassName>(); \
37 } \
38 } \
39 } \
40 return nullptr; \
41}
42
43// Optional: PlayerController를 받아서 해당 LocalPlayer의 서브시스템을 가져오는 매크로도 만들 수 있어요
44#define DEFINE_LOCALPLAYER_FROM_PC_SUBSYSTEM_GETTER_INLINE(ClassName) \
45UFUNCTION(BlueprintPure, Category="CoffeeLibrary|Subsystem", meta=(WorldContext="WorldContextObject")) \
46static ClassName* GetFromPlayerController(UObject* WorldContextObject, APlayerController* PC) \
47{ \
48 if (!WorldContextObject || !PC) \
49 return nullptr; \
50 if (ULocalPlayer* LP = Cast<ULocalPlayer>(PC->Player)) \
51 { \
52 return LP->GetSubsystem<ClassName>(); \
53 } \
54 return nullptr; \
55}
56
57
58
59// 공통 선언 매크로
60#define DECLARE_SUBSYSTEM_GETTER(ClassName) \
61UFUNCTION(BlueprintPure, Category="CoffeeLibrary|Subsystem", meta=(WorldContext="WorldContextObject")) \
62static ClassName* Get(UObject* WorldContext);
63
64// 공통 구현 매크로
65#define DEFINE_SUBSYSTEM_GETTER_IMPL(ClassName) \
66static ClassName* Get(UObject* WorldContext) \
67{ \
68 if (!WorldContext) \
69 return nullptr; \
70 if (auto* World = WorldContext->GetWorld()) \
71 if (auto* GI = World->GetGameInstance()) \
72 return GI->GetSubsystem<ClassName>(); \
73 return nullptr; \
74}
75
76#define BIND_DYNAMIC_DELEGATE(DelegateType, Obj, ClassType, FuncName) \
77[] (auto* InObj) { \
78DelegateType Tmp; \
79Tmp.BindUFunction(InObj, GET_FUNCTION_NAME_CHECKED(ClassType, FuncName)); \
80return Tmp; \
81} (Obj)
82
83#define ENUM_TO_NAME(EnumType, Value) \
84(StaticEnum<EnumType>()->GetNameStringByValue(static_cast<int64>(Value)))
85
86#define ENUM_TO_TEXT(EnumType, Value) \
87(StaticEnum<EnumType>()->GetDisplayNameTextByValue(static_cast<int64>(Value)))