25 PrimaryActorTick.bCanEverTick =
true;
31 USceneComponent* Root = CreateDefaultSubobject<USceneComponent>(TEXT(
"DefaultSceneRoot"));
35 MeshComponent = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT(
"MeshComponent"));
39 BoxCollision = CreateDefaultSubobject<UBoxComponent>(TEXT(
"BoxCollision"));
42 BoxCollision->SetCollisionEnabled(ECollisionEnabled::QueryOnly);
43 BoxCollision->SetCollisionResponseToAllChannels(ECR_Overlap);
46 HoldPos = CreateDefaultSubobject<USceneComponent>(TEXT(
"HoldPos"));
111 UPrimitiveComponent* OverlappedComponent,
113 UPrimitiveComponent* OtherComp,
114 int32 OtherBodyIndex,
116 const FHitResult& SweepResult)
127 ALingoGameState* GS = Cast<ALingoGameState>(GetWorld()->GetGameState());
133 if (
AFood*
Food = Cast<AFood>(OtherActor))
140 TempData.
word1 =
Food->CurrentFoodData.word1;
141 TempData.
word2 =
Food->CurrentFoodData.word2;
149 UE_LOG(LogTemp, Warning, TEXT(
"[FoodHolder] Correct"));
155 FTimerHandle TimerHandle;
156 GetWorldTimerManager().SetTimer(TimerHandle, [
this,
Food]
161 AActor* FoodContainerManager = UGameplayStatics::GetActorOfClass(GetWorld(), AFoodCourtManager::StaticClass());
162 if (
AFoodCourtManager* FCManager = Cast<AFoodCourtManager>(FoodContainerManager))
164 FCManager->DisableAllListenAnswersText();
168 Food->CurrentFoodData.word1.name = TEXT(
"");
169 Food->CurrentFoodData.word2.name = TEXT(
"");
171 if (HasAuthority())
Food->UpdateFoodWidget();
179 UE_LOG(LogTemp, Warning, TEXT(
"[FoodHolder] Wrong"));
182 FTimerHandle TimerHandle;
183 GetWorldTimerManager().SetTimer(TimerHandle, [
this,
Food, GS]
192 TArray<AActor*> CityNames;
193 UGameplayStatics::GetAllActorsOfClass(GetWorld(), ACityName::StaticClass(), CityNames);
195 for (AActor* Actor : CityNames)
197 if (
ACityName* CN = Cast<ACityName>(Actor))
199 CN->SetDefaultText();
204 TArray<AActor*> OrderKiosks;
205 UGameplayStatics::GetAllActorsOfClass(GetWorld(), AOrderKiosk::StaticClass(), OrderKiosks);
206 for (
auto OrderKiosk : OrderKiosks)
208 if (
AOrderKiosk* Kiosk = Cast<AOrderKiosk>(OrderKiosk))
209 Kiosk->IsOnceStopped =
false;
219 AActor* FoodContainerManager = UGameplayStatics::GetActorOfClass(GetWorld(), AFoodCourtManager::StaticClass());
220 if (
AFoodCourtManager* FCManager = Cast<AFoodCourtManager>(FoodContainerManager))
222 FCManager->SpawnFoodContainer();
224 FTimerHandle PartialAnswerTimer;
225 GetWorldTimerManager().SetTimer(PartialAnswerTimer, [
this, PrevData]
227 AFood* NewFood = Cast<AFood>(UGameplayStatics::GetActorOfClass(GetWorld(), AFood::StaticClass()));
230 UE_LOG(LogTemp, Error, TEXT(
"[FoodHolder] NewFood is nullptr!"));
235 bool bCityCorrect =
false;
236 bool bFoodCorrect =
false;
240 if (bCityCorrect && !bFoodCorrect)
242 UE_LOG(LogTemp, Warning, TEXT(
"[FoodHolder] City Only Correct - Updating City name widget"));
247 else if (!bCityCorrect && bFoodCorrect)
249 UE_LOG(LogTemp, Warning, TEXT(
"[FoodHolder] Food Only Correct - Updating Food mesh"));
255 else if (!bCityCorrect && !bFoodCorrect)
257 UE_LOG(LogTemp, Warning, TEXT(
"[FoodHolder] Both Wrong - NewFood remains empty"));
269 if (!TargetFood)
return false;
272 if (TargetFood->
Mesh)
274 TargetFood->
Mesh->SetSimulatePhysics(
false);
275 TargetFood->
Mesh->SetCollisionEnabled(ECollisionEnabled::NoCollision);
279 ALingoGameState* GS = Cast<ALingoGameState>(GetWorld()->GetGameState());
280 if (!GS)
return false;
285 FString CorrectCityName = ScenarioData[CorrectIdx].word1.name;
286 FString CorrectFoodName = ScenarioData[CorrectIdx].word2.name;
292 FVector ActivatedLocation =
HoldPos->GetComponentLocation();
294 TargetFood->SetActorLocation(ActivatedLocation);
295 TargetFood->SetActorRotation(
HoldPos->GetComponentRotation());
308 UE_LOG(LogTemp, Warning, TEXT(
"[CheckFood] Returning FALSE"));
void OnFoodBoxOverlapBegin(UPrimitiveComponent *OverlappedComponent, AActor *OtherActor, UPrimitiveComponent *OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult &SweepResult)
BoxCollision Overlap 콜백