forked from kookmin-sw/cap-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tickable한 GameSingleton 클래스 추가, Default Game Singleton Class로 설정
- Loading branch information
Showing
3 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
capstone_2024_20/Source/capstone_2024_20/Common/UGameSingleton.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
26
capstone_2024_20/Source/capstone_2024_20/Common/UGameSingleton.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
}; |