16#include "Components/BoxComponent.h"
17#include "Components/WidgetComponent.h"
18#include "Net/UnrealNetwork.h"
19#include "GameFramework/PlayerController.h"
20#include "Engine/World.h"
21#include "Materials/MaterialParameterCollection.h"
22#include "Materials/MaterialParameterCollectionInstance.h"
24#define LUGGAGE_INTERACT_WIDGET_PATH TEXT("/Game/CustomContents/UI/Widgets/WBP_InteractWidget_Luggage.WBP_InteractWidget_Luggage_C")
28 PrimaryActorTick.bCanEverTick =
true;
31 Mesh1Comp = CreateDefaultSubobject<UStaticMeshComponent>(TEXT(
"Mesh1Comp"));
34 BoxComp = CreateDefaultSubobject<UBoxComponent>(TEXT(
"BoxComp"));
35 BoxComp->SetupAttachment(GetRootComponent());
36 BoxComp->SetBoxExtent(FVector(55));
38 Mesh2Comp = CreateDefaultSubobject<UStaticMeshComponent>(TEXT(
"Mesh2Comp"));
41 Mesh3Comp = CreateDefaultSubobject<UStaticMeshComponent>(TEXT(
"Mesh3Comp"));
44 InteractableComp = CreateDefaultSubobject<UInteractableComponent>(TEXT(
"Interactable"));
48 HookComp = CreateDefaultSubobject<UHookComponent>(TEXT(
"Hook"));
51 Mesh1Comp->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
52 Mesh1Comp->SetCollisionProfileName(TEXT(
"PhysicsActor"));
59 SetNetUpdateFrequency(100.0f);
60 SetMinNetUpdateFrequency(33.0f);
62 WidgetComp = CreateDefaultSubobject<UWidgetComponent>(TEXT(
"WidgetComp"));
64 if (boxWidgetRef.Succeeded())
66 WidgetComp->SetWidgetClass(boxWidgetRef.Class);
67 WidgetComp->SetupAttachment(GetRootComponent());
68 WidgetComp->SetWidgetSpace(EWidgetSpace::Screen);
69 WidgetComp->SetDrawSize(FVector2D(2048.0f, 1024.0f));
72 ConstructorHelpers::FObjectFinder<UMaterialInterface> cubeBodyMaterialRef(TEXT(
"/Script/Engine.MaterialInstanceConstant'/Game/CustomContents/Platfrom/Assets/portal_block/Materials/M_Cube_Body.M_Cube_Body'"));
73 if (cubeBodyMaterialRef.Succeeded())
78 ConstructorHelpers::FObjectFinder<UMaterialInterface> cubeStickerMaterialRef(TEXT(
"/Script/Engine.Material'/Game/CustomContents/Platfrom/Assets/portal_block/Materials/M_Cube_Sticker.M_Cube_Sticker'"));
79 if (cubeStickerMaterialRef.Succeeded())
84 ConstructorHelpers::FObjectFinder<UMaterialInterface> cubeCoverMaterialRef(TEXT(
"/Script/Engine.MaterialInstanceConstant'/Game/CustomContents/Platfrom/Assets/portal_block/Materials/M_Cube_Cover.M_Cube_Cover'"));
85 if (cubeCoverMaterialRef.Succeeded())
103 Mesh1Comp->SetMassOverrideInKg(NAME_None, 5.f,
true);
106 SetReplicateMovement(
true);
116 Super::Tick(DeltaTime);
121 if (
auto InfoWidget = Cast<ULuggageInfoWidget>(
WidgetComp->GetWidget()))
141 Super::GetLifetimeReplicatedProps(OutLifetimeProps);
183 PRINTLOG(TEXT(
"OnRep_IsBeingHooked: %s is being hooked by %s"),
190 PRINTLOG(TEXT(
"OnRep_IsBeingHooked: %s hook released"), *GetName());
202 if (!IsInGameThread())
204 AsyncTask(ENamedThreads::GameThread, [
this, InColorIdx]()
214 if (UGameDataManager::Get(GetWorld())->GetColorData(InColorIdx, ColorData))
235 if (!IsInGameThread())
237 AsyncTask(ENamedThreads::GameThread, [
this, InPatternIdx]()
249 UGameDataManager::Get(GetWorld())->GetReadData(InPatternIdx, ReadData);
257 UTexture2D* LoadedTexture =
nullptr;
258 if (ReadData.
Texture.IsValid())
259 LoadedTexture = ReadData.
Texture.Get();
261 LoadedTexture = ReadData.
Texture.LoadSynchronous();
267 cubeStickerMID->SetTextureParameterValue(FName(
"TextureParam"), LoadedTexture);
277 if (
auto InfoWidget = Cast<ULuggageInfoWidget>(
WidgetComp->GetWidget()))
285 Mesh1Comp->SetRenderCustomDepth(bShouldShowOutline);
286 Mesh2Comp->SetRenderCustomDepth(bShouldShowOutline);
287 Mesh3Comp->SetRenderCustomDepth(bShouldShowOutline);
311 BoxComp->SetCollisionEnabled(ECollisionEnabled::QueryOnly);
317 Mesh1Comp->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
322 Mesh2Comp->SetCollisionEnabled(ECollisionEnabled::NoCollision);
327 Mesh3Comp->SetCollisionEnabled(ECollisionEnabled::NoCollision);
333 InteractableComp->DetectionRange->SetCollisionEnabled(ECollisionEnabled::QueryOnly);
342 BoxComp->SetSimulatePhysics(
false);
343 BoxComp->SetCollisionEnabled(ECollisionEnabled::NoCollision);
349 Mesh1Comp->SetCollisionEnabled(ECollisionEnabled::NoCollision);
354 Mesh2Comp->SetCollisionEnabled(ECollisionEnabled::NoCollision);
359 Mesh3Comp->SetCollisionEnabled(ECollisionEnabled::NoCollision);
365 InteractableComp->DetectionRange->SetCollisionEnabled(ECollisionEnabled::NoCollision);
369 PRINTLOG(TEXT(
"Aluggage::SetAllCollision - Collisions disabled for %s"), *GetName());
417 PRINTLOG(TEXT(
"[Luggage] OnInteract - Interactor is null"));
422 APlayerController* PC = Cast<APlayerController>(Interactor->GetInstigatorController());
425 PRINTLOG(TEXT(
"[Luggage] OnInteract - PlayerController is null"));
429 APlayerState* PS = PC->GetPlayerState<APlayerState>();
432 PRINTLOG(TEXT(
"[Luggage] OnInteract - PlayerState is null"));
442void Aluggage::ServerNotifySelection_Implementation(APlayerState* Player)
446 PRINTLOG(TEXT(
"[Luggage] ServerNotifySelection - Player is null"));
450 PRINTLOG(TEXT(
"[Luggage] ServerNotifySelection - Processing selection for player"));
460 PRINTLOG(TEXT(
"[Luggage] ServerNotifySelection - GameMode is null or not ALingoGameMode"));
464bool Aluggage::ServerNotifySelection_Validate(APlayerState* Player)
467 return Player !=
nullptr;
482 if (
auto KLingoNetwork = UKLingoNetworkSystem::Get(GetWorld()))
486 KLingoNetwork->RequestListenAudio(
Declares the player-controlled character actor.
YiSan 전반에서 사용하는 공용 인터페이스를 선언합니다.
#define PRINTLOG(fmt,...)
UGameDataManager 클래스를 선언합니다.
KLingo API 요청을 담당하는 서브시스템을 선언합니다.
void HandleLuggageSelection(class APlayerState *Player, class Aluggage *luggage)
virtual void GetLifetimeReplicatedProps(TArray< class FLifetimeProperty > &OutLifetimeProps) const override
TObjectPtr< class UMaterialInstanceDynamic > cubeCoverMID
TObjectPtr< class UStaticMeshComponent > Mesh1Comp
TObjectPtr< class UMaterialInstanceDynamic > cubeStickerMID
TObjectPtr< class UStaticMeshComponent > Mesh2Comp
virtual void BeginPlay() override
bool bIsBeingHooked
훅 중 플래그 (복제됨)
TObjectPtr< class UWidgetComponent > WidgetComp
TObjectPtr< class UMaterialInterface > cubeStickerMaterial
const float dissolveMaxVal
TObjectPtr< class UHookComponent > HookComp
void ApplyPatternToMesh(int32 InPatternIdx)
void ApplyCollisionState(bool bEnable)
TObjectPtr< class UInteractableComponent > InteractableComp
TObjectPtr< class UMaterialInstanceDynamic > cubeBodyMID
TObjectPtr< class UStaticMeshComponent > Mesh3Comp
void OnOutlineStateChanged(bool bShouldShowOutline)
InteractableComponent의 아웃라인 상태 변경 이벤트 핸들러
virtual void Tick(float DeltaTime) override
TObjectPtr< class UBoxComponent > BoxComp
void ApplyColorToMesh(int32 InColorIdx)
TObjectPtr< class UMaterialInterface > cubeBodyMaterial
void OnRep_CollisionEnabled()
void RequestListenAudio(const FString &AudioText)
void OnRep_IsBeingHooked()
bIsBeingHooked 복제 시 호출되는 콜백
void OnResponseListenAudio(FResponseListenAudio &ResponseData, bool bWasSuccessful)
TObjectPtr< AActor > HookedBy
현재 이 Luggage를 훅하고 있는 플레이어
void SetLuggageInfo(int32 InIdx, FString InColor, FString InPattern)
void SetAllCollision(bool bEnable)
모든 컴포넌트의 충돌과 물리를 설정합니다.
void OnInteract(AActor *Interactor)
플레이어가 캐리어를 선택했을 때 호출됩니다.
void ServerNotifySelection(class APlayerState *Player)
서버에 캐리어 선택을 알립니다.
TObjectPtr< class UMaterialInterface > cubeCoverMaterial
static class APlayerActor * GetPlayerActor(const UObject *WorldContextObject)
첫 번째 플레이어의 PlayerActor를 가져옵니다.
#define LUGGAGE_INTERACT_WIDGET_PATH
FLinearColor GetLinearColor() const
HexColor 문자열을 FLinearColor로 변환하여 반환
TSoftObjectPtr< UTexture2D > Texture
TArray< uint8 > audio_base64