void Package::update (uint32_t deltaTime) { CollectableEntity::update(deltaTime); if (_addRopeJointTo) { addRopeJoint(_addRopeJointTo); _addRopeJointTo = nullptr; } if ((_arrived || _delivered || isDestroyed()) && _ropeJoint) { removeRopeJoint(); } if (isCollected()) { setLinearDamping(0.0f); setAngularDamping(0.0); } if (!_target) { _target = _map.getPackageTarget(); // if we can't find a package target, we will destroy the package if (!_target) setDestroyed(); } if (!isCounted() && isDelivered()) { _map.countTransferedPackage(); setCounted(); } }
bool hasHandler() { ASSERT(!isCollected()); ScriptState::Scope scope(m_scriptState); v8::Local<v8::Value> value = m_promise.newLocal(m_scriptState->isolate()); return v8::Local<v8::Promise>::Cast(value)->HasHandler(); }
void Package::onContact (b2Contact* contact, IEntity* entity) { const bool oldCollectedState = isCollected(); CollectableEntity::onContact(contact, entity); if (!oldCollectedState && isCollected()) { _addRopeJointTo = entity; } else { if (entity->isSolid() || entity->isStone() || entity->isPackage()) { setLinearDamping(3.0f); setAngularDamping(1.0); if (isImpactVelocityMoreThan(contact, 1.5f)) _map.sendSound(getVisMask(), SoundTypes::SOUND_PACKAGE_COLLIDE, getPos()); } else if (entity->isBorder()) { const Border *b = assert_cast<const Border*, const IEntity*>(entity); if (!b->isTop()) { setLinearDamping(4.0f); setAngularDamping(1.0); } } else if (entity->isNpcAttacking()) { setDestroyed(true); } } }