Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7493 for code/trunk/src


Ignore:
Timestamp:
Sep 27, 2010, 7:53:30 PM (14 years ago)
Author:
dafrick
Message:

Fixing small bug in Script (regarding number of executions).
Fixed bug in WorldEntity, that caused the visibility and activity to be synchronized incorrectly (since bVisibleMem and bActiveMem are not synchronized).
Some small changed in documentation.
Started "synchronizing" pickups. Seems to work (except GUI), but haven't done any extensive testing yet.

Location:
code/trunk/src
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/modules/objects/Script.cc

    r7486 r7493  
    186186        {
    187187            // If the number of executions have been used up.
    188             if(this->times_ != Script::INF && this->remainingExecutions_ == 0)
     188            if(this->times_ != Script::INF && this->remainingExecutions_ <= 0)
    189189                return;
    190190        }
     
    209209                    callStaticNetworkFunction(Script::executeHelper, it->first, this->getCode(), this->getMode(), this->getNeedsGraphics());
    210210                    if(this->times_ != Script::INF) // Decrement the number of remaining executions.
     211                    {
    211212                        this->remainingExecutions_--;
     213                        if(this->remainingExecutions_ <= 0)
     214                            break;
     215                    }
    212216                }
    213217            }
  • code/trunk/src/modules/pickup/CollectiblePickup.h

    r7456 r7493  
    4444    /**
    4545    @brief
    46         Collectible Pickup class. Any pickup inheriting from this class can be added to a PickupCollection and thus be part uf such.
     46        The CollectiblePickup class encompasses all @ref orxonox::Pickupable "Pickupables" that can be added to a @ref orxonox::PickupCollection "PickupCollection" and thus be part of such.
     47
     48        All you need to do to make your @ref orxonox:.Pickupable "Pickupable" a CollectiblePickup is to, in some way, inherit from it. (The @ref orxonox::Pickup Pickup class, for example, is already a CollectiblePickup).
     49
    4750    @author
    4851        Damian 'Mozork' Frick
  • code/trunk/src/modules/pickup/DroppedPickup.cc

    r7401 r7493  
    5151    {
    5252        RegisterObject(DroppedPickup);
    53 
    5453    }
    5554
     
    8382    DroppedPickup::~DroppedPickup()
    8483    {
    85         if(this->pickup_ != NULL && this->pickup_->isPickedUp())
    86         {
    87             this->pickup_ = NULL;
    88         }
     84
    8985    }
    9086
     
    9692    Pickupable* DroppedPickup::getPickup(void)
    9793    {
    98         return this->pickup_;
     94        Pickupable* pickup = this->pickup_;
     95        this->pickup_ = NULL;
     96        return pickup;
    9997    }
    10098
  • code/trunk/src/modules/pickup/DroppedPickup.h

    r7456 r7493  
    4545    /**
    4646    @brief
    47         Special PickupSpawner that is created whe a Pickupable is dropped. It just spawns one pickup, the one that was dropped.
     47        Special PickupSpawner that is created when a @ref orxonox::Pickupable "Pickupable" is dropped. It just spawns one pickup, the one that was dropped.
     48
    4849    @author
    4950        Daniel 'Huty' Haggenmueller
     51    @author
    5052        Damian 'Mozork' Frick
    5153    */
  • code/trunk/src/modules/pickup/PickupSpawner.cc

    r7401 r7493  
    3535
    3636#include "core/CoreIncludes.h"
     37#include "core/GameMode.h"
    3738#include "core/Template.h"
    3839#include "core/XMLPort.h"
     
    9495            PickupRepresentation* representation = PickupManager::getInstance().getRepresentation(this->pickup_->getPickupIdentifier());
    9596            this->attach(representation->getSpawnerRepresentation(this));
     97            this->setActive(true); //TODO: Needed?
    9698        }
    9799    }
     
    146148        {
    147149            PickupRepresentation* representation = PickupManager::getInstance().getRepresentation(this->pickup_->getPickupIdentifier());
    148             representation->setVisible(this->isActive());
    149150            this->attach(representation->getSpawnerRepresentation(this));
    150             this->setActive(true);
     151            this->setActive(true); //TODO: Needed?
    151152        }
    152153    }
     
    160161        SUPER(PickupSpawner, changedActivity);
    161162
    162         this->setVisible(this->isActive());
     163        if(GameMode::isMaster())
     164            this->setVisible(this->isActive());
    163165    }
    164166
     
    169171        Time since last tick.
    170172    */
    171     //TODO: Replace with collisions.
     173    //TODO: Replace with collisions?
    172174    void PickupSpawner::tick(float dt)
    173175    {
    174176        SUPER(PickupSpawner, tick, dt);
    175177
    176         //! If the PickupSpawner is active.
    177         if (this->isActive())
     178        // If the PickupSpawner is active.
     179        if(GameMode::isMaster() && this->isActive())
    178180        {
    179181            SmartPtr<PickupSpawner> temp = this; //Create a smart pointer to keep the PickupSpawner alive until we iterated through all Pawns (in case a Pawn takes the last pickup)
    180182
    181             //! Iterate trough all Pawns.
     183            // Iterate trough all Pawns.
    182184            for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); ++it)
    183185            {
    184186                Vector3 distance = it->getWorldPosition() - this->getWorldPosition();
    185187                PickupCarrier* carrier = dynamic_cast<PickupCarrier*>(*it);
    186                 //! If a Pawn, that fits the target-range of the item spawned by this Pickup, is in trigger-distance.
     188                // If a Pawn, that fits the target-range of the item spawned by this Pickup, is in trigger-distance.
    187189                if (distance.length() < this->triggerDistance_ && carrier != NULL && carrier->isTarget(this->pickup_))
    188190                {
     
    214216    {
    215217        if(this->spawnsRemaining_ != INF)
    216         {
    217218            this->spawnsRemaining_--;
    218         }
     219
    219220        if(this->spawnsRemaining_ != 0 && this->respawnTime_ > 0)
    220221        {
     
    283284    void PickupSpawner::trigger(Pawn* pawn)
    284285    {
    285         if (this->isActive()) //!< Checks whether PickupSpawner is active.
     286        if(this->isActive()) // Checks whether PickupSpawner is active.
    286287        {
    287288            COUT(4) << "PickupSpawner (&" << this << ") triggered and active." << std::endl;
     
    303304            Pickupable* pickup = this->getPickup();
    304305
    305             if(target != NULL && pickup != NULL)
    306             {
    307                 if(pickup->pickup(target))
    308                     this->decrementSpawnsRemaining();
    309                 else
    310                 {
    311                     this->selfDestruct_ = true;
    312                     pickup->destroy();
    313                 }
    314             }
    315             else
    316             {
    317                 if(target == NULL)
    318                     COUT(1) << "PickupSpawner (&" << this << "): Pickupable has no target." << std::endl;
    319 
    320                 if(pickup == NULL)
    321                     COUT(1) << "PickupSpawner (&" << this << "): getPickup produced an error, no Pickupable created." << std::endl;
    322                 else
    323                 {
    324                     this->selfDestruct_ = true;
    325                     pickup->destroy();
    326                 }
    327             }
     306            assert(pickup);
     307            assert(target);
     308            assert(pickup->pickup(target));
     309
     310            this->decrementSpawnsRemaining();
    328311        }
    329312    }
  • code/trunk/src/modules/pickup/items/HealthPickup.h

    r7456 r7493  
    6262        A pickup that can do (dependent upon the parameters) lots of different things to the health of a Pawn.
    6363        There are 4 parameters that can be chosen:
    64         1) The health. The amount of health that (in a way dependent on the other parameters) is transfered to the Pawn.
    65         2) The activation type: It can be chosen to be either 'immediate' or 'onUse'. The activation type essentially (as indicated by the name) defines when the health is transfered, either immediately after being picked up or only after the player uses it.
    66         3) The duration type: It can be chosen to be either 'once' or 'continuous'. For 'once' the specified health is transfered once to the Pawn, for 'continuous' the set health is transfered over a span of time at a rate defined by the health rate parameter.
    67         4) The health type: The health type can be chosen to be 'limited', 'temporary' or 'permanent'. 'limited' means that the health is increased only to the maximum health of the Pawn. 'temporary' means that the maximum health is temporarily elevated but will be set back as soon as the pickup is no longer in use. 'permanent' means that the maximum health of the Pawn is increased such that the health provided by the pickup will fit in and the maximum health stays that way.
     64        - The @b health The amount of health that (in a way dependent on the other parameters) is transfered to the Pawn.
     65        - The @b activation @b type It can be chosen to be either 'immediate' or 'onUse'. The activation type essentially (as indicated by the name) defines when the health is transfered, either immediately after being picked up or only after the player uses it.
     66        - The @b duration @b type It can be chosen to be either 'once' or 'continuous'. For 'once' the specified health is transfered once to the Pawn, for 'continuous' the set health is transfered over a span of time at a rate defined by the health rate parameter.
     67        - The @b health @b type The health type can be chosen to be 'limited', 'temporary' or 'permanent'. 'limited' means that the health is increased only to the maximum health of the Pawn. 'temporary' means that the maximum health is temporarily elevated but will be set back as soon as the pickup is no longer in use. 'permanent' means that the maximum health of the Pawn is increased such that the health provided by the pickup will fit in and the maximum health stays that way.
    6868    @author
    6969        Damian 'Mozork' Frick
  • code/trunk/src/modules/pickup/items/InvisiblePickup.h

    r7456 r7493  
    5050        A pickup that makes the Pawn invisible.
    5151        There are 2 parameters that can be chosen:
    52         1) The activation type: It can be chosen to be either 'immediate' or 'onUse'. The activation type essentially (as indicated by the name) defines when the Pawn will be invisible, either immediately after being picked up or only after the player uses it.
    53         2) The duration type: It can be chosen how long the Pawn will be invisibel.
     52        - The @b activation @b type It can be chosen to be either 'immediate' or 'onUse'. The activation type essentially (as indicated by the name) defines when the Pawn will be invisible, either immediately after being picked up or only after the player uses it.
     53        - The @b duration @b type It can be chosen how long the Pawn will be invisibel.
    5454    @author
    5555        Benedict Simlinger
  • code/trunk/src/modules/pickup/items/MetaPickup.h

    r7456 r7493  
    5858    @brief
    5959        The MetaPickup is a pickup that can, depending on the parameter 'metaType', do different things. If the 'metaType' is set to
    60         1) 'use', all the pickups, the PickupCarrier has, are immediately set to used upon pickup of the MetaPickup.
    61         2) 'drop', all the pickups, the PickupCarrier has, are immediately dropped upon pickup of the MetaPickup.
    62         3) 'destroy', all the pickups, the PickupCarrier has, are immediately destroyed upon pickup of the MetaPickup.
    63         4) 'destroyCarrier', the PickupCarrier is immediately destroyed upon pickup of the MetaPickup.
     60        - @b use All the pickups, the PickupCarrier has, are immediately set to used upon pickup of the MetaPickup.
     61        - @b drop All the pickups, the PickupCarrier has, are immediately dropped upon pickup of the MetaPickup.
     62        - @b destroy All the pickups, the PickupCarrier has, are immediately destroyed upon pickup of the MetaPickup.
     63        - @b destroyCarrier The PickupCarrier is immediately destroyed upon pickup of the MetaPickup.
    6464    @author
    6565        Damian 'Mozork' Frick
  • code/trunk/src/modules/pickup/items/ShieldPickup.h

    r7456 r7493  
    5151        A Pickup which can add a Shield to the Pawn.
    5252
    53         1) The percentage: The percentage the shield takes from the damage dealt to a Pawn
    54         2) The hit points: The amount of damage points a shield can teake before collapsing
    55         3) The activation type: 'immediate' or 'onUse'. defines if the item is used when it's picked up or only after the player chooses to use it.
    56         4) The duration: the activation time of the pickup.
     53        There are 4 parameters that can be cosen.
     54        - The @b percentage The percentage the shield takes from the damage dealt to a Pawn
     55        - The @b hit @b points The amount of damage points a shield can teake before collapsing
     56        - The @b activation @b type 'immediate' or 'onUse'. defines if the item is used when it's picked up or only after the player chooses to use it.
     57        - The @b duration the activation time of the pickup.
    5758
    5859    @author
  • code/trunk/src/modules/pickup/items/SpeedPickup.h

    r7456 r7493  
    5050        A Pickup which can manipulate the Speed of a Pawn.
    5151
    52         1) The speed multiplier:
    53            The additional (forward) speed:
    54         2) The activation type: 'immediate' or 'onUse'. defines if the item is used when it's picked up or only after the player chooses to use it.
    55         4) The duration: the activation time of the pickup.
     52        There are 4 parameters that can be cosen:
     53        - The @b speed @b multiplier
     54        - The @b additional (forward) @b speed
     55        - The @b activation @b type 'immediate' or 'onUse'. defines if the item is used when it's picked up or only after the player chooses to use it.
     56        - The @b duration The activation time of the pickup.
    5657
    5758    @author
  • code/trunk/src/orxonox/interfaces/Pickupable.cc

    r7163 r7493  
    6868    Pickupable::~Pickupable()
    6969    {
    70         COUT(4) << "Pickupable (" << this->getIdentifier()->getName() << ") (&" << this << ") destroyed." << std::endl;
    7170        if(this->pickupIdentifier_ != NULL)
     71        {
     72            COUT(4) << "Pickupable (" << this->getIdentifier()->getName() << ") (&" << this << ") destroyed." << std::endl;
    7273            this->pickupIdentifier_->destroy();
     74        }
    7375    }
    7476
  • code/trunk/src/orxonox/worldentities/WorldEntity.cc

    r7401 r7493  
    214214        SUPER(WorldEntity, changedActivity);
    215215
    216         for (std::set<WorldEntity*>::const_iterator it = this->getAttachedObjects().begin(); it != this->getAttachedObjects().end(); it++)
    217         {
    218             if(!this->isActive())
    219             {
    220                 (*it)->bActiveMem_ = (*it)->isActive();
    221                 (*it)->setActive(this->isActive());
    222             }
    223             else
    224             {
    225                 (*it)->setActive((*it)->bActiveMem_);
     216        if(GameMode::isMaster())
     217        {
     218            for (std::set<WorldEntity*>::const_iterator it = this->getAttachedObjects().begin(); it != this->getAttachedObjects().end(); it++)
     219            {
     220                if(!this->isActive())
     221                {
     222                    (*it)->bActiveMem_ = (*it)->isActive();
     223                    (*it)->setActive(this->isActive());
     224                }
     225                else
     226                {
     227                    (*it)->setActive((*it)->bActiveMem_);
     228                }
    226229            }
    227230        }
     
    236239        SUPER(WorldEntity, changedVisibility);
    237240
    238         for (std::set<WorldEntity*>::const_iterator it = this->getAttachedObjects().begin(); it != this->getAttachedObjects().end(); it++)
    239         {
    240             if(!this->isVisible())
    241             {
    242                 (*it)->bVisibleMem_ = (*it)->isVisible();
    243                 (*it)->setVisible(this->isVisible());
    244             }
    245             else
    246             {
    247                 (*it)->setVisible((*it)->bVisibleMem_);
     241        if(GameMode::isMaster())
     242        {
     243            for (std::set<WorldEntity*>::const_iterator it = this->getAttachedObjects().begin(); it != this->getAttachedObjects().end(); it++)
     244            {
     245                if(!this->isVisible())
     246                {
     247                    (*it)->bVisibleMem_ = (*it)->isVisible();
     248                    (*it)->setVisible(this->isVisible());
     249                }
     250                else
     251                {
     252                    (*it)->setVisible((*it)->bVisibleMem_);
     253                }
    248254            }
    249255        }
Note: See TracChangeset for help on using the changeset viewer.