Ejemplo n.º 1
0
void
dmz::CyclesPluginWallOSG::_init (Config &local) {

   activate_default_object_attribute (
      ObjectDestroyMask |
      ObjectPositionMask |
      ObjectVelocityMask |
      ObjectStateMask);

   Definitions defs (get_plugin_runtime_context ());

   defs.lookup_state (
      config_to_string ("state.dead", local, DefaultStateNameDead),
      _deadState);

   defs.lookup_state (
      config_to_string ("state.engine_on", local, "Engine_On"),
      _engineOnState);

   _defaultHandle = defs.create_named_handle (ObjectAttributeDefaultName);
}
void
dmz::EntityPluginRestoreHealth::_init (Config &local) {

   Definitions defs (get_plugin_runtime_context ());

   defs.lookup_state (DefaultStateNameDead, _dead);

   _healthAttrHandle = defs.create_named_handle (EntityAttributeHealthName);

   _defaultAttrHandle = activate_default_object_attribute (ObjectStateMask);

   _health = config_to_float64 ("health.value", local, _health);
}
void
dmz::EntityPluginGroundSimple::_init (Config &local) {

   Definitions defs (get_plugin_runtime_context (), &_log);

   defs.lookup_state (DefaultStateNameDead, _deadState);
   defs.lookup_state (DefaultStateNameAirBorn, _airBornState);

   _defaultHandle = activate_default_object_attribute (ObjectStateMask);

   _hilHandle = activate_object_attribute (
      ObjectAttributeHumanInTheLoopName,
      ObjectFlagMask);

   _throttleHandle = activate_object_attribute (
      ObjectAttributeScalarThrottleName,
      ObjectScalarMask);

   _move.maxSpeed = config_to_float64 ("movement.speed", local, _move.maxSpeed);
   _move.maxAccel = config_to_float64 ("movement.acceleration", local, _move.maxAccel);
   _move.maxDecel = config_to_float64 ("movement.deceleration", local, _move.maxDecel);
   _move.turnRate = config_to_float64 ("movement.turn", local, _move.turnRate);
   _move.brakeRate = config_to_float64 ("movement.brake", local, _move.brakeRate);
   _move.whiskerLength = config_to_float64 ("whisker.length", local, _move.whiskerLength);
   _move.whiskerHeight = config_to_float64 ("whisker.height", local, _move.whiskerHeight);

   init_input_channels (
      local,
      InputEventButtonMask | InputEventAxisMask | InputEventChannelStateMask,
      &_log);

   _isectParameters.set_test_result_type (IsectAllPoints);
   _isectParameters.set_calculate_normal (True);
   _isectParameters.set_calculate_object_handle (True);
   _isectParameters.set_calculate_distance (False);
   _isectParameters.set_calculate_cull_mode (True);
}
Ejemplo n.º 4
0
/*!

\brief Converts Config to a Mask containing state values.
\details Defined in dmzRuntimeConfigToState.h.
\code
RuntimeContext *context (get_plugin_runtime_context ());
const dmz::String DefaultStateName ("Some_State|Another_State");
dmz::Mask value = dmz::config_to_state ("dmz.state.value", local, DefaultStateName, context);
\endcode
\param[in] Name String containing name of config context to convert.
\param[in] Source Config containing config context to convert.
\param[in] DefaultStateName String containing default state name to use
if the config context is not found.
\param[in] context Pointer to the runtime context.
\return Returns dmz::Mask containing the state values.

*/
dmz::Mask
dmz::config_to_state (
      const String &Name,
      const Config &Source,
      const String &DefaultStateName,
      RuntimeContext *context) {

   Mask defaultMask;

   Definitions defs (context);

   defs.lookup_state (DefaultStateName, defaultMask);

   return config_to_state (Name, Source, defaultMask, context);
}
Ejemplo n.º 5
0
void
dmz::EntityPluginDeadTimer::_init (Config &local) {

   Definitions defs (get_plugin_runtime_context (), &_log);

   defs.lookup_state (DefaultStateNameDead, _deadState);

   _defaultHandle =
      activate_default_object_attribute (ObjectDestroyMask | ObjectStateMask);

   _hilHandle = activate_object_attribute (
      ObjectAttributeHumanInTheLoopName,
      ObjectFlagMask);

   set_time_slice_interval (
      config_to_float64 ("timer.value", local, get_time_slice_interval ()));
}
Ejemplo n.º 6
0
void
dmz::EntityPluginOverlayDead::_init (Config &local) {

   Definitions defs (get_plugin_runtime_context (), &_log);

   defs.lookup_state (DefaultStateNameDead, _deadState);

   activate_default_object_attribute (ObjectStateMask);

   _hilAttrHandle = activate_object_attribute (
      ObjectAttributeHumanInTheLoopName,
      ObjectFlagMask);

   _overlaySwitchName =
      config_to_string ("overlay.switch.name", local, _overlaySwitchName);

   _overlayScaleName = config_to_string ("overlay.scale.name", local, _overlayScaleName);
}
Ejemplo n.º 7
0
void
dmz::EntityPluginDamage::_init (Config &local) {

   Definitions defs (get_plugin_runtime_context (), &_log);

   _targetHandle = defs.create_named_handle (EventAttributeTargetName);

   const String StateNames = config_to_string ("state.name", local, DefaultStateNameDead);

   defs.lookup_state (StateNames, _deadState);

   _defaultObjectHandle = activate_default_object_attribute (ObjectDestroyMask);

   _hilHandle = activate_object_attribute (
      ObjectAttributeHumanInTheLoopName,
      ObjectFlagMask);

   _detonationType = activate_event_callback (EventDetonationName, EventCloseMask);
}
Ejemplo n.º 8
0
/*!

\brief Converts Config to a Mask containing state values.
\details Defined in dmzRuntimeConfigToState.h.
\code
RuntimeContext *context (get_plugin_runtime_context ());
const dmz::Mask DefaultState;
dmz::Mask value = dmz::config_to_state ("dmz.state.value", local, DefaultState, context);
\endcode
\param[in] Name String containing name of config context to convert.
\param[in] Source Config containing config context to convert.
\param[in] DefaultState Mask containing default state to use
if the config context is not found.
\param[in] context Pointer to the runtime context.
\return Returns dmz::Mask containing the state values.

*/
dmz::Mask
dmz::config_to_state (
      const String &Name,
      const Config &Source,
      const Mask &DefaultState,
      RuntimeContext *context) {

   Mask result;

   String stateName;

   if (local_config_to_string (Name, Source, stateName)) {

      Definitions defs (context);

      defs.lookup_state (stateName, result);
   }
   else { result = DefaultState; }

   return result;
}
Ejemplo n.º 9
0
dmz::NetModuleLocalDRBasic::ObjectUpdate *
dmz::NetModuleLocalDRBasic::_create_update_list (Config &listData) {

   Definitions defs (get_plugin_runtime_context (), &_log);

   ObjectUpdate *head (0), *current (0);

   ConfigIterator it;
   Config cd;

   while (listData.get_next_config (it, cd)) {

      ObjectUpdate *next (0);

      const String Type (config_to_string ("type", cd).to_lower ());

      const String AttributeName (
         config_to_string ("attribute", cd, ObjectAttributeDefaultName));

      const Handle AttributeHandle (defs.create_named_handle (AttributeName));

      const Handle LNVHandle (defs.create_named_handle (
         config_to_string (
            "lnv-attribute",
            cd,
            create_last_network_value_name (AttributeName))));

      if (Type == "position") {

         next = new vectorTest (
            TestPosition,
            AttributeHandle,
            LNVHandle,
            config_to_float64 ("value", cd, 0.25));
      }
      else if (Type == "velocity") {

         next = new vectorTest (
            TestVelocity,
            AttributeHandle,
            LNVHandle,
            config_to_float64 ("value", cd, 0.25));
      }
      else if (Type == "acceleration") {

         next = new vectorTest (
            TestAcceleration,
            AttributeHandle,
            LNVHandle,
            config_to_float64 ("value", cd, 0.25));
      }
      else if (Type == "vector") {

         next = new vectorTest (
            TestVector,
            AttributeHandle,
            LNVHandle,
            config_to_float64 ("value", cd, 0.25));
      }
      else if (Type == "orientation") {

         next = new oriTest (
            AttributeHandle,
            LNVHandle,
            config_to_float64 ("value", cd, 0.25));
      }
      else if (Type == "scalar") {

         next = new scalarTest (
            AttributeHandle,
            LNVHandle,
            config_to_float64 ("value", cd, 0.25));
      }
      else if (Type == "counter") {

         next = new counterTest (AttributeHandle, LNVHandle);
      }
      else if (Type == "state") {

         Definitions defs (get_plugin_runtime_context (), &_log);

         Mask state;

         defs.lookup_state (config_to_string ("value", cd), state);

         next = new stateTest (AttributeHandle, LNVHandle, state);
      }
      else if (Type == "skew") {

         next = new posSkewTest (
            AttributeHandle,
            LNVHandle,
            _time,
            config_to_float64 ("value", cd, 0.25));
      }
      else if (Type == "heartbeat") {

         next = new heartbeatTest (
            LNVHandle,
            _time,
            config_to_float64 ("value", cd, 5.0));
      }
      else if (Type == "rate-limit") {

         next = new limitRateTest (
            LNVHandle,
            _time,
            // 1/15 of a second max update rate is the default.
            config_to_float64 ("value", cd, 0.066666666667));
      }

      if (next) {

         _log.info << "Adding rule: " << Type << endl;
         if (current) { current->next = next; current = next; }
         else { head = current = next; }
      }
   }

   return head;
}
Ejemplo n.º 10
0
void
dmz::NetExtPacketCodecObjectBasic::_init (Config &local) {

   Definitions defs (get_plugin_runtime_context (), &_log);

   _defaultHandle = defs.create_named_handle (ObjectAttributeDefaultName);
   _lnvHandle = defs.create_named_handle (ObjectAttributeLastNetworkValueName);

   defs.lookup_state (
      config_to_string ("deactivate.name", local, DefaultStateNameDeactivate),
      _deactivateState);

   Config scalarData;

   if (local.lookup_all_config ("scalar", scalarData)) {

      ConfigIterator it;

      Config data;

      Boolean found (scalarData.get_first_config (it, data));

      while (found) {

         const String Name (config_to_string ("name", data));

         const String LNVName (
            config_to_string (
               "lnvname",
                data,
                create_last_network_value_name (Name)));

         const UInt32 Value (config_to_uint32 ("value", data));

         if (Name) {

            ScalarStruct *ss (new ScalarStruct (
               Value,
               defs.create_named_handle (Name),
               defs.create_named_handle (LNVName)));

            if (ss && !_scalarTable.store (ss->NetHandle, ss)) {

               delete ss; ss = 0;
            }
         }
         else {

         }

         found = scalarData.get_next_config (it, data);
      }
   }
   else {

      ScalarStruct *ss (
         new ScalarStruct (
            1,
            defs.create_named_handle (ObjectAttributeScalarThrottleName),
            defs.create_named_handle (
               create_last_network_value_name (ObjectAttributeScalarThrottleName))));

      if (ss && !_scalarTable.store (ss->NetHandle, ss)) { delete ss; ss = 0; }
   }
}