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

Method initNPCFromScript

src/components/VobClasses.cpp:19–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17#include <logic/ScriptEngine.h>
18
19Handle::EntityHandle VobTypes::initNPCFromScript(World::WorldInstance& world, Daedalus::GameState::NpcHandle scriptInstance)
20{
21 Handle::EntityHandle e = Vob::constructVob(world);
22
23 Daedalus::GEngineClasses::C_Npc& npc = world.getScriptEngine().getGameState().getNpc(scriptInstance);
24
25 //LogInfo() << "Instance: " << scriptInstance.index;
26 //LogInfo() << "Creating vob for: " << npc.name[0];
27
28 // Link the script instance to our entity
29 ScriptInstanceUserData* userData = new ScriptInstanceUserData;
30 userData->vobEntity = e;
31 userData->world = world.getMyHandle();
32
33 world.getScriptEngine().getGameState().getNpc(scriptInstance).userPtr = userData;
34
35 Components::PositionComponent& pos = world.getEntity<Components::PositionComponent>(e);
36 pos.m_DrawDistanceFactor = 0.25f; // TODO: Config entry for this...
37
38 // Setup the playercontroller
39 Components::LogicComponent& logic = world.getEntity<Components::LogicComponent>(e);
40 logic.m_pLogicController = new Logic::PlayerController(world, e, scriptInstance);
41
42 // Assign a default visual
43 Vob::VobInformation vob = Vob::asVob(world, e);
44 Vob::setVisual(vob, "HUM_BODY_NAKED0.MDM");
45
46 // FIXME: Debug, remove this
47 Components::BBoxComponent& bbox = world.getEntity<Components::BBoxComponent>(e);
48 bbox.m_DebugColor = 0; //0xFFFFFFFF;
49 bbox.m_BBox3D.min = Math::float3(-1, -1, -1);
50 bbox.m_BBox3D.max = Math::float3(1, 1, 1);
51
52 return e;
53}
54
55Handle::EntityHandle VobTypes::initItemFromScript(World::WorldInstance& world, size_t scriptInstance)
56{

Callers

nothing calls this directly

Calls 1

getMyHandleMethod · 0.80

Tested by

no test coverage detected