| 1381 | } |
| 1382 | |
| 1383 | bool PathController::validateEdge(ActorMovementController& movementController, PlatformerAStar::Edge const& edge) { |
| 1384 | using namespace PlatformerAStar; |
| 1385 | |
| 1386 | auto const groundCollision = CollisionSet{ CollisionKind::Null, CollisionKind::Block, CollisionKind::Slippery, CollisionKind::Platform }; |
| 1387 | auto const solidCollision = CollisionSet{ CollisionKind::Null, CollisionKind::Block, CollisionKind::Slippery }; |
| 1388 | |
| 1389 | auto const openDoors = [&](RectF const& bounds) { |
| 1390 | auto objects = m_world->entityQuery(bounds, entityTypeFilter<Object>()); |
| 1391 | auto opened = objects.filtered([&](EntityPtr const& e) -> bool { |
| 1392 | if (auto object = as<Object>(e)) { |
| 1393 | if (object->isMaster()) { |
| 1394 | auto arg = m_world->luaRoot()->luaEngine().createString("closedDoor"); |
| 1395 | auto res = object->callScript("hasCapability", LuaVariadic<LuaValue>{arg}); |
| 1396 | if (res && res->is<LuaBoolean>() && res->get<LuaBoolean>()){ |
| 1397 | m_world->sendEntityMessage(e->entityId(), "openDoor"); |
| 1398 | return true; |
| 1399 | } |
| 1400 | } |
| 1401 | } |
| 1402 | return false; |
| 1403 | }); |
| 1404 | return !opened.empty(); |
| 1405 | }; |
| 1406 | |
| 1407 | auto poly = movementController.collisionPoly(); |
| 1408 | poly.translate(edge.target.position); |
| 1409 | if (m_world->polyCollision(poly) || movingCollision(movementController, poly)) { |
| 1410 | auto bounds = RectI::integral(poly.boundBox()); |
| 1411 | // for (auto line : bounds.edges()) { |
| 1412 | // SpatialLogger::logLine("world", Line2F(line), Color::Magenta.toRgba()); |
| 1413 | // } |
| 1414 | if (m_world->rectTileCollision(bounds) && !m_world->rectTileCollision(bounds, solidCollision)) { |
| 1415 | if (!openDoors(poly.boundBox())) { |
| 1416 | // SpatialLogger::logPoly("world", poly, Color::Yellow.toRgba()); |
| 1417 | return false; |
| 1418 | } |
| 1419 | } else { |
| 1420 | // SpatialLogger::logPoly("world", poly, Color::Red.toRgba()); |
| 1421 | return false; |
| 1422 | } |
| 1423 | } |
| 1424 | //SpatialLogger::logPoly("world", poly, Color::Blue.toRgba()); |
| 1425 | |
| 1426 | auto inLiquid = [&](Vec2F const& position) -> bool { |
| 1427 | auto bounds = movementController.localBoundBox().translated(position); |
| 1428 | auto liquidLevel = m_world->liquidLevel(bounds); |
| 1429 | if (liquidLevel.level >= movementController.baseParameters().minimumLiquidPercentage.value(1.0)) { |
| 1430 | // for (auto line : bounds.edges()) { |
| 1431 | // SpatialLogger::logLine("world", line, Color::Blue.toRgba()); |
| 1432 | // } |
| 1433 | return true; |
| 1434 | } else { |
| 1435 | // for (auto line : bounds.edges()) { |
| 1436 | // SpatialLogger::logLine("world", line, Color::Red.toRgba()); |
| 1437 | // } |
| 1438 | return false; |
| 1439 | } |
| 1440 | }; |
nothing calls this directly
no test coverage detected