Reserve onReset of scripting method for library nodes (unused atm)

This commit is contained in:
Benau 2017-12-02 15:24:36 +08:00
parent 3607c7d520
commit 7ab8477a53
2 changed files with 24 additions and 2 deletions

View File

@ -180,6 +180,7 @@ TrackObjectPresentationLibraryNode::TrackObjectPresentationLibraryNode(
{
m_parent = NULL;
m_start_executed = false;
m_reset_executed = false;
std::string name;
xml_node.get("name", &name);
@ -289,6 +290,22 @@ void TrackObjectPresentationLibraryNode::update(float dt)
m_start_executed = true;
std::string fn_name = StringUtils::insertValues("void %s::onStart(const string)", m_name.c_str());
if (m_parent != NULL)
{
std::string lib_id = m_parent->getID();
std::string* lib_id_ptr = &lib_id;
Scripting::ScriptEngine::getInstance()->runFunction(false, fn_name,
[&](asIScriptContext* ctx) {
ctx->SetArgObject(0, lib_id_ptr);
});
}
}
if (!m_reset_executed)
{
m_reset_executed = true;
std::string fn_name = StringUtils::insertValues("void %s::onReset(const string)", m_name.c_str());
if (m_parent != NULL)
{
std::string lib_id = m_parent->getID();

View File

@ -187,13 +187,18 @@ class TrackObjectPresentationLibraryNode : public TrackObjectPresentationSceneNo
TrackObject* m_parent;
using TrackObjectPresentationSceneNode::move;
std::string m_name;
bool m_start_executed;
bool m_start_executed, m_reset_executed;
public:
TrackObjectPresentationLibraryNode(TrackObject* parent,
const XMLNode& xml_node,
ModelDefinitionLoader& model_def_loader);
virtual ~TrackObjectPresentationLibraryNode();
virtual void update(float dt);
virtual void update(float dt) OVERRIDE;
virtual void reset() OVERRIDE
{
m_reset_executed = false;
TrackObjectPresentationSceneNode::reset();
}
void move(const core::vector3df& xyz, const core::vector3df& hpr,
const core::vector3df& scale, bool isAbsoluteCoord, bool moveChildrenPhysicalBodies);
}; // TrackObjectPresentationLibraryNode