| 46 | } |
| 47 | |
| 48 | void LiquidItem::fire(FireMode mode, bool shifting, bool edgeTriggered) { |
| 49 | if (!initialized() || !ready() || !owner()->inToolRange()) |
| 50 | return; |
| 51 | |
| 52 | PlaceLiquid placeLiquid{liquidId(), liquidQuantity()}; |
| 53 | TileModificationList modifications; |
| 54 | |
| 55 | float radius; |
| 56 | |
| 57 | if (!shifting) |
| 58 | radius = m_blockRadius; |
| 59 | else |
| 60 | radius = m_altBlockRadius; |
| 61 | |
| 62 | if (!multiplaceEnabled()) |
| 63 | radius = 1; |
| 64 | |
| 65 | for (auto pos : tileAreaBrush(radius, owner()->aimPosition(), true)) { |
| 66 | if (canPlaceAtTile(pos)) |
| 67 | modifications.append({pos, placeLiquid}); |
| 68 | } |
| 69 | |
| 70 | // Make sure not to make any more modifications than we have consumables. |
| 71 | if (modifications.size() > count()) |
| 72 | modifications.resize(count()); |
| 73 | size_t failed = world()->applyTileModifications(modifications, false).size(); |
| 74 | if (failed < modifications.size()) { |
| 75 | FireableItem::fire(mode, shifting, edgeTriggered); |
| 76 | consume(modifications.size() - failed); |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | LiquidId LiquidItem::liquidId() const { |
| 81 | return m_liquidId; |
nothing calls this directly
no test coverage detected