| 1496 | } |
| 1497 | |
| 1498 | Maybe<String> WorldEntityCallbacks::entityHandItem(World* world, EntityId entityId, String const& handName) { |
| 1499 | ToolHand toolHand; |
| 1500 | if (handName == "primary") { |
| 1501 | toolHand = ToolHand::Primary; |
| 1502 | } else if (handName == "alt") { |
| 1503 | toolHand = ToolHand::Alt; |
| 1504 | } else { |
| 1505 | throw StarException(strf("Unknown tool hand {}", handName)); |
| 1506 | } |
| 1507 | |
| 1508 | if (auto entity = world->get<ToolUserEntity>(entityId)) { |
| 1509 | if (auto item = entity->handItem(toolHand)) { |
| 1510 | return item->name(); |
| 1511 | } |
| 1512 | } |
| 1513 | |
| 1514 | return {}; |
| 1515 | } |
| 1516 | |
| 1517 | Json WorldEntityCallbacks::entityHandItemDescriptor(World* world, EntityId entityId, String const& handName) { |
| 1518 | ToolHand toolHand; |
nothing calls this directly
no test coverage detected