Fixed #1086 - Popup message was displayed constantly when you were in garage in overworld.

TODO: Compare distance between garage and kart with for example length
of the kart or distance of object defined in scene.xml.
Currently (m_garage_pos-m_kart_pos).length2_2d() gives much higher values than
getKart(0)->getKartModel()->getLength() and I must look at this closer.

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@14804 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
deveee
2013-12-27 02:12:16 +00:00
parent 32a61d770e
commit 27e397d2c7
4 changed files with 43 additions and 3 deletions

View File

@@ -31,6 +31,7 @@
#include "states_screens/offline_kart_selection.hpp"
#include "states_screens/race_gui_overworld.hpp"
#include "tracks/track.hpp"
#include "tracks/track_object_manager.hpp"
//-----------------------------------------------------------------------------
OverWorld::OverWorld() : WorldWithRank()
@@ -124,6 +125,31 @@ void OverWorld::update(float dt)
m_karts[n]->setEnergy(100.0f);
}
TrackObjectManager* tom = getTrack()->getTrackObjectManager();
PtrVector<TrackObject>& objects = tom->getObjects();
for(int i=0; i<objects.size(); i++)
{
TrackObject* obj = objects.get(i);
if(!obj->isGarage())
continue;
Vec3 m_garage_pos = obj->getPosition();
AbstractKart* m_kart = getKart(0);
Vec3 m_kart_pos = m_kart->getXYZ();
//~ float kart_len = m_kart->getKartModel()->getLength();
//~ printf("%f\n", (m_garage_pos-m_kart_pos).length2_2d());
//~ printf("%f\n", kart_len);
//TODO: Compare distance between garage and kart with for example length
// of the kart or distance of object defined in scene.xml
if ((m_garage_pos-m_kart_pos).length2_2d() > CHALLENGE_DISTANCE_SQUARED*3)
{
obj->reset();
}
}
if (m_return_to_garage)
{
m_return_to_garage = false;
@@ -133,7 +159,7 @@ void OverWorld::update(float dt)
s->setMultiplayer(false);
s->setFromOverworld(true);
StateManager::get()->resetAndGoToScreen(s);
}
}
} // update
//-----------------------------------------------------------------------------

View File

@@ -101,6 +101,8 @@ void TrackObject::init(const XMLNode &xml_node, LODNode* lod_node)
m_soccer_ball = false;
xml_node.get("soccer_ball", &m_soccer_ball);
m_garage = false;
std::string type;
xml_node.get("type", &type );
@@ -122,6 +124,13 @@ void TrackObject::init(const XMLNode &xml_node, LODNode* lod_node)
}
else if (type == "action-trigger")
{
std::string m_action;
xml_node.get("action", &m_action);
if (m_action == "garage")
{
m_garage = true;
}
m_presentation = new TrackObjectPresentationActionTrigger(xml_node);
}
else if (type == "billboard")

View File

@@ -73,11 +73,13 @@ protected:
std::string m_type;
bool m_soccer_ball;
bool m_garage;
PhysicalObject* m_rigid_body;
ThreeDAnimation* m_animator;
void init(const XMLNode &xml_node, LODNode* lodNode);
public:
@@ -106,7 +108,8 @@ public:
const std::string& getType() const { return m_type; }
bool isSoccerBall() const { return m_soccer_ball; }
bool isGarage() const { return m_garage; }
const PhysicalObject* getPhysics() const { return m_rigid_body; }
PhysicalObject* getPhysics() { return m_rigid_body; }

View File

@@ -612,6 +612,8 @@ void TrackObjectPresentationActionTrigger::onTriggerItemApproached(Item* who)
if (m_action == "garage")
{
m_action_active = false;
new RacePausedDialog(0.8f, 0.6f);
//dynamic_cast<OverWorld*>(World::getWorld())->scheduleSelectKart();
}