EventManager: moved files around, made eventExample not run by default, and got rid of the silly NONE event type.

develop
expwnent 2012-12-15 17:43:41 -05:00
parent 86e002f3ff
commit 935058f0a5
4 changed files with 13 additions and 3 deletions

@ -12,7 +12,6 @@ namespace DFHack {
namespace EventManager {
namespace EventType {
enum EventType {
NONE,
TICK,
JOB_INITIATED,
JOB_COMPLETED,

@ -130,7 +130,6 @@ if (BUILD_SUPPORTED)
#DFHACK_PLUGIN(versionosd versionosd.cpp)
DFHACK_PLUGIN(misery misery.cpp)
#DFHACK_PLUGIN(dfstream dfstream.cpp LINK_LIBRARIES clsocket dfhack-tinythread)
DFHACK_PLUGIN(eventExample eventExample.cpp)
endif()

@ -18,6 +18,7 @@ DFHACK_PLUGIN(stripcaged stripcaged.cpp)
DFHACK_PLUGIN(rprobe rprobe.cpp)
DFHACK_PLUGIN(nestboxes nestboxes.cpp)
DFHACK_PLUGIN(vshook vshook.cpp)
DFHACK_PLUGIN(eventExample eventExample.cpp)
IF(UNIX)
DFHACK_PLUGIN(ref-index ref-index.cpp)
ENDIF()

@ -9,7 +9,10 @@
#include "df/item.h"
#include "df/world.h"
#include <vector>
using namespace DFHack;
using namespace std;
DFHACK_PLUGIN("eventExample");
@ -19,7 +22,15 @@ void timePassed(color_ostream& out, void* ptr);
void unitDeath(color_ostream& out, void* ptr);
void itemCreate(color_ostream& out, void* ptr);
command_result eventExample(color_ostream& out, vector<string>& parameters);
DFhackCExport command_result plugin_init(color_ostream &out, std::vector<PluginCommand> &commands) {
commands.push_back(PluginCommand("eventExample", "Sets up a few event triggers.",eventExample));
return CR_OK;
}
command_result eventExample(color_ostream& out, vector<string>& parameters) {
EventManager::EventHandler initiateHandler(jobInitiated);
EventManager::EventHandler completeHandler(jobCompleted);
EventManager::EventHandler timeHandler(timePassed);
@ -35,7 +46,7 @@ DFhackCExport command_result plugin_init(color_ostream &out, std::vector<PluginC
EventManager::registerTick(timeHandler, 8, me);
EventManager::registerListener(EventManager::EventType::UNIT_DEATH, deathHandler, me);
EventManager::registerListener(EventManager::EventType::ITEM_CREATED, itemHandler, me);
out.print("Events registered.\n");
return CR_OK;
}