Add the necessary code to trigger location-specific action; for now there is a placeholder in the location of the overworld garage

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@10803 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2012-02-05 01:32:35 +00:00
parent 547fd78d6d
commit 7711bab285
3 changed files with 31 additions and 7 deletions

View File

@ -57,12 +57,12 @@ TrackObject::TrackObject(const XMLNode &xml_node)
xml_node.get("lod_group", &m_lod_group);
/** For sound effects */
bool trigger_when_near = false;
/** For sound effects */
float trigger_distance = 1.0f;
std::string type;
xml_node.get("type", &type );
bool trigger_when_near = false;
float trigger_distance = 1.0f;
// FIXME: at this time sound emitters are just disabled in multiplayer
// otherwise the sounds would be constantly heard
if (sound.size() > 0 && race_manager->getNumLocalPlayers() == 1)
@ -105,14 +105,27 @@ TrackObject::TrackObject(const XMLNode &xml_node)
"[TrackObject] Sound emitter object could not be created\n");
}
}
else if (type == "action-trigger")
{
trigger_when_near = true;
xml_node.get("distance", &trigger_distance);
xml_node.get("action", &m_action);
if (m_action.size() == 0)
{
fprintf(stderr, "[TrackObject] WARNING: action-trigger has no action defined\n");
}
}
// Some animated objects (billboards, sound emitters)
// Some animated objects (billboards, sound emitters, action triggers)
// don't use this scene node
if (model_name == "")
{
m_node = NULL;
m_mesh = NULL;
if (trigger_when_near)
{
item_manager->newItem(m_init_xyz, trigger_distance, this);
@ -295,4 +308,8 @@ void TrackObject::onTriggerItemApproached(Item* who)
{
m_sound->play();
}
else if (m_action.size() > 0)
{
printf("Action %s\n", m_action.c_str());
}
}

View File

@ -88,6 +88,9 @@ protected:
/** LOD group this object is part of, if it is LOD */
std::string m_lod_group;
/** For action trigger objects */
std::string m_action;
public:
TrackObject(const XMLNode &xml_node);
TrackObject(const core::vector3df& pos, const core::vector3df& hpr,

View File

@ -83,6 +83,10 @@ void TrackObjectManager::add(const XMLNode &xml_node)
{
m_all_objects.push_back(new TrackObject(xml_node));
}
else if(type=="action-trigger")
{
m_all_objects.push_back(new TrackObject(xml_node));
}
else
{
fprintf(stderr, "Unknown track object: '%s' - ignored.\n",