1 /* 2 * Copyright (C) 2004 Ivo Danihelka (ivo@danihelka.net) 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 2 of the License, or 7 * (at your option) any later version. 8 */ 9 #include "ModelList.h" 10 11 #include "View.h" 12 #include "Landslip.h" 13 14 //----------------------------------------------------------------- 15 /** 16 * Create new wrapper. 17 * @param models wrapped models. 18 */ ModelList(const Cube::t_models * models)19ModelList::ModelList(const Cube::t_models *models) 20 { 21 m_models = models; 22 } 23 //----------------------------------------------------------------- 24 void drawOn(View * view) const25ModelList::drawOn(View *view) const 26 { 27 Cube::t_models::const_iterator end = m_models->end(); 28 for (Cube::t_models::const_iterator i = m_models->begin(); i != end; ++i) { 29 view->drawModel(*i); 30 } 31 } 32 //----------------------------------------------------------------- 33 /** 34 * Stone all models on fixed pad. 35 * @return true when new model was stoned 36 */ 37 bool stoneOn(Landslip * slip) const38ModelList::stoneOn(Landslip *slip) const 39 { 40 bool change = false; 41 Cube::t_models::const_iterator end = m_models->end(); 42 for (Cube::t_models::const_iterator i = m_models->begin(); i != end; ++i) { 43 if (slip->stoneModel(*i)) { 44 change = true; 45 } 46 } 47 return change; 48 } 49 //----------------------------------------------------------------- 50 /** 51 * Let all not stoned models to fall. 52 * @return true when something is falling 53 */ 54 bool fallOn(Landslip * slip) const55ModelList::fallOn(Landslip *slip) const 56 { 57 bool falling = false; 58 Cube::t_models::const_iterator end = m_models->end(); 59 for (Cube::t_models::const_iterator i = m_models->begin(); i != end; ++i) { 60 falling |= slip->fallModel(*i); 61 } 62 return falling; 63 } 64 65