| 509 | } |
| 510 | |
| 511 | Handle::EntityHandle ScriptEngine::createDefaultPlayer(const std::string& symbolname) |
| 512 | { |
| 513 | LogInfo() << "Creating default player"; |
| 514 | if (!hasSymbol(symbolname)) |
| 515 | { |
| 516 | LogError() << "Error: could not start as NPC with name: " + symbolname; |
| 517 | return Handle::EntityHandle::makeInvalidHandle(); |
| 518 | } |
| 519 | |
| 520 | std::vector<size_t> startpoints = m_World.findStartPoints(); |
| 521 | |
| 522 | if (!startpoints.empty()) |
| 523 | { |
| 524 | std::string startpoint = m_World.getWaynet().waypoints[startpoints[0]].name; |
| 525 | |
| 526 | LogInfo() << "Inserting player of class '" + symbolname + "' at startpoint '" << startpoint << "'"; |
| 527 | |
| 528 | auto entityHandle = VobTypes::Wld_InsertNpc(m_World, symbolname, startpoint); |
| 529 | // FIXME startpoints are inverted? |
| 530 | auto playerController = VobTypes::asNpcVob(m_World, entityHandle).playerController; |
| 531 | playerController->setDirection(-1 * playerController->getDirection()); |
| 532 | return entityHandle; |
| 533 | } |
| 534 | return Handle::EntityHandle::makeInvalidHandle(); |
| 535 | } |
| 536 | |
| 537 | void ScriptEngine::onNPCRemoved(Daedalus::GameState::NpcHandle npc) |
| 538 | { |
no test coverage detected