Skip to content

Commit

Permalink
CSS-49 [프로그램][신규] 일반_싱글톤
Browse files Browse the repository at this point in the history
Tickable한 GameSingleton 클래스 추가, Default Game Singleton Class로 설정
  • Loading branch information
autumn-na committed Mar 12, 2024
1 parent e814217 commit 259cf87
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 0 deletions.
1 change: 1 addition & 0 deletions capstone_2024_20/Config/DefaultEngine.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
44 changes: 44 additions & 0 deletions capstone_2024_20/Source/capstone_2024_20/Common/UGameSingleton.cpp
Original file line number Diff line number Diff line change
@@ -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<UGameSingleton>(GEngine->GameSingleton))
return *Instance;

return *NewObject<UGameSingleton>();
}

// [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
26 changes: 26 additions & 0 deletions capstone_2024_20/Source/capstone_2024_20/Common/UGameSingleton.h
Original file line number Diff line number Diff line change
@@ -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
};

0 comments on commit 259cf87

Please sign in to comment.