KLingo Project Documentation 1.0.0
Unreal Engine 5.6 C++ Project Documentation
로딩중...
검색중...
일치하는것 없음
APedestalSwitch.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 "APedestalSwitch.h"
5
6#include "GameLogging.h"
9#include "UInteractWidget.h"
10#include "Components/WidgetComponent.h"
11
12#define INTERACT_WIDGET_PATH TEXT("/Game/CustomContents/UI/Widgets/WBP_InteractWidget.WBP_InteractWidget_C")
13
15{
16 PrimaryActorTick.bCanEverTick = false;
17
18 RootComponent = CreateDefaultSubobject<USceneComponent>(TEXT("Root"));
19
20 SwitchBody = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("SwitchBody"));
21 SwitchBody->SetupAttachment(RootComponent);
22 SwitchBody->SetRelativeLocation(FVector::ZeroVector);
23
24 InteractableComp = CreateDefaultSubobject<UInteractableComponent>(TEXT("Interactable"));
25 InteractableComp->InteractionType = EInteractionType::Button;
26 InteractableComp->InteractionPrompt = TEXT("Activate");
27
28 WidgetComp = CreateDefaultSubobject<UWidgetComponent>(TEXT("WidgetComp"));
29 ConstructorHelpers::FClassFinder<UInteractWidget> WidgetRef(INTERACT_WIDGET_PATH);
30 if (WidgetRef.Succeeded())
31 {
32 WidgetComp->SetWidgetClass(WidgetRef.Class);
33 WidgetComp->SetupAttachment(GetRootComponent());
34 WidgetComp->SetWidgetSpace(EWidgetSpace::Screen);
35 WidgetComp->SetDrawSize(FVector2D(2048.0f, 1024.0f));
36 }
37}
38
40{
41 Super::BeginPlay();
42
43 // InitSwitch 호출
44 InitSwitch();
45
46 // 델리게이트 바인딩
47 InteractableComp->InitWidget(WidgetComp);
48 InteractableComp->OnInteractionTriggered.AddDynamic(this, &APedestalSwitch::OnInteractionTriggered);
49 InteractableComp->OnOutlineStateChanged.AddDynamic(this, &APedestalSwitch::OnOutlineStateChanged);
50}
51
53{
54 UAnimInstance* AnimInstance = SwitchBody->GetAnimInstance();
55 if (!AnimInstance)
56 {
57 PRINTLOG( TEXT("AnimInstance is null"));
58 return;
59 }
60
61 UTweenAnimInstance* AnimBP = Cast<UTweenAnimInstance>(AnimInstance);
62 if (AnimBP)
63 {
64 AnimBlueprint = AnimBP;
65 }
66 else
67 {
68 PRINTLOG( TEXT("Failed to cast to AnimBP"));
69 }
70}
71
73{
74 if (AnimBlueprint)
75 {
76 // 버튼 눌림 애니메이션
77 AnimBlueprint->ChangeState(true);
78
79 // 딜레이 후 버튼 리커버리
80 GetWorld()->GetTimerManager().SetTimer(
82 this,
85 false
86 );
87 }
88 else
89 {
90 PRINTLOG( TEXT("AnimBlueprint is null"));
91 }
92
93 OnActivate();
94}
95
97{
98 AnimBlueprint->ChangeState(false);
99}
100
102{
103 PRINT_STRING(TEXT("Pedestal Switch Activated"));
104}
105
106void APedestalSwitch::OnOutlineStateChanged(bool bShouldShowOutline)
107{
108 if (SwitchBody)
109 {
110 SwitchBody->SetRenderCustomDepth(bShouldShowOutline);
111 }
112}
#define INTERACT_WIDGET_PATH
YiSan 전반에서 사용하는 공용 인터페이스를 선언합니다.
#define PRINTLOG(fmt,...)
Definition GameLogging.h:30
#define PRINT_STRING(fmt,...)
Definition GameLogging.h:45
UTweenAnimInstance 클래스를 선언합니다.
void OnInteractionTriggered(AActor *Interactor)
상호작용 콜백 (InteractableComponent 델리게이트용)
FTimerHandle RecoveryTimerHandle
버튼을 원래 상태로 되돌리는 타이머
void RecoveryButton()
버튼을 원래 상태로 되돌림
TObjectPtr< class UWidgetComponent > WidgetComp
virtual void BeginPlay() override
virtual void OnActivate_Implementation()
TObjectPtr< class USkeletalMeshComponent > SwitchBody
TObjectPtr< class UInteractableComponent > InteractableComp
InteractableComponent - 상호작용 시스템
void OnOutlineStateChanged(bool bShouldShowOutline)
TObjectPtr< class UTweenAnimInstance > AnimBlueprint
블루프린트에서 사용할 수 있는 간단한 트윈 애님 인스턴스.