KLingo Project Documentation 1.0.0
Unreal Engine 5.6 C++ Project Documentation
로딩중...
검색중...
일치하는것 없음
AEvaluationTrigger.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
5#include "Components/BoxComponent.h"
6#include "DrawDebugHelpers.h"
7#include "APlayerActor.h"
8#include "GameFramework/PlayerController.h"
9#include "GameLogging.h"
11#include "ULingoGameHelper.h"
12#include "UPopupManager.h"
13#include "UPopup_Evaluation.h"
14
16{
17 PrimaryActorTick.bCanEverTick = true;
18 bReplicates = true;
19
20 // 루트 컴포넌트로 BoxComponent 생성
21 TriggerBox = CreateDefaultSubobject<UBoxComponent>(TEXT("TriggerBox"));
22 RootComponent = TriggerBox;
23
24 // 박스 크기 기본값 설정
25 TriggerBox->SetBoxExtent(FVector(100.0f, 100.0f, 100.0f));
26
27 // Overlap 이벤트 활성화
28 TriggerBox->SetGenerateOverlapEvents(true);
29 TriggerBox->SetCollisionEnabled(ECollisionEnabled::QueryOnly);
30 TriggerBox->SetCollisionResponseToAllChannels(ECR_Ignore);
31 TriggerBox->SetCollisionResponseToChannel(ECC_Pawn, ECR_Overlap);
32
33 // 초기값 설정
34 bIsTriggered = false;
35 bShowDebugBox = true;
36 DebugBoxColor = FColor::Green;
38
39}
40
42{
43 Super::BeginPlay();
44
45 if (TriggerBox)
46 TriggerBox->OnComponentBeginOverlap.AddDynamic(this, &AEvaluationTrigger::OnTriggerBeginOverlap);
47}
48
49void AEvaluationTrigger::Tick(float DeltaTime)
50{
51 Super::Tick(DeltaTime);
52
54 {
55 FVector BoxCenter = TriggerBox->GetComponentLocation();
56 FVector BoxExtent = TriggerBox->GetScaledBoxExtent();
57 FRotator BoxRotation = TriggerBox->GetComponentRotation();
58
59 // 디버그 박스 표시 (트리거 활성화 상태일 때만)
60 if (!bIsTriggered)
61 {
62 DrawDebugBox(
63 GetWorld(),
64 BoxCenter,
65 BoxExtent,
66 BoxRotation.Quaternion(),
68 false,
69 -1.0f,
70 0,
71 2.0f
72 );
73 }
74
75 // 트리거 정보를 텍스트로 표시
76 FString StatusText = bIsTriggered ? TEXT("[TRIGGERED]") : TEXT("[ACTIVE]");
77 FColor TextColor = bIsTriggered ? FColor::Red : FColor::Green;
78
79 FVector TextLocation = BoxCenter + FVector(0.0f, 0.0f, BoxExtent.Z + 50.0f);
80
81 // 상태 표시
82 DrawDebugString(
83 GetWorld(),
84 TextLocation,
85 StatusText,
86 nullptr,
87 TextColor,
88 0.0f,
89 true,
90 1.2f
91 );
92 }
93}
94
96 UPrimitiveComponent* OverlappedComponent, AActor* OtherActor,
97 UPrimitiveComponent* OtherComp, int32 OtherBodyIndex,
98 bool bFromSweep, const FHitResult& SweepResult)
99{
100 // 원샷 모드이고 이미 트리거되었으면 무시
101 if ( bIsTriggered)
102 return;
103
104 // PlayerActor인지 확인
105 APlayerActor* PlayerActor = Cast<APlayerActor>(OtherActor);
106 if (PlayerActor)
107 {
108 // 로컬 플레이어만 처리 (각 클라이언트가 독립적으로 Evaluation 요청)
109 if (APlayerController* PC = Cast<APlayerController>(PlayerActor->GetController()))
110 {
111 if (PC->IsLocalPlayerController())
112 {
113 OnActivate();
114 bIsTriggered = true;
115 }
116 }
117 }
118}
119
121{
122 if (auto KLingoNetwork = UKLingoNetworkSystem::Get(GetWorld()))
123 {
124 if (auto GS = ULingoGameHelper::GetLingoGameState(GetWorld()))
125 {
126 KLingoNetwork->RequestEvaluationResult(
127 GS->GetRoomId(),
128 FResponseEvaluationResultDelegate::CreateUObject(this, &AEvaluationTrigger::OnResponseEvaluationResult)
129 );
130 }
131 }
132 else
133 {
134 PRINTLOG(TEXT("UKLingoNetworkSystem not found!"));
135 }
136}
137
139{
140 if (bWasSuccessful)
141 {
142 PRINTLOG(TEXT("--- Evaluation Result SUCCESS ---"));
143
144 if (auto Popup = UPopupManager::ShowPopupAs<UPopup_Evaluation>( GetWorld(), EPopupType::Evaluation))
145 Popup->InitPopup(ResponseData);
146 }
147 else
148 {
149 PRINTLOG(TEXT("--- OCR Extract FAILED ---"));
150 }
151}
Declares the player-controlled character actor.
YiSan 전반에서 사용하는 공용 인터페이스를 선언합니다.
#define PRINTLOG(fmt,...)
Definition GameLogging.h:30
KLingo API 요청을 담당하는 서브시스템을 선언합니다.
virtual void BeginPlay() override
void OnResponseEvaluationResult(FResponseEvaluationResult &ResponseData, bool bWasSuccessful)
FColor DebugBoxColor
디버그 박스 색상
virtual void Tick(float DeltaTime) override
virtual void OnActivate_Implementation()
void OnTriggerBeginOverlap(UPrimitiveComponent *OverlappedComponent, AActor *OtherActor, UPrimitiveComponent *OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult &SweepResult)
트리거 박스 Overlap 시작 이벤트 핸들러
bool bShowDebugBox
디버그 드로우 표시 여부
TObjectPtr< class UBoxComponent > TriggerBox
트리거 영역을 정의하는 박스 컴포넌트
bool bIsTriggered
트리거 활성화 상태 (false = 활성화, true = 비활성화)
Main character driven directly by the player.
static class ALingoGameState * GetLingoGameState(const UObject *WorldContextObject)
Evaluation 결과 응답 구조체입니다.