void Maze::scanForEntrances() { for (uint32_t i = 1; i <= getFloorCount(); i++) { Map* curMap = getFloor(i); if (i == 1) { // In this case, we want up stairs. bool foundEntrance = false; bool multipleWarned = false; for (int32_t y = 0; y < curMap->getHeight(); y++) { for (int32_t x = 0; x < curMap->getWidth(); x++) { Activatable* act = curMap->getActivatable(x, y); if (act) { Stairs* stairs = act->asStairs(); if (stairs && stairs->getDirection() == StairDirection::UP) { Facing dstFacing = stairs->getDestinationFacing(); // Adjust the position so that when the player enters, they're // facing the right direction, and in the right position. int32_t dstX = x; int32_t dstY = y; switch(dstFacing) { case Facing::NORTH: dstY--; break; case Facing::EAST: dstX++; break; case Facing::SOUTH: dstY++; break; case Facing::WEST: dstX--; break; } if (foundEntrance && !multipleWarned) { writeToLog(MessageLevel::WARNING, "Maze::scanForEntrances(): Multiple up stairs found on floor of maze."); multipleWarned = true; } else { if (!curMap->canEntityEnter(dstX, dstY)) { writeToLog(MessageLevel::WARNING, "Maze::scanForEntrances(): Entrance as specified would place player in solid wall."); } else { mazeEntrance = Entrance(i, dstX, dstY, dstFacing); foundEntrance = true; } } } } } } } else { // Otherwise, we're looking for geomagnetic poles. This is currently // not implemented. Mostly because geopoles don't exist. } } }
void VerticalMirrorAnimation::displayLevelAndVerticalSeparator() const & { const auto& context = getContext(); getLevel()->display(getFloor()); context.getSfmlWindow().draw( context.getShapesManager().getVerticalSeparator() ); }
void SludgeFloorMaker::button1Release(int local_pointx, int local_pointy) { int xx, yy; awaitButton1Release = FALSE; selx2 = xx = (local_pointx+x)*zmul; sely2 = yy = (local_pointy-y)*zmul; lit = snapToClosest(&xx, &yy, getFloor()); litX = xx; litY = yy; if (lit && (xx != selx1 || yy != sely1)) { selx2 = xx; sely2 = yy; } selection = 0; switch (mode) { case 1: // Move vertices if (moveVertices(selx1, sely1, selx2, sely2, getFloor())) { setFileChanged(); } else { errorBox("Can't move vertex", "Sorry - that vertex is already contained in one or more of the polygons you're changing."); return; } break; case 4: // Split lines splitLine(selx1, sely1, selx2, sely2, getFloor()); setFileChanged(); break; case 5: // Split segments struct polyList * firstPoly = getFloor(); splitPoly(selx1, sely1, selx2, sely2, &firstPoly); setFloor(firstPoly); setFileChanged(); break; } }
Vector FloorLocator::getSurfaceNormal_w ( void ) const { Floor const * floor = getFloor(); if(floor) { return floor->getTransform_o2w().rotate_l2p(getSurfaceNormal_l()); } else { return getSurfaceNormal_l(); } }
std::list<HumanPtr> Elevator::removeArrivedPeople() { std::list<HumanPtr>::iterator iter = containedPeople_.begin(); std::list<HumanPtr> quit; while (iter != containedPeople_.end()) { if ((*iter)->destinationFloor() == getFloor()) { quit.push_back(*iter); iter = containedPeople_.erase(iter); } else ++iter; } return quit; }
void FloorLocator::reattach ( void ) { Floor const * floor = getFloor(); if(floor) { FloorLocator temp; if(floor->dropTest(getPosition_p(),2.0f,temp)) { temp.setRadius(getRadius()); *this = temp; } } }
void SludgeFloorMaker::button1Motion(int local_pointx, int local_pointy) { int xx, yy; selx2 = xx = (local_pointx+x)*zmul; sely2 = yy = (local_pointy-y)*zmul; lit = snapToClosest(&xx, &yy, getFloor()); litX = xx; litY = yy; if (lit && (xx != selx1 || yy != sely1)) { selx2 = xx; sely2 = yy; } }
void VerticalMirrorAnimation::updateRightSideTransparency() const & { const unsigned short firstIndex = dimensions::CELLS_PER_FLOOR * getFloor(); const unsigned short lastIndex = firstIndex + dimensions::CELLS_PER_FLOOR; for( unsigned short index = firstIndex; index < lastIndex; index += 1 ) { if (index % dimensions::CELLS_PER_LINE >= CELLS_PER_LINE_PER_SIDE) { applyTransparencyOnOneCell(index); } } }
void SludgeFloorMaker::drawRect() { glClearColor(0, 0, 0, 0); glClear(GL_COLOR_BUFFER_BIT); glColor3f(1.0f, 1.00f, 1.00f); pasteSprite(&backdrop.sprites[0], &backdrop.myPalette, FALSE); glDisable(GL_TEXTURE_2D); glColor3f(1.0f, 0.35f, 0.35f); glBegin(GL_LINES); { glVertex3f( 0.0, 0.0, 0.0); glVertex3f( 1000.0, 0.0, 0.0); glVertex3f( 0.0, 0.0, 0.0); glVertex3f( 0.0, 1000.0, 0.0); } glEnd(); if (lit) { glColor3f(1.0f, 0.00f, 1.00f); glBegin(GL_QUADS); { glVertex3i( litX-8, litY-8, 0); glVertex3i( litX+8, litY-8, 0); glVertex3i( litX+8, litY+8, 0); glVertex3i( litX-8, litY+8, 0); } glEnd(); } drawFloor(getFloor(), r, g, b); if (selection == 1) { glColor3f(1.0f, 0.00f, 1.00f); glBegin(GL_LINES); { glVertex3i(selx1, sely1, 0); glVertex3i(selx2, sely2, 0); } glEnd(); } }
std::vector<Person> Elevator::removeArrivedPeople() { std::vector<Person> stay; // list of people who stay in elevator std::vector<Person> arrived; // list of people who arrived at their destination // check for each person ... for(size_t i = 0; i < containedPeople.size(); ++i) { // whether it arrived if(containedPeople.at(i).getDestinationFloor() == getFloor()) { arrived.push_back(containedPeople.at(i)); } else { stay.push_back(containedPeople.at(i)); } } containedPeople = stay; std::cout << "Removing " << arrived.size() << " arrived people" << std::endl; return arrived; }
CellProperty * FloorLocator::getCell ( void ) { Floor const * floor = getFloor(); if (floor) { return const_cast<CellProperty *>(floor->getCell()); } else { if(getFloorMesh()) { return NULL; } else { return CellProperty::getWorldCellProperty(); } } }
void VerticalMirrorAnimation::invertSides() const & { const unsigned short firstIndex = getFloor() * dimensions::CELLS_PER_FLOOR; constexpr unsigned short LAST_FLOOR_CELL_INDEX {255}; const unsigned short lastIndex = firstIndex + LAST_FLOOR_CELL_INDEX; const auto& level = getLevel(); const unsigned short previousPlayerCell = level->getPlayerCellIndex(); unsigned short line {0}; for ( unsigned short index = firstIndex; index < lastIndex; index += 1 ) { if (index % dimensions::CELLS_PER_LINE >= CELLS_PER_LINE_PER_SIDE) { continue; } const char type = level->getCells()[index]->getType(); const bool visible = level->getCells()[index]->isVisible(); const unsigned short invertedIndex = findInvertedIndex( line, index ); level->getCells()[index]->setType( level->getCells()[invertedIndex]->getType() ); showOrHideCell( index, level->getCells()[invertedIndex]->isVisible() ); level->getCells()[invertedIndex]->setType(type); showOrHideCell( invertedIndex, visible ); if (previousPlayerCell == index) { setUpdatedPlayerIndex( findInvertedIndex( line, index ) ); } else if ( previousPlayerCell == findInvertedIndex( line, index ) ) { setUpdatedPlayerIndex(index); } constexpr unsigned short CELLS_PER_LINE_OFFSET {7}; if ( index and (index - CELLS_PER_LINE_OFFSET) % CELLS_PER_LINE_PER_SIDE == 0 ) { line += 1; } } }
bool FloorLocator::isAttachedTo( Floor const * pFloor ) const { return getFloor() == pFloor; }
void SludgeFloorMaker::button1Press(int local_pointx, int local_pointy) { gboolean keepOn = TRUE; int i, xx, yy; mouseLoc1x = local_pointx; mouseLoc1y = local_pointy; xx = (local_pointx+x)*zmul; yy = (local_pointy-y)*zmul; switch (mode) { case 0: // Define floor border snapToClosest(&xx, &yy, getFloor()); while (keepOn) { keepOn = FALSE; i = addVertex(xx, yy, getFloor()); switch (i) { case 1: setFileChanged(); return; case 0: errorBox("Can't add vertex", "Out of memory."); return; case 3: errorBox("Can't add vertex", "That vertex is already used in this polygon, but isn't the start point."); return; case 2: if ( askAQuestion("Can't add vertex", "Can't add another vertex as the floor is already complete... do you want to start a NEW polygon at this point?") ) { setFloor( addPoly(getFloor()) ); keepOn = TRUE; setFileChanged(); } else { return; } break; } } break; case 1: // Move vertices case 4: // Split lines case 5: // Split segments if (! snapToClosest(&xx, &yy, getFloor())) return; selx1 = xx; sely1 = yy; selection = 1; awaitButton1Release = TRUE; break; case 2: // Remove vertices if (! snapToClosest(&xx, &yy, getFloor())) return; struct polyList * firstPoly = getFloor(); killVertex(xx, yy, &firstPoly); setFloor(firstPoly); setFileChanged(); break; } lit = snapToClosest(&xx, &yy, getFloor()); litX = xx; litY = yy; }