| 20 | |
| 21 | |
| 22 | virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_Meta) override |
| 23 | { |
| 24 | cFastRandom rand; |
| 25 | |
| 26 | if (a_Meta == 0x7) |
| 27 | { |
| 28 | // Is fully grown, drop the entire produce: |
| 29 | switch (m_BlockType) |
| 30 | { |
| 31 | case E_BLOCK_CROPS: |
| 32 | { |
| 33 | a_Pickups.push_back(cItem(E_ITEM_WHEAT, 1, 0)); |
| 34 | a_Pickups.push_back(cItem(E_ITEM_SEEDS, (char)(1 + (rand.NextInt(3) + rand.NextInt(3)) / 2), 0)); // [1 .. 3] with high preference of 2 |
| 35 | break; |
| 36 | } |
| 37 | case E_BLOCK_CARROTS: |
| 38 | { |
| 39 | a_Pickups.push_back(cItem(E_ITEM_CARROT, (char)(1 + (rand.NextInt(3) + rand.NextInt(3)) / 2), 0)); // [1 .. 3] with high preference of 2 |
| 40 | break; |
| 41 | } |
| 42 | case E_BLOCK_POTATOES: |
| 43 | { |
| 44 | a_Pickups.push_back(cItem(E_ITEM_POTATO, (char)(1 + (rand.NextInt(3) + rand.NextInt(3)) / 2), 0)); // [1 .. 3] with high preference of 2 |
| 45 | if (rand.NextInt(21) == 0) |
| 46 | { |
| 47 | // With a 5% chance, drop a poisonous potato as well |
| 48 | a_Pickups.push_back(cItem(E_ITEM_POISONOUS_POTATO, 1, 0)); |
| 49 | } |
| 50 | break; |
| 51 | } |
| 52 | default: |
| 53 | { |
| 54 | ASSERT(!"Unhandled block type"); |
| 55 | break; |
| 56 | } |
| 57 | } // switch (m_BlockType) |
| 58 | } |
| 59 | else |
| 60 | { |
| 61 | // Drop 1 item of whatever is growing |
| 62 | switch (m_BlockType) |
| 63 | { |
| 64 | case E_BLOCK_CROPS: a_Pickups.push_back(cItem(E_ITEM_SEEDS, 1, 0)); break; |
| 65 | case E_BLOCK_CARROTS: a_Pickups.push_back(cItem(E_ITEM_CARROT, 1, 0)); break; |
| 66 | case E_BLOCK_POTATOES: a_Pickups.push_back(cItem(E_ITEM_POTATO, 1, 0)); break; |
| 67 | default: |
| 68 | { |
| 69 | ASSERT(!"Unhandled block type"); |
| 70 | break; |
| 71 | } |
| 72 | } |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | |
| 77 | virtual void OnUpdate(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_PluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override |