/// Gibt Dynamische Objekte, die von einem bestimmten Punkt aus laufen oder dort stehen sowie andere Objekte, /// die sich dort befinden, zurück void GameWorldBase::GetDynamicObjectsFrom(const MapCoord x, const MapCoord y,list<noBase*>& objects) const { // Auch über und unter dem Punkt gucken, da dort auch die Figuren hängen können! const unsigned short coords[6] = { x,y, GetXA(x,y,1),GetYA(x,y,1), GetXA(x,y,2),GetYA(x,y,2) }; for(unsigned i = 0;i<3;++i) { for(list<noBase*>::iterator it = GetFigures(coords[i*2],coords[i*2+1]).begin(); it.valid();++it) { // Ist es auch ein Figur und befindet sie sich an diesem Punkt? if((*it)->GetType() == NOP_FIGURE || (*it)->GetGOT() == GOT_ANIMAL || (*it)->GetGOT() == GOT_SHIP) { if(static_cast<noMovable*>(*it)->GetX() == x && static_cast<noMovable*>(*it)->GetY() == y) objects.push_back(*it); } else if(i == 0) // Den Rest nur bei den richtigen Koordinaten aufnehmen objects.push_back(*it); } } }
/// Return a ship at this position owned by the given player. Prefers ships that need instructions. noShip* GameWorldViewer::GetShip(const MapPoint pt, const unsigned char player) const { noShip* ship = NULL; for (unsigned i = 0; i < 7; ++i) { MapPoint pa; if (i == 6) { pa = pt; } else { pa = GetNeighbour(pt, i); } const std::list<noBase*>& figures = GetFigures(pa); for(std::list<noBase*>::const_iterator it = figures.begin(); it != figures.end(); ++it) { if((*it)->GetGOT() == GOT_SHIP) { noShip* tmp = static_cast<noShip*>(*it); if (tmp->GetPlayer() == player) { if ((tmp->GetPos() == pt) || (tmp->GetDestinationForCurrentMove() == pt)) { if (tmp->IsWaitingForExpeditionInstructions()) { return(tmp); } ship = tmp; } } } } } return(ship); }
void PathGeometry::Build () { PathFigureCollection *figures; PathFigure *figure; path = moon_path_renew (path, 0); if (!(figures = GetFigures ())) return; int figure_count = figures->GetCount (); for (int i = 0; i < figure_count; i++) { figure = figures->GetValueAt (i)->AsPathFigure (); if (!figure->IsBuilt ()) figure->Build (); moon_merge (path, figure->path); } }
void SceneObject::DumpGeometry(SceneObjectGeometry* _geometry) const { _geometry->figures.resize(EnumFigures()); for (unsigned int i = 0; i < EnumFigures(); i++) { _geometry->figures[i].depth = GetFigures()[i]->GetDepth(); _geometry->figures[i].z = GetFigures()[i]->GetZ(); _geometry->figures[i].friction = GetFigures()[i]->GetFriction(); _geometry->figures[i] .vertices.resize(GetFigures()[i]->EnumVertices()); for (unsigned int j = 0; j < GetFigures()[i]->EnumVertices(); j++) { _geometry->figures[i].vertices[j] = GetFigures()[i]->GetVertices()[j]; } } }