| 60 | |
| 61 | |
| 62 | void cDropSpenserEntity::DropSpense(cChunk & a_Chunk) |
| 63 | { |
| 64 | // Pick one of the occupied slots: |
| 65 | int OccupiedSlots[9]; |
| 66 | int SlotsCnt = 0; |
| 67 | for (int i = m_Contents.GetNumSlots() - 1; i >= 0; i--) |
| 68 | { |
| 69 | if (!m_Contents.GetSlot(i).IsEmpty()) |
| 70 | { |
| 71 | OccupiedSlots[SlotsCnt] = i; |
| 72 | SlotsCnt++; |
| 73 | } |
| 74 | } // for i - m_Contents[] |
| 75 | |
| 76 | if (SlotsCnt == 0) |
| 77 | { |
| 78 | // Nothing in the dropspenser, play the click sound |
| 79 | m_World->BroadcastSoundEffect("random.click", m_PosX * 8, m_PosY * 8, m_PosZ * 8, 1.0f, 1.2f); |
| 80 | return; |
| 81 | } |
| 82 | |
| 83 | int RandomSlot = m_World->GetTickRandomNumber(SlotsCnt - 1); |
| 84 | |
| 85 | // DropSpense the item, using the specialized behavior in the subclasses: |
| 86 | DropSpenseFromSlot(a_Chunk, OccupiedSlots[RandomSlot]); |
| 87 | |
| 88 | // Broadcast a smoke and click effects: |
| 89 | NIBBLETYPE Meta = a_Chunk.GetMeta(m_RelX, m_PosY, m_RelZ); |
| 90 | int SmokeDir = 0; |
| 91 | switch (Meta) |
| 92 | { |
| 93 | case E_META_DROPSPENSER_FACING_YP: SmokeDir = 4; break; // YP & YM don't have associated smoke dirs, just do 4 (centre of block) |
| 94 | case E_META_DROPSPENSER_FACING_YM: SmokeDir = 4; break; |
| 95 | case E_META_DROPSPENSER_FACING_XM: SmokeDir = 3; break; |
| 96 | case E_META_DROPSPENSER_FACING_XP: SmokeDir = 5; break; |
| 97 | case E_META_DROPSPENSER_FACING_ZM: SmokeDir = 1; break; |
| 98 | case E_META_DROPSPENSER_FACING_ZP: SmokeDir = 7; break; |
| 99 | } |
| 100 | m_World->BroadcastSoundParticleEffect(2000, m_PosX, m_PosY, m_PosZ, SmokeDir); |
| 101 | m_World->BroadcastSoundEffect("random.click", m_PosX * 8, m_PosY * 8, m_PosZ * 8, 1.0f, 1.0f); |
| 102 | } |
| 103 | |
| 104 | |
| 105 |
nothing calls this directly
no test coverage detected