KLingo Project Documentation 1.0.0
Unreal Engine 5.6 C++ Project Documentation
로딩중...
검색중...
일치하는것 없음
NPCExaminer.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 "NPCExaminer.h"
5
6#include "AOwlPlayer.h"
7#include "Components/SphereComponent.h"
8#include "Onepiece/Onepiece.h"
9#include "ASpeakStageActor.h"
10#include "GameLogging.h"
11
12
13// Sets default values
15{
16 // Set this character to call Tick() every frame. You can turn this off to improve performance if you don't need it.
17 PrimaryActorTick.bCanEverTick = true;
18
19 ConstructorHelpers::FObjectFinder<UMaterialInterface> materialRef(TEXT("/Script/Engine.MaterialInstanceConstant'/Game/CustomContents/Character/Asset/Robot14/Materials/MI_Robot14_2_Inst4_NowUsing.MI_Robot14_2_Inst4_NowUsing'"));
20 if (materialRef.Succeeded())
21 {
22 Material2 = materialRef.Object;
23 }
24
25 PlayerDetectSphereComp = CreateDefaultSubobject<USphereComponent>(TEXT("PlayerDetectSphereComp"));
26 PlayerDetectSphereComp->SetupAttachment(GetRootComponent());
27 PlayerDetectSphereComp->SetSphereRadius(200.f);
28}
29
30// Called when the game starts or when spawned
32{
33 Super::BeginPlay();
34
35 // Set Dynamic Material
36 DynamicMaterial2 = UMaterialInstanceDynamic::Create(Material2, this);
37 GetMesh()->SetMaterial(0, DynamicMaterial2);
38
39 // Bind Overlap Event
40 PlayerDetectSphereComp->OnComponentBeginOverlap.AddDynamic(this, &ANPCExaminer::OnSphereBeginOverlap);
41 PlayerDetectSphereComp->OnComponentEndOverlap.AddDynamic(this, &ANPCExaminer::OnSphereEndOverlap);
42}
43
44// Called every frame
45void ANPCExaminer::Tick(float DeltaTime)
46{
47 Super::Tick(DeltaTime);
48}
49
50// Called to bind functionality to input
51void ANPCExaminer::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
52{
53 Super::SetupPlayerInputComponent(PlayerInputComponent);
54}
55
57{
59 {
60 UE_LOG(LogTemp, Warning, TEXT("Fail to ChangeEyeColor because DynamicMaterial2 is Null!!!"));
61 return;
62 }
63
64 DynamicMaterial2->SetVectorParameterValue(EyeColorName, EyeColor);
65}
66
67void ANPCExaminer::OnSphereBeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
68{
69 bIsPlayerNear = true;
70 DetectedPlayer = Cast<AOwlPlayer>(OtherActor);
71}
72
73void ANPCExaminer::OnSphereEndOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex)
74{
75 bIsPlayerNear = false;
76 DetectedPlayer = nullptr;
77}
78
79//----------------------------------------------------------//
80// Speak Stage System
81//----------------------------------------------------------//
82
84{
85 SpeakStage = InSpeakStage;
86 PRINTLOG(TEXT("[NPCExaminer] SpeakStage Connected: %s"), SpeakStage ? TEXT("Success") : TEXT("Failed"));
87}
88
90{
91 if (SpeakStage)
92 {
94 }
95
96 return TEXT("");
97}
98
YiSan 전반에서 사용하는 공용 인터페이스를 선언합니다.
#define PRINTLOG(fmt,...)
Definition GameLogging.h:30
TObjectPtr< class ASpeakStageActor > SpeakStage
연결된 SpeakStage
Definition NPCExaminer.h:70
TObjectPtr< class USphereComponent > PlayerDetectSphereComp
Definition NPCExaminer.h:54
TObjectPtr< class UMaterialInterface > Material2
Definition NPCExaminer.h:32
void OnSphereEndOverlap(UPrimitiveComponent *OverlappedComponent, AActor *OtherActor, UPrimitiveComponent *OtherComp, int32 OtherBodyIndex)
TObjectPtr< class UMaterialInstanceDynamic > DynamicMaterial2
Definition NPCExaminer.h:35
FName EyeColorName
Definition NPCExaminer.h:38
FLinearColor EyeColor
Definition NPCExaminer.h:39
virtual void SetupPlayerInputComponent(class UInputComponent *PlayerInputComponent) override
void SetSpeakStage(class ASpeakStageActor *InSpeakStage)
SpeakStage 설정 (GameMode에서 호출)
virtual void BeginPlay() override
virtual void Tick(float DeltaTime) override
void ChangeEyeColor()
void OnSphereBeginOverlap(UPrimitiveComponent *OverlappedComponent, AActor *OtherActor, UPrimitiveComponent *OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult &SweepResult)
FString GetCurrentQuestion() const
현재 질문 가져오기
bool bIsPlayerNear
Definition NPCExaminer.h:50
TObjectPtr< class AOwlPlayer > DetectedPlayer
Definition NPCExaminer.h:47
Speak Stage 시스템
FString GetCurrentQuestion() const