have more than one lap line, which will always be in synch (i.e. if one is triggered, all will be set to inactive). git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@6161 178a84e3-b1eb-0310-8ba1-8eac791a3b58
81 lines
2.9 KiB
C++
81 lines
2.9 KiB
C++
// $Id: check_manager.cpp 1681 2008-04-09 13:52:48Z hikerstk $
|
|
//
|
|
// SuperTuxKart - a fun racing game with go-kart
|
|
// Copyright (C) 2009 Joerg Henrichs
|
|
//
|
|
// This program is free software; you can redistribute it and/or
|
|
// modify it under the terms of the GNU General Public License
|
|
// as published by the Free Software Foundation; either version 3
|
|
// of the License, or (at your option) any later version.
|
|
//
|
|
// This program is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with this program; if not, write to the Free Software
|
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
#include "tracks/check_manager.hpp"
|
|
|
|
#include <string>
|
|
|
|
#include "io/xml_node.hpp"
|
|
#include "tracks/check_line.hpp"
|
|
#include "tracks/ambient_light_sphere.hpp"
|
|
#include "tracks/check_structure.hpp"
|
|
#include "tracks/track.hpp"
|
|
|
|
CheckManager::CheckManager(const XMLNode &node, Track *track)
|
|
{
|
|
bool lap_line_found = false;
|
|
for(unsigned int i=0; i<node.getNumNodes(); i++)
|
|
{
|
|
const XMLNode *check_node = node.getNode(i);
|
|
const std::string &type = check_node->getName();
|
|
if(type=="check-line")
|
|
{
|
|
CheckLine *cl = new CheckLine(this, *check_node, i);
|
|
m_all_checks.push_back(cl);
|
|
// Only record the first lap line to be used to compute
|
|
// start coordinates with. The track exporter always exports
|
|
// the one based on the quads first.
|
|
if(cl->getType()==CheckStructure::CT_NEW_LAP && !lap_line_found)
|
|
{
|
|
track->setStartCoordinates(cl->getLine2D());
|
|
lap_line_found = true;
|
|
}
|
|
} // checkline
|
|
else if(type=="check-sphere")
|
|
{
|
|
AmbientLightSphere *cs = new AmbientLightSphere(this, *check_node,
|
|
i);
|
|
m_all_checks.push_back(cs);
|
|
} // checksphere
|
|
else
|
|
printf("Unknown check structure '%s' - ignored.\n", type.c_str());
|
|
} // for i<node.getNumNodes
|
|
} // CheckManager
|
|
|
|
// ----------------------------------------------------------------------------
|
|
/** Resets all checks. */
|
|
void CheckManager::reset(const Track &track)
|
|
{
|
|
std::vector<CheckStructure*>::iterator i;
|
|
for(i=m_all_checks.begin(); i!=m_all_checks.end(); i++)
|
|
(*i)->reset(track);
|
|
} // reset
|
|
|
|
// ----------------------------------------------------------------------------
|
|
/** Updates all animations. Called one per time step.
|
|
* \param dt Time since last call.
|
|
*/
|
|
void CheckManager::update(float dt)
|
|
{
|
|
std::vector<CheckStructure*>::iterator i;
|
|
for(i=m_all_checks.begin(); i!=m_all_checks.end(); i++)
|
|
(*i)->update(dt);
|
|
} // update
|
|
|