ActorId PhysXPhysics::FindActorId(PxRigidBody const * const body) { PysXRigidBodyToActorIdTable::const_iterator found = m_rigidBodyActorMap.find(body); if (found != m_rigidBodyActorMap.end()) { return found->second; } return ActorId(); }
void TrapSummonMonster::trigger( Actor& actor, const AbilityRollResult dodgeResult) { traceVerbose << "TrapSummonMonster::trigger()..." << endl; (void)dodgeResult; const bool IS_PLAYER = &actor == eng.player; traceVerbose << "TrapSummonMonster: Is player: " << IS_PLAYER << endl; if(IS_PLAYER == false) { traceVerbose << "TrapSummonMonster: Not triggered by player" << endl; traceVerbose << "TrapSummonMonster::trigger() [DONE]" << endl; return; } const bool CAN_SEE = actor.getPropHandler().allowSee(); traceVerbose << "TrapSummonMonster: Actor can see: " << CAN_SEE << endl; const string actorName = actor.getNameThe(); traceVerbose << "TrapSummonMonster: Actor name: " << actorName << endl; eng.player->incrShock(5, ShockSrc::misc); eng.player->updateFov(); if(CAN_SEE) { eng.log->addMsg("A curious shape on the floor starts to glow!"); } else { eng.log->addMsg("I feel a peculiar energy around me!"); } trace << "TrapSummonMonster: Finding summon candidates" << endl; vector<ActorId> summonCandidates; for(int i = 1; i < endOfActorIds; i++) { const ActorData& data = eng.actorDataHandler->dataList[i]; if(data.canBeSummoned && data.spawnMinDLVL <= eng.map->getDlvl() + 3) { summonCandidates.push_back(ActorId(i)); } } const int NR_ELEMENTS = summonCandidates.size(); trace << "TrapSummonMonster: Nr candidates: " << NR_ELEMENTS << endl; if(NR_ELEMENTS == 0) { trace << "TrapSummonMonster: No eligible candidates found" << endl; } else { const int ELEMENT = Rnd::range(0, NR_ELEMENTS - 1); const ActorId actorIdToSummon = summonCandidates.at(ELEMENT); trace << "TrapSummonMonster: Actor id: " << actorIdToSummon << endl; eng.actorFactory->summonMonsters( pos_, vector<ActorId>(1, actorIdToSummon), true); trace << "TrapSummonMonster: Monster was summoned" << endl; } traceVerbose << "TrapSummonMonster::trigger() [DONE]" << endl; }
/// executes action virtual void Do(IModel& /*model*/) override { ObjectPtr sp = ArgumentRef().m_sp; // must be a mobile MobilePtr spMobile = std::dynamic_pointer_cast<Mobile>(sp); const ObjectId& actorId = ActorId(); spMobile->Selection(actorId); // LogAction(_T("SelectMobile")); }
void XmppHistoryResponseActor::execute() { qDebug("EXECUTE SignerResponse"); BEGIN_EXECUTE; // Analyze the request { XmppTag* pubsub = m_stanza.child("pubsub"); XmppTag* items = pubsub ? pubsub->child( "items" ) : 0; XmppTag* history = items ? items->child("delta-history") : 0; if ( !history ) { XMPPERROR("Malformed delta-hiistory request"); } // TODO: Inspect the hashes that are being sent bool ok = true; m_start = history->attribute("start-version").toLong(&ok); if ( !ok || m_start < 0) { XMPPERROR("start-version missing"); } m_end = history->attribute("end-version").toLong(&ok); if ( !ok || m_end < 0 ) { XMPPERROR("end-version missing"); } QString waveletName = history->attribute("wavelet-name"); m_url = WaveUrl( waveletName ); if ( m_url.isNull() ) { XMPPERROR("Malformed wavelet-name"); } } // Wait until the connection is ready if ( !connection()->isReady() ) yield( RecvSignal( connection(), SIGNAL(ready())) ); // Send a query to the database asking for the deltas { m_msgId = nextId(); PBMessage<messages::QueryWaveletUpdates>* query = new PBMessage<messages::QueryWaveletUpdates>( ActorId("store", m_url.toString() ), m_msgId ); query->setCreateOnDemand( true ); query->set_wavelet_name(m_url.toString().toStdString() ); query->set_start_version( m_start ); query->set_end_version( m_end ); bool ok = post( query ); if ( !ok ) { XMPPERROR("Internal server error. Could not talk to database."); } } // Wait for a response from the database yield( RecvPB<messages::QueryWaveletUpdatesResponse>(m_msgId) | Timeout(10000) ); if ( REASON(RecvPB<messages::QueryWaveletUpdatesResponse>) ) { if ( !REASON->ok() ) { XMPPERROR("Data base reported an error:" + QString::fromStdString( REASON->error() )); } // Send the requested deltas { QString send; QXmlStreamWriter writer( &send ); writer.writeStartElement("iq"); writer.writeAttribute("type", "result" ); writer.writeAttribute("id", m_stanza.stanzaId() ); writer.writeAttribute("to", connection()->domain() ); writer.writeAttribute("from", Settings::settings()->xmppComponentName() ); writer.writeStartElement("pubsub"); writer.writeAttribute("xmlns", "http://jabber.org/protocol/pubsub" ); writer.writeStartElement("items"); for( i = 0; i < REASON->applied_delta_size(); ++i ) { QByteArray ba = QByteArray::fromRawData( REASON->applied_delta(i).data(), REASON->applied_delta(i).length() ); QString str64 = QString::fromAscii( ba.toBase64() ); writer.writeStartElement("item"); writer.writeStartElement("applied-delta"); writer.writeCDATA( str64 ); writer.writeEndElement(); writer.writeEndElement(); } writer.writeStartElement("item"); writer.writeStartElement("commit-notice"); writer.writeAttribute("xmlns", "http://waveprotocol.org/protocol/0.2/waveserver" ); writer.writeAttribute("version", QString::number(REASON->end_version()) ); writer.writeEndElement(); writer.writeEndElement(); writer.writeStartElement("item"); writer.writeStartElement("history-truncated"); writer.writeAttribute("xmlns", "http://waveprotocol.org/protocol/0.2/waveserver" ); writer.writeAttribute("version", QString::number(REASON->end_version()) ); writer.writeEndElement(); writer.writeEndElement(); writer.writeEndElement(); writer.writeEndElement(); writer.writeEndElement(); connection()->send( send ); } } else { XMPPERROR("Timeout waiting for database"); } END_EXECUTE; }