track objects can be enabled/disabled/their status can be checked on, TODO: move this to scripting
This commit is contained in:
9
src/scriptengine/haybail.as
Normal file
9
src/scriptengine/haybail.as
Normal file
@@ -0,0 +1,9 @@
|
||||
void onTrigger()
|
||||
{
|
||||
/*to activate this add the following line to stk-assets/farm/scene.xml
|
||||
|
||||
<object type="action-trigger" action="haybail" distance="30.0" xyz="100.72 10.20 -26.22" hpr="0.0 -0.0 0.0" scale="7.00 7.00 7.00"/>
|
||||
|
||||
*/
|
||||
displayMessage("Everything Disappeared!");
|
||||
}
|
||||
@@ -91,6 +91,7 @@ void TrackObject::init(const XMLNode &xml_node, scene::ISceneNode* parent,
|
||||
|
||||
m_physical_object = NULL;
|
||||
|
||||
xml_node.get("model", &m_name );
|
||||
xml_node.get("xyz", &m_init_xyz );
|
||||
xml_node.get("hpr", &m_init_hpr );
|
||||
xml_node.get("scale", &m_init_scale);
|
||||
|
||||
@@ -53,6 +53,8 @@ private:
|
||||
|
||||
TrackObjectPresentation* m_presentation;
|
||||
|
||||
std::string m_name;
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
@@ -109,6 +111,9 @@ public:
|
||||
|
||||
const std::string& getType() const { return m_type; }
|
||||
|
||||
const std::string getName() const { return m_name; }
|
||||
|
||||
bool isEnabled() const { return m_enabled; }
|
||||
bool isSoccerBall() const { return m_soccer_ball; }
|
||||
bool isGarage() const { return m_garage; }
|
||||
float getDistance() const { return m_distance; }
|
||||
|
||||
@@ -86,6 +86,36 @@ void TrackObjectManager::reset()
|
||||
} // reset
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void TrackObjectManager::disable(std::string name){
|
||||
TrackObject* curr;
|
||||
for_in (curr,m_all_objects){
|
||||
if (curr->getName() == (name)){
|
||||
//OutputDebugString("came here2");
|
||||
curr->setEnable(false);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
void TrackObjectManager::enable(std::string name){
|
||||
TrackObject* curr;
|
||||
for_in (curr,m_all_objects){
|
||||
if (curr->getName() == (name)){
|
||||
//OutputDebugString("came here2");
|
||||
curr->setEnable(true);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
bool TrackObjectManager::getStatus(std::string name){
|
||||
TrackObject* curr;
|
||||
for_in (curr,m_all_objects){
|
||||
if (curr->getName() == (name)){
|
||||
//OutputDebugString("came here2");
|
||||
return curr->isEnabled();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
/** Handles an explosion, i.e. it makes sure that all physical objects are
|
||||
* affected accordingly.
|
||||
* \param pos Position of the explosion.
|
||||
|
||||
@@ -55,6 +55,9 @@ public:
|
||||
bool secondary_hits=true);
|
||||
void reset();
|
||||
void init();
|
||||
void disable(std::string name);
|
||||
void enable(std::string name);
|
||||
bool getStatus(std::string name);
|
||||
|
||||
/** Enable or disable fog on objects */
|
||||
void enableFog(bool enable);
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include "states_screens/dialogs/tutorial_message_dialog.hpp"
|
||||
#include "tracks/lod_node_loader.hpp"
|
||||
#include "tracks/track.hpp"
|
||||
#include "tracks/track_object_manager.hpp"
|
||||
#include "scriptengine/script_engine.hpp";
|
||||
#include <ISceneManager.h>
|
||||
#include <IMeshSceneNode.h>
|
||||
@@ -45,6 +46,9 @@
|
||||
#include <ILightSceneNode.h>
|
||||
#include <IMeshManipulator.h>
|
||||
|
||||
//for testing
|
||||
#include <time.h>
|
||||
#include <iostream>
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
TrackObjectPresentation::TrackObjectPresentation(const XMLNode& xml_node)
|
||||
@@ -716,6 +720,30 @@ void TrackObjectPresentationActionTrigger::onTriggerItemApproached(Item* who)
|
||||
ScriptEngineOne* m_script_engine = new ScriptEngineOne();
|
||||
m_script_engine->doit(m_action);
|
||||
}
|
||||
else if (m_action == "haybail")
|
||||
{
|
||||
if (World::getWorld()->getTrack()->getTrackObjectManager()->getStatus("hayBail.b3d"))
|
||||
World::getWorld()->getTrack()->getTrackObjectManager()->disable("hayBail.b3d");
|
||||
else
|
||||
World::getWorld()->getTrack()->getTrackObjectManager()->enable("hayBail.b3d");
|
||||
//Check performance
|
||||
/*
|
||||
clock_t t1,t2;
|
||||
t1=clock();
|
||||
for (int i=0;i<20;i++){
|
||||
ScriptEngineOne* m_script_engine = new ScriptEngineOne();
|
||||
m_script_engine->doit(m_action);
|
||||
t2=clock();
|
||||
float diff ((double)t2-(double)t1);
|
||||
std::cout << "System Time in milliseconds is " << 1000*diff/CLOCKS_PER_SEC<<std::endl;
|
||||
*/
|
||||
ScriptEngineOne* m_script_engine = new ScriptEngineOne();
|
||||
m_script_engine->doit(m_action);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
else if (m_action == "tutorial_giftboxes")
|
||||
{
|
||||
m_action_active = false;
|
||||
|
||||
Reference in New Issue
Block a user