| 371 | } |
| 372 | |
| 373 | Maybe<Json> Vehicle::receiveMessage(ConnectionId connectionId, String const& message, JsonArray const& args) { |
| 374 | m_aliveMasterConnections[connectionId] = GameTimer(m_slaveControlTimeout); |
| 375 | if (message.equalsIgnoreCase("control_on")) { |
| 376 | auto& loungePosition = m_loungePositions.valueAt(args.at(0).toUInt()); |
| 377 | loungePosition.masterControlState[LoungeControlNames.getLeft(args.at(1).toString())].slavesHeld.add(connectionId); |
| 378 | return Json(); |
| 379 | } else if (message.equalsIgnoreCase("control_off")) { |
| 380 | auto& loungePosition = m_loungePositions.valueAt(args.at(0).toUInt()); |
| 381 | loungePosition.masterControlState[LoungeControlNames.getLeft(args.at(1).toString())].slavesHeld.remove(connectionId); |
| 382 | return Json(); |
| 383 | } else if (message.equalsIgnoreCase("control_all")) { |
| 384 | auto& loungePosition = m_loungePositions.valueAt(args.at(0).toUInt()); |
| 385 | Set<LoungeControl> allControlsHeld; |
| 386 | for (auto const& s : args.at(1).iterateArray()) |
| 387 | allControlsHeld.add(LoungeControlNames.getLeft(s.toString())); |
| 388 | for (auto& p : loungePosition.masterControlState) { |
| 389 | if (allControlsHeld.contains(p.first)) |
| 390 | p.second.slavesHeld.add(connectionId); |
| 391 | else |
| 392 | p.second.slavesHeld.remove(connectionId); |
| 393 | } |
| 394 | return Json(); |
| 395 | } else if (message.equalsIgnoreCase("aim")) { |
| 396 | auto& loungePosition = m_loungePositions.valueAt(args.at(0).toUInt()); |
| 397 | loungePosition.masterAimPosition = {args.at(1).toFloat(), args.at(2).toFloat()}; |
| 398 | return Json(); |
| 399 | } else { |
| 400 | return m_scriptComponent.handleMessage(message, connectionId == world()->connection(), args); |
| 401 | } |
| 402 | } |
| 403 | |
| 404 | RectF Vehicle::interactiveBoundBox() const { |
| 405 | return collisionArea(); |
nothing calls this directly
no test coverage detected