Skip to content

Commit

Permalink
Integrates tick events with eventful
Browse files Browse the repository at this point in the history
  • Loading branch information
cppcooper committed Mar 16, 2023
1 parent e2bc986 commit 1a4914b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion plugins/eventful.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ DEFINE_LUA_EVENT_NH_2(onProjUnitCheckImpact, df::proj_unitst*, bool);
DEFINE_LUA_EVENT_NH_1(onProjUnitCheckMovement, df::proj_unitst*);
//event manager
DEFINE_LUA_EVENT_NH_1(onBuildingCreatedDestroyed, int32_t);
DEFINE_LUA_EVENT_NH_1(onTick, int32_t);
DEFINE_LUA_EVENT_NH_1(onJobInitiated, df::job*);
DEFINE_LUA_EVENT_NH_1(onJobStarted, df::job*);
DEFINE_LUA_EVENT_NH_1(onJobCompleted, df::job*);
Expand Down Expand Up @@ -124,6 +125,7 @@ DFHACK_PLUGIN_LUA_EVENTS {
/* event manager events */
DFHACK_LUA_EVENT(onBuildingCreatedDestroyed),
DFHACK_LUA_EVENT(onConstructionCreatedDestroyed),
DFHACK_LUA_EVENT(onTick),
DFHACK_LUA_EVENT(onJobInitiated),
DFHACK_LUA_EVENT(onJobStarted),
DFHACK_LUA_EVENT(onJobCompleted),
Expand All @@ -140,6 +142,11 @@ DFHACK_PLUGIN_LUA_EVENTS {
DFHACK_LUA_END
};

void ev_mng_tick(color_ostream& out, void* tick)
{
int32_t tval = (int32_t)(intptr_t)tick;
onTick(out, tval);
}
static void ev_mng_jobInitiated(color_ostream& out, void* job)
{
df::job* ptr=reinterpret_cast<df::job*>(job);
Expand Down Expand Up @@ -229,7 +236,7 @@ using namespace EventManager::EventType;
handler_t getManager(EventType t) {
switch (t) {
case TICK:
return nullptr;
return ev_mng_tick;
case JOB_INITIATED:
return ev_mng_jobInitiated;
case JOB_STARTED:
Expand Down

0 comments on commit 1a4914b

Please sign in to comment.