void Control::Initialise(Control* _parent, MyGUI::Widget* _place, const std::string& _layoutName) { OnInitialise(_parent, _place, _layoutName); ActivateControllers(); }
void SCA_ISensor::Activate(class SCA_LogicManager* logicmgr) { // calculate if a __triggering__ is wanted // don't evaluate a sensor that is not connected to any controller if (m_links && !m_suspended) { bool result = this->Evaluate(); // store the state for the rest of the logic system m_prev_state = m_state; m_state = this->IsPositiveTrigger(); if (result) { // the sensor triggered this frame if (m_state || !m_tap) { ActivateControllers(logicmgr); // reset these counters so that pulse are synchronized with transition m_pos_ticks = 0; m_neg_ticks = 0; } else { result = false; } } else { /* First, the pulsing behavior, if pulse mode is * active. It seems something goes wrong if pulse mode is * not set :( */ if (m_pos_pulsemode) { m_pos_ticks++; if (m_pos_ticks > m_pulse_frequency) { if ( m_state ) { ActivateControllers(logicmgr); result = true; } m_pos_ticks = 0; } } // negative pulse doesn't make sense in tap mode, skip if (m_neg_pulsemode && !m_tap) { m_neg_ticks++; if (m_neg_ticks > m_pulse_frequency) { if (!m_state ) { ActivateControllers(logicmgr); result = true; } m_neg_ticks = 0; } } } if (m_tap) { // in tap mode: we send always a negative pulse immediately after a positive pulse if (!result) { // the sensor did not trigger on this frame if (m_prev_state) { // but it triggered on previous frame => send a negative pulse ActivateControllers(logicmgr); result = true; } // in any case, absence of trigger means sensor off m_state = false; } } if (!result && m_level) { // This level sensor is connected to at least one controller that was just made // active but it did not generate an event yet, do it now to those controllers only for (vector<SCA_IController*>::const_iterator c= m_linkedcontrollers.begin(); c!=m_linkedcontrollers.end();++c) { SCA_IController* contr = *c; if (contr->IsJustActivated()) logicmgr->AddTriggeredController(contr, this); } } } }
void Control::Initialise(const std::string& _layoutName) { OnInitialise(nullptr, nullptr, _layoutName); ActivateControllers(); }