Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 14, 2010, 11:20:16 AM (14 years ago)
Author:
dafrick
Message:

Some more documenting.

Location:
code/trunk/src/modules/pickup
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/modules/pickup/PickupManager.h

    r7533 r7540  
    164164            PickupRepresentation* defaultRepresentation_; //!< The default PickupRepresentation.
    165165
    166             std::map<const PickupIdentifier*, PickupRepresentation*, PickupIdentifierCompare> representations_; //!< Map linking @ref oroxnox::PickupIdentifier "PickupIdentifiers" (representing types of @ref orxonox::Pickupable "Pickupables") and @ref orxonox::PickupRepresentation "PickupRepresentations".
    167             std::map<uint32_t, PickupRepresentation*> representationsNetworked_; //!< Map linking the @ref orxonox::PickupRepresentation "PickupRepresentation's" objectId to the @ref orxonox::PickupRepresentation "PickupRepresentation" itself. It is used for networking purposes.
     166            std::map<const PickupIdentifier*, PickupRepresentation*, PickupIdentifierCompare> representations_; //!< Map linking PickupIdentifiers (representing types of Pickupables) and PickupRepresentations.
     167            std::map<uint32_t, PickupRepresentation*> representationsNetworked_; //!< Map linking the PickupRepresentation's objectId to the PickupRepresentation itself. It is used for networking purposes.
    168168
    169             std::map<uint32_t, PickupInventoryContainer*> pickupInventoryContainers_; //!< Map linking a number identifying a @ref orxonox::Pickupable "Pickupable" to a @ref orxonox::PickupInventoryContainer "PickupInventoryContainer", which contains all necessary information about that @ref orxonox::Pickupable "Pickupable".
     169            std::map<uint32_t, PickupInventoryContainer*> pickupInventoryContainers_; //!< Map linking a number identifying a Pickupable to a PickupInventoryContainer, which contains all necessary information about that Pickupable.
    170170            std::map<uint32_t, PickupInventoryContainer*>::iterator pickupsIterator_; //!< An iterator pointing to the current Pickupable in pickupsList_.
    171171
    172             std::map<uint32_t, WeakPtr<Pickupable>*> pickups_; //!< Map linking a number identifying a @ref orxonox::Pickupable "Pickupable" to a weak pointer of a @ref orxonox::Pickupable "Pickupable".
    173             std::map<Pickupable*, uint32_t> indexes_;//!< Map linking @ref orxonox::Pickupable "Pickupable" to the number identifying it.
     172            std::map<uint32_t, WeakPtr<Pickupable>*> pickups_; //!< Map linking a number identifying a Pickupable to a weak pointer of a Pickupable.
     173            std::map<Pickupable*, uint32_t> indexes_;//!< Map linking Pickupable to the number identifying it.
    174174
    175175            void updateGUI(void); //!< Updates the PickupInventory GUI.
  • code/trunk/src/modules/pickup/PickupRepresentation.cc

    r7533 r7540  
    3636#include "core/CoreIncludes.h"
    3737#include "core/GameMode.h"
     38#include "util/StringUtils.h"
     39
    3840#include "graphics/Billboard.h"
    39 #include "util/StringUtils.h"
     41
    4042#include "PickupManager.h"
    4143
     
    5557
    5658        this->initialize();
    57         this->setSyncMode(0x0);
     59        this->setSyncMode(0x0); // The default PickupRperesentation created by each PickupManager is not synchronised, since it only exists locally.
    5860    }
    5961
     
    6971        this->registerVariables();
    7072
    71         PickupManager::getInstance().registerRepresentation(this); //!< Registers the PickupRepresentation with the PickupManager.
     73        PickupManager::getInstance().registerRepresentation(this); // Registers the PickupRepresentation with the PickupManager.
    7274    }
    7375
     
    107109    }
    108110
     111    /**
     112    @brief
     113        Registers the variables that need to be synchornised.
     114    */
    109115    void PickupRepresentation::registerVariables(void)
    110116    {
     
    131137        if(GameMode::isMaster())
    132138        {
    133             PickupManager::getInstance().registerRepresentation(this->pickup_->getPickupIdentifier(), this); //!< Registers the PickupRepresentation with the PickupManager through the PickupIdentifier of the Pickupable it represents.
     139            // Registers the PickupRepresentation with the PickupManager through the PickupIdentifier of the Pickupable it represents.
     140            PickupManager::getInstance().registerRepresentation(this->pickup_->getPickupIdentifier(), this);
    134141        }
    135142
     
    156163            {
    157164                COUT(4) << "PickupRepresentation: Spawner template is empty." << std::endl;
    158                 //!< If neither spawnerRepresentation nor spawnerTemplate was specified
     165                // If neither spawnerRepresentation nor spawnerTemplate was specified
    159166                return this->getDefaultSpawnerRepresentation(spawner);
    160167            }
     
    180187        Returns a pointer to the StaticEntity.
    181188    */
    182     //TODO: Possibility to define default representation through XML.
     189    //TODO: Possibility to define default representation through XML?
    183190    StaticEntity* PickupRepresentation::getDefaultSpawnerRepresentation(PickupSpawner* spawner)
    184191    {
  • code/trunk/src/modules/pickup/PickupRepresentation.h

    r7539 r7540  
    4242#include "pickup/PickupIdentifier.h"
    4343#include "worldentities/StaticEntity.h"
     44
    4445#include "PickupSpawner.h"
    4546
     
    5253    /**
    5354    @brief
    54         The PickupRepresentation class represents a specific pickup type (identified by its PickupIdentifier). It defines the information displayed in the GUI and how PickupSpawners that spawn the pickup type look like.
    55         They are created through XML and are registered with the PickupManager.
     55        The PickupRepresentation class represents a specific pickup type (identified by its @ref orxonox::PickupIdentififer "PickupIdentifier"). It defines the information displayed in the GUI (PickupInventory) and how @ref orxonox::PickupSpawner "PickupSpawners" that spawn the pickup type look like.
     56        They are created through XML and are registered with the @ref orxonox::PickupManager "PickupManager".
     57
     58        Creating a PickupRepresentation in XML could look as follows:
     59        @code
     60        <PickupRepresentation
     61            name = "My awesome Pickup"
     62            description = "This is the most awesome Pickup ever to exist."
     63            spawnerTemplate = "awesomePickupRepresentation"
     64            inventoryRepresentation = "AwesomePickup"
     65        >
     66            <pickup>
     67                <SomePickup />
     68            </pickup>
     69        </PickupRepresentation>
     70        @endcode
     71        As you might have noticed, there is a parameter called <em>spawnerTemplate</em> and also another parameter called <em>inventoryRepresentation</em>. Let's first explain the second one, <em>inventoryRepresentation</em>.
     72        - The <b>inventoryRepresentation</b> specifies the image that is displayed in the PickupInventory for the specific type of @ref orxonox::Pickupable "Pickupable". More technically, it is the name of an image located in the <code>PickupInventory.imageset</code>, which in turn is located in <code>data_extern/gui/imagesets/</code>.
     73        - The <b>spawnerTemplate</b> specifies how the type of @ref orxonox::Pickupable "Pickupable" (or more precisely the @ref orxonox::PickupSpawner "PickupSpawner", that spawns that type of @ref orxonox::Pickupable "Pickupable") is displayed ingame. It is a @ref orxnox::Template "Template" defined in XML. The <em>spawnerTemplate</em> can be specified as follows (keep in mind, that the template needs to have been specified before the definition of the PickupRepresentation that uses it).
     74        @code
     75        <Template name="awesomePickupRepresentation">
     76            <PickupRepresentation>
     77                <spawner-representation>
     78                    <StaticEntity>
     79                        <attached>
     80                            <!-- Here you can put all the objects which define the look of the spawner. -->
     81                        </attached>
     82                    </StaticEntity>
     83                </spawner-representation>
     84            </PickupRepresentation>
     85        </Template>
     86        @endcode
     87
     88        For the purpose of them working over the network, they are synchronised.
    5689
    5790    @author
     
    69102            virtual ~PickupRepresentation(); //!< Destructor.
    70103
    71             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     104            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a PickupRepresentation object through XML.
    72105
    73106            /**
     
    152185            StaticEntity* getDefaultSpawnerRepresentation(PickupSpawner* spawner); //!< Get the default spawnerRepresentation for a specific PickupSpawner.
    153186
    154             void registerVariables(void); //!< Register some variables for synchronisation.
     187            void registerVariables(void); //!< Registers the variables that need to be synchronised.
    155188
    156189            std::string name_; //!< The name of the Pickupable represented by this PickupRepresentation.
  • code/trunk/src/modules/pickup/PickupSpawner.cc

    r7493 r7540  
    106106    {
    107107        this->triggerDistance_ = 10;
    108         this->respawnTime_ = 0;
     108        this->respawnTime_ = 0; //TODO: Smart? Shouldn't we have a better mechanism to prevent unwanted multiple pickups?
    109109        this->maxSpawnedItems_ = INF;
    110110        this->spawnsRemaining_ = INF;
  • code/trunk/src/modules/pickup/PickupSpawner.h

    r7494 r7540  
    3939
    4040#include <string>
     41
     42#include "tools/Timer.h"
     43
    4144#include "interfaces/Pickupable.h"
    42 #include "tools/Timer.h"
    4345
    4446#include "tools/interfaces/Tickable.h"
     
    4951    /**
    5052        @brief
    51             The PickupSpawner class is responsible for spawning pickups of a specific type.
    52             Forthermore it can be specified how long the time interval between spawning two items is and how many pickups are spawned at maximum, amongst other things.
     53            The PickupSpawner class is responsible for spawning @ref orxonox::Pickupable "Pickupables" of a specific type.
     54            Furthermore it can be specified how long the time interval between spawning two items is and how many @ref orxonox::Pickupable "Pickupables" are spawned at maximum, amongst other things. The parameters that can be used to further specify the behaviour of the PickupSpawner are:
     55            - The <b>triggerDistance</b> can be used to specify how far away an entity has to be to still trigger the PickupSPawner (and thus receive a @ref orxonox::Pickupable "Pickupable" form it). The default is 10.
     56            - The <b>respawnTime</b> is the time in seconds that passes until the PickupSpawner is enabled again, after having spawned a @ref orxonox::Pickupable "Pickupable". The default is 0.
     57            - The <b>maxSpawnedItems</b> is the number of @ref orxonox::Pickupable "Pickupables" that are spawned by this PickupSpawner at the most. The default is -1, which denotes infinity.
     58
     59            A PickupSpawner is created in XML, which can be done in the following fashion:
     60            @code
     61            <PickupSpawner position="-100,0,-100" respawnTime="30" maxSpawnedItems="10">
     62                <pickup>
     63                    <SomePickup >
     64                </pickup>
     65            </PickupSpawner>
     66            @endcode
     67            As we can see, since the PickupSpawner is a StaticEntity, it also has spatial coordinates. We can also see, that the type of @ref orxonox::Pickupable "Pickupable" which is spawned hast to be specified as well.
    5368
    5469        @author
     
    5671        @author
    5772            Damian 'Mozork' Frick
     73
     74        @ingroup Pickup
    5875    */
    5976    class _PickupExport PickupSpawner : public StaticEntity, public Tickable
     
    6683            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);  //!< Method for creating a PickupSpawner through XML.
    6784            virtual void changedActivity(); //!< Invoked when activity has changed (set visibilty).
    68             virtual void tick(float dt);
     85            virtual void tick(float dt); //!< Tick, checks if any Pawn is close enough to trigger.
    6986
    7087            /**
Note: See TracChangeset for help on using the changeset viewer.