13#include "Components/BoxComponent.h"
14#include "Components/StaticMeshComponent.h"
15#include "Components/SkeletalMeshComponent.h"
16#include "Animation/AnimationAsset.h"
17#include "Components/WidgetComponent.h"
18#include "Kismet/GameplayStatics.h"
19#include "Kismet/KismetMathLibrary.h"
20#include "Net/UnrealNetwork.h"
24 PrimaryActorTick.bCanEverTick =
true;
30 USceneComponent* Root = CreateDefaultSubobject<USceneComponent>(TEXT(
"DefaultSceneRoot"));
34 MeshComponent = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT(
"MeshComponent"));
38 BoxCollision = CreateDefaultSubobject<UBoxComponent>(TEXT(
"BoxCollision"));
41 BoxCollision->SetCollisionEnabled(ECollisionEnabled::QueryOnly);
42 BoxCollision->SetCollisionResponseToAllChannels(ECR_Overlap);
45 HoldPos = CreateDefaultSubobject<USceneComponent>(TEXT(
"HoldPos"));
48 WidgetGuideComp = CreateDefaultSubobject<UWidgetComponent>(TEXT(
"WidgetGuideComp"));
52 ConstructorHelpers::FClassFinder<UUserWidget> widgetGuideClassRef(TEXT(
"/Game/CustomContents/UI/Widgets/WBP_LuggageSlotWidget.WBP_LuggageSlotWidget_C"));
53 if (widgetGuideClassRef.Succeeded())
73 Super::Tick(DeltaTime);
78 FRotator CurrentRotation =
CurTarget->GetActorRotation();
80 CurTarget->SetActorRotation(CurrentRotation);
88 Super::GetLifetimeReplicatedProps(OutLifetimeProps);
107 Luggage->SetAllCollision(
false);
108 PRINTLOG(TEXT(
"AHolder::OnRep_CurTarget - Disabled collision for Luggage on client"));
114 UPrimitiveComponent* OverlappedComponent,
116 UPrimitiveComponent* OtherComp,
117 int32 OtherBodyIndex,
119 const FHitResult& SweepResult)
130 ALingoGameState* GS = Cast<ALingoGameState>(GetWorld()->GetGameState());
135 if (
auto Luggage = Cast<Aluggage>(OtherActor))
138 if (Luggage->bIsBeingHooked)
149 int32 CorrectIdx = Luggage->GetSpawnIdx();
155 FTimerHandle TimerHandle;
156 GetWorldTimerManager().SetTimer(TimerHandle, [
this, CorrectIdx]
166 FTimerHandle TimerHandle;
167 GetWorldTimerManager().SetTimer(TimerHandle, [
this, Luggage, GS]
177 if (Luggage->UpdateDissolve())
179 GetWorldTimerManager().ClearTimer(DestroyTimerHandle);
183 },GetWorld()->DeltaTimeSeconds,
true);
202 FVector ActivatedLocation =
HoldPos->GetComponentLocation();
204 TargetLuggage->SetActorLocation(ActivatedLocation);
205 TargetLuggage->SetActorRotation(
HoldPos->GetComponentRotation());
231 UMaterialInstanceDynamic* DynamicMaterial = Cast<UMaterialInstanceDynamic>(
MeshComponent->GetMaterial(0));
232 if (!DynamicMaterial)
233 DynamicMaterial =
MeshComponent->CreateDynamicMaterialInstance(0);
236 DynamicMaterial->SetScalarParameterValue(FName(
"Activate"), State ? 1.0f : 0.0f);
251 AActor* Camera = UGameplayStatics::GetPlayerCameraManager(GetWorld(), 0);
256 FRotator Rotation = UKismetMathLibrary::MakeRotFromXZ( -Camera->GetActorForwardVector(), Camera->GetActorUpVector() );
273void ALuggageHolder::Multicast_ShowResultPopup_Implementation(int32 CorrectAnswerIndex)
276 if (
ALingoGameState* GS = Cast<ALingoGameState>(GetWorld()->GetGameState()))
278 GS->AddWrongReadAnswer(CorrectAnswerIndex);
282 if (
auto Popup = UPopupManager::ShowPopupAs<UPopup_Result>(GetWorld(), EPopupType::Result))
295void ALuggageHolder::Multicast_ShowWrongPopup_Implementation(
const FString& LuggageColor,
const FString& LuggagePattern)
298 FString StyledMessage = FString::Printf(
299 TEXT(
"WRONG ANSWER\n")
300 TEXT(
"------------------\n")
301 TEXT(
"The selected item does not match.\n")
303 TEXT(
"Pattern: %s\n")
304 TEXT(
"------------------\n")
305 TEXT(
"Please try another luggage."),
306 *LuggageColor, *LuggagePattern
309 if (
auto DM = UBroadcastManager::Get(
this))
310 DM->SendTutorMessage(FText::FromString(StyledMessage));
네트워크 복제를 위한 전역 브로드캐스트 Actor
YiSan 전반에서 사용하는 공용 인터페이스를 선언합니다.
#define PRINTLOG(fmt,...)
void SetCompassVisibilityByTag(FName Tag, bool bVisible)
void SetAllCompassVisibility(bool bVisible)
FORCEINLINE const FResponseReadScenario & GetReadScenarioData() const
void AddWrongReadAnswer(int32 Value)
void BillboardInteractWidget()
상호작용 위젯 빌보드화 (카메라를 향하도록)
virtual void BeginPlay() override
FTimerHandle DestroyTimerHandle
bool CheckLuggage(class Aluggage *TargetLuggage, int CorrectIndex)
float ActivatedHeightOffset
void Multicast_ShowWrongPopup(const FString &LuggageColor, const FString &LuggagePattern)
[Multicast RPC] 모든 클라이언트에 오답 메시지 표시
TObjectPtr< class USceneComponent > HoldPos
void UpdateActivateState(bool State)
virtual void SetCompassMarkerInto(ECompassMarkerType InMarkerType) override
void OnBoxOverlapBegin(UPrimitiveComponent *OverlappedComponent, AActor *OtherActor, UPrimitiveComponent *OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult &SweepResult)
void Multicast_ShowResultPopup(int32 CorrectAnswerIndex)
[Multicast RPC] 모든 클라이언트에 정답 결과 팝업 표시
virtual void Tick(float DeltaTime) override
void OnActivate(bool bSuccess)
TObjectPtr< class UWidgetComponent > WidgetGuideComp
virtual void GetLifetimeReplicatedProps(TArray< class FLifetimeProperty > &OutLifetimeProps) const override
TObjectPtr< class AActor > CurTarget
TObjectPtr< class USkeletalMeshComponent > MeshComponent
TObjectPtr< class UBoxComponent > BoxCollision
FORCEINLINE int32 GetSpawnIdx()
void SetAllCollision(bool bEnable)
모든 컴포넌트의 충돌과 물리를 설정합니다.
ECompassMarkerType MarkerType
int32 correct_answer_index