From 259cf87f8fa73c932d84ae0751b49c5bca4d7440 Mon Sep 17 00:00:00 2001 From: autumn-na Date: Tue, 12 Mar 2024 21:19:01 +0900 Subject: [PATCH] =?UTF-8?q?CSS-49=20[=ED=94=84=EB=A1=9C=EA=B7=B8=EB=9E=A8]?= =?UTF-8?q?[=EC=8B=A0=EA=B7=9C]=20=EC=9D=BC=EB=B0=98=5F=EC=8B=B1=EA=B8=80?= =?UTF-8?q?=ED=86=A4=20Tickable=ED=95=9C=20GameSingleton=20=ED=81=B4?= =?UTF-8?q?=EB=9E=98=EC=8A=A4=20=EC=B6=94=EA=B0=80,=20Default=20Game=20Sin?= =?UTF-8?q?gleton=20Class=EB=A1=9C=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- capstone_2024_20/Config/DefaultEngine.ini | 1 + .../Common/UGameSingleton.cpp | 44 +++++++++++++++++++ .../capstone_2024_20/Common/UGameSingleton.h | 26 +++++++++++ 3 files changed, 71 insertions(+) create mode 100644 capstone_2024_20/Source/capstone_2024_20/Common/UGameSingleton.cpp create mode 100644 capstone_2024_20/Source/capstone_2024_20/Common/UGameSingleton.h diff --git a/capstone_2024_20/Config/DefaultEngine.ini b/capstone_2024_20/Config/DefaultEngine.ini index 003df4e862..7944ba065b 100644 --- a/capstone_2024_20/Config/DefaultEngine.ini +++ b/capstone_2024_20/Config/DefaultEngine.ini @@ -60,6 +60,7 @@ FontDPI=72 [/Script/Engine.Engine] +ActiveGameNameRedirects=(OldGameName="TP_Blank",NewGameName="/Script/capstone_2024_20") +ActiveGameNameRedirects=(OldGameName="/Script/TP_Blank",NewGameName="/Script/capstone_2024_20") +GameSingletonClassName=/Script/capstone_2024_20.GameSingleton [/Script/AndroidFileServerEditor.AndroidFileServerRuntimeSettings] bEnablePlugin=True diff --git a/capstone_2024_20/Source/capstone_2024_20/Common/UGameSingleton.cpp b/capstone_2024_20/Source/capstone_2024_20/Common/UGameSingleton.cpp new file mode 100644 index 0000000000..8d82e6e74f --- /dev/null +++ b/capstone_2024_20/Source/capstone_2024_20/Common/UGameSingleton.cpp @@ -0,0 +1,44 @@ +#include "UGameSingleton.h" + +UGameSingleton::UGameSingleton(): bTickable(true), bTickableWhenPaused(false) +{ +} + +void UGameSingleton::Tick(float DeltaTime) +{ +} + +UGameSingleton& UGameSingleton::GetInstance() +{ + if (UGameSingleton* Instance = CastChecked(GEngine->GameSingleton)) + return *Instance; + + return *NewObject(); +} + +// [begin] FTickableGameObject +bool UGameSingleton::IsTickable() const +{ + return bTickable; +} + +bool UGameSingleton::IsTickableInEditor() const +{ + return bTickable; +} + +bool UGameSingleton::IsTickableWhenPaused() const +{ + return bTickableWhenPaused; +} + +TStatId UGameSingleton::GetStatId() const +{ + return TStatId(); +} + +UWorld* UGameSingleton::GetWorld() const +{ + return GetOuter()->GetWorld(); +} +// [end] FTickableGameObject diff --git a/capstone_2024_20/Source/capstone_2024_20/Common/UGameSingleton.h b/capstone_2024_20/Source/capstone_2024_20/Common/UGameSingleton.h new file mode 100644 index 0000000000..80f0201d68 --- /dev/null +++ b/capstone_2024_20/Source/capstone_2024_20/Common/UGameSingleton.h @@ -0,0 +1,26 @@ +#pragma once + +#include "UGameSingleton.generated.h" + +UCLASS() +class CAPSTONE_2024_20_API UGameSingleton : public UObject, public FTickableGameObject +{ + GENERATED_BODY() + +public: + UGameSingleton(); + + virtual void Tick(float DeltaTime) override; + + static UGameSingleton& GetInstance(); + + // [begin] FTickableGameObject + virtual bool IsTickable() const override; + virtual bool IsTickableInEditor() const override; + virtual bool IsTickableWhenPaused() const override; + virtual TStatId GetStatId() const override; + virtual UWorld* GetWorld() const override; + bool bTickable; + bool bTickableWhenPaused; + // [end] FTickableGameObject +};