| 1047 | } |
| 1048 | |
| 1049 | Vec2I Plant::baseDamagePosition(List<Vec2I> const& positions) const { |
| 1050 | starAssert(positions.size()); |
| 1051 | auto res = positions.at(0); |
| 1052 | |
| 1053 | for (auto const& piece : m_pieces) { |
| 1054 | if (piece.structuralSegment) { |
| 1055 | for (auto space : piece.spaces) { |
| 1056 | for (auto position : positions) { |
| 1057 | if (world()->geometry().equal(m_tilePosition + space, position)) { |
| 1058 | // if this space is a "better match" for the root of the plant |
| 1059 | if ((res[1] < position[1]) == m_ceiling) { |
| 1060 | res = position; |
| 1061 | } |
| 1062 | } |
| 1063 | } |
| 1064 | } |
| 1065 | } |
| 1066 | } |
| 1067 | |
| 1068 | return res; |
| 1069 | } |
| 1070 | |
| 1071 | bool Plant::damagable() const { |
| 1072 | if (m_stemDropConfig.type() != Json::Type::Object) |