var var::invoke (const Identifier method, const var* arguments, int numArguments) const { if (DynamicObject* const o = getDynamicObject()) return o->invokeMethod (method, arguments, numArguments); return var::null; }
//============================================================================== var var::operator[] (const Identifier propertyName) const { if (DynamicObject* const o = getDynamicObject()) return o->getProperty (propertyName); return var::null; }
var var::getProperty (const Identifier propertyName, const var& defaultReturnValue) const { if (DynamicObject* const o = getDynamicObject()) return o->getProperties().getWithDefault (propertyName, defaultReturnValue); return defaultReturnValue; }
var var::invoke (const Identifier& method, const var* arguments, int numArguments) const { if (auto* o = getDynamicObject()) return o->invokeMethod (method, var::NativeFunctionArgs (*this, arguments, numArguments)); return {}; }
bool var::hasProperty (const Identifier& propertyName) const noexcept { if (auto* o = getDynamicObject()) return o->hasProperty (propertyName); return false; }
//============================================================================== const var& var::operator[] (const Identifier& propertyName) const { if (auto* o = getDynamicObject()) return o->getProperty (propertyName); return getNullVarRef(); }
var var::invoke (Identifier method, const var* arguments, int numArguments) const { if (DynamicObject* const o = getDynamicObject()) return o->invokeMethod (method, var::NativeFunctionArgs (*this, arguments, numArguments)); return var(); }
//! bool CGameNodeButton::activate(IGameNode* activator) { if (State == EBS_UNPUSHED) { m_Activated = true; State = EBS_PUSHING; dyn::IDynamicObject *dynobj = getDynamicObject(); if (dynobj) { dyn::SDynamicObjectParams Button_dynparams = dynobj->getParameters(); Button_dynparams.DynamicConstraints = DynamicConstraints; dynobj->setParameters(Button_dynparams); } IGameNode *activator = this; game::IGameTasksManager >mgr = GAME_TASK_MANAGER; for (u32 i=0; i<m_TargetNodes.size(); i++) { // registering task (node activation) gtmgr.registerGameTask( new game::SGameTaskActivate(activator, m_TargetNodes[i]) ); } //stopSoundEffect(BUTTON_DEACTIVATED_SOUND); playSoundEffect(BUTTON_ACTIVATED_SOUND); return true; } return false; }
var var::invoke (const Identifier& method, const var* arguments, int numArguments) const { DynamicObject* const o = getDynamicObject(); return o != nullptr ? o->invokeMethod (method, arguments, numArguments) : var::null; }
var var::getProperty (const Identifier& propertyName, const var& defaultReturnValue) const { DynamicObject* const o = getDynamicObject(); return o != nullptr ? o->getProperties().getWithDefault (propertyName, defaultReturnValue) : defaultReturnValue; }
//============================================================================== var var::operator[] (const Identifier& propertyName) const { DynamicObject* const o = getDynamicObject(); return o != nullptr ? o->getProperty (propertyName) : var::null; }
//! calling every time after doing all game stuff (dynamic, scriptin, etc.) void CGameNodeButton::OnPostDynamic(f64 delta_time_sec) { IGameNodeActivatable::OnPostDynamic(delta_time_sec); s32 now = m_NowTimeMs; CurrentPos = m_SceneNode->getPosition(); if (State == EBS_PUSHING) { dyn::IDynamicObject *dynobj = getDynamicObject(); if (dynobj) { core::vector3df vec = PushedPos-CurrentPos; f32 angle = PushDir.getAngleDeg(vec); if (angle>85) { State = EBS_WAITING; dyn::SDynamicObjectParams Button_dynparams = dynobj->getParameters(); Button_dynparams.DynamicConstraints = dyn::EDTC_NO_TRANSF; dynobj->setParameters(Button_dynparams); StartUnpushTime = now + m_WaitTimeSec * 1000; //stopSoundEffect(BUTTON_ACTIVATED_SOUND); playSoundEffect(BUTTON_DEACTIVATED_SOUND); } } } else if (State == EBS_UNPUSHING) { dyn::IDynamicObject *dynobj = getDynamicObject(); if (dynobj) { core::vector3df vec = UnpushedPos-CurrentPos; f32 angle = PushDir.getAngleDeg(vec); if (angle<90) { State = EBS_UNPUSHED; dyn::SDynamicObjectParams Button_dynparams = dynobj->getParameters(); Button_dynparams.DynamicConstraints = dyn::EDTC_NO_TRANSF; dynobj->setParameters(Button_dynparams); m_Activated = false; } } } else if (State == EBS_WAITING) { if (now>StartUnpushTime) { State = EBS_UNPUSHING; dyn::IDynamicObject *dynobj = getDynamicObject(); if (dynobj) { dyn::SDynamicObjectParams Button_dynparams = dynobj->getParameters(); Button_dynparams.DynamicConstraints = DynamicConstraints; dynobj->setParameters(Button_dynparams); } } } }