More cleanup to remove hardcoded things in favor of scripting, and start work to allow for more action trigger shapes (work in progress)
This commit is contained in:
parent
9b562d31f4
commit
77fac34e41
@ -128,6 +128,7 @@ void OverWorld::update(float dt)
|
||||
m_karts[n]->setEnergy(100.0f);
|
||||
}
|
||||
|
||||
/*
|
||||
TrackObjectManager* tom = getTrack()->getTrackObjectManager();
|
||||
PtrVector<TrackObject>& objects = tom->getObjects();
|
||||
for(unsigned int i=0; i<objects.size(); i++)
|
||||
@ -145,6 +146,7 @@ void OverWorld::update(float dt)
|
||||
obj->reset();
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
if (m_return_to_garage)
|
||||
{
|
||||
|
@ -44,6 +44,7 @@ private:
|
||||
CheckManager() {m_all_checks.clear();};
|
||||
~CheckManager();
|
||||
public:
|
||||
void add(CheckStructure* strct) { m_all_checks.push_back(strct); }
|
||||
void load(const XMLNode &node);
|
||||
void update(float dt);
|
||||
void reset(const Track &track);
|
||||
|
@ -71,9 +71,7 @@ TrackObject::TrackObject(const core::vector3df& xyz, const core::vector3df& hpr,
|
||||
m_presentation = presentation;
|
||||
m_is_driveable = false;
|
||||
m_soccer_ball = false;
|
||||
m_garage = false;
|
||||
m_initially_visible = false;
|
||||
m_distance = 0;
|
||||
m_type = "";
|
||||
|
||||
if (m_interaction != "ghost" && m_interaction != "none" &&
|
||||
@ -127,9 +125,6 @@ void TrackObject::init(const XMLNode &xml_node, scene::ISceneNode* parent,
|
||||
m_soccer_ball = false;
|
||||
xml_node.get("soccer_ball", &m_soccer_ball);
|
||||
|
||||
m_garage = false;
|
||||
m_distance = 0;
|
||||
|
||||
std::string type;
|
||||
xml_node.get("type", &type );
|
||||
|
||||
@ -179,16 +174,9 @@ void TrackObject::init(const XMLNode &xml_node, scene::ISceneNode* parent,
|
||||
}
|
||||
else if (type == "action-trigger")
|
||||
{
|
||||
std::string m_action;
|
||||
xml_node.get("action", &m_action);
|
||||
xml_node.get("distance", &m_distance);
|
||||
m_name = m_action;
|
||||
//adds action as name so that it can be found by using getName()
|
||||
if (m_action == "garage")
|
||||
{
|
||||
m_garage = true;
|
||||
}
|
||||
|
||||
std::string action;
|
||||
xml_node.get("action", &action);
|
||||
m_name = action; //adds action as name so that it can be found by using getName()
|
||||
m_presentation = new TrackObjectPresentationActionTrigger(xml_node);
|
||||
}
|
||||
else if (type == "billboard")
|
||||
|
@ -80,13 +80,9 @@ protected:
|
||||
|
||||
bool m_soccer_ball;
|
||||
|
||||
bool m_garage;
|
||||
|
||||
/** True if a kart can drive on this object. This will */
|
||||
bool m_is_driveable;
|
||||
|
||||
float m_distance;
|
||||
|
||||
PhysicalObject* m_physical_object;
|
||||
|
||||
ThreeDAnimation* m_animator;
|
||||
@ -161,10 +157,6 @@ public:
|
||||
// ------------------------------------------------------------------------
|
||||
bool isSoccerBall() const { return m_soccer_ball; }
|
||||
// ------------------------------------------------------------------------
|
||||
bool isGarage() const { return m_garage; }
|
||||
// ------------------------------------------------------------------------
|
||||
float getDistance() const { return m_distance; }
|
||||
// ------------------------------------------------------------------------
|
||||
const PhysicalObject* getPhysicalObject() const { return m_physical_object; }
|
||||
// ------------------------------------------------------------------------
|
||||
PhysicalObject* getPhysicalObject() { return m_physical_object; }
|
||||
|
@ -40,6 +40,8 @@
|
||||
#include "modes/world.hpp"
|
||||
#include "scriptengine/script_engine.hpp"
|
||||
#include "states_screens/dialogs/tutorial_message_dialog.hpp"
|
||||
#include "tracks/check_manager.hpp"
|
||||
#include "tracks/check_sphere.hpp"
|
||||
#include "tracks/model_definition_loader.hpp"
|
||||
#include "tracks/track.hpp"
|
||||
#include "tracks/track_manager.hpp"
|
||||
@ -935,12 +937,40 @@ TrackObjectPresentationActionTrigger::TrackObjectPresentationActionTrigger(
|
||||
xml_node.get("distance", &trigger_distance);
|
||||
xml_node.get("action", &m_action );
|
||||
|
||||
std::string trigger_type;
|
||||
xml_node.get("trigger-type", &trigger_type);
|
||||
if (trigger_type == "point")
|
||||
{
|
||||
m_type = TRIGGER_TYPE_POINT;
|
||||
}
|
||||
else if (trigger_type == "cylinder")
|
||||
{
|
||||
m_type = TRIGGER_TYPE_CYLINDER;
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
m_action_active = true;
|
||||
|
||||
if (m_action.size() == 0)
|
||||
Log::warn("TrackObject", "Action-trigger has no action defined.");
|
||||
|
||||
ItemManager::get()->newItem(m_init_xyz, trigger_distance, this);
|
||||
if (m_type == TRIGGER_TYPE_POINT)
|
||||
{
|
||||
// TODO: rewrite as a sphere check structure?
|
||||
ItemManager::get()->newItem(m_init_xyz, trigger_distance, this);
|
||||
}
|
||||
else if (m_type == TRIGGER_TYPE_CYLINDER)
|
||||
{
|
||||
// TODO: create the right check structure
|
||||
CheckManager::get()->add(new CheckSphere(xml_node, 0 /* TODO what is this? */));
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
} // TrackObjectPresentationActionTrigger
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -956,6 +986,7 @@ TrackObjectPresentationActionTrigger::TrackObjectPresentationActionTrigger(
|
||||
float trigger_distance = distance;
|
||||
m_action = script_name;
|
||||
m_action_active = true;
|
||||
m_type = TRIGGER_TYPE_POINT;
|
||||
ItemManager::get()->newItem(m_init_xyz, trigger_distance, this);
|
||||
} // TrackObjectPresentationActionTrigger
|
||||
|
||||
|
@ -349,6 +349,13 @@ public:
|
||||
}; // TrackObjectPresentationLight
|
||||
|
||||
// ============================================================================
|
||||
|
||||
enum ActionTriggerType
|
||||
{
|
||||
TRIGGER_TYPE_POINT = 0,
|
||||
TRIGGER_TYPE_CYLINDER = 1
|
||||
};
|
||||
|
||||
/** \ingroup tracks
|
||||
* A track object representation that consists of an action trigger
|
||||
*/
|
||||
@ -361,6 +368,8 @@ private:
|
||||
|
||||
bool m_action_active;
|
||||
|
||||
ActionTriggerType m_type;
|
||||
|
||||
public:
|
||||
TrackObjectPresentationActionTrigger(const XMLNode& xml_node);
|
||||
TrackObjectPresentationActionTrigger(const core::vector3df& xyz,
|
||||
|
Loading…
Reference in New Issue
Block a user