-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGame.h
More file actions
43 lines (34 loc) · 1.19 KB
/
Copy pathGame.h
File metadata and controls
43 lines (34 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#pragma once
#include <string>
#include <pybind11/embed.h>
#include <imgui.h>
#include "../../ue/Engine.h"
/**
* @file
* @brief pybind11 module exposing lightweight game-state reads to user scripts as
* `SplitgateInternal.Game.*` — frame rate, current map/world name, and the local player's name.
*/
namespace py = pybind11;
namespace Scripts
{
namespace Modules
{
/// Registers the `Game` submodule.
void Game(py::module_& m)
{
auto game = m.def_submodule("Game");
game.def("fps", []
{ return ImGui::GetIO().Framerate; }, "Current frame rate (ImGui's smoothed estimate).");
game.def("map_name", []() -> py::object
{
if (!Engine::World) return py::none();
return py::str(Engine::World->GetName()); }, "The current world/map object name, or None.");
game.def("local_name", []() -> py::object
{
if (!Engine::PlayerController) return py::none();
auto* c = reinterpret_cast<APortalWarsCharacter*>(Engine::PlayerController->Character);
if (!c || !c->PlayerState) return py::none();
return py::str(c->PlayerState->PlayerNamePrivate.ToString()); }, "The local player's display name, or None.");
}
} // namespace Modules
} // namespace Scripts