void Aircraft::updateTexts() { // Display hitpoints if (isDestroyed()) mHealthDisplay->setString(""); else mHealthDisplay->setString(toString(getHitpoints()) + " HP"); mHealthDisplay->setPosition(0.f, 50.f); mHealthDisplay->setRotation(-getRotation()); // Display missiles, if available if (mMissileDisplay) { if (mMissileAmmo == 0 || isDestroyed()) mMissileDisplay->setString(""); else mMissileDisplay->setString("Missiles: " + toString(mMissileAmmo)); } if (mLaserDisplay) { if (mLaserAmmo == 0 || isDestroyed()) mLaserDisplay->setString(""); else mLaserDisplay->setString("Lasers: " + toString(mLaserAmmo)); } }
void BulletAIComponent::update() { if (isDestroyed_ == true) return; if (movementCoolDown.Update() == true) { if (game::pHandler.playerAt(position) == true) { Player *player = nullptr; if (game::pHandler.getPlayerAt(position, &player) == true) { if (player == nullptr) return; player->damage(damage); isDestroyed(true); clean(); return; } } if (rangeIndex == range) { isDestroyed(true); clean(); return; } Position nPos = position; nPos.go(direction); game::game.getTileRefAt(position).removeOverlay(); Tile& tile = game::game.getTileRefAt(nPos); if (tile.isWall() == true) { isDestroyed(true); clean(); return; } if (game::pHandler.playerAt(nPos) == true) { Player *player = nullptr; if (game::pHandler.getPlayerAt(nPos, &player) == true) { if (player == nullptr) return; player->damage(damage); isDestroyed(true); clean(); return; } } tile.setOverlayEnabled(true); tile.setOverlayGraphic(graphic_); position = nPos; rangeIndex++; movementCoolDown.StartNewTimer(movementCoolDownTime); } }
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(); } }
void GameManager::tick(Ogre::Real timeDelta) { // process objects that are scheduled to start running if (!m_startingObjectList.empty()) { for (auto obj : m_startingObjectList) { // object started, move to running list obj->onStart(); m_runningObjectList.push_back(obj); } m_startingObjectList.clear(); } // process objects that are currently running for (auto objIterator = m_runningObjectList.begin(); objIterator != m_runningObjectList.end();) { auto obj = *objIterator; // if object is flagged as destroyed, remove from running list if (obj->isDestroyed()) { obj->onDestroy(); objIterator = m_runningObjectList.erase(objIterator); } else { // object is running so elapse time for it obj->tick(timeDelta); objIterator++; } } }
//------------------------------------------------------------------------------------- PyObject* Proxy::pyClientAddr() { if(isDestroyed()) { PyErr_Format(PyExc_AssertionError, "%s: %d is destroyed!\n", scriptName(), id()); PyErr_PrintEx(0); return 0; } PyObject* pyobj = PyTuple_New(2); if(clientMailbox() == NULL || clientMailbox()->getChannel() == NULL || clientMailbox()->getChannel()->pEndPoint() == NULL) { PyTuple_SetItem(pyobj, 0, PyLong_FromLong(0)); PyTuple_SetItem(pyobj, 1, PyLong_FromLong(0)); } else { const Network::Address& addr = clientMailbox()->getChannel()->pEndPoint()->addr(); PyTuple_SetItem(pyobj, 0, PyLong_FromUnsignedLong(addr.ip)); PyTuple_SetItem(pyobj, 1, PyLong_FromUnsignedLong(addr.port)); } return pyobj; }
void SceneNode::checkNodeCollision(SceneNode& node, std::set<SceneNode::Pair>& collisionPairs){ if (this != &node && collision(*this, node) && !isDestroyed() && !node.isDestroyed()) collisionPairs.insert(std::minmax(this, &node)); FOREACH(Ptr& child, mChildren){ child->checkNodeCollision(node, collisionPairs); }
void Tile::updateCurrent(sf::Time dt, CommandQueue& commands) { // Entity has been destroyed: Possibly drop pickup, mark for removal if (isDestroyed()) { checkPickupDrop(commands); mExplosion.update(dt); // Play explosion sound only once if (!mExplosionBegan) { // Play sound effect SoundEffect::ID soundEffect = (randomInt(2) == 0) ? SoundEffect::Explosion1 : SoundEffect::Explosion2; playLocalSound(commands, soundEffect); // Emit network game action for explosions if (isBlock()) { sf::Vector2f position = getWorldPosition(); Command command; command.category = Category::Network; command.action = derivedAction<NetworkNode>([position] (NetworkNode& node, sf::Time) { node.notifyGameAction(GameActions::EnemyExplode, position); }); commands.push(command); mExplosionBegan = true; } } return; } Entity::updateCurrent(dt, commands); }
void Ship::updateCurrent(sf::Time dt, CommandQueue& commands) { // Entity has been destroyed if (isDestroyed()) { _isMarkedForRemoval = true; return; } // Check if bullets fired checkProjectileLaunch(dt, commands); // Update enemy movement pattern; apply velocity & friction Entity::updateCurrent(dt, commands); setVelocity((1-0.025)*getVelocity().x, (1-0.025)*getVelocity().y); // Ship is invulnerable after respawn if(_godmode) _invisTimer += dt; if(_invisTimer >= sf::seconds(3)) { _invisTimer = sf::Time::Zero; _godmode = 0; } }
void Aircraft::drawCurrent(sf::RenderTarget& target, sf::RenderStates states) const { if (isDestroyed() && mShowExplosion) target.draw(mExplosion, states); else target.draw(mSprite, states); }
bool Package::shouldCollide (const IEntity *entity) const { if (isDestroyed()) return false; if (entity->isPlayer()) { const Player* player = assert_cast<const Player*, const IEntity*>(entity); return !player->isCrashed() && !isArrived() && !isDelivered() && entity->getPos().y < getPos().y; } if (entity->isPackageTarget() || entity->isWater()) { return !isArrived() && !isDelivered(); } if (entity->isNpcAttacking()) { const NPCAttacking *npc = assert_cast<const NPCAttacking*, const IEntity*>(entity); return npc->isAttacking(); } if (entity->isStone()) return true; if (entity->isPackage()) { const Package* package = assert_cast<const Package*, const IEntity*>(entity); return !package->isDestroyed(); } return CollectableEntity::shouldCollide(entity); }
HtmlEditor::~HtmlEditor() { kDebug(); if ( !instancePrivate.isDestroyed() ) { delete mEditor; kDebug() << "editor deleted"; } }
void ScriptEditorWindow::onFocusChanged(bool inFocus) { if (isDestroyed() || mManagedInstance == nullptr) return; void* params[1] = { &inFocus}; onFocusChangedMethod->invokeVirtual(mManagedInstance, params); }
void Tile::drawCurrent(sf::RenderTarget& target, sf::RenderStates states) const { if (isDestroyed()){ //target.draw(mExplosion, states); } else target.draw(mSprite, states); }
void SceneNode::checkNodeCollision(SceneNode& node, std::set<Pair> &collisionPairs) { // valid collision if (this != &node && collision(*this, node)&& !isDestroyed() && !node.isDestroyed()) collisionPairs.insert(std::minmax(this, &node)); for (auto & child : mChildren) child->checkNodeCollision(node, collisionPairs); }
void ScriptEditorWindow::onWidgetResized(UINT32 width, UINT32 height) { if (isDestroyed() || !mEditorWidget->isInitialized() || mManagedInstance == nullptr) return; void* params[2] = { &width, &height }; onResizedMethod->invokeVirtual(mManagedInstance, params); }
void ScriptEditorWindow::onFocusChanged(bool inFocus) { MonoObject* managedInstance = mEditorWidget->getManagedInstance(); if (isDestroyed() || managedInstance == nullptr) return; void* params[1] = { &inFocus}; onFocusChangedMethod->invokeVirtual(managedInstance, params); }
void Maze::checkNodeCollision(SceneNode & node, std::set<Pair>& collisionPairs) { //Handle from maze to others (maze as 'this' and others as 'node') if (this != &node && mazeCollision(node) && !isDestroyed() && !node.isDestroyed()) collisionPairs.insert(std::minmax(static_cast<SceneNode*>(this), &node)); //Upcasting the pointer is safe, no slicing happens, SceneNode is a base class of Maze for (uPtr& child : children_) child->checkNodeCollision(node, collisionPairs); }
bool Package::isRemove () const { // skip CollectableEntity - because we don't want to remove the package immediately even if it's collected if (IEntity::isRemove()) return true; if (isDestroyed() && _time > _destroyedTime + DESTROYED_REMOVE_TIME) return true; return isCounted(); }
void ScriptEditorWindow::endRefresh(const ScriptObjectBackup& backupData) { if (isDestroyed()) { // We couldn't restore managed instance because window class cannot be found _onManagedInstanceDeleted(false); } PersistentScriptObjectBase::endRefresh(backupData); }
void VehicleObjectImplementation::fillObjectMenuResponse(ObjectMenuResponse* menuResponse, CreatureObject* player) { if (!player->getPlayerObject()->isPrivileged() && linkedCreature != player) return; menuResponse->addRadialMenuItem(205, 1, "@pet/pet_menu:menu_enter_exit"); menuResponse->addRadialMenuItem(61, 3, ""); if (player->getPlayerObject()->isPrivileged() || (checkInRangeGarage() && !isDestroyed())) menuResponse->addRadialMenuItem(62, 3, "@pet/pet_menu:menu_repair_vehicle"); //Repair Vehicle }
Wall* Wall::_getWall(const Grid& pos) { auto building = m_field->getBuilding(pos); if (building && !building->isDestroyed() && building->isBuildingGroup(BUILDING_GROUP::GROUP_WALL)) { return static_cast<Wall*>(building); } return nullptr; }
void SocketBuffer::autoFlushThread() { char data[512]; int pos = 0; while (!isDestroyed()) { int len = readBuffer(data, 1, sizeof(data)); pos += len; send(socketfd, data, len, 0); } }
void Creature::drawCurrent(sf::RenderTarget &target, sf::RenderStates states) const { if(isDestroyed()) return; /*sf::FloatRect rect = getBoundingRect(); sf::RectangleShape shape; shape.setPosition(sf::Vector2f(rect.left, rect.top)); shape.setSize(sf::Vector2f(rect.width, rect.height)); shape.setFillColor(sf::Color::Transparent); shape.setOutlineColor(sf::Color::Green); shape.setOutlineThickness(1.f); target.draw(shape);*/ target.draw(mAnimations[getDirection()], states); if(isKnocked() && !isDestroyed()) { target.draw(mKnockedAnimation, states); } }
void Channel::destroy() { if(isDestroyed()) { // CRITICAL_MSG("is channel has Destroyed!\n"); return; } clearState(); mFlags |= Flag_Destroyed; }
//------------------------------------------------------------------------------------- void Base::onRemoteMethodCall(Mercury::Channel* pChannel, MemoryStream& s) { // 如果是外部通道调用则判断来源性 if(pChannel->isExternal()) { ENTITY_ID srcEntityID = pChannel->proxyID(); if(srcEntityID <= 0 || srcEntityID != this->getID()) { WARNING_MSG("Base::onRemoteMethodCall: srcEntityID:%d, thisEntityID:%d.\n", srcEntityID, this->getID()); return; } } if(isDestroyed()) { ERROR_MSG("%s::onRemoteMethodCall: %d is destroyed!\n", getScriptName(), getID()); s.read_skip(s.opsize()); return; } ENTITY_METHOD_UID utype = 0; s >> utype; MethodDescription* md = scriptModule_->findBaseMethodDescription(utype); if(md == NULL) { ERROR_MSG("Base::onRemoteMethodCall: can't found method. utype=%u, callerID:%d.\n", utype, id_); return; } DEBUG_MSG("Base::onRemoteMethodCall: entityID:%d, methodType:%s(%u).\n", id_, md->getName(), utype); md->currCallerID(this->getID()); PyObject* pyFunc = PyObject_GetAttrString(this, const_cast<char*> (md->getName())); if(md != NULL) { PyObject* pyargs = md->createFromStream(&s); if(pyargs) { md->call(pyFunc, pyargs); Py_XDECREF(pyargs); } else { SCRIPT_ERROR_CHECK(); } } Py_XDECREF(pyFunc); }
MonoObject* ScriptEditorWindow::_createManagedInstance(bool construct) { if (!isDestroyed()) { mEditorWidget->createManagedInstance(); return mEditorWidget->getManagedInstance(); } else return nullptr; }
//------------------------------------------------------------------------------------- PyObject* Proxy::pyGetRoundTripTime() { if (!hasFlags(ENTITY_FLAGS_DESTROYING) && isDestroyed()) { PyErr_Format(PyExc_AssertionError, "%s: %d is destroyed!\n", scriptName(), id()); PyErr_PrintEx(0); return 0; } return PyFloat_FromDouble(this->getRoundTripTime()); }
//------------------------------------------------------------------------------------- PyObject* Proxy::pyGetTimeSinceHeardFromClient() { if(isDestroyed()) { PyErr_Format(PyExc_AssertionError, "%s: %d is destroyed!\n", scriptName(), id()); PyErr_PrintEx(0); return 0; } return PyFloat_FromDouble(this->getTimeSinceHeardFromClient()); }
void Planet::updateCurrent(sf::Time dt, CommandQueue& commands) { if (isDestroyed()) { mIsMarkedForRemoval = true; return; } updateMovementPattern(dt); mSprite.rotate(15 * dt.asSeconds()); Entity::updateCurrent(dt, commands); }
//------------------------------------------------------------------------------------- PyObject* Proxy::pyGetRoundTripTime() { if(isDestroyed()) { PyErr_Format(PyExc_AssertionError, "%s: %d is destroyed!\n", getScriptName(), getID()); PyErr_PrintEx(0); return 0; } return PyFloat_FromDouble(this->getRoundTripTime()); }