From b1d926361b9d613ad712ad161f9a8b7ccab4551d Mon Sep 17 00:00:00 2001 From: Jonathan Bradley Date: Thu, 27 Jun 2024 21:22:50 -0400 Subject: checkpoint: more explicit callback system --- example/example.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'example') diff --git a/example/example.cpp b/example/example.cpp index b870806..7b82ebc 100644 --- a/example/example.cpp +++ b/example/example.cpp @@ -3,23 +3,23 @@ #include "components.hpp" -void OnEntityTypeCollision(const EntityHandle &lhs, const EntityHandle &rhs) { +void OnEntityTypeCollision(const void *lhs, const void *rhs) { fprintf(stdout, "[Example::OnEntityTypeCollision] Called\n"); } -void OnEntityCollision(const EntityHandle &lhs, const EntityHandle &rhs) { +void OnEntityCollision(const void *lhs, const void *rhs) { fprintf(stdout, "[Example::OnEntityCollision] Called\n"); } void OnInit() { - PkeArray_Add(&pkePluginCallbacks, PkeCallback { - .name = "OnEntTypeColl", - .func = reinterpret_cast(OnEntityTypeCollision), - }); - PkeArray_Add(&pkePluginCallbacks, PkeCallback { - .name = "OnEntColl", - .func = reinterpret_cast(OnEntityCollision), - }); + // create/register entity types + pkePluginInterface.PkeEntityInterfaceCount = 1; + pkePluginInterface.PkeEntityInterface = Pke_New(1); + + // set up entity types + auto *typeIntfs = reinterpret_cast(pkePluginInterface.PkeEntityInterface); + typeIntfs[0].OnEntityTypeCollision = reinterpret_cast(OnEntityTypeCollision); + typeIntfs[0].OnEntityInstanceCollision = reinterpret_cast(OnEntityCollision); } PKEPluginInterface pkePluginInterface { -- cgit v1.2.3