diff options
| author | Jonathan Bradley <jcb@pikum.xyz> | 2023-12-21 17:44:03 -0500 |
|---|---|---|
| committer | Jonathan Bradley <jcb@pikum.xyz> | 2023-12-23 11:42:23 -0500 |
| commit | fa7fc343a0e444da72938fad58d219cf52228976 (patch) | |
| tree | 24630be0c54f9768a13f32c5970558768e343543 /example | |
| parent | 6fa3b137c74536d2bab77f3309ca5b4c60953fe0 (diff) | |
plugin checkpoint - multiple plugins and collision callbacks
Diffstat (limited to 'example')
| -rw-r--r-- | example/CMakeLists.txt | 14 | ||||
| -rw-r--r-- | example/example.cpp | 27 | ||||
| -rw-r--r-- | example/example.hpp | 14 | ||||
| -rw-r--r-- | example/example_export.h | 42 |
4 files changed, 97 insertions, 0 deletions
diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt new file mode 100644 index 0000000..a895b5d --- /dev/null +++ b/example/CMakeLists.txt @@ -0,0 +1,14 @@ +project(pke_example VERSION 0.0) + +set(PKE_EDITOR_SOURCE_FILES + # example_export.h + example.hpp + example.cpp +) + +add_library(pke_example + ${PKE_EDITOR_SOURCE_FILES} +) + +target_link_libraries(pke_example PUBLIC pke) +target_include_directories(pke_example PUBLIC pke) diff --git a/example/example.cpp b/example/example.cpp new file mode 100644 index 0000000..b870806 --- /dev/null +++ b/example/example.cpp @@ -0,0 +1,27 @@ + +#include "example.hpp" + +#include "components.hpp" + +void OnEntityTypeCollision(const EntityHandle &lhs, const EntityHandle &rhs) { + fprintf(stdout, "[Example::OnEntityTypeCollision] Called\n"); +} + +void OnEntityCollision(const EntityHandle &lhs, const EntityHandle &rhs) { + fprintf(stdout, "[Example::OnEntityCollision] Called\n"); +} + +void OnInit() { + PkeArray_Add(&pkePluginCallbacks, PkeCallback { + .name = "OnEntTypeColl", + .func = reinterpret_cast<void *>(OnEntityTypeCollision), + }); + PkeArray_Add(&pkePluginCallbacks, PkeCallback { + .name = "OnEntColl", + .func = reinterpret_cast<void *>(OnEntityCollision), + }); +} + +PKEPluginInterface pkePluginInterface { + .OnInit = OnInit, +}; diff --git a/example/example.hpp b/example/example.hpp new file mode 100644 index 0000000..c64b3e9 --- /dev/null +++ b/example/example.hpp @@ -0,0 +1,14 @@ +#ifndef PKE_EXAMPLE_HPP +#define PKE_EXAMPLE_HPP + +#include "plugins.hpp" + +// EXAMPLE_EXPORT void OnEntityTypeCollision(const EntityHandle &lhs, const EntityHandle &rhs); +// void OnEntityTypeCollision(const EntityHandle &lhs, const EntityHandle &rhs); + +// EXAMPLE_EXPORT void OnEntityCollision(const EntityHandle &lhs, const EntityHandle &rhs); +// void OnEntityCollision(const EntityHandle &lhs, const EntityHandle &rhs); + +extern PKEPluginInterface pkePluginInterface; + +#endif /* PKE_EXAMPLE_HPP */ diff --git a/example/example_export.h b/example/example_export.h new file mode 100644 index 0000000..53bf208 --- /dev/null +++ b/example/example_export.h @@ -0,0 +1,42 @@ + +#ifndef EXAMPLE_EXPORT_H +#define EXAMPLE_EXPORT_H + +#ifdef EXAMPLE_STATIC_DEFINE +# define EXAMPLE_EXPORT +# define EXAMPLE_NO_EXPORT +#else +# ifndef EXAMPLE_EXPORT +# ifdef extension_EXPORTS + /* We are building this library */ +# define EXAMPLE_EXPORT extern "C" __attribute__((visibility("default"))) +# else + /* We are using this library */ +# define EXAMPLE_EXPORT __attribute__((visibility("default"))) +# endif +# endif + +# ifndef EXAMPLE_NO_EXPORT +# define EXAMPLE_NO_EXPORT __attribute__((visibility("hidden"))) +# endif +#endif + +#ifndef EXAMPLE_DEPRECATED +# define EXAMPLE_DEPRECATED __attribute__ ((__deprecated__)) +#endif + +#ifndef EXAMPLE_DEPRECATED_EXPORT +# define EXAMPLE_DEPRECATED_EXPORT EXAMPLE_EXPORT EXAMPLE_DEPRECATED +#endif + +#ifndef EXAMPLE_DEPRECATED_NO_EXPORT +# define EXAMPLE_DEPRECATED_NO_EXPORT EXAMPLE_NO_EXPORT EXAMPLE_DEPRECATED +#endif + +#if 0 /* DEFINE_NO_DEPRECATED */ +# ifndef EXAMPLE_NO_DEPRECATED +# define EXAMPLE_NO_DEPRECATED +# endif +#endif + +#endif /* EXAMPLE_EXPORT_H */ |
