Пример #1
0
// Event Observer Interface
void
dmz::EntityPluginDamage::close_event (
      const Handle EventHandle,
      const EventType &Type,
      const EventLocalityEnum Locality) {

   if (_hil && Type.is_of_type (_detonationType)) {

      EventModule *eventMod (get_event_module ());

      if (eventMod) {

         Handle target (0);

         if (eventMod->lookup_object_handle (EventHandle, _targetHandle, target)) {

            if (_hil == target) {

               ObjectModule *objMod (get_object_module ());

               if (objMod) {

                  Mask state;

                  objMod->lookup_state (_hil, _defaultObjectHandle, state);

                  state |= _deadState;

                  objMod->store_state (_hil, _defaultObjectHandle, state);
               }
            }
         }
      }
   }
}
// Event Observer Interface
void
dmz::StarfighterPluginAces::close_event (
      const Handle EventHandle,
      const EventType &Type,
      const EventLocalityEnum Locality) {

   EventModule *event = get_event_module ();

   if (event) {

      Handle target (0);

      if (event->lookup_object_handle (EventHandle, _targetEventAttr, target)) {

         AceStruct *as = _aceTable.remove (target);

         if (as) {

            if (_common) {

               const Handle Out = _common->create_open_detonation_event (target, 0);
               Handle source (0);
               event->lookup_object_handle (EventHandle, _sourceEventAttr, source);
               event->store_object_handle (Out, _killsEventAttr, source);
               event->close_event (Out);
            }

            if (_objMod) { _objMod->destroy_object (target); }
            delete as; as = 0;
         }
      }
   }
}
Пример #3
0
// Event Observer Interface
void
dmz::AudioPluginEventSimple::close_event (
      const Handle EventHandle,
      const EventType &Type,
      const EventLocalityEnum Locality) {

   EventType current (Type);
   EventStruct *es (0);

   while (!es && current) {

      es = _eventTable.lookup (current.get_handle ());

      if (!es) { current.become_parent (); }
   }
  
   if (es && es->sound) {

      EventModule *eventMod (get_event_module ());

      if (_audioMod && eventMod) {

         Vector pos;

         if (eventMod->lookup_position (EventHandle, _defaultEventHandle, pos)) {

            SoundInit init;
            SoundAttributes attributes;
            attributes.set_position (pos);
            _audioMod->play_sound (es->sound, init, attributes);
         }
      }
   }
}
Пример #4
0
// RenderPluginEventOSG Interface
dmz::RenderPluginEventOSG::TypeStruct *
dmz::RenderPluginEventOSG::_get_type (
      const Handle EventHandle,
      const EventType &Type) {

   TypeStruct *result (0);

   EventModule *module = get_event_module ();

   TypeTable *table (0);

   EventType event (Type);

   while (event && !result) {

      TypeTable *table = _get_type_table (Type);

      if (table) {

         ObjectType current;

         if (module) {

            module->lookup_object_type (EventHandle, table->TypeAttr, current);
         }

         const ObjectType Start (current);

         while (current && !result) {

            result = table->map.lookup (current.get_handle ());

            if (!result) {

               result = _create_type (EventHandle, event, current, *table);
            }

            if (!result) { current.become_parent (); }
         }

         if (result && (current != Start)) {

            table->map.store (Start.get_handle (), result);
         }
      }

      if (!result) { event.become_parent (); }
   }

   return result;
}
Пример #5
0
void
dmz::RenderPluginEventOSG::_create_event (const Handle EventHandle, TypeStruct &ts) {

   EventStruct *event = new EventStruct (ts);

   if (event) {

      event->root = new osg::AutoTransform ();
      event->root->setAutoRotateMode (osg::AutoTransform::ROTATE_TO_SCREEN);
      event->scale = new osg::MatrixTransform;
      event->root->addChild (event->scale);

      UInt32 mask = event->root->getNodeMask ();
      mask &= ~(_isectMask);
      event->root->setNodeMask (mask);

      EventModule *module = get_event_module ();

      if (module) {

         Vector pos;
         module->lookup_position (EventHandle, _defaultHandle, pos);
         event->root->setPosition (to_osg_vector (pos));
      }

      event->scale->addChild (ts.model.get ());

      if (_eventTable.store (EventHandle, event)) {

         osg::Group *group = _core ? _core->get_dynamic_objects () : 0;

         if (group) { group->addChild (event->root.get ()); }
         else { _log.error << "Failed to add geode!" << endl; }
      }
      else { delete event; event = 0; }
   }
}