| 1362 | } |
| 1363 | |
| 1364 | sp<Equipment> Agent::getEquipmentAt(const Vec2<int> &position) const |
| 1365 | { |
| 1366 | Vec2<int> slotPosition = {0, 0}; |
| 1367 | for (auto &slot : type->equipment_layout->slots) |
| 1368 | { |
| 1369 | if (slot.bounds.within(position)) |
| 1370 | { |
| 1371 | slotPosition = slot.bounds.p0; |
| 1372 | } |
| 1373 | } |
| 1374 | // Find whatever equipped in the slot itself |
| 1375 | for (auto &eq : this->equipment) |
| 1376 | { |
| 1377 | if (eq->equippedPosition == slotPosition) |
| 1378 | { |
| 1379 | return eq; |
| 1380 | } |
| 1381 | } |
| 1382 | // Find whatever occupies this space |
| 1383 | for (auto &eq : this->equipment) |
| 1384 | { |
| 1385 | Rect<int> eqBounds{eq->equippedPosition, eq->equippedPosition + eq->type->equipscreen_size}; |
| 1386 | if (eqBounds.within(slotPosition)) |
| 1387 | { |
| 1388 | return eq; |
| 1389 | } |
| 1390 | } |
| 1391 | return nullptr; |
| 1392 | } |
| 1393 | |
| 1394 | const std::list<EquipmentLayoutSlot> &Agent::getSlots() const |
| 1395 | { |