CToolSingleton

Overview

Typed singleton access wrapping UCSingletonManager. Uses CTypedName keys defined in CSingletonName namespace.

Functions

Name Description
getSettings Returns UCSettings* via GetMutableDefault.
storeSingleton Store a singleton in the manager. Template-asserts the object derives from the key type.
retrieveSingleton Retrieve a singleton cast to the requested type. Logs warning if type mismatch.
withSingleton Retrieve and execute lambda if found. Logs warning if not found.
// Store
storeSingleton(myCoordinator, CSingletonName::CNAME_Singleton_Coordinator);

// Retrieve
ACCoordinator* coord = retrieveSingleton<ACCoordinator>(CSingletonName::CNAME_Singleton_Coordinator);

// Retrieve and use
withSingleton<UCQuestManager>(CSingletonName::CNAME_Singleton_QuestManager, [](UCQuestManager* qm) {
    qm->StartQuest();
});

// Settings
UCSettings* settings = getSettings();
if (settings->timer) { /* ... */ }

Predefined singleton keys (CSingletonName)

Name Type
CNAME_Singleton_Perf UCPerf
CNAME_Singleton_Coordinator ACCoordinator
CNAME_Singleton_PlayerSpawner ACPlayerSpawner
CNAME_Singleton_RoomSpawner ACRoomSpawner
CNAME_Singleton_ActorSpawner ACActorSpawner
CNAME_Singleton_WorldSpawner ACWorldSpawner
CNAME_Singleton_HexaSpawner ACHexaSpawner
CNAME_Singleton_FOWSpawner ACFOWSpawner
CNAME_Singleton_MapSpawner ACMapSpawner
CNAME_Singleton_CellSpawner ACellSpawner
CNAME_Singleton_GameManager UCGameManager
CNAME_Singleton_QuestManager UCQuestManager
CNAME_Singleton_SkillManager UCSkillManager
CNAME_Singleton_ResourceManager UCResourceManager
CNAME_Singleton_WorldNoise UCNoisator
CNAME_Singleton_ClusterNoise UCNoisator
CNAME_Singleton_ClusterShiftNoise UCNoisator
CNAME_Singleton_RoomNoise UCNoisator
CNAME_Singleton_BiomeNoise UCNoisator