@@ -63,11 +63,12 @@ struct workshop_hack_data
63
63
typedef std::map<int32_t ,workshop_hack_data> workshops_data_t ;
64
64
workshops_data_t hacked_workshops;
65
65
66
- static void handle_update_action (color_ostream &out,df::building_workshopst*){};
66
+ DEFINE_LUA_EVENT_NH_1 (onUpdateAction,df::building_workshopst*);
67
+ DEFINE_LUA_EVENT_NH_2 (onSetTriggerState,df::building_workshopst*,int32_t );
67
68
68
- DEFINE_LUA_EVENT_1 (onUpdateAction,handle_update_action,df::building_workshopst*);
69
- DFHACK_PLUGIN_LUA_EVENTS {
69
+ DFHACK_PLUGIN_LUA_EVENTS{
70
70
DFHACK_LUA_EVENT (onUpdateAction),
71
+ DFHACK_LUA_EVENT (onSetTriggerState),
71
72
DFHACK_LUA_END
72
73
};
73
74
@@ -267,6 +268,13 @@ struct work_hook : df::building_workshopst{
267
268
}
268
269
INTERPOSE_NEXT (updateAction)();
269
270
}
271
+ DEFINE_VMETHOD_INTERPOSE (void , setTriggerState,(int32_t state))
272
+ {
273
+ CoreSuspendClaimer suspend;
274
+ color_ostream_proxy out (Core::getInstance ().getConsole ());
275
+ onSetTriggerState (out, this ,state);
276
+ INTERPOSE_NEXT (setTriggerState)(state); // pretty sure default workshop has nothing related to this, but to be future proof lets do it like this
277
+ }
270
278
DEFINE_VMETHOD_INTERPOSE (void , drawBuilding, (uint32_t curtick,df::building_drawbuffer *db, int16_t z_offset))
271
279
{
272
280
INTERPOSE_NEXT (drawBuilding)(curtick,db, z_offset);
@@ -329,6 +337,7 @@ IMPLEMENT_VMETHOD_INTERPOSE(work_hook, canConnectToMachine);
329
337
IMPLEMENT_VMETHOD_INTERPOSE (work_hook, isUnpowered);
330
338
IMPLEMENT_VMETHOD_INTERPOSE (work_hook, canBeRoomSubset);
331
339
IMPLEMENT_VMETHOD_INTERPOSE (work_hook, updateAction);
340
+ IMPLEMENT_VMETHOD_INTERPOSE (work_hook, setTriggerState);
332
341
IMPLEMENT_VMETHOD_INTERPOSE (work_hook, drawBuilding);
333
342
334
343
@@ -501,6 +510,7 @@ static void enable_hooks(bool enable)
501
510
INTERPOSE_HOOK (work_hook,canBeRoomSubset).apply (enable);
502
511
// update n render
503
512
INTERPOSE_HOOK (work_hook,updateAction).apply (enable);
513
+ INTERPOSE_HOOK (work_hook,setTriggerState).apply (enable);
504
514
INTERPOSE_HOOK (work_hook,drawBuilding).apply (enable);
505
515
}
506
516
DFhackCExport command_result plugin_onstatechange (color_ostream &out, state_change_event event)
0 commit comments