MCPcopy Create free account
hub / github.com/cuberite/cuberite / PlaceStartingPiece

Method PlaceStartingPiece

src/Generating/PieceGenerator.cpp:327–362  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

325
326
327cPlacedPiece * cPieceGenerator::PlaceStartingPiece(int a_BlockX, int a_BlockY, int a_BlockZ, cFreeConnectors & a_OutConnectors)
328{
329 m_PiecePool.Reset();
330 int rnd = m_Noise.IntNoise3DInt(a_BlockX, a_BlockY, a_BlockZ) / 7;
331
332 // Choose a random one of the starting pieces:
333 cPieces StartingPieces = m_PiecePool.GetStartingPieces();
334 cPiece * StartingPiece = StartingPieces[rnd % StartingPieces.size()];
335 rnd = rnd >> 16;
336
337 // Choose a random supported rotation:
338 int Rotations[4] = {0};
339 int NumRotations = 1;
340 for (size_t i = 1; i < ARRAYCOUNT(Rotations); i++)
341 {
342 if (StartingPiece->CanRotateCCW(i))
343 {
344 Rotations[NumRotations] = i;
345 NumRotations += 1;
346 }
347 }
348 int Rotation = Rotations[rnd % NumRotations];
349
350 cPlacedPiece * res = new cPlacedPiece(NULL, *StartingPiece, Vector3i(a_BlockX, a_BlockY, a_BlockZ), Rotation);
351
352 // Place the piece's connectors into a_OutConnectors:
353 const cPiece::cConnectors & Conn = StartingPiece->GetConnectors();
354 for (cPiece::cConnectors::const_iterator itr = Conn.begin(), end = Conn.end(); itr != end; ++itr)
355 {
356 a_OutConnectors.push_back(
357 cFreeConnector(res, StartingPiece->RotateMoveConnector(*itr, Rotation, a_BlockX, a_BlockY, a_BlockZ))
358 );
359 }
360
361 return res;
362}
363
364
365

Callers

nothing calls this directly

Calls 10

cFreeConnectorClass · 0.85
IntNoise3DIntMethod · 0.80
sizeMethod · 0.80
beginMethod · 0.80
endMethod · 0.80
RotateMoveConnectorMethod · 0.80
ResetMethod · 0.45
GetStartingPiecesMethod · 0.45
CanRotateCCWMethod · 0.45
GetConnectorsMethod · 0.45

Tested by

no test coverage detected