void nodeManager::implementReactions(ofPtr<clamourNode> n, ofPtr<clamourNode> tgt) { vector<reaction> r = n->getReactions(); vector<reaction>::iterator it = r.begin(); while(it != r.end()) { if(it->trig != "COLLIDE") { ++it; continue; } if(it->floatParams.find("DELAY_SECS") != it->floatParams.end()) { eventComm e; int delFrames = it->floatParams["DELAY_SECS"] * ofGetFrameRate(); e.execAt = ofGetFrameNum() + delFrames; if(it->intParams.find("ENV_INDEX") != it->intParams.end())e.eventIndex = it->intParams["ENV_INDEX"]; e.ownerIndex = tgt->getName(); e.r = *it; mFutureEvents.push_back(e); } else { //implement immediately implementReaction(*it, tgt); } ++it; } }
void zoneManager::implementReactions(ofPtr<zone> z, bool isOn) { vector<reaction> r = z->getReactions(); //TODO copy the reactions out and replace them at the end of this method // ptrs don't work here vector<reaction>::iterator it = r.begin(); while(it != r.end()) { if((it->trig == "ON" && !isOn) || (it->trig == "OFF" && isOn)) { ++it; continue; } bool isReverse = (it->trig == "ON_OFF" && !isOn); vector<ofPtr<zone> > zt; if(it->zTargets.size() == 0){ zt.push_back(z); }else{ for(int i = 0; i < it->zTargets.size(); i++) { if(mZones.find(it->zTargets[i]) != mZones.end())zt.push_back(mZones[it->zTargets[i]]); } } for(int i = 0; i < zt.size(); i++) { if(it->floatParams.find("DELAY_SECS") != it->floatParams.end()) { //ON_OFF events not available for these //very messy definitely needs reworking eventComm e; int delFrames = it->floatParams["DELAY_SECS"] * ofGetFrameRate(); e.execAt = ofGetFrameNum() + delFrames; if(it->intParams.find("ENV_INDEX") != it->intParams.end())e.eventIndex = it->intParams["ENV_INDEX"]; e.ownerIndex = zt[i]->getName(); e.r = *it; mFutureEvents.push_back(e); }else{ //implement immediately implementReaction(*it, zt[i], isReverse); } } ++it; } //z->setReactions(r); NOT CURRENTLY STORING DATA };