Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8185


Ignore:
Timestamp:
Apr 4, 2011, 3:12:49 PM (13 years ago)
Author:
sven
Message:

DockToShip and some fixes

Location:
code/branches/dockingsystem
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • code/branches/dockingsystem/data/levels/docking.oxw

    r8151 r8185  
    3232
    3333
    34         <!-- stolen from underAttack.oxw -->
     34    <Dock>
     35        <effects>
     36            <DockToShip />
     37        </effects>
     38        <events>
     39            <execute>
     40                <EventListener event="dockMe" />
     41            </execute>
     42        </events>
     43        <attached>
     44            <DistanceTrigger position="0,0,0" distance="20" target="ControllableEntity" name="dockMe" />
     45            <Billboard material="Examples/Flare" colour="1.0, 0, 0" />
     46        </attached>
     47    </Dock>
    3548
     49
     50    <!--
    3651    <Destroyer
    3752      position          = "100,150,0"
     
    4661
    4762      <attached>
    48 
    49                 <Dock>
    50                         <effects>
    51                                 <DockToShip />
    52                         </effects>
    53             <events>
    54                 <execute>
    55                     <EventListener event="dockMe" />
    56                 </execute>
    57             </events>
    58             <attached>
    59                 <DistanceTrigger position="0,0,0" distance=2 target="ControllableEntity" name="dockMe" />
    60             </attached>
    61         </Dock>
    62 
    6363        <TeamSpawnPoint team=1 position="150,0,7" direction="-1,0,0" roll=90 yaw=0 spawnclass=SpaceShip pawndesign=spaceshipassff />
    6464        <TeamSpawnPoint team=1 position="0,0,7" lookat="-1,0,0" roll="90"  yaw=0 spawnclass=SpaceShip pawndesign=spaceshipassff />
     
    147147      </collisionShapes>
    148148    </Destroyer>
    149 
     149    //-->
    150150
    151151  </Scene>
  • code/branches/dockingsystem/src/modules/docking/Dock.cc

    r8151 r8185  
    3737namespace orxonox
    3838{
    39 
    40         CreateFactory(Dock);
     39    CreateFactory(Dock);
    4140
    4241    Dock::Dock(BaseObject* creator) : StaticEntity(creator)
    4342    {
    4443        RegisterObject(Dock);
    45                 COUT(0) << "Registering dock..." << std::endl;
     44        COUT(0) << "Registering dock..." << std::endl;
    4645    }
    4746
     
    7069
    7170    bool Dock::execute(bool bTriggered, BaseObject* trigger)
    72         {
    73                 COUT(0) << "Dock executed (bTriggered = " << (bTriggered? "true":"false") << ").." << std::endl;
    74                 return true;
    75         }
     71    {
     72        COUT(0) << "Dock executed (bTriggered = " << (bTriggered? "true":"false") << ").." << std::endl;
     73
     74        //TODO: Handle MultiDistanceTrigger
     75
     76        //TODO: This way too oversimplified
     77        if(bTriggered) {
     78            DockingEffect::invokeEffect(docking::DOCKING, NULL, effects_);
     79            DockingEffect::invokeEffect(docking::ATTACH, NULL, effects_);
     80        } else {
     81            DockingEffect::invokeEffect(docking::RELEASE, NULL, effects_);
     82        }
    7683
    7784
    78         bool Dock::addEffect(DockingEffect* effect) {
    79                 assert(effect);
    80                 effects_.push_back(effect);
    81                 return true;
    82         }
    83    
    84         const DockingEffect* Dock::getEffect(unsigned int index) const {
    85                 int i = index;
     85        return true;
     86    }
     87
     88
     89    bool Dock::addEffect(DockingEffect* effect) {
     90        assert(effect);
     91        effects_.push_back(effect);
     92        return true;
     93    }
     94
     95    const DockingEffect* Dock::getEffect(unsigned int index) const {
     96        int i = index;
    8697        for (std::list<DockingEffect*>::const_iterator effect = this->effects_.begin(); effect != this->effects_.end(); ++effect)
    8798        {
     
    92103        }
    93104        return NULL;
    94         }
    95 
     105    }
    96106}
  • code/branches/dockingsystem/src/modules/docking/Dock.h

    r8151 r8185  
    4747
    4848
    49         class _DockingExport Dock : public StaticEntity {
    50         public:
    51                 Dock(BaseObject* creator);
     49    class _DockingExport Dock : public StaticEntity {
     50    public:
     51        Dock(BaseObject* creator);
    5252        virtual ~Dock();
    5353
     
    5757        bool execute(bool bTriggered, BaseObject* trigger);
    5858
    59         private:
    60                 std::list<DockingEffect*> effects_; //!< The list of DockingEffects to be executed when a player docks.
    61 
    6259        bool addEffect(DockingEffect* effect); //!< Add a DockingEffect to the Dock.
    6360        const DockingEffect* getEffect(unsigned int index) const; //!< Get the DockingEffect at a given index.
    64         };
     61
     62    private:
     63        std::list<DockingEffect*> effects_; //!< The list of DockingEffects to be executed when a player docks.
     64    };
    6565
    6666
  • code/branches/dockingsystem/src/modules/docking/DockToShip.cc

    r8151 r8185  
     1/*
     2 *   ORXONOX - the hottest 3D action shooter ever to exist
     3 *                    > www.orxonox.net <
     4 *
     5 *
     6 *   License notice:
     7 *
     8 *   This program is free software; you can redistribute it and/or
     9 *   modify it under the terms of the GNU General Public License
     10 *   as published by the Free Software Foundation; either version 2
     11 *   of the License, or (at your option) any later version.
     12 *
     13 *   This program is distributed in the hope that it will be useful,
     14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
     15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     16 *   GNU General Public License for more details.
     17 *
     18 *   You should have received a copy of the GNU General Public License
     19 *   along with this program; if not, write to the Free Software
     20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
     21 *
     22 *   Author:
     23 *      Damian 'Mozork' Frick
     24 *   Co-authors:
     25 *      ...
     26 *
     27 */
     28
     29/**
     30    @file DockToShip.cc
     31    @brief Implementation of the DockToShip class.
     32*/
     33
     34#include "DockingEffect.h"
     35#include "DockToShip.h"
     36#include "core/CoreIncludes.h"
     37
     38namespace orxonox
     39{
     40    CreateFactory(DockToShip);
     41
     42    DockToShip::DockToShip(BaseObject* creator) : DockingEffect(creator)
     43    {
     44        RegisterObject(DockToShip);
     45        COUT(0) << "DockToShip instance created.." << endl;
     46    }
     47
     48    DockToShip::~DockToShip()
     49    {
     50
     51    }
     52
     53    bool DockToShip::docking(PlayerInfo* player)
     54    {
     55        COUT(0) << "DockToShip::docking" << endl;
     56        return true;
     57    }
     58
     59    bool DockToShip::attach(PlayerInfo* player)
     60    {
     61        COUT(0) << "DockToShip::attach" << endl;
     62        return true;
     63    }
     64
     65    bool DockToShip::release(PlayerInfo* player)
     66    {
     67        COUT(0) << "DockToShip::release" << endl;
     68        return true;
     69    }
     70}
  • code/branches/dockingsystem/src/modules/docking/DockToShip.h

    r8151 r8185  
     1/*
     2 *   ORXONOX - the hottest 3D action shooter ever to exist
     3 *                    > www.orxonox.net <
     4 *
     5 *
     6 *   License notice:
     7 *
     8 *   This program is free software; you can redistribute it and/or
     9 *   modify it under the terms of the GNU General Public License
     10 *   as published by the Free Software Foundation; either version 2
     11 *   of the License, or (at your option) any later version.
     12 *
     13 *   This program is distributed in the hope that it will be useful,
     14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
     15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     16 *   GNU General Public License for more details.
     17 *
     18 *   You should have received a copy of the GNU General Public License
     19 *   along with this program; if not, write to the Free Software
     20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
     21 *
     22 *   Author:
     23 *      Sven Stucki
     24 *   Co-authors:
     25 *      ...
     26 *
     27 */
     28
     29/**
     30    @file DockToShip.h
     31    @brief DockingEffect which transfers control from spaceship to docked ship ASDF
     32    @ingroup Docking
     33*/
     34
     35#ifndef _DockToShip_H__
     36#define _DockToShip_H__
     37
     38#include "DockingPrereqs.h"
     39#include "DockToShip.h"
     40
     41
     42namespace orxonox
     43{
     44
     45    /**
     46    @brief
     47        Allows players to dock onto a ship
     48
     49    @author
     50        Sven Stucki
     51
     52    @ingroup Docking
     53    */
     54    class _DockingExport DockToShip : public DockingEffect
     55    {
     56        public:
     57            DockToShip(BaseObject* creator);
     58            virtual ~DockToShip();
     59
     60            virtual bool docking(PlayerInfo* player); //!< Called when docking starts
     61            virtual bool attach(PlayerInfo* player); //!< Called after docking animation
     62            virtual bool release(PlayerInfo* player); //!< Called when player wants undock
     63    };
     64
     65}
     66
     67#endif /* _DockToShip_H__ */
  • code/branches/dockingsystem/src/modules/docking/DockingEffect.cc

    r8153 r8185  
    4747    }
    4848
    49     bool DockingEffect::invokeEffects(PlayerInfo* player, std::list<DockingEffect*> & effects)
     49    bool DockingEffect::invokeEffect(docking::event event, PlayerInfo* player, std::list<DockingEffect*> & effects)
    5050    {
    5151        bool check = true;
     
    5353        COUT(4) << "Invoking DockingEffects on player: " << player << " ."  << std::endl;
    5454
    55         for (std::list<DockingEffect*>::iterator effect = effects.begin(); effect != effects.end(); effect++)
    56             check = check       ;// && (*effect)->invoke(player);  TODO
     55        for (std::list<DockingEffect*>::iterator effect = effects.begin(); effect != effects.end(); effect++) {
     56            switch(event) {
     57                case docking::DOCKING:
     58                    check &= (*effect)->docking(player);
     59                    break;
     60                case docking::ATTACH:
     61                    check &= (*effect)->attach(player);
     62                    break;
     63                case docking::RELEASE:
     64                    check &= (*effect)->release(player);
     65                    break;
     66                default:
     67                    assert(0);
     68            }
     69        }
    5770
    5871        return check;
  • code/branches/dockingsystem/src/modules/docking/DockingEffect.h

    r8151 r8185  
    4343namespace orxonox
    4444{
     45    namespace docking {
     46        enum event {
     47            DOCKING,
     48            ATTACH,
     49            RELEASE
     50        };
     51    }
    4552
    4653    /**
     
    6067
    6168            virtual bool docking(PlayerInfo* player) = 0; //!< Called when docking starts
    62                         virtual bool attach(PlayerInfo* player) = 0; //!< Called after docking animation
    63                         virtual bool release(PlayerInfo* player) = 0; //!< Called when player wants undock
     69            virtual bool attach(PlayerInfo* player) = 0; //!< Called after docking animation
     70            virtual bool release(PlayerInfo* player) = 0; //!< Called when player wants undock
    6471
    65             static bool invokeEffects(PlayerInfo* player, std::list<DockingEffect*> & effects); //!< Invokes all DockingEffects in the list.
     72            static bool invokeEffect(docking::event event, PlayerInfo* player, std::list<DockingEffect*> & effects); //!< Invokes the event specific method of all DockingEffects in the list
    6673    };
    6774
  • code/branches/dockingsystem/src/modules/docking/DockingPrereqs.h

    r8151 r8185  
    6666{
    6767    class Dock;
    68         class DockingEffect;
     68    class DockingEffect;
     69    class DockToShip;
    6970}
    7071
  • code/branches/dockingsystem/src/orxonox/infos/PlayerInfo.cc

    r7163 r8185  
    224224
    225225        this->controllableEntity_->setController(0);
    226        
     226
    227227        this->controllableEntity_ = this->oldControllableEntity_;
    228228        this->controllableEntityID_ = this->controllableEntity_->getObjectID();
Note: See TracChangeset for help on using the changeset viewer.