|
CS2-Kit
C++23 library for CS2 Metamod:Source plugin development
|
Work in Progress — This architecture may change as the library evolves.
CS2-Kit is organized into six modules, each in its own namespace under CS2Kit:
Singleton<T> base with pass-key idiom for safe, lazy initialization.CS2Kit::Initialize(ismm, error, maxlen) handles all SDK interface resolution, gamedata loading, and subsystem init. The consumer only needs to drive the player lifecycle (PlayerManager::AddPlayer/RemovePlayer) from its connect/disconnect hooks; ILogger has a built-in default.All singleton classes inherit from CS2Kit::Core::Singleton<T>:
The pass-key idiom (Token) prevents external code from constructing additional instances while allowing Singleton<T> to create the one instance.
CS2-Kit uses std::function callbacks throughout:
| Callback | Signature | Used in |
|---|---|---|
| Command handler | CommandResult(Players::Player*, const vector<string>&) | CommandBuilder |
| Menu button activate | void(int slot) | MenuBuilder (AddButton, AddDynamicButton) |
| Menu toggle get / flip | bool(int) / void(int) | MenuBuilder (AddToggle) |
| Menu choice get / set / commit | int(int) / void(int, int) / void(int, const T&) | MenuBuilder (AddChoice, AddSelector) |
| Menu slider get / set | int(int) / void(int, int) | MenuBuilder (AddSlider) |
| Menu input get / validate | string(int) / bool(int, string_view) | MenuBuilder (AddInput) |
| Menu close | void(int slot) | MenuBuilder |
| Submenu factory | shared_ptr<Menu>(int slot) | MenuBuilder (AddSubmenu) |
| Chat input capture | bool(int slot, string_view text) | ChatInputCapture (BeginCapture) |
| Scheduler task | void() | Scheduler |
| Permission check | bool(int slot, const string& flags) | CommandManager |
| Interface | Purpose | Required? |
|---|---|---|
ILogger | Logging backend (Info/Warn/Error) | No — built-in ConsoleLogger used by default |