| 560 | |
| 561 | |
| 562 | void cChunk::Tick(float a_Dt) |
| 563 | { |
| 564 | BroadcastPendingBlockChanges(); |
| 565 | |
| 566 | // Set all blocks that have been queued for setting later: |
| 567 | ProcessQueuedSetBlocks(); |
| 568 | |
| 569 | CheckBlocks(); |
| 570 | |
| 571 | // Tick simulators: |
| 572 | m_World->GetSimulatorManager()->SimulateChunk(a_Dt, m_PosX, m_PosZ, this); |
| 573 | |
| 574 | TickBlocks(); |
| 575 | |
| 576 | // Tick all block entities in this chunk: |
| 577 | for (cBlockEntityList::iterator itr = m_BlockEntities.begin(); itr != m_BlockEntities.end(); ++itr) |
| 578 | { |
| 579 | m_IsDirty = (*itr)->Tick(a_Dt, *this) | m_IsDirty; |
| 580 | } |
| 581 | |
| 582 | // Tick all entities in this chunk (except mobs): |
| 583 | for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end(); ++itr) |
| 584 | { |
| 585 | // Mobs are tickes inside MobTick (as we don't have to tick them if they are far away from players) |
| 586 | if (!((*itr)->IsMob())) |
| 587 | { |
| 588 | (*itr)->Tick(a_Dt, *this); |
| 589 | } |
| 590 | } // for itr - m_Entitites[] |
| 591 | |
| 592 | // Remove all entities that were scheduled for removal: |
| 593 | for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end();) |
| 594 | { |
| 595 | if ((*itr)->IsDestroyed()) |
| 596 | { |
| 597 | LOGD("Destroying entity #%i (%s)", (*itr)->GetUniqueID(), (*itr)->GetClass()); |
| 598 | cEntity * ToDelete = *itr; |
| 599 | itr = m_Entities.erase(itr); |
| 600 | delete ToDelete; |
| 601 | continue; |
| 602 | } |
| 603 | itr++; |
| 604 | } // for itr - m_Entitites[] |
| 605 | |
| 606 | // If any entity moved out of the chunk, move it to the neighbor: |
| 607 | for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end();) |
| 608 | { |
| 609 | if ( |
| 610 | ((*itr)->GetChunkX() != m_PosX) || |
| 611 | ((*itr)->GetChunkZ() != m_PosZ) |
| 612 | ) |
| 613 | { |
| 614 | MoveEntityToNewChunk(*itr); |
| 615 | itr = m_Entities.erase(itr); |
| 616 | } |
| 617 | else |
| 618 | { |
| 619 | ++itr; |
nothing calls this directly
no test coverage detected