bool WorldMap::columnHasFourNeighbors(int columnIndex) { v3di_t columnPosition = mColumns[columnIndex].mWorldPosition; columnPosition.y = 0; v3di_t neighborPosition; // LEFT neighborPosition = v3di_add(columnPosition, v3di_v(-WORLD_CHUNK_SIDE, 0, 0)); if (pickColumn(neighborPosition) == -1) { return false; } // RIGHT neighborPosition = v3di_add(columnPosition, v3di_v(WORLD_CHUNK_SIDE, 0, 0)); if (pickColumn(neighborPosition) == -1) { return false; } // BACK neighborPosition = v3di_add(columnPosition, v3di_v(0, 0, -WORLD_CHUNK_SIDE)); if (pickColumn(neighborPosition) == -1) { return false; } // FRONT neighborPosition = v3di_add(columnPosition, v3di_v(0, 0, WORLD_CHUNK_SIDE)); if (pickColumn(neighborPosition) == -1) { return false; } return true; }
void WorldMap::clearBlock(const v3di_t& position) { int column = pickColumn(position); if (column == -1) { mOverdrawManager.setBlock(position, BLOCK_TYPE_AIR); return; } // just get out if there's no change block_t *block = mColumns[column].getBlockAtWorldPosition (position); if (block != NULL && block->type == BLOCK_TYPE_AIR) { return; } // FIXME: this will (re)generate rocky outcroppings...no good // but we need to do it to drill into the ground generateChunkContaining(mColumns[column], position); mColumns[column].clearBlockAtWorldPosition(position); // make note of that change... addToChangedList(column); // check if some plant is on top // FIXME: beware! this is recursive v3di_t neighborPosition = position; neighborPosition.y += 1; if (gBlockData.get(mColumns[column].getBlockType(neighborPosition))->solidityType == BLOCK_SOLIDITY_TYPE_PLANT) { clearBlock(neighborPosition); } // now deal with the boundary issues for (int i = 0; i < NUM_BLOCK_SIDES; i++) { neighborPosition = v3di_add(position, gBlockNeighborAddLookup[i]); int neighborColumn = pickColumn(neighborPosition); if (neighborColumn >= 0) { generateChunkContaining(mColumns[neighborColumn], neighborPosition); mColumns[neighborColumn].mNeedShadowVolume = true; addToChangedList(neighborColumn); } } }
int WorldMap::getBlockType(const v3di_t& position) const { int column = pickColumn(position); if (column == -1) { return BLOCK_TYPE_INVALID; } return mColumns[column].getBlockType(position); }
bool WorldMap::isSolidBlock(const v3di_t& position) const { int column = pickColumn(position); if (column == -1) { return false; } return mColumns[column].isSolidBlockAtWorldPosition(position); }
void WorldMap::setUniqueLighting( const v3di_t& position, BYTE level ) { int column = pickColumn( position ); if (column == -1) { return; } mColumns[column].setUniqueLighting(position, level); }
BYTE WorldMap::getUniqueLighting(const v3di_t& position) const { int column = pickColumn( position ); if (column == -1) { return LIGHT_LEVEL_INVALID; } return mColumns[column].getUniqueLighting( position ); }
block_t* WorldMap::getBlock(const v3di_t& position) const { int column = pickColumn(position); if (column == -1) { return NULL; } return mColumns[column].getBlockAtWorldPosition(position); }
void WorldMap::setBlockVisibility(const v3di_t& position, BYTE visibility) { int column = pickColumn(position); if (column == -1) { return; } mColumns[column].setBlockVisibility(position, visibility); }
void WorldMap::setBlockType(const v3di_t& position, BYTE type) { int column = pickColumn(position); if (column == -1) { mOverdrawManager.setBlock(position, type); return; } if (mColumns[column].getBlockType(position) != type) { addToChangedList(column); } mColumns[column].setBlockType(position, type); }
int WorldMap::setBlock(const v3di_t& position, const block_t& block) { int column = pickColumn(position); if (column == -1) { mOverdrawManager.setBlock(position, block.type); return -1; } // if we're actually changing to a different block type, make note if (mColumns[column].getBlockType(position) != block.type) { addToChangedList(column); } mColumns[column].setBlockAtWorldPosition(position, block); return 0; }
bool GUIListGadget::update() { updateScrollBars(&HorzScroll_, &VertScroll_); if (hasFocus() && GlbGUIMngr->MouseWheel_) VertScroll_.scroll(-GlbGUIMngr->MouseWheel_ * 30); if (!checkDefaultUpdate()) return false; if (isEnabled_ && mouseOver(Rect_) && !foreignUsage()) { if (mouseLeft()) { focus(); GUIListColumn* Column; bool isEdgePick; if (pickColumn(Column, isEdgePick)) { FocusedColumn_ = Column; if (isEdgePick) useFocus(USAGE_RESIZE_COLUMN); else ; // !TODO! } } } dim::point2di Pos(getItemsStartPos()); for (std::list<GUIListItem*>::iterator it = ItemList_.begin(); it != ItemList_.end(); ++it) updateItem(*it, Pos); if (usage(USAGE_RESIZE_COLUMN) && FocusedColumn_) FocusedColumn_->setColumnSize(GlbGUIMngr->CursorPos_.X - FocusedColumnPosHorz_); updateChildren(); return true; }