summaryrefslogtreecommitdiff
path: root/src/plugin-types.hpp
blob: 63b097ecaad74b4e8bcc29c4324aaef3b2078f17 (plain)
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
#ifndef PKE_PLUGIN_TYPES_HPP
#define PKE_PLUGIN_TYPES_HPP

#include <cstdint>
#include <istream>

constexpr int64_t CallbackSignatureLength = 16;
using CallbackSignature = char[CallbackSignatureLength];

typedef void (*DeserializeDelegate)(std::istream *stream);
typedef void (*SerializeDelegate)(std::istream *stream);
typedef void (*CollisionDelegate)(const void *entHandleLeft, const void *entHandleRight);

struct PkeEntityTypeInterface {
	void (*OnDeserialize)(std::ifstream *stream) = nullptr;
	void (*OnSerialize)(std::ostringstream *stream, void *obj) = nullptr;
	void (*OnEntityTypeCollision)(const void *entHandleLeft, const void *entHandleRight) = nullptr;
	void (*OnEntityInstanceCollision)(const void *entHandleLeft, const void *entHandleRight) = nullptr;
};

struct PKEPluginInterface {
	// for internal use only
	void *pluginHandle = nullptr;
	void (*OnInit)() = nullptr;
	void (*OnTick)(double delta) = nullptr;
	void (*OnTeardown)() = nullptr;
	void (*OnImGuiRender)() = nullptr;
	void *PkeEntityInterface = nullptr;
	std::size_t PkeEntityInterfaceCount = 0;
};

struct PkeCallback {
	// the 16 char signature(name) of a function
	CallbackSignature name = {'\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0'};
	// the address of the function to call - populated on startup
	void (*func)() = nullptr;
};

#endif /* PKE_PLUGIN_TYPES_HPP */