Polyphase Game Engine
Loading...
Searching...
No Matches
Engine.h
Go to the documentation of this file.
1#pragma once
2
3#include <stdint.h>
4#include <string>
5
6#include "PolyphaseAPI.h"
7#include "EngineTypes.h"
8#include "Property.h"
9
10extern void OctPreInitialize(EngineConfig& config);
11extern void OctPostInitialize();
12extern void OctPreUpdate();
13extern void OctPostUpdate();
14extern void OctPreShutdown();
15extern void OctPostShutdown();
16
17// W1: Hook registration indirection. Today the engine static-lib path resolves
18// the six Oct* externs above at exe-link time (Standalone/Main.cpp,
19// Template/Main.cpp, or a user game's Main.cpp provides the defs). That extern
20// model can't cross the engine-DLL boundary, so the engine routes its hook
21// calls through this small function-pointer struct instead.
22//
23// - Static-lib builds (POLYPHASE_DLL_BUILD undefined): Engine/Source/Engine/OctHookAutoRegister.cpp
24// takes the address of the externs at static-init time and calls RegisterOctHooks().
25// Zero source change required of existing game projects.
26// - DLL builds (POLYPHASE_DLL_BUILD=1): the engine DLL has no Oct* externs in
27// its TUs. The consuming exe (POLYPHASE_DLL_CONSUMER=1) defines its own Oct*
28// and registers them via the DLL-exported RegisterOctHooks() at exe static
29// init — see Standalone/Source/Main.cpp.
31{
32 void (*preInitialize)(EngineConfig&) = nullptr;
33 void (*postInitialize)() = nullptr;
34 void (*preUpdate)() = nullptr;
35 void (*postUpdate)() = nullptr;
36 void (*preShutdown)() = nullptr;
37 void (*postShutdown)() = nullptr;
38};
41
42bool Initialize();
43
44bool Update();
45
46void Shutdown();
47
48void Quit();
49
50POLYPHASE_API class World* GetWorld(int32_t index);
53
54// Resolves shipped engine content ("Assets/", "Scripts/") to a readable path.
55// Prefers the root-relative "Engine/<subDir>" and falls back to
56// "<projectDir>Engine/<subDir>", which is where console packages end up when
57// they're deployed into a per-project folder on an SD card.
58POLYPHASE_API std::string GetEngineContentDir(const char* subDir);
59
63
64POLYPHASE_API const class Clock* GetAppClock();
65
66// Default scene names to search for when no explicit scene is specified
67// Developers can modify this list to add custom default scene names
68extern const std::vector<std::string>& GetDefaultSceneNames();
69void SetDefaultSceneNames(const std::vector<std::string>& names);
70
71
72bool IsShuttingDown();
73
74void LoadProject(const std::string& path, bool discoverAssets = true);
75
76// Close the currently-loaded project — symmetric counterpart to LoadProject.
77// Ends PIE, closes edit scenes, purges asset state, unloads the project
78// directory, clears loaded Lua scripts, and (when unloadNativeAddons=true)
79// FreeLibrary's every loaded native addon DLL. Leaves engine state empty
80// (mProjectDirectory == ""); the editor falls back to its no-project UI.
81// LoadProject calls this internally before loading a new path; callers that
82// just want the close half (e.g. Tools > Close Project, Tier-2 recovery)
83// invoke it directly. Editor-only — shipped runtimes have no close concept.
84#if EDITOR
85void CloseProject(bool unloadNativeAddons = true);
86#endif
87
88void EnableConsole(bool enable);
89
90void ResizeWindow(uint32_t width, uint32_t height);
91
93bool IsPlaying();
94
96
98
99void ReloadAllScripts(bool restartComponents = true);
100
101#if EDITOR
102void SetScriptHotReloadEnabled(bool enabled);
104#endif
105
106void SetPaused(bool paused);
107bool IsPaused();
108void FrameStep();
109
110void SetTimeDilation(float timeDilation);
111float GetTimeDilation();
112
113void GarbageCollect();
114
115void GatherGlobalProperties(std::vector<Property>& props);
116
119
120void WriteEngineConfig(std::string path = "");
121void ReadEngineConfig(std::string path = "");
122void ResetEngineConfig();
123
124// Rewrite the .octp project file's `name=` line in place. Preserves other lines
125// (assets=, solution=, etc.). Used to keep the .octp in sync when the project
126// name is edited via AppSettings, since the .octp is what packaging reads.
127void WriteProjectFile(const std::string& path, const std::string& newName);
128
129void ReadCommandLineArgs(int32_t argc, char** argv);
130
131
132#if LUA_ENABLED
133POLYPHASE_API lua_State* GetLua();
134#endif
bool IsScriptHotReloadEnabled()
Definition Engine.cpp:1776
void SetScriptHotReloadEnabled(bool enabled)
Definition Engine.cpp:1765
void OctPreShutdown()
Definition Main.cpp:80
POLYPHASE_API const class Clock * GetAppClock()
Definition Engine.cpp:1271
POLYPHASE_API const OctGameHooks & GetOctHooks()
Definition Engine.cpp:1266
const std::vector< std::string > & GetDefaultSceneNames()
Definition Engine.cpp:113
void WriteProjectFile(const std::string &path, const std::string &newName)
Definition Engine.cpp:1834
POLYPHASE_API bool IsHeadless()
Definition Engine.cpp:371
void SetTimeDilation(float timeDilation)
Definition Engine.cpp:1799
void ReadCommandLineArgs(int32_t argc, char **argv)
Definition Engine.cpp:376
bool Update()
Definition Engine.cpp:897
POLYPHASE_API void RegisterOctHooks(const OctGameHooks &hooks)
Definition Engine.cpp:1261
bool Initialize()
Definition Engine.cpp:545
void SetPaused(bool paused)
Definition Engine.cpp:1784
void ReadEngineConfig(std::string path="")
Definition Engine.cpp:1945
void WriteEngineConfig(std::string path="")
Definition Engine.cpp:1885
void FrameStep()
Definition Engine.cpp:1794
POLYPHASE_API class World * GetWorld(int32_t index)
Definition Engine.cpp:1228
void SetDefaultSceneNames(const std::vector< std::string > &names)
Definition Engine.cpp:118
void OctPostShutdown()
Definition Main.cpp:85
void OctPostInitialize()
Definition Main.cpp:65
void ResizeWindow(uint32_t width, uint32_t height)
Definition Engine.cpp:1616
POLYPHASE_API class SignalBus * GetSignalBus()
Definition SignalBus.cpp:7
bool IsPlaying()
Definition Engine.cpp:1643
void ResetEngineConfig()
Definition Engine.cpp:2097
void EnableConsole(bool enable)
Definition Engine.cpp:1610
bool IsPaused()
Definition Engine.cpp:1789
void OctPreUpdate()
Definition Main.cpp:70
void GarbageCollect()
Definition Engine.cpp:1809
POLYPHASE_API int32_t GetNumWorlds()
Definition Engine.cpp:1235
bool IsShuttingDown()
Definition Engine.cpp:1276
void LoadProject(const std::string &path, bool discoverAssets=true)
Definition Engine.cpp:1346
bool IsGameTickEnabled()
Definition Engine.cpp:1652
POLYPHASE_API struct EngineState * GetEngineState()
Definition Engine.cpp:1240
void Quit()
Definition Engine.cpp:1223
ScreenOrientation GetScreenOrientation()
Definition Engine.cpp:1829
POLYPHASE_API struct EngineConfig * GetMutableEngineConfig()
Definition Engine.cpp:1250
float GetTimeDilation()
Definition Engine.cpp:1804
void Shutdown()
Definition Engine.cpp:1147
POLYPHASE_API lua_State * GetLua()
Definition Engine.cpp:2103
POLYPHASE_API const struct EngineConfig * GetEngineConfig()
Definition Engine.cpp:1245
POLYPHASE_API std::string GetEngineContentDir(const char *subDir)
Definition Engine.cpp:504
void ReloadAllScripts(bool restartComponents=true)
Definition Engine.cpp:1661
void SetScreenOrientation(ScreenOrientation mode)
Definition Engine.cpp:1824
void OctPostUpdate()
Definition Main.cpp:75
bool IsPlayingInEditor()
Definition Engine.cpp:1634
void GatherGlobalProperties(std::vector< Property > &props)
Definition Engine.cpp:1815
Export macros for Polyphase Engine symbols.
#define POLYPHASE_API
Definition PolyphaseAPI.h:31
ScreenOrientation
Definition SystemTypes.h:83
InitOptions OctPreInitialize()
Definition Main.cpp:20
Definition Clock.h:6
Definition SignalBus.h:45
Definition World.h:24
Definition EngineTypes.h:416
Definition EngineTypes.h:483
Definition Engine.h:31
void(* postInitialize)()
Definition Engine.h:33
void(* preUpdate)()
Definition Engine.h:34
void(* postShutdown)()
Definition Engine.h:37
void(* preShutdown)()
Definition Engine.h:36
void(* preInitialize)(EngineConfig &)
Definition Engine.h:32
void(* postUpdate)()
Definition Engine.h:35