Polyphase Game Engine
Loading...
Searching...
No Matches
PolyphasePluginAPI.h
Go to the documentation of this file.
1#pragma once
2
11#include <stdint.h>
12
13// Platform-specific export/import macros.
14// Legacy scaffolds ship with OCTAVE_PLUGIN_EXPORT defined (the pre-rename alias);
15// accept either name here so those projects select dllexport correctly. Without this,
16// the plugin entry point is treated as dllimport and its definition hits C2491.
17#if defined(OCTAVE_PLUGIN_EXPORT) && !defined(POLYPHASE_PLUGIN_EXPORT)
18 #define POLYPHASE_PLUGIN_EXPORT
19#endif
20
21#ifdef _WIN32
22 #ifdef POLYPHASE_PLUGIN_EXPORT
23 #define POLYPHASE_PLUGIN_API __declspec(dllexport)
24 #else
25 #define POLYPHASE_PLUGIN_API __declspec(dllimport)
26 #endif
27#else
28 #define POLYPHASE_PLUGIN_API __attribute__((visibility("default")))
29#endif
30
31// Plugin API version - increment when breaking changes are made
32#define POLYPHASE_PLUGIN_API_VERSION 3
33
34// Forward declarations
36struct EditorUIHooks;
37struct lua_State;
38
46{
47 // Plugin metadata
48 uint32_t apiVersion; // Must match POLYPHASE_PLUGIN_API_VERSION
49 const char* pluginName; // Human-readable plugin name
50 const char* pluginVersion; // Plugin version string (e.g., "1.0.0")
51
52 // Lifecycle callbacks
53 int (*OnLoad)(PolyphaseEngineAPI* api); // Called when plugin is loaded, return 0 on success
54 void (*OnUnload)(); // Called before plugin is unloaded
55
56 // Tick callbacks (set to nullptr if not needed)
57 void (*Tick)(float deltaTime); // Called during gameplay (PIE or built game)
58 void (*TickEditor)(float deltaTime); // Called in editor regardless of play state (editor builds only)
59
60 // Registration callbacks (called after OnLoad)
61 void (*RegisterTypes)(void* nodeFactory); // Register custom node types
62 void (*RegisterScriptFuncs)(struct lua_State* L); // Register Lua bindings
63
64 // Editor UI extension (editor builds only, set to nullptr for game-only plugins)
65 void (*RegisterEditorUI)(EditorUIHooks* hooks, uint64_t hookId);
66
76 void (*OnEditorPreInit)();
77
87 void (*OnEditorReady)();
88};
89
100
101// Macro for declaring the plugin entry point
102#define POLYPHASE_PLUGIN_ENTRY() \
103 extern "C" POLYPHASE_PLUGIN_API int PolyphasePlugin_GetDesc(PolyphasePluginDesc* outDesc)
104
105// Backwards-compatibility aliases (deprecated, will be removed in a future version)
106#ifndef POLYPHASE_NO_LEGACY_MACROS
107 #define OCTAVE_PLUGIN_API POLYPHASE_PLUGIN_API
108 #ifndef OCTAVE_PLUGIN_EXPORT
109 #define OCTAVE_PLUGIN_EXPORT POLYPHASE_PLUGIN_EXPORT
110 #endif
111 #define OCTAVE_PLUGIN_API_VERSION POLYPHASE_PLUGIN_API_VERSION
112 #define OCTAVE_PLUGIN_ENTRY POLYPHASE_PLUGIN_ENTRY
113 #define OctavePluginDesc PolyphasePluginDesc
114 #define OctavePlugin_GetDescFunc PolyphasePlugin_GetDescFunc
115 #define OctavePlugin_GetDesc PolyphasePlugin_GetDesc
116 #define OctaveEngineAPI PolyphaseEngineAPI
117#endif
int(* PolyphasePlugin_GetDescFunc)(PolyphasePluginDesc *outDesc)
Plugin entry point function signature.
Definition PolyphasePluginAPI.h:99
Engine API provided to plugins during OnLoad.
Definition PolyphaseEngineAPI.h:32
Plugin descriptor returned by PolyphasePlugin_GetDesc.
Definition PolyphasePluginAPI.h:46
void(* TickEditor)(float deltaTime)
Definition PolyphasePluginAPI.h:58
const char * pluginVersion
Definition PolyphasePluginAPI.h:50
const char * pluginName
Definition PolyphasePluginAPI.h:49
uint32_t apiVersion
Definition PolyphasePluginAPI.h:48
void(* RegisterTypes)(void *nodeFactory)
Definition PolyphasePluginAPI.h:61
void(* OnUnload)()
Definition PolyphasePluginAPI.h:54
void(* Tick)(float deltaTime)
Definition PolyphasePluginAPI.h:57
void(* OnEditorPreInit)()
Called before the editor ImGui context is fully initialized.
Definition PolyphasePluginAPI.h:76
void(* RegisterScriptFuncs)(struct lua_State *L)
Definition PolyphasePluginAPI.h:62
void(* RegisterEditorUI)(EditorUIHooks *hooks, uint64_t hookId)
Definition PolyphasePluginAPI.h:65
void(* OnEditorReady)()
Called after the editor is fully initialized, before the main loop starts.
Definition PolyphasePluginAPI.h:87
int(* OnLoad)(PolyphaseEngineAPI *api)
Definition PolyphasePluginAPI.h:53