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

Method update

source/game/StarProjectile.cpp:258–356  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

256}
257
258void Projectile::update(float dt, uint64_t) {
259 m_movementController->setTimestep(dt);
260
261 if (isMaster()) {
262 m_timeToLive -= dt;
263 if (m_timeToLive < 0)
264 m_timeToLive = 0;
265
266 m_effectEmitter->addEffectSources("normal", m_config->emitters);
267
268 if (m_referenceVelocity)
269 m_movementController->setVelocity(m_movementController->velocity() - *m_referenceVelocity);
270
271 m_scriptComponent.update(m_scriptComponent.updateDt(dt));
272 m_movementController->accelerate(m_movementController->velocity().normalized() * m_acceleration);
273
274 if (m_referenceVelocity)
275 m_movementController->setVelocity(m_movementController->velocity() + *m_referenceVelocity);
276
277 m_movementController->tickMaster(dt);
278 m_travelLine.min() = m_travelLine.max();
279 m_travelLine.max() = m_movementController->position();
280
281 tickShared(dt);
282
283 if (m_trackSourceEntity) {
284 if (auto sourceEntity = world()->entity(m_sourceEntity)) {
285 Vec2F newEntityPosition = sourceEntity->position();
286 m_movementController->translate(newEntityPosition - m_lastEntityPosition);
287 m_lastEntityPosition = newEntityPosition;
288 } else {
289 m_trackSourceEntity = false;
290 }
291 }
292
293 if (m_movementController->atWorldLimit())
294 m_timeToLive = 0.0f;
295
296 if ((m_movementController->isColliding() || m_movementController->stickingDirection()) && !m_movementController->isNullColliding()) {
297 if (!m_wasColliding)
298 m_collisionEvent.trigger();
299 m_wasColliding = true;
300 } else {
301 m_wasColliding = false;
302 }
303
304 if (m_movementController->isColliding()) {
305 if (m_movementController->isNullColliding()) {
306 // Don't trigger collision action, just silently die if we collide with a
307 // null block.
308 m_timeToLive = 0.0f;
309 } else if (m_bounces != 0) {
310 m_scriptComponent.invoke("bounce");
311 if (m_bounces > 0)
312 --m_bounces;
313 } else if (m_falldown && !(m_movementController->onGround() || m_movementController->isCollisionStuck() || m_movementController->stickingDirection())) {
314 // Wait til this projectile actually hits the ground before dying
315

Callers

nothing calls this directly

Calls 15

setTimestepMethod · 0.80
addEffectSourcesMethod · 0.80
updateDtMethod · 0.80
accelerateMethod · 0.80
normalizedMethod · 0.80
atWorldLimitMethod · 0.80
stickingDirectionMethod · 0.80
isNullCollidingMethod · 0.80
isCollisionStuckMethod · 0.80
isClientMethod · 0.80
toRgbaMethod · 0.80
setVelocityMethod · 0.45

Tested by

no test coverage detected