Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 16, 2011, 6:21:05 PM (14 years ago)
Author:
sven
Message:

Added docking animations, skeletton for DockingController..

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/dockingsystem2/src/modules/docking/Dock.cc

    r8434 r8493  
    5757    {
    5858        RegisterObject(Dock);
    59         COUT(0) << "Registering dock..." << std::endl;
    6059    }
    6160
     
    7069
    7170        XMLPortObject(Dock, DockingEffect, "effects", addEffect, getEffect, xmlelement, mode);
     71        XMLPortObject(Dock, DockingAnimation, "animations", addAnimation, getAnimation, xmlelement, mode);
    7272        XMLPortEventSink(Dock, BaseObject, "execute", execute, xmlelement, mode);
    73 
    74         COUT(0) << "Dock created.." << std::endl;
    7573    }
    7674
     
    9694            }
    9795            pawn = pTrigger->getTriggeringPlayer();
    98         } else {
     96        }
     97        else
     98        {
    9999            COUT(2) << "Docking::execute Not a player trigger, can't extract pawn from it.." << std::endl;
    100100            return false;
     
    110110        if(player == NULL)
    111111        {
    112             COUT(2) << "The PlayerInfo* is NULL." << std::endl;
    113             return false;
    114         }
    115 
    116         COUT(0) << "Dock triggered by player: " << player->getName() << ".." << std::endl;
     112            COUT(2) << "Docking::execute The PlayerInfo* is NULL." << std::endl;
     113            return false;
     114        }
    117115
    118116        if(bTriggered)
     
    123121            // Show docking dialog
    124122            GUIManager::showGUI("DockingDialog");
    125             //DockingEffect::invokeEffect(docking::DOCKING, player, effects_);
    126123        }
    127124        else
     
    129126            // Remove player from candidates list
    130127            candidates.erase(player);
    131 
    132             //DockingEffect::invokeEffect(docking::RELEASE, player, effects_);
    133128        }
    134129
     
    163158        if(candidates.find(player) == candidates.end())
    164159        {
    165             COUT(0) << "Player is not a candidate!" << std::endl;
    166             return false;
    167         }
    168 
    169         // Remove player from candidates, add to docked players and invoke docking effect
     160            COUT(0) << "Dock::dock Player is not a candidate!" << std::endl;
     161            return false;
     162        }
     163
    170164        candidates.erase(player);
    171165        docked.insert(player);
    172         DockingEffect::invokeEffect(docking::ATTACH, player, effects);
     166
     167        if (animations.empty())
     168            return dockingAnimationFinished(player);
     169        else
     170            DockingAnimation::invokeAnimation(true, player, animations);
     171
     172        return true;
     173    }
     174
     175    bool Dock::dockingAnimationFinished(PlayerInfo* player)
     176    {
     177        if(docked.find(player) == docked.end())
     178        {
     179            COUT(0) << "Dock::dockingAnimationFinished Player is not currently docked." << std::endl;
     180            return false;
     181        }
     182
     183        DockingEffect::invokeEffect(true, player, effects);
    173184        return true;
    174185    }
     
    179190        if(docked.find(player) == docked.end())
    180191        {
    181             COUT(0) << "Player is not docked to this Dock." << std::endl;
    182             return false;
    183         }
    184 
    185         // Remove player from docked, add to candidates and reverse DockingEffect
     192            COUT(0) << "Dock::undock Player is not docked to this Dock." << std::endl;
     193            return false;
     194        }
     195
    186196        docked.erase(player);
    187197        candidates.insert(player);
    188         DockingEffect::invokeEffect(docking::RELEASE, player, effects);
     198
     199        DockingEffect::invokeEffect(false, player, effects);
     200
     201        if (animations.empty())
     202            return undockingAnimationFinished(player);
     203        else
     204            DockingAnimation::invokeAnimation(false, player, animations);
     205
     206        return true;
     207    }
     208
     209    bool Dock::undockingAnimationFinished(PlayerInfo* player) {
     210        COUT(0) << "Dock::undockingAnimationFinished executed" << std::endl;
    189211        return true;
    190212    }
     
    226248    }
    227249
    228     const DockingEffect* Dock::getEffect(unsigned int index) const
    229     {
    230         int i = index;
     250    const DockingEffect* Dock::getEffect(unsigned int i) const
     251    {
    231252        for (std::list<DockingEffect*>::const_iterator effect = this->effects.begin(); effect != this->effects.end(); ++effect)
    232253        {
     
    237258        return NULL;
    238259    }
     260
     261    bool Dock::addAnimation(DockingAnimation* animation)
     262    {
     263        assert(animation);
     264        animation->setParent(this);
     265        animations.push_back(animation);
     266        return true;
     267    }
     268
     269    const DockingAnimation* Dock::getAnimation(unsigned int i) const
     270    {
     271        for (std::list<DockingAnimation*>::const_iterator animation = this->animations.begin(); animation != this->animations.end(); ++animation)
     272        {
     273            if(i == 0)
     274               return *animation;
     275            i--;
     276        }
     277        return NULL;
     278    }
    239279}
Note: See TracChangeset for help on using the changeset viewer.