KLingo Project Documentation 1.0.0
Unreal Engine 5.6 C++ Project Documentation
로딩중...
검색중...
일치하는것 없음
ADoor.cpp
이 파일의 문서화 페이지로 가기
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
3
4#include "ADoor.h"
5
6#include "FComponentHelper.h"
7#include "UBroadcastManager.h"
8
9#define DOOR_FRAME_PATH TEXT("/Game/CustomContents/Platfrom/Assets/Portal_Door/portal_door_Frame.portal_door_Frame")
10#define DOOR_LEFT_PATH TEXT("/Game/CustomContents/Platfrom/Assets/Portal_Door/portal_door_Right.portal_door_Right")
11#define DOOR_RIGHT_PATH TEXT("/Game/CustomContents/Platfrom/Assets/Portal_Door/portal_door_left.portal_door_left")
12
14{
15 SceneRoot = CreateDefaultSubobject<USceneComponent>(TEXT("SceneRoot"));
16 SetRootComponent(SceneRoot);
17
18 SM_Frame = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("SM_Frame"));
19 SM_Frame->SetupAttachment(SceneRoot);
21
22 SM_Right = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("SM_Right"));
23 SM_Right->SetupAttachment(SceneRoot);
25
26 SM_Left = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("SM_Left"));
27 SM_Left->SetupAttachment(SceneRoot);
29}
30
32{
33 Super::BeginPlay();
34
35 UBroadcastManager::Get(GetWorld())->OnDoorMessage.AddDynamic(this, &ADoor::OnDoorMessage);
36
37 // 맵 배치 시 설정한 초기 상태 적용
38 if (bStartOpened)
39 {
40 Alpha = 1.0f;
42 }
43 else
44 {
45 Alpha = 0.0f;
47 }
48}
49
50void ADoor::UpdateDoor(float InAlpha)
51{
52 Alpha = InAlpha; // Blueprint에서 SET 한 것과 대응
53
54 // Right
55 {
56 const FVector ClosedPos = FVector::ZeroVector;
57 const FVector OpenPos = RightOpen;
58
59 const FVector NewPos = FMath::Lerp(ClosedPos, OpenPos, Alpha);
60 SM_Right->SetRelativeLocation(NewPos, false, nullptr, ETeleportType::None);
61 }
62
63 // Left
64 {
65 const FVector ClosedPos = FVector::ZeroVector;
66 const FVector OpenPos = LeftOpen;
67
68 const FVector NewPos = FMath::Lerp(ClosedPos, OpenPos, Alpha);
69 SM_Left->SetRelativeLocation(NewPos, false, nullptr, ETeleportType::None);
70 }
71}
72
73void ADoor::OnDoorMessage(int32 InDoorIndex, bool bInOpen, AActor* EventInstigator)
74{
75 if (InDoorIndex != DoorIndex)
76 return;
77
78 CurCount += (bInOpen ? 1 : -1);
79 CurCount = FMath::Clamp(CurCount, 0, ReqCount); // 안전
80
81 if (CurCount >= ReqCount)
82 OpenDoor();
83 else
84 CloseDoor();
85}
86
90
#define DOOR_FRAME_PATH
Definition ADoor.cpp:9
#define DOOR_LEFT_PATH
Definition ADoor.cpp:10
#define DOOR_RIGHT_PATH
Definition ADoor.cpp:11
FComponentHelper 구조체를 선언합니다.
TObjectPtr< UStaticMeshComponent > SM_Right
Definition ADoor.h:44
int32 DoorIndex
Definition ADoor.h:47
TObjectPtr< UStaticMeshComponent > SM_Left
Definition ADoor.h:42
TObjectPtr< USceneComponent > SceneRoot
Definition ADoor.h:37
virtual void CloseDoor_Implementation()
Definition ADoor.cpp:91
virtual void BeginPlay() override
Definition ADoor.cpp:31
void UpdateDoor(float InAlpha)
Definition ADoor.cpp:50
FVector RightOpen
Definition ADoor.h:62
ADoor()
Definition ADoor.cpp:13
float Alpha
Definition ADoor.h:66
bool bStartOpened
맵 배치 시 문이 열린 상태로 시작할지 여부
Definition ADoor.h:57
void OnDoorMessage(int32 InDoorIndex, bool bInOpen, AActor *EventInstigator)
Definition ADoor.cpp:73
int32 CurCount
Definition ADoor.h:65
FVector LeftOpen
Definition ADoor.h:60
void OpenDoor()
void CloseDoor()
TObjectPtr< UStaticMeshComponent > SM_Frame
Definition ADoor.h:40
int32 ReqCount
Definition ADoor.h:50
virtual void OpenDoor_Implementation()
Definition ADoor.cpp:87
static T * LoadAsset(const TCHAR *Path)