MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / init

Method init

source/game/StarVehicle.cpp:183–211  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

181}
182
183void Vehicle::init(World* world, EntityId entityId, EntityMode mode) {
184 Entity::init(world, entityId, mode);
185 m_movementController.init(world);
186 m_movementController.setIgnorePhysicsEntities({entityId});
187 if (isMaster()) {
188 m_scriptComponent.addCallbacks("vehicle", makeVehicleCallbacks());
189 m_scriptComponent.addCallbacks(
190 "config", LuaBindings::makeConfigCallbacks(bind(&Vehicle::configValue, this, _1, _2)));
191 m_scriptComponent.addCallbacks("entity", LuaBindings::makeEntityCallbacks(this));
192 m_scriptComponent.addCallbacks("mcontroller", LuaBindings::makeMovementControllerCallbacks(&m_movementController));
193 m_scriptComponent.addCallbacks("animator", LuaBindings::makeNetworkedAnimatorCallbacks(&m_networkedAnimator));
194 m_scriptComponent.init(world);
195 } else {
196 m_slaveHeartbeatTimer.reset();
197 }
198
199 if (world->isClient()) {
200 m_scriptedAnimator.addCallbacks("animationConfig", LuaBindings::makeScriptedAnimatorCallbacks(&m_networkedAnimator,
201 [this](String const& name, Json const& defaultValue) -> Json {
202 return m_scriptedAnimationParameters.value(name, defaultValue);
203 }));
204 m_scriptedAnimator.addCallbacks("config", LuaBindings::makeConfigCallbacks([this](String const& name, Json const& def) {
205 return configValue(name, def);
206 }));
207 m_scriptedAnimator.addCallbacks("entity", LuaBindings::makeEntityCallbacks(this));
208
209 m_scriptedAnimator.init(world);
210 }
211}
212
213void Vehicle::uninit() {
214 m_scriptComponent.uninit();

Callers

nothing calls this directly

Calls 6

initFunction · 0.85
isClientMethod · 0.80
addCallbacksMethod · 0.45
resetMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected