KLingo Project Documentation 1.0.0
Unreal Engine 5.6 C++ Project Documentation
로딩중...
검색중...
일치하는것 없음
LuggageManager.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 "LuggageManager.h"
5
6#include "ALingoGameState.h"
7#include "ALuggageHolder.h"
8#include "EngineUtils.h"
9#include "luggage.h"
10#include "NetworkData.h"
11#include "UGameDataManager.h"
12
13
14// Sets default values
16{
17 // Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
18 PrimaryActorTick.bCanEverTick = false;
19}
20
22{
23 if (!HasAuthority()) return;
24
26
27 // 첫 번째 luggage는 즉시 스폰
29
30 // 나머지는 타이머로 스폰
31 GetWorldTimerManager().SetTimer(
33 this,
35 SpawnTime,
36 true // 반복
37 );
38}
39
41{
42 ALingoGameState* GS = Cast<ALingoGameState>(GetWorld()->GetGameState());
43 if (!GS) return;
44
45 const TArray<FScenarioTargetData>& ScenarioData = GS->GetReadScenarioData().target_data;
46
47 // 모두 스폰했으면 타이머 중지
48 if (CurrentSpawnIndex >= ScenarioData.Num())
49 {
50 GetWorldTimerManager().ClearTimer(SpawnTimerHandle);
51 return;
52 }
53
54 // 현재 인덱스의 luggage 스폰
55 auto SD = ScenarioData[CurrentSpawnIndex];
56 Aluggage* NewLuggage = GetWorld()->SpawnActor<Aluggage>(
58 GetActorLocation(),
59 FRotator::ZeroRotator
60 );
61
62 if (NewLuggage)
63 {
64 // 상자 정보 지정
65 NewLuggage->SetLuggageInfo(CurrentSpawnIndex, SD.word2.name, SD.word1.name);
66
67 // 인덱스로 상자 색&무늬 지정
68 int32 ColorIdx = FCString::Atoi(*SD.word2.code);
69 NewLuggage->ApplyColorToMesh(ColorIdx);
70
71 int32 PatternIdx = FCString::Atoi(*SD.word1.code);
72 NewLuggage->ApplyPatternToMesh(PatternIdx);
73 }
74
76}
77
78// void ALuggageManager::InitHolder(FResponseReadScenario& ResponseData)
79// {
80// // {
81// // "word1": { "name": "닭", "code": "6" },
82// // "word2": { "name": "빨강", "code": "1" }
83// // }
84//
85// const FScenarioTargetData& CorrectAnswer = ResponseData.target_data[ResponseData.correct_answer_index];
86// const int32 PatternIdx = FCString::Atoi(*CorrectAnswer.word1.code);
87// const int32 ColorIdx = FCString::Atoi(*CorrectAnswer.word2.code);
88//
89// for (TActorIterator<ALuggageHolder> It(GetWorld()); It; ++It)
90// {
91// ALuggageHolder* Holder = *It;
92// if (Holder)
93// {
94// Holder->SetAnswerData(ColorIdx, PatternIdx);
95// break;
96// }
97// }
98// }
네트워크 요청과 응답에 사용되는 구조체 및 설정을 정의합니다.
UGameDataManager 클래스를 선언합니다.
FORCEINLINE const FResponseReadScenario & GetReadScenarioData() const
FTimerHandle SpawnTimerHandle
TSubclassOf< class Aluggage > LuggageClass
상호작용 가능한 수하물 액터
Definition luggage.h:15
void ApplyPatternToMesh(int32 InPatternIdx)
Definition luggage.cpp:232
void ApplyColorToMesh(int32 InColorIdx)
Definition luggage.cpp:199
void SetLuggageInfo(int32 InIdx, FString InColor, FString InPattern)
Definition luggage.cpp:155
TArray< FScenarioTargetData > target_data