Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8382


Ignore:
Timestamp:
May 2, 2011, 4:16:27 PM (14 years ago)
Author:
sven
Message:

Added dock/undock console commands.

Location:
code/branches/dockingsystem2
Files:
5 edited

Legend:

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

    r8257 r8382  
    1717>
    1818  <templates>
    19     <Template link=lodtemplate_default />
     19    <Template link="lodtemplate_default" />
    2020  </templates>
    2121
     
    2525  >
    2626
    27     <Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0" />
     27    <Light type="directional" position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0" />
    2828
    2929    <?lua for i = 1, 10, 1 do ?>
    30       <SpawnPoint position="<?lua print(math.random() * 500 - 250) ?>,<?lua print(math.random() * 500 - 250) ?>,<?lua print(math.random() * 500 - 250) ?>" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff />
     30      <SpawnPoint position="<?lua print(math.random() * 500 - 250) ?>,<?lua print(math.random() * 500 - 250) ?>,<?lua print(math.random() * 500 - 250) ?>" lookat="0,0,0" spawnclass="SpaceShip" pawndesign="spaceshipassff" />
    3131    <?lua end ?>
    3232
    3333    <Dock position="-50,-100,50">
    3434            <effects>
    35                 <DockToShip target="asdf" />
     35                <DockToShip target="theDestroyer" />
    3636            </effects>
    3737            <events>
     
    4141            </events>
    4242            <attached>
    43                 <DistanceTrigger position="0,0,0" distance="20" target="Pawn" beaconMode="exclude" targetname="beacon1" name="dockMe" />
     43                <DistanceTrigger position="0,0,0" distance="20" target="Pawn" beaconMode="exclude" targetname="destroyerBeacon" name="dockMe" />
    4444                <Billboard material="Examples/Flare" colour="1.0, 0, 0" />
    4545            </attached>
     
    4747
    4848
     49   
     50
    4951      <SpaceShip
    50    hudtemplate            = spaceshiphud
    51    camerapositiontemplate = spaceshipassffcameras
    52    engine                 = spaceshipassffengine
     52   hudtemplate            = "spaceshiphud"
     53   camerapositiontemplate = "spaceshipassffcameras"
     54   engine                 = "spaceshipassffengine"
    5355   spawnparticlesource    = "Orxonox/fairytwirl"
    54    spawnparticleduration  = 3
    55    explosionchunks        = 6
    56 
    57    health            = 100
    58    maxhealth         = 200
    59    initialhealth     = 100
    60 
    61    primaryThrust     = 100;
    62    auxilaryThrust    = 30;
    63    rotationThrust    = 25;
     56   spawnparticleduration  = "3"
     57   explosionchunks        = "6"
     58
     59   health            = "100"
     60   maxhealth         = "200"
     61   initialhealth     = "100"
     62
     63   primaryThrust     = "100;"
     64   auxilaryThrust    = "30;"
     65   rotationThrust    = "25;"
    6466
    6567   collisionType     = "dynamic"
    66    mass              = 100
    67    linearDamping     = 0.7
    68    angularDamping    = 0.9999999
     68   mass              = "100"
     69   linearDamping     = "0.7"
     70   angularDamping    = "0.9999999"
    6971  >
    7072    <attached>
     
    7274        <DockingTarget name="asdf" />
    7375
    74       <Model position="0,0,0" yaw=90 pitch=-90 roll=0 scale=4 mesh="assff.mesh" />
    75       <BlinkingBillboard position="17,-1.5,0" material="Examples/Flare" colour="1.0, 0.5, 0.3" amplitude=0.1 frequency=0.5 quadratic=1 />
    76       <BlinkingBillboard position="-17,-1.5,0" material="Examples/Flare" colour="0.5, 1.0, 0.3" amplitude=0.1 frequency=0.5 phase=180 quadratic=1 />
    77       <DistanceTriggerBeacon name="PlayerDistanceTrigger" /> <!--added DistanceTrigger-->
     76      <Model position="0,0,0" yaw="90" pitch="-90" roll="0" scale="4" mesh="assff.mesh" />
     77      <BlinkingBillboard position="17,-1.5,0" material="Examples/Flare" colour="1.0, 0.5, 0.3" amplitude="0.1" frequency="0.5" quadratic="1" />
     78      <BlinkingBillboard position="-17,-1.5,0" material="Examples/Flare" colour="0.5, 1.0, 0.3" amplitude="0.1" frequency="0.5" phase="180" quadratic="1" />
     79      <DistanceTriggerBeacon name="PlayerDistanceTrigger" />
    7880    </attached>
    7981    <collisionShapes>
     
    9092  </SpaceShip>
    9193
    92 
    93     <!--  <Destroyer
     94   
     95
     96
     97    <Destroyer
    9498      position          = "100,150,0"
    95       collisionType     = dynamic
    96       mass              = 100000
     99      collisionType     = "dynamic"
     100      mass              = "100000"
    97101      velocity          = "0,0,0"
    98       angularDamping    = 0.9999999
    99       health            = 10000
    100       maxhealth         = 10000
    101       initialhealth     = 10000
     102      angularDamping    = "0.9999999"
     103      health            = "10000"
     104      maxhealth         = "10000"
     105      initialhealth     = "10000"
    102106    >
    103107
    104108      <attached>
    105        
    106         <DistanceTriggerBeacon name="beacon1" />
    107         <DockingTarget name="asdf" />
    108 
    109 
    110         <TeamSpawnPoint team=1 position="150,0,7" direction="-1,0,0" roll=90 yaw=0 spawnclass=SpaceShip pawndesign=spaceshipassff />
    111         <TeamSpawnPoint team=1 position="0,0,7" lookat="-1,0,0" roll="90"  yaw=0 spawnclass=SpaceShip pawndesign=spaceshipassff />
    112         <TeamSpawnPoint team=1 position="-50,0,7" lookat="-1,0,0" roll="90" yaw=0 spawnclass=SpaceShip pawndesign=spaceshipassff />
    113         <TeamSpawnPoint team=1 position="100,0,7" lookat="-1,0,0" roll="90" yaw=0 spawnclass=SpaceShip pawndesign=spaceshipassff />
    114         <TeamSpawnPoint team=1 position="50,0,7" lookat="-1,0,0" roll="90" yaw=0 spawnclass=SpaceShip pawndesign=spaceshipassff />
     109
     110        <DistanceTriggerBeacon name="destroyerBeacon" />
     111        <DockingTarget name="theDestroyer" />
     112
     113
     114        <TeamSpawnPoint team="1" position="150,0,7" direction="-1,0,0" roll="90" yaw="0" spawnclass="SpaceShip" pawndesign="spaceshipassff" />
     115        <TeamSpawnPoint team="1" position="0,0,7" lookat="-1,0,0" roll="90"  yaw="0" spawnclass="SpaceShip" pawndesign="spaceshipassff" />
     116        <TeamSpawnPoint team="1" position="-50,0,7" lookat="-1,0,0" roll="90" yaw="0" spawnclass="SpaceShip" pawndesign="spaceshipassff" />
     117        <TeamSpawnPoint team="1" position="100,0,7" lookat="-1,0,0" roll="90" yaw="0" spawnclass="SpaceShip" pawndesign="spaceshipassff" />
     118        <TeamSpawnPoint team="1" position="50,0,7" lookat="-1,0,0" roll="90" yaw="0" spawnclass="SpaceShip" pawndesign="spaceshipassff" />
    115119        <?lua for i = 1, 100, 1 do ?>
    116120          <TeamSpawnPoint
    117             team=0
     121            team="0"
    118122            position="<?lua print((math.random() * 500 + 500) * (math.floor(math.random() + 0.5) * 2 - 1)) ?>,<?lua print((math.random() * 500 + 500) * (math.floor(math.random() + 0.5) * 2 - 1)) ?>,<?lua print((math.random() * 500 + 500) * (math.floor(math.random() + 0.5) * 2 - 1)) ?>"
    119123            lookat="0,0,0"
    120             spawnclass=SpaceShip
    121             pawndesign=spaceshipassff
     124            spawnclass="SpaceShip"
     125            pawndesign="spaceshipassff"
    122126          />
    123127        <?lua end ?>
     
    125129        <Model mesh="Carrier.mesh" scale="5" />
    126130        <Backlight
    127           mainstate=activity
    128           active=false
    129           scale=0.4
    130           name=bltest
     131          mainstate="activity"
     132          active="false"
     133          scale="0.4"
     134          name="bltest"
    131135          position=" 7.6, 0, 6"
    132136          colour="0.2, 0.65, 1.0, 1.0"
    133           width=15
    134           length=1500
    135           lifetime=2
    136           elements=50
     137          width="15"
     138          length="1500"
     139          lifetime="2"
     140          elements="50"
    137141          trailmaterial="Trail/backlighttrail"
    138           turnontime=1
    139           turnofftime=1
     142          turnontime="1"
     143          turnofftime="1"
    140144          material="Flares/ThrusterFlare1"
    141145        />
     146        <Backlight
     147                  scale="1"
     148                  position=" 169, 75, -15"
     149                  colour="1, 0.85, 0.5, 0.5"
     150                  width="40"
     151                  length="1000"
     152                  lifetime="5"
     153                  elements="15"
     154                  trailmaterial="Trail/backlighttrail"
     155                  material="Examples/Flare"
     156                  />
     157        <Backlight
     158                  scale="1"
     159                  position=" 169, -75, -15"
     160                  colour="1, 0.85, 0.5, 0.5"
     161                  width="40"
     162                  length="1000"
     163                  lifetime="5"
     164                  elements="15"
     165                  trailmaterial="Trail/backlighttrail"
     166                  material="Examples/Flare"
     167         />
    142168        <?lua for i=0,8,1 do ?>
    143169          <BlinkingBillboard
     
    146172            colour="1.0, 0.5, 0.3"
    147173            phase="<?lua print(-360/8*i)?>"
    148             amplitude=0.1
    149             frequency=0.5
    150             quadratic=1
     174            amplitude="0.1"
     175            frequency="0.5"
     176            quadratic="1"
    151177          />
    152178
     
    156182            colour="1.0, 0.5, 0.3"
    157183            phase="<?lua print(-360/8*i)?>"
    158             amplitude=0.1
    159             frequency=0.5
    160             quadratic=1
     184            amplitude="0.1"
     185            frequency="0.5"
     186            quadratic="1"
    161187          />
    162188        <?lua end ?>
    163189
    164         <Backlight
    165           scale=1
    166           position=" 169, 75, -15"
    167           colour="1, 0.85, 0.5, 0.5"
    168           width=40
    169           length=1000
    170           lifetime=5
    171           elements=15
    172           trailmaterial="Trail/backlighttrail"
    173           material="Examples/Flare"
    174         />
    175         <Backlight
    176           scale=1
    177           position=" 169, -75, -15"
    178           colour="1, 0.85, 0.5, 0.5"
    179           width=40
    180           length=1000
    181           lifetime=5
    182           elements=15
    183           trailmaterial="Trail/backlighttrail"
    184           material="Examples/Flare" />
    185190      </attached>
    186191      <collisionShapes>
     
    193198        <BoxCollisionShape position="167,0,70"      halfExtents="17, 20, 20" />
    194199      </collisionShapes>
     200
    195201    </Destroyer>
    196     //-->
    197202
    198203  </Scene>
  • code/branches/dockingsystem2/src/modules/docking/Dock.cc

    r8257 r8382  
    3333
    3434#include "Dock.h"
     35
    3536#include "infos/HumanPlayer.h"
    3637#include "worldentities/pawns/Pawn.h"
    3738#include "interfaces/PlayerTrigger.h"
     39#include "controllers/HumanController.h"
     40#include "core/command/ConsoleCommand.h"
     41
    3842
    3943
     
    4145{
    4246    CreateFactory(Dock);
     47
     48    SetConsoleCommand("Dock", "dock",    &Dock::cmdDock).addShortcut().setAsInputCommand();
     49    SetConsoleCommand("Dock", "undock",  &Dock::cmdUndock).addShortcut().setAsInputCommand();
    4350
    4451    Dock::Dock(BaseObject* creator) : StaticEntity(creator)
     
    8087        {
    8188            if(!pTrigger->isForPlayer()) {  // The PlayerTrigger is not exclusively for Pawns which means we cannot extract one.
    82                 COUT(0) << "Docking:execute PlayerTrigger was not triggered by a player.." << std::endl;
     89                COUT(2) << "Docking:execute PlayerTrigger was not triggered by a player.." << std::endl;
    8390                return false;
    8491            }
    8592            pawn = pTrigger->getTriggeringPlayer();
    8693        } else {
    87             COUT(0) << "Docking::execute Not a player trigger, can't extract pawn from it.." << std::endl;
     94            COUT(2) << "Docking::execute Not a player trigger, can't extract pawn from it.." << std::endl;
    8895            return false;
    8996        }
    9097        if(pawn == NULL)
    9198        {
    92             COUT(0) << "Docking::execute Can't retrieve Pawn from Trigger. (" << trigger->getIdentifier()->getName() << ")" << std::endl;
     99            COUT(2) << "Docking::execute Can't retrieve Pawn from Trigger. (" << trigger->getIdentifier()->getName() << ")" << std::endl;
    93100            return false;
    94101        }
     
    98105        if(player == NULL)
    99106        {
    100             COUT(0) << "The PlayerInfo* is NULL." << std::endl;
     107            COUT(2) << "The PlayerInfo* is NULL." << std::endl;
    101108            return false;
    102109        }
     
    105112
    106113        if(bTriggered) {
    107             DockingEffect::invokeEffect(docking::DOCKING, player, effects_);
    108             DockingEffect::invokeEffect(docking::ATTACH, player, effects_);
     114            // Add player to this Docks candidates
     115            candidates.insert(player);
     116
     117            //DockingEffect::invokeEffect(docking::DOCKING, player, effects_);
    109118        } else {
    110             DockingEffect::invokeEffect(docking::RELEASE, player, effects_);
     119            // Remove player from candidates list
     120            candidates.erase(player);
     121
     122            //DockingEffect::invokeEffect(docking::RELEASE, player, effects_);
    111123        }
    112124
     
    115127
    116128
     129    void Dock::cmdDock() {
     130        PlayerInfo* player = HumanController::getLocalControllerSingleton()->getPlayer();
     131        for(ObjectList<Dock>::iterator it = ObjectList<Dock>::begin(); it != ObjectList<Dock>::end(); ++it) {
     132            if(it->dock(player))
     133                break;
     134        }
     135    }
     136
     137    void Dock::cmdUndock() {
     138        PlayerInfo* player = HumanController::getLocalControllerSingleton()->getPlayer();
     139        for(ObjectList<Dock>::iterator it = ObjectList<Dock>::begin(); it != ObjectList<Dock>::end(); ++it) {
     140            if(it->undock(player))
     141                break;
     142        }
     143    }
     144
     145
     146    bool Dock::dock(PlayerInfo* player) {
     147        // Check if player is a candidate
     148        if(candidates.find(player) == candidates.end()) {
     149            COUT(0) << "Player is not a candidate!";
     150            return false;
     151        }
     152
     153        // Remove player from candidates, add to docked players and invoke docking effect
     154        candidates.erase(player);
     155        docked.insert(player);
     156        DockingEffect::invokeEffect(docking::ATTACH, player, effects);
     157        return true;
     158    }
     159
     160    bool Dock::undock(PlayerInfo* player) {
     161        // Check if player is docked to this Dock
     162        if(docked.find(player) == docked.end()) {
     163            COUT(0) << "Player is not docked to this Dock." << std::endl;
     164            return false;
     165        }
     166
     167        // Remove player from docked, add to candidates and reverse DockingEffect
     168        docked.erase(player);
     169        candidates.insert(player);
     170        DockingEffect::invokeEffect(docking::RELEASE, player, effects);
     171        return true;
     172    }
     173
     174
    117175    bool Dock::addEffect(DockingEffect* effect) {
    118176        assert(effect);
    119         effects_.push_back(effect);
     177        effects.push_back(effect);
    120178        return true;
    121179    }
     
    123181    const DockingEffect* Dock::getEffect(unsigned int index) const {
    124182        int i = index;
    125         for (std::list<DockingEffect*>::const_iterator effect = this->effects_.begin(); effect != this->effects_.end(); ++effect)
    126         {
     183        for (std::list<DockingEffect*>::const_iterator effect = this->effects.begin(); effect != this->effects.end(); ++effect) {
    127184            if(i == 0)
    128185               return *effect;
    129 
    130186            i--;
    131187        }
  • code/branches/dockingsystem2/src/modules/docking/Dock.h

    r8196 r8382  
    3636#define _Dock_H__
    3737
     38#include <map>
     39
    3840#include "core/CoreIncludes.h"
    3941#include "core/XMLPort.h"
     
    4143
    4244#include "worldentities/StaticEntity.h"
     45#include "notifications/NotificationManager.h"
     46
    4347#include "DockingEffect.h"
    4448#include "DockingPrereqs.h"
    4549
    46 namespace orxonox {
    47 
     50namespace orxonox {
    4851
    4952    class _DockingExport Dock : public StaticEntity {
     
    6063        const DockingEffect* getEffect(unsigned int index) const; //!< Get the DockingEffect at a given index.
    6164
     65        bool dock(PlayerInfo* player); //!< Returns true if given player docked successfully (player must be a candidate)
     66        bool undock(PlayerInfo* player); //!< Undocks a player (player must be docked)
     67
     68        static void cmdDock();
     69        static void cmdUndock();
     70
    6271    private:
    63         std::list<DockingEffect*> effects_; //!< The list of DockingEffects to be executed when a player docks.
     72        std::set<PlayerInfo*> candidates; //!< A set of all players which are allowed to dock using the console command.
     73        std::set<PlayerInfo*> docked; //!< A set of all docked players
     74        std::list<DockingEffect*> effects; //!< The list of DockingEffects to be executed when a player docks.
    6475    };
    6576
  • code/branches/dockingsystem2/src/modules/docking/DockToShip.cc

    r8257 r8382  
    8989        }
    9090
     91        // Make sure target isn't removed when undocking
     92        dockTo->setDestroyWhenPlayerLeft(false);
    9193        player->startTemporaryControl(dockTo);
    9294
     
    9799    {
    98100        COUT(0) << "DockToShip::release" << endl;
     101
     102        player->stopTemporaryControl();
     103
    99104        return true;
    100105    }
  • code/branches/dockingsystem2/src/orxonox/infos/PlayerInfo.cc

    r8289 r8382  
    223223        this->controllableEntity_->setController(0);
    224224       
    225         this->controllableEntity_ = this->previousControllableEntity_.back();
     225//        this->controllableEntity_ = this->previousControllableEntity_.back();
    226226        do {
    227227            this->controllableEntity_ = this->previousControllableEntity_.back();
Note: See TracChangeset for help on using the changeset viewer.