KLingo Project Documentation 1.0.0
Unreal Engine 5.6 C++ Project Documentation
로딩중...
검색중...
일치하는것 없음
CityName.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 "CityName.h"
5
6#include "CityNameWidget.h"
7#include "Components/WidgetComponent.h"
8#include "Net/UnrealNetwork.h"
9
10
11// Sets default values
13{
14 // Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
15 PrimaryActorTick.bCanEverTick = true;
16
17 WidgetComp = CreateDefaultSubobject<UWidgetComponent>(TEXT("WidgetComp"));
18 SetRootComponent(WidgetComp);
19}
20
21// Called when the game starts or when spawned
23{
24 Super::BeginPlay();
25
26 FTimerHandle TimerHandle;
27 GetWorldTimerManager().SetTimer(TimerHandle, FTimerDelegate::CreateLambda([this]
28 {
30 }), 0.5f, false);
31}
32
33// Called every frame
34void ACityName::Tick(float DeltaTime)
35{
36 Super::Tick(DeltaTime);
37}
38
39void ACityName::GetLifetimeReplicatedProps(TArray<class FLifetimeProperty>& OutLifetimeProps) const
40{
41 Super::GetLifetimeReplicatedProps(OutLifetimeProps);
42
43 DOREPLIFETIME(ACityName, CityName);
44}
45
47{
48 if (Index == 0) CityName = TEXT("Food Here");
49 else if (Index == 1) CityName = TEXT("City Here");
50
51 if (HasAuthority())
52 {
54 }
55}
56
58{
59 CityName = TEXT("OK!");
60
61 if (HasAuthority())
62 {
64 }
65}
66
68{
69 UUserWidget* CityNameWidget = WidgetComp->GetWidget();
70 if (UCityNameWidget* CNW = Cast<UCityNameWidget>(CityNameWidget))
71 {
72 CNW->SetCityName(CityName);
73
74 // 텍스트 색 설정
75 if (CityName == TEXT("OK!"))
76 {
77 CNW->SetTextColor(FLinearColor::Green);
78 }
79 else
80 {
81 CNW->SetTextColor(FLinearColor::White);
82 }
83 }
84}
85
int32 Index
Definition CityName.h:30
virtual void GetLifetimeReplicatedProps(TArray< class FLifetimeProperty > &OutLifetimeProps) const override
Definition CityName.cpp:39
class UWidgetComponent * WidgetComp
Definition CityName.h:27
FString CityName
Definition CityName.h:33
void SetDefaultText()
Definition CityName.cpp:46
void SetChecked()
Definition CityName.cpp:57
virtual void Tick(float DeltaTime) override
Definition CityName.cpp:34
virtual void BeginPlay() override
Definition CityName.cpp:22
void OnRep_CityName()
Definition CityName.cpp:67