void PacketHandlers::HandleInteractionRequest(Session* sess, SmartPacket& packet)
{
    uint64_t guid = packet.ReadUInt64();

    WorldObject* obj = sObjectAccessor->FindWorldObject(guid);
    if (!obj)
        return;

    // TODO: distance check

    if (obj->GetType() == OTYPE_CREATURE)
        obj->ToCreature()->Interact(sess->GetPlayer());
}
void PacketHandlers::HandleDialogueDecision(Session* sess, SmartPacket& packet)
{
    uint64_t guid = packet.ReadUInt64();
    uint32_t decision = packet.ReadUInt32();

    WorldObject* obj = sObjectAccessor->FindWorldObject(guid);
    // if the object is not found, or is not creature, send dialogue close packet
    if (!obj || obj->GetType() != OTYPE_CREATURE)
    {
        SmartPacket pkt(SP_DIALOGUE_CLOSE);
        sess->SendPacket(pkt);
        return;
    }

    obj->ToCreature()->DialogueDecision(sess->GetPlayer(), decision);
}
Exemple #3
0
    void AreaEffect::_Update()
    {
        // Notes for the new post refactor way to update
        // Everything in vectors.  Create a new temp vector composed of the old frames "overlapping" items.
        // Go through all items detected by ghost proxy and attempt to remove them from the temporary vector.
        // If it successfully removes, add it to the current overlapping vector.  If it fails add to the added vector.
        // Once one iteration of this is done, all the remaining items in the temp vector are placed in the removed vector.

        if ( !AddedActors.empty() )
            this->AddedActors.clear();
        if ( !RemovedActors.empty() )
            this->RemovedActors.clear();
        btSoftRigidDynamicsWorld* PhysWorld = Entresol::GetSingletonPtr()->GetPhysicsManager()->_GetPhysicsWorldPointer();

        std::list<ActorBase*>::iterator it = OverlappingActors.begin();
        // Make a bool vector to keep track of which actors to keep when updating.
        std::vector<bool> Tracker;
        Tracker.resize(OverlappingActors.size());
        std::vector<bool>::iterator bit;
        for ( bit = Tracker.begin() ; bit != Tracker.end() ; bit++ )
        {
            (*bit) = false;
        }

        btManifoldArray manifoldArray;
        btBroadphasePairArray& pairArray = Ghost->getOverlappingPairCache()->getOverlappingPairArray();
        int numPairs = pairArray.size();
        for (int i=0;i<numPairs;i++)
        {
            manifoldArray.clear();
            const btBroadphasePair& pair = pairArray[i];
            btBroadphasePair* collisionPair = PhysWorld->getPairCache()->findPair(pair.m_pProxy0,pair.m_pProxy1);
            if (!collisionPair)
                continue;
            if (collisionPair->m_algorithm)
                collisionPair->m_algorithm->getAllContactManifolds(manifoldArray);

            for (int j=0;j<manifoldArray.size();j++)
            {
                btPersistentManifold* manifold = manifoldArray[j];
                for (int p=0;p<manifold->getNumContacts();p++)
                {
                    //const btManifoldPoint& pt = manifold->getContactPoint(p);
                    //if(pt.m_distance1 > 0)
                    //    continue;
                    btCollisionObject* ColObj = manifold->getBody0() != Ghost ? (btCollisionObject*)(manifold->getBody0()) : (btCollisionObject*)(manifold->getBody1());

                    WorldObject* WO = static_cast<WorldObject*>(ColObj->getUserPointer());
                    ActorBase* Actor = NULL;
                    if( Mezzanine::WSO_TerrainFirst > WO->GetType() )
                        Actor = static_cast<ActorBase*>( WO );
                    else
                        continue;
                    // Check list for the actor in the pair.
                    for( it = this->OverlappingActors.begin(), bit = Tracker.begin() ; it != this->OverlappingActors.end() ; it++, bit++ )
                    {
                        if ( Actor == (*it) )
                        {
                            (*bit) = true;
                            break;
                        }
                    }
                    if ( it == this->OverlappingActors.end() )
                    {
                        this->AddActorToList(Actor);
                        Tracker.push_back(true);
                    }
                }
            }
        }

        // Verify they are the same size.  Then remove items from the list as necessary.
        if ( OverlappingActors.size() == Tracker.size() )
        {
            std::list<ActorBase*>::iterator sit = OverlappingActors.begin();
            for ( bit = Tracker.begin() ; bit != Tracker.end() ; )
            {
                if ( (*bit) == false )
                {
                    bit = Tracker.erase(bit);
                    ActorBase* Act = (*sit);
                    RemovedActors.push_back(Act);
                    sit = OverlappingActors.erase(sit);
                }else{
                    sit++;
                    bit++;
                }
            }
        }// */
    }