Exemple #1
0
   void Entity::observe(Being *observer, bool triggerEvents, bool displayFull) {

      EventArgumentList eventArgs;

      if (triggerEvents) {

         eventArgs.push_back(this);
         eventArgs.push_back(observer);

         game->setupEventHandler();
         game->addEventListener(triggers);
         game->addEventListener(observer->getEventListener());
         if (!game->event("beforeObserve", eventArgs)) {
            return;
         }
      }

      display(observer, displayFull);
      observedByMap[observer] = true;

      if (triggerEvents) {
         game->setupEventHandler();
         game->addEventListener(triggers);
         game->addEventListener(observer->getEventListener());
         game->event("afterObserve", eventArgs);
      }
   }
Exemple #2
0
   void Entity::glance(Being *observer, bool triggerEvents) {

      EventArgumentList eventArgs;

      if (triggerEvents) {

         eventArgs.push_back(this);
         eventArgs.push_back(observer);

         game->setupEventHandler();
         game->addEventListener(triggers);
         game->addEventListener(observer->getEventListener());
         if (!game->event("beforeGlance", eventArgs)) {
            return;
         }
      }

      displayShort(observer);
      glancedByMap[observer] = true;

      if (triggerEvents) {
         game->setupEventHandler();
         game->addEventListener(triggers);
         game->addEventListener(observer->getEventListener());
         game->event("afterGlance", eventArgs);
      }
   }
Exemple #3
0
EventArgumentList EvData_Test::getArguments() const
{
	EventArgumentList args;
	args.push_back(convertArgument(_x));
	args.push_back(convertArgument(_y));

	return args;
}
Exemple #4
0
   void LuaEventTrigger::execute(EventArgumentList args) {

      L->call(function);

      for (int i = 0; i < args.size(); i++) {

         switch (args[i].which()) {

            case 0: // int
               L->pushArgument((double)boost::get<int>(args[i]));
               break;

            case 1: // double
               L->pushArgument(boost::get<double>(args[i]));
               break;

            case 2: // bool
               L->pushArgument(boost::get<bool>(args[i]));
               break;

            case 3: // string
               L->pushArgument(boost::get<string>(args[i]));
               break;

            // TODO: we should pass the Game once we have a Lua object for it
            case 4: // we ignore Game *
               break;

            default: // it's some kind of Entity

               Entity *arg = boost::get<Entity *>(args[i]);

               if (0 == arg) {
                  L->pushNilArgument();
               }

               else {
                  L->pushArgument(arg);
               }

               break;
         }
      }

      L->execute(2);

      continueExecutionFlag = L->getBoolean(0);
      allowActionFlag = L->getBoolean(1);
   }