MCPcopy Create free account
hub / github.com/REGoth-project/REGoth / createDefaultPlayer

Method createDefaultPlayer

src/logic/ScriptEngine.cpp:511–535  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

509}
510
511Handle::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
537void ScriptEngine::onNPCRemoved(Daedalus::GameState::NpcHandle npc)
538{

Callers 1

startNewGameMethod · 0.80

Calls 4

findStartPointsMethod · 0.80
setDirectionMethod · 0.80
getDirectionMethod · 0.80
emptyMethod · 0.45

Tested by

no test coverage detected