void Terrain::DestroyBlock(PositionedBlock *block) { Vector3 chunk, pos; chunk.X = floor(block->pos.X / ChunkSize); chunk.Y = floor(block->pos.Y / ChunkSize); chunk.Z = floor(block->pos.Z / ChunkSize); pos = block->pos - (chunk * ChunkSize); PlaceBlock(0, chunk, pos); }
//------------------------------------------------------------------------------ // Method: InsertConstBlock // // Description: Inserts a constant block into the current Extend model. // // Parameters: // constValue numeric value of the constant // xPos x position to place block at - if there is a neighbor // specified, this position is relative to the neighbor // yPos y position to place block at - if there is a neighbor // specified, this position is relative to the neighbor // neigh neighbor block, -1 if no neighbor // side how the block is placed relative to neighbor // 0 - left // 1 - top // 2 - right // 3 - bottom // blockNum will contain the // // Return: // true no errors occured // false error occured // //------------------------------------------------------------------------------ bool ExtendBridge::InsertConstBlock(double constValue, int xPos, int yPos, int neigh, int side, int &blockNum) { bool result = true; // add constant block result = PlaceBlock("Constant", GENERIC_LIB, xPos, yPos, neigh, side, blockNum); if (!result) { return(false); } // set constant value & return result result = PokeDouble("conValue", blockNum, constValue); return(result); }
void Terrain::PlaceAboveTarget(Player *player) { PositionedBlock *block = CheckAim(player); if (!block) return; Vector3 chunk, pos; chunk.X = floor(block->pos.X / ChunkSize); chunk.Y = floor(block->pos.Y / ChunkSize); chunk.Z = floor((block->pos.Z + 1) / ChunkSize); pos = block->pos - (chunk * ChunkSize) + Vector3(0, 0, 1); PlaceBlock(3, chunk, pos); }