Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8108 for code


Ignore:
Timestamp:
Mar 23, 2011, 9:57:54 PM (14 years ago)
Author:
dafrick
Message:

Merging changes from tetris branch into trunk, since they are also useful, there.

Location:
code/trunk
Files:
21 edited
5 copied

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/doc/api/Groups.dox

    r7679 r8108  
    119119    @defgroup Notifications Notifications
    120120    @ingroup Modules
    121 
    122     @ref orxonox::Notification "Notifications" are short messages, that can be sent from anywhere in Orxonox and then are displayed on the screen to inform the user about some occurence he has to know about. Such an occurence could be, that he just shot and killed his Archnemesis Overlord3, that he just got a new Pickup or that he received a Quest and needs to have a look at the Quest-Menu.
    123 
    124     @section NotificationsUsage Usage
    125     Let's very briefly talk about what you have to do to either send @ref orxonox::Notification "Notifications" from some part of Orxonox or display Notifications on your screen.
    126 
    127     @subsection NotifictionsSending Sending notifications
    128     Sending a new @ref orxonox::Notification "Notification" from (almost) anywhere in Orxonox is fairly easy.
    129     You first have to decide on a message, it shouldn't be too long but be long enough to get your point accross.
    130     Then you have to decide on a sender. The sender is a string by which the different @ref orxonox::NotificationQueue "NotificationQueues" (the entities that display the @ref orxonox::Notification "Notifications") can decide whether they should display the @ref orxonox::Notification "Notification" or not. So the sender is some string that identifies a group of @ref orxonox::Notification "Notifications" that have something in common or some entity that is sending them. For example: All @ref orxonox::Notification "Notifications" sent by any part of the Questsystem have "questsystem" as sender and thus we could create a @ref orxonox::NotificationQueue "NotificationQueue" that only displays @ref orxonox::Notification "Notifications" from the Questsystem, but more to that later.
    131     And lastly you have to decide to whom you want to send this @ref orxonox::Notification "Notification". You have to get the clientId of the intended recipient (e.g. trough a @ref orxonox::PlayerInfo "PlayerInfo") or you only send the @ref orxonox::Notification "Notification" locally, either by setting the clientId to Host::getPlayerID() or by setting the variable 'isLocal' to true, and setting clientId to what ever you want, since it will be ignored.
    132     Once you have decided all that you can send the Notification by calling:
    133     @code
    134     NotificationManager::sendNotification(message, clientId, sender, isLocal); // isLocal = false can be ommitted since that is the default value.
    135     @endcode
    136 
    137     @subsection NotificationsDisplay Displaying notifications
    138     Displaying @ref orxonox::Notification "Notifications" is even easier, all you need to do is to load the NotificationLayer in the level, where you want @ref orxonox::Notification "Notifications" displayed. You can either do this manually by executing the following command in the console:
    139     @code
    140     showGUI NotificationLayer false true
    141     @endcode
    142     Or automatically, by adding a @ref orxonox::Script "Script" to the levelfile that does it for you:
    143     @code
    144     <Script code="showGUI NotificationLayer false true" needsGraphics="true" />
    145     @endcode
    146 
    147     If you want to change the way the @ref orxonox::Notification "Notifications" are displayed, you can enter the (at this point rather rudimentary) edit mode and add new @ref orxonox::NotificationQueue "NotificationQueues" or change position and properties of the existing ones, by executing the following command in the console:
    148     @code
    149     enterEditMode
    150     @endcode
    151 
    152     @section NotificationsTechincalDetails Technical details
    153     The Notifications module has three major parts that interact with each other. First there is the @ref orxonox::NotificationQueue "NotificationQueue", this is the entity that (logically, not effectively) displays @ref orxonox::Notification "Notifications" according to some rules, then there is the NotificationLayer, which is the GUI which (actually) displays @ref orxonox::Notification "Notifications" by visualizing the @ref orxonox::NotificationQueue "NotificationQueues" and as a result also the @ref orxonox::Notification "Notifications", that are displayed by the respective @ref orxonox::NotificationQueue "NotificationQueues" and lastly there is the @ref orxonox::NotificationManager "NotificationManager", which connects these two.
    154 
    155     @subsection NotificationQueue NotificationQueue
    156     The @ref orxonox::NotificationQueue "NotificationQueue" is the entity, that (as said earlier) logically displays @ref orxonox::Notification "Notifications". Furthermore a @ref orxonox::NotificationQueue "NotificationQueue" displays only a subset of all the @ref orxonox::Notification "Notifications". The parameters that reduce the range of displayed @ref orxonox::Notification "Notifications" are:
    157     - @b senders The senders, the set of targets of a @ref orxonox::NotificationQueue "NotificationQueue" is the set of senders a @ref orxonox::NotificationQueue "NotificationQueue" displays  @ref orxonox::Notification "Notifications" from. E.g. If one would set the senders to "questsystem" then only  @ref orxonox::Notification "Notifications" from the Questsystem would be displayed in that particular queue. If you set senders to "all" then all Notifications will be displayed. Different senders can be concatinated with commas.
    158     - @b size The size specifies how many @ref orxonox::Notification "Notifications" are displayed at the most, if there are more @ref orxonox::Notification "Notifications" that could be displayed, then only the most recent are displayed.
    159     - @b displayTime The display time specifies how long a @ref orxonox::Notification "Notification" is displayed at the most.
    160 
    161     @subsection NotificationLayer NotificationLayer
    162     The NotificationLayer is a GUI sheet, that displays all the @ref orxonox::NotificationQueue "NotificationQueues" and their @ref orxonox::Notification "Notifications". In its normal mode of operation it is transparent to input, meaning that it only functions as a means of displaying, however if switched to edit mode the NotificationLayer no longer is transparent to input and allows for the adding, removal and modification of @ref orxonox::NotificationQueue "NotificationQueues". For every @ref orxonox::NotificationQueue "NotificationQueue" there is the equivalent representation in the NotificationLayer. So @ref orxonox::NotificationQueue "NotificationQueues" are not each represented by a GUI sheet, but thely all belong to one and the same GUI sheet, the NotificationLayer.
    163 
    164     @subsection NotificationManager NotificationManager
    165     The @ref orxonox::NotificationManager "NotificationManager" is (hence the name) the managing entity in this setting. It is responsible for the registering and unregistering of @ref orxonox::NotificationListener "NotificationListeners" (which the @ref orxonox::NotificationQueue "NotificationQueue" is) and also informs them about changes related to @ref orxonox::Notification "Notifications". It is also responsible for the creation and destruction of @ref orxonox::NotificationQueue "NotificationQueues" through the NotificationLayer and is also the point of approach for the NotificationLayer to get information it needs to display the queues. Finally the @ref orxonox::NotificationManager "NotificationManager" is responsible for sending (and in the process creating) @ref orxonox::Notification "Notifications" and is a means for the @ref orxonox::NotificationQueue "NotificationQueues" to get the information they need about @ref orxonox::Notification "Notifications".
    166 
    167     @subsection Notification Notification
    168     The @ref orxonox::Notification "Notification" class is more or less a data structure that groups the notification message and the sender, and possibly other future parameters, together to form a comprehensive structure that we call Notification.
    169 
    170     Additionally there is another important class of objects belonging to the Notifications module. The @ref orxonox::NotificationDispatcher "NotificationDispatchers".
    171 
    172     @subsection NotificationDispatcher NotificationDispatcher
    173     @ref orxonox::NotificationDispatcher "NotificationDispatchers" are entities that are instantiated in a level file (through XML) and that dispatch (or send) a specific @ref orxonox::Notification "Notification" upon having received a triggering event.
    174 
    175     @defgroup NotificationDispatchers Dispatchers
    176     @ingroup Notifications
    177 
    178     @ref orxonox::NotificationDispatcher "NotificationDispatchers" are entities that are instantiated in a level file (through XML) and that dispatch (or send) a specific @ref orxonox::Notification "Notification" upon having received a triggering event.
    179 
    180     At this point there are two @ref orxonox::NotificationDispatcher "NotificationDispatchers", the @ref orxonox::SimpleNotification "SimpleNotification", which just displays a specified message, and the @ref orxonox::CommandNotification "CommandNotification" which displays a message with a binding for a specified command in it.
    181121*/
    182122
     
    193133    @defgroup Triggers Triggers
    194134    @ingroup Objects
    195 
    196     Triggers are objects which react to certain events. They can be combined and used as simple overlay logic in levels.
    197 
    198     @defgroup NormalTrigger Trigger
    199     @ingroup Triggers
    200 
    201     @defgroup MultiTrigger MultiTrigger
    202     @ingroup Triggers
    203 
    204     @ref orxonox::MultiTrigger "MultiTriggers" are (as they are @ref orxonox::TriggerBase "Triggers") objects which react to certain events. They offer all the functionality that the common @ref orxonox::Trigger "Triggers" do with one significant difference. The common @ref orxonox::Trigger "Trigger" has just one state, it can either be <em>triggered</em> or <em>not triggered</em>, it doesn't discriminate between who's triggering (or not triggering) it. A @ref orxonox::MultiTrigger "MultiTrigger", on the other hand, has a distinct state (<em>triggered</em> or <em>not triggered</em>) for each entity that is defined as being able to trigger said @ref orxonox::MultiTrigger "MultiTrigger".
    205 
    206     This difference becomes significant, when, for example, you want a @ref orxonox::DistanceTrigger "DistanceTrigger" to trigger a @ref orxonox::QuestEffectBeacon "QuestEffectBeacon" to hand out a @ref orxonox::Quest "Quest" to any @ref orxonox::Pawn "Pawn" that enters its range. With a simple @ref orxonox::DistanceTrigger "DistanceTrigger" (as opposed to the more complex @ref orxonox::DistanceMultiTrigger "DistanceMultiTrigger") the first @ref orxonox::Pawn "Pawn" to be in range would trigger it an receive the @ref orxonox::Quest "Quest", however if a second @ref orxonox::Pawn "Pawn" would enter the range, while the first @ref orxonox::Pawn "Pawn" still is in the range nothing would happen and even after the first @ref orxonox::Pawn "Pawn" left nothing would happen, since the whole time the @ref orxonox::DistanceTrigger "DistanceTrigger" would just be triggered. In contrast with a @ref orxonox::DistanceMultiTrigger "DistanceMultiTrigger" the first @ref orxonox::Pawn "Pawn" would enter the range and the @ref orxonox::DistanceMultiTrigger "DistanceMultiTrigger" would have the state <em>triggered</em> for this exact @ref orxonox::Pawn "Pawn" (but for none else) and thus the @ref orxonox::Pawn "Pawn" would receive the @ref orxonox::Quest "Quest" and when the second @ref orxonox::Pawn "Pawn" enters the range the state of the @ref orxonox::DistanceMultiTrigger "DistanceMultiTrigger" for that second @ref orxonox::Pawn "Pawn" would change to <em>triggered</em> and it would receive the @ref orxonox::Quest "Quest" as well.
    207 
    208     @section WhenToUseMultiTriggers When to use MultiTriggers
    209     Consequentially you would use @ref orxonox::MultiTrigger "MultiTriggers" (instead of common @ref orxonox::Trigger "Triggers"), when it is important that the trigger has different states for each triggering entity and when that fact is essential in the concept of the object that reacts to the triggering. However you should not just use @ref orxonox::MultiTrigger "MultiTrigger" instead of @ref orxonox::Trigger "Trigger", when in doubt, because @ref orxonox::MultiTrigger "MultiTrigger" produces significantly more overhead than @ref orxonox::Trigger "Trigger" due to the added complexity.
    210 
    211     @section HowToUseMultiTriggers How to use MultiTriggers
    212     ...
    213 
    214     @section MultiTriggerTechnicalDetails Technical Details
    215     A common @ref orxonox::Trigger "Trigger" is an object that can either be <em>active</em> or <em>inactive</em>, with a specified behavior how to switch between the two. A @ref orxonox::MultiTrigger "MultiTrigger" generalizes that behavior for multiple objects triggering the trigger. A @ref orxonox::MultiTrigger "MultiTrigger" can be <em>active</em> or <em>inactive</em> for any object triggering it, with the state for each object being completely independent of the state for all other objects. Each time a switch occurs an @ref orxonox::Event "Event" is fired, with a @ref orxonox::MultiTriggerContainer "MultiTriggerContainer" as the originator, containing a pointer to the @ref orxonox::MultiTrigger "MultiTrigger" that caused the @ref orxonox::Event "Event" and a pointer to the object that caused the trigger to change it's activity. This way the entity that reacts to the @ref orxonox::MultiTrigger "MultiTrigger" triggering receives the information it needs about the entity that triggered the @ref orxonox::MultiTrigger "MultiTrigger".
    216 
    217     Also, just as with all triggers, @ref orxonox::MultiTrigger "MultiTriggers" can be nested (event with triggers other than @ref orxonox::MultiTrigger "MultiTriggers").
    218     @code
    219     <MultiTrigger switch="true" delay="2">
    220         <DistanceMultiTrigger position="100,0,0" distance="80" />
    221         <EventTrigger ... />
    222     </Trigger>
    223     @endcode
    224 
    225     @ref orxonox::MultiTrigger "MultiTriggers" also allow for additional complexity which can be added through the choice of the parameters (some of which are also present in the common @ref orxonox::Trigger "Trigger") explained (briefly) below.
    226     But first it is important to understand a small implementational detail. There is a distinction between the @ref orxonox::MultiTrigger "MultiTrigger" being triggered (there is the state <em>triggered</em> for that) and the @ref orxonox::MultiTrigger "MultiTrigger" being active (for that is the state <em>activity</em>). From the outside only the <em>activity</em> is visible (and has above been referred to as <em>triggered</em> for the sake of comprehensibility). The state <em>triggered</em> tells us whether the trigger is actually triggered, but it could pretend (for some reason, some of which we will see shortly) to be <em>triggered</em> to the outside, while it in fact isn't (but it would then be <em>active</em>). The standard behavior is, that the <em>activity</em> changes, when the @ref orxonox::MultiTrigger "MultiTrigger" transits from being triggered to not being triggered or the other way around. So to the inside a @ref orxonox::MultiTrigger "MultiTrigger" being <em>active</em> is synonymous to the @ref orxonox::MultiTrigger "MultiTrigger" being <em>triggered</em> to the outside.
    227 
    228     The parameters of the @ref orxonox::MultiTrigger "MultiTrigger" are:
    229     - @b delay The delay is the time in seconds, that the trigger waits until it reacts (i.e. changes it's state) to the triggering condition being fulfilled. Internally this is handled by a state queue coupled with a counter, for each state that is delayed. The state becomes <em>active</em> when the counter runs out. This allows the @ref orxonox::MultiTrigger "MultiTrigger" to work even if the delay changes at runtime. However if the delay changes it only affects newly arriving states not the ones already in the queue. The default is <code>0</code>.
    230     - @b switch Switch is a boolean, if <code>true</code> the @ref orxonox::MultiTrigger "MultiTrigger" is in <em>switch-mode</em>, meaning, that the <em>activity</em> changes only when the trigger is triggered, not when it is un-triggered (Just like a light switch does). This means, that in <em>switch-mode</em> the <em>activity</em> only changes, when the trigger changes from not being triggered to being triggered but not the other way around. The default is <code>false</code>.
    231     - @b stayActive Stay active is also a boolean, if <code>true</code> the @ref orxonox::MultiTrigger "MultiTrigger" stays active after it has been activated as many times as specified by the parameter <em>activations</em>. In essence this means, that after the last time it is activated it cannot be deactivated. The default is <code>false</code>.
    232     - @b activations Activations is the number of times the @ref orxonox::MultiTrigger "MultiTrigger" can be activated until the trigger can't be triggered anymore. The default is <code>-1</code>, which denotes infinity.
    233     - @b invert Invert is a boolean, if <code>true</code> the @ref orxonox::MultiTrigger "MultiTrigger" is in <em>invert-mode</em>, meaning, that if the triggering condition is fulfilled the @ref orxonox::MultiTrigger "MultiTrigger" will have the state <em>not triggered</em> and and if the condition is not fulfilled it will have the state <em>triggered</em>. In short it inverts the behavior of the @ref orxonox::MultiTrigger "MultiTrigger". The default is <code>false</code>.
    234     - @b simultaneousTriggerers The number of simultaneous triggerers limits the number of objects that are allowed to trigger the @ref orxonox::MultiTrigger "MultiTrigger" at the same time. Or more precisely, the number of distinct objects the @ref orxonox::MultiTrigger "MultiTrigger" has positive <em>triggered</em> states for, at each point in time. The default is <code>-1</code>, which denotes infinity.
    235     - @b mode The mode describes how the @ref orxonox::MultiTrigger "MultiTrigger" acts in relation to all the triggers (its children), that are appended to it. There are 3 modes: <em>and</em>, meaning that the @ref orxonox::MultiTrigger "MultiTrigger" can only be triggered if all the appended triggers are active. <em>or</em>, meaning that the @ref orxonox::MultiTrigger "MultiTrigger" can only be triggered if at least one of the appended triggers is active. And <em>xor</em>, meaning that the @ref orxonox::MultiTrigger "MultiTrigger" can only be triggered if one and only one appended trigger is active. Note, that I wrote 'can only be active', that implies, that there is an additional condition to the <em>activity</em> of the @ref orxonox::MultiTrigger "MultiTrigger" and that is the fulfillment of the triggering condition (the @ref orxonox::MultiTrigger "MultiTrigger" class itself doesn't have one, but all derived classes should). Also bear in mind, that the <em>activity</em> of a @ref orxonox::MultiTrigger "MultiTrigger" is still coupled to the object that triggered it. The default is <em>and</em>.
    236     - @b broadcast Broadcast is a boolean, if <code>true</code> the @ref orxonox::MultiTrigger "MultiTrigger" is in <em>broadcast-mode</em>, meaning, that all trigger events that are caused by no originator (originator is <code>NULL</code>) are broadcast as having come from every possible originator, or more precisely as having come from all objects that are specified targets of this @ref orxonox::MultiTrigger "MultiTrigger". The default is <code>false</code>.
    237     - @b target The target describes the kind of objects that are allowed to trigger this @ref orxonox::MultiTrigger "MultiTrigger". The parameter has to be set to the class name of the class that is allowed to trigger the @ref orxonox::MultiTrigger "MultiTrigger". The default is <code>Pawn</code>.
    238 
    239     @subsection Sub-typesOfMultiTriggers Sub-types of MultiTriggers
    240 
    241     @subsubsection EventMultiTrigger EventMultiTrigger
    242     An @ref orxonox::EventMultiTrigger "EventMultiTrigger" can either be used to broadcast an @ref orxonox::Event "Event" that does not come from a @ref orxonox::MultiTrigger "MultiTrigger" to all entities that are targets of the @ref orxonox::EventMultiTrigger "EventMultiTrigger" or, more in line with its prototype the @ref orxonox::EventTrigger "EventTrigger", to be triggered for an entity when an @ref orxonox::Event "Event" that was caused by an entity of the same type is captured.
    243 
    244     A common usage could look like this:
    245     @code
    246     <EventMultiTrigger invert="true" delay="1">
    247         <events>
    248             <trigger>
    249                 <MultiTrigger ... />
    250                 <Trigger ... />
    251             </trigger>
    252         </events>
    253     </EventMultiTrigger>
    254     @endcode
    255 
    256     @subsubsection DistanceMultiTrigger DistanceMultiTrigger
    257     A @ref orxonox::DistanceMultiTrigger "DistanceMultiTrigger" is the MultiTrigger equivalent of the @ref orxonox::DistanceTrigger "DistanceTrigger" and works just the same way. It triggers (now separately for each object triggering it, since it's a @ref orxonox::MultiTrigger "MultiTrigger") whenever an object that is a target of the @ref orxonox::DistanceMultiTrigger "DistanceMultiTrigger" is in the specified range.
    258 
    259     Two additional parameters can be specified for the @ref orxonox::DistanceMultiTrigger "DistanceMultiTrigger" are the <em>distance</em>, which defines the maximum distance at which an object still triggers the @ref orxonox:: "DistanceMultiTrigger", and the <em>targetname</em>. Setting the <em>targename</em> puts the @ref orxonox::DistanceMultiTrigger "DistanceMultiTrigger" in <em>single-target mode</em>. In this mode the @ref orxonox::DistanceMultiTrigger "DistanceMultiTrigger"  can only be triggered by objects that have a @ref orxonox::DistanceTriggerBeacon "DistanceTriggerBeacon" with the name specified by <em>targetname</em> directly attached. For the <em>single-target mode</em> to work the target of the @ref orxonox::DistanceMultiTrigger "DistanceMultiTrigger" has to be set to <code>DistanceTriggerBeacon</code>.
    260 
    261     A common usage (without @ref orxonox::DistanceTriggerBeacon "DistanceTriggerBeacon") would look like this:
    262     @code
    263     <DistanceMultiTrigger position="0,0,0" switch="true" target="Pawn" distance="20" />
    264     @endcode
    265 
    266     With @ref orxonox::DistanceTriggerBeacon "DistanceTriggerBeacon" it would look like this:
    267     @code
    268     <DistanceMultiTrigger position="0,0,0" target="DistanceMultiTrigger" targetname="beacon1" distance="30" />
    269     @endcode
    270135*/
    271136
     
    278143    @defgroup Pickup Pickup
    279144    @ingroup Modules
    280 
    281     The Pickup module adds a special type of object to Orxonox, the so-called @ref orxonox::Pickupable "Pickupables". @ref orxonox::Pickupable "Pickupables" are objects that can be picked up (by virtually any entity, but commonly by the @ref orxonox::Pawn "Pawn") and have some kind of effect on the entity that picked the @ref orxonox::Pickupable "Pickupable" up.
    282 
    283     @section IncludingPickups Including pickups in a level
    284     @ref orxonox::Pickupable "Pickupables" are designed so that they can be included in levels fairly easily, while also ensuring, that the pickup itself (its game-logic component) and how it is represented (e.g. in the PickupInventory (the GUI that displays @ref orxonox::Pickupable "Pickupables") or in the game) are neatly seperated.
    285     To be able to use @ref orxonox::Pickupable "Pickupables" in a level one must understand some basic concepts.
    286     - @ref orxonox::Pickupable "Pickupables" are entities which (by itself) have no physical (or graphical) dimension. The simply represent the effect they will have on a @ref orxonox::PickupCarrier "PickupCarrier" (the entity that can pick up @ref orxonox::Pickupable "Pickupables", @ref orxonox::Pawn "Pawn" for example inherits from @ref orxonox::PickupSpawner "PickupSpawner" and thus is able to pick up and carry @ref orxonox::Pickupable "Pickupables"), when used and the mechanism that leads to that.
    287     - The physical (or graphical) dimension of a pickup is called a @ref orxonox::PickupRepresentation "PickupRepresentation".
    288     - The @ref orxonox::PickupRepresentation "PickupRepresentation" of a @ref orxonox::Pickupable "Pickupable" and the @ref orxonox::Pickupable "Pickupable" itself are linked to each other, in such a way that a @ref orxonox::PickupRepresentation "PickupRepresentation" can only represent one type of @ref orxonox::Pickupable "Pickupable".
    289     - A type of @ref orxonox::Pickupable "Pickupable" is a specific pickup class (inheriting from @ref orxonox::Pickupable "Pickupable") with specific values for all its relevant parameters. This means, that a pickup of the same class with the same values for all parameters except for one is a different type of pickup and will therefore have a different @ref orxonox::PickupRepresentation "PickupRepresentation". Which parameters are the ones relevant to destinguish between two types of pickups can be defined in the class description of the specific pickup.
    290     - The entity that actually gives a @ref orxonox::Pickupable "Pickupable" to a @ref orxonox::PickupCarrier "PickupCarrier" is called a @ref orxonox::PickupSpawner "PickupSpawner". A @ref orxonox::PickupSpawner "PickupSpawner" creates (based on some parameters) @ref orxonox::Pickupable "Pickupables" which then is picked up by the @ref orxonox::PickupCarrier "PickupCarrier", that caused the @ref orxonox::PickupSpawner "PickupSpawner" to spawn a new pickup. How the spawner looks in the game is defined by the @ref orxonox::PickupRepresentation "PickupRepresentation" of the @ref orxonox::Pickupable "Pickupable" it spawns.
    291 
    292     @subsection UsingPredifinedPickups Using predefined pickups
    293     There is a file called <code>pickupRepresentationTemplates.oxt</code> in <code>levels/templates</code>, which holds the templates for the @ref orxonox::PickupRepresentation "PickupRepresentations" and also templates for @ref orxonox::Pickupable "Pickupables". The templates for the @ref orxonox::PickupRepresentation "PickupRepresentations" define the @ref orxonox::StaticEntity "StaticEntities" that are attached to the @ref orxonox::PickupSpawner "PickupSpawners" to make them look like the @ref orxonox::Pickupable "Pickupable" they are spawning. The templates for the @ref orxonox::Pickupable "Pickupables" can be added just for ease of use.
    294     If you want to use pickups you will have to include this file in your level file, somewhere above the Level-tag.
    295     @code
    296     <?lua
    297         include("templates/pickupRepresentationTemplates.oxt")
    298     ?>
    299     ...
    300     <Level>
    301     ...
    302     @endcode
    303     There is another file called <code>pickups.oxi</code> in <code>level/includes</code> which creates all @ref orxonox::PickupRepresentation "PickupRepresentations" needed for the @ref orxonox::Pickupable "Pickupable" supplied by the <code>pickupRepresentationTemplates.oxt</code> file. This file will have to be included as well. It has to be somewhere after the opening Scene-tag and your first use of a pickup.
    304     @code
    305     <Scene>
    306     ...
    307     <?lua
    308         include("includes/pickups.oxi")
    309     ?>
    310     @endcode
    311     After that all the predefined pickups specified in those two files can be used just by creating a @ref orxonox::PickupSpawner "PickupSpawner" for them in the respective level.
    312     For example:
    313     @code
    314     <PickupSpawner position="-100,0,-100" respawnTime="30" maxSpawnedItems="10">
    315         <pickup>
    316             <HealthPickup
    317                 health = 10
    318                 healthType = "limited"
    319                 activationType = "immediate"
    320                 durationType = "once"
    321             />
    322         </pickup>
    323     </PickupSpawner>
    324     @endcode
    325     Please be aware, that the @ref orxonox::Pickupable "Pickupable" specified for the @ref orxonox::PickupSpawner "PickupSpawner", has to be exactly the same (including all parameters) to the one specified in the <code>pickups.oxi</code> file.
    326     To make things simpler, one could just use the templates specified in the <code>pickupRepresentationTemplates.oxt</code> file. Which, following the previous example, would look like this:
    327     @code
    328     <PickupSpawner position="-100,0,-100" respawnTime="30" maxSpawnedItems="10">
    329         <pickup>
    330             <HealthPickup template="smallhealthpickup" />
    331         </pickup>
    332     </PickupSpawner>
    333     @endcode
    334 
    335     @subsection UnsingNon-PredefinedPickups Using non-predefined pickups
    336     To include a type of pickup (which, as we remember, is the class of the @ref orxonox::Pickupable "Pickupable" with specific values for all the relevant parameters) in a level file, you can just create a new @ref orxonox::PickupSpawner "PickupSpawner" and specify the @ref orxonox::Pickupable "Pickupable".
    337     @code
    338     <PickupSpawner position="-100,0,-100" respawnTime="30" maxSpawnedItems="10">
    339     <pickup>
    340         <HealthPickup
    341             health = 33
    342             healthType = "limited"
    343             activationType = "immediate"
    344             durationType = "once"
    345         />
    346     </pickup>
    347     </PickupSpawner>
    348     @endcode
    349     As can be seen in the <code>pickupRepresentationTemplates.oxt</code> file and the <code>pickups.oxi</code> file there is no @ref orxonox::PickupRepresentation "PickupRepresentation" defined for this type of pickup. Thus the default representation will be used.
    350 
    351     To create an appropriate @ref orxonox::PickupRepresentation "PickupRepresentation" for the inserted pickup above, you can just create a @ref orxonox::PickupRepresentation "PickupRepresentation" within the scene (Within the Scene-tags).
    352     @code
    353     <PickupRepresentation
    354         name = "My new health pickup"
    355         description = "This is an awesome new health pickup."
    356         spawnerTemplate = "mediumhealthpickupRepresentation"
    357         inventoryRepresentation = "MediumHealth"
    358     >
    359         <pickup>
    360             <HealthPickup
    361             health = 33
    362             healthType = "limited"
    363             activationType = "immediate"
    364             durationType = "once"
    365         />
    366         </pickup>
    367     </PickupRepresentation>
    368     @endcode
    369     Notice, that the type of pickup specified for the @ref orxonox::PickupRepresentation "PickupRepresentation", naturally, needs to be the same (this is the way they can be connected). Also, we just used an existing <em>spawnerTemplate</em>, to make things simpler.
    370 
    371     The next step is to create a <em>spawnerRepresentation</em> uniquely for our new type of pickup. Lets call it <code>newhealthpickupRepresentation</code>. Thus the parameter <em>spawnerTemplate</em> of the @ref orxonox::PickupRepresentation "PickupRepresentation" has to be changed to that value.
    372     @code
    373     spawnerTemplate = "newhealthpickupRepresentation"
    374     @endcode
    375     The <em>spawnerTemplate</em> defines how the @ref orxonox::PickupSpawner "PickupSpawner" is displayed in a level.
    376     In our example case it could look like this:
    377     @code
    378     <Template name=newhealthpickupRepresentation>
    379         <PickupRepresentation>
    380             <spawner-representation>
    381                 <StaticEntity>
    382                     <attached>
    383                         -- Here you can put all the objects which define the look of the spawner. --
    384                     </attached>
    385                 </StaticEntity>
    386             </spawner-representation>
    387         </PickupRepresentation>
    388     </Template>
    389     @endcode
    390     Please refer to the <code>pickupRepresentationTemplates.oxt</code> for more examples.
    391 
    392     The @ref orxonox::PickupRepresentation "PickupRepresentation" also needs another parameter the <em>inventoryRepresentation</em>. This parameter defined how the @ref orxonox::Pickupable "Pickupable" is displayed in the PickupInventory (a menu to browse the currently equipped pickups).
    393     @code
    394     inventoryRepresentation = "MediumHealth"
    395     @endcode
    396     This is the name of an image defined in the PickupInventory imageset (<code>PickupInventory.imageset</code>), which can be found in <code>data_extern/gui/imagesets</code>.
    397 
    398     This is all that has to be done. Now you have a new pickup type with an appropriate @ref orxonox::PickupRepresentation "PickupRepresentation" for your use. If you feel that your pickup is useful in general, please don't hesitate to create a template for the pickup and add your pickup to the <code>pickupRepresentationTemplates.oxt</code> file and the <code>pickups.oxi</code> file, so that anyone who wants to use it can do so quite easily.
    399 
    400     There is also an additional way to create new types of pickups to be used in a level (without having to do any coding). There is a @ref orxonox::Pickupable "Pickupable" called the @ref orxonox::PickupCollection "PickupCollection", which is just a collection (hence the name) of @ref orxonox::Pickupable "Pickupables" (more precisely of @ref orxonox::CollectiblePickup "CollectiblePickups"), behaving as if it was just one @ref orxonox::Pickupable "Pickupable".
    401     A @ref orxonox::PickupCollection "PickupCollection" can be created as follows:
    402     @code
    403     <PickupCollection>
    404         <pickupables>
    405             -- some pickups you want to have in your collection, e.g. --
    406             <HealthPickup template=smallhealthpickup />
    407             <HealthPickup health=50 healthRate=5 durationType=continuous activationType=immediate healthType=limited />
    408         </pickupables>
    409     </PickupCollection>
    410     @endcode
    411     Of which types of pickups a collection is made up is entirely up to the one creating the @ref orxonox::PickupCollection "PickupCollection", they can be mixed freely.
    412 
    413     @section CreatingAPickup Creating a new pickup
    414     Things have been fairly straightforward so far. Creating a @ref orxonox::Pickupable "Pickupable" form scratch isn't as easy. Therefore I'm just going to supply you with a recipe, or a set of steps you have to take, without which your pickup won't work and point out some common pitfalls.
    415 
    416     @subsection CreatingAPickupClass Creating the class
    417     For a new @ref orxonox::Pickupable "Pickupable" you need to create a new class in <code>>modules/pickup/items</code>. Your class needs to be derived from another pickup class, normally this would either be @ref orxonox::Pickupable "Pickupable", @ref orxonox::CollectiblePickup "CollectiblePickup" or @ref orxonox::Pickup "Pickup". @ref orxonox::Pickupable "Pickupable" is (as mentioned earlier) the base class of all things that can be picked up, thus of all pickups. @ref orxonox::CollectiblePickup "CollectiblePickup" is a (directly) derived class of @ref orxonox::Pickupable  "Pickupable" and provides the additional functionality of enabling your pickup to be used in a @ref orxonox::PickupCollection "PickupCollection". However you are probably going to want to derive your class form @ref orxonox::Pickup "Pickup", because it is a @ref orxonox::CollectiblePickup "CollectiblePickup" and provides some useful methods. So have a look at @ref orxonox::Pickup "Pickup".
    418     Once you have created your new pickup class you have to insert it in the <code>PickupPrereqs.h</code> file in the <code>modules/pickup</code> folder and in the <code>CMakeList.txt</code> file in the <code>modules/pickup/items</code> folder. Also have a look at other pickups to make sure you include all the necessary files in your class.
    419 
    420     @subsection ChoosingTheCarriers Coosing the carriers
    421     You also have to choose the entities that are allowed to pick your pickup up. After you have chosen the entity that carries your pickup, you need to do the following.
    422     - The enity that carries your pickup needs to be derived from the @ref orxonox::PickupCarrier "PickupCarrier" interface. And you need to implement the @ref orxonox::PickupCarrier "PickupCarriers'" virtual functions <code>getCarrierChildren()</code> and <code>getCarrierParent()</code>. These tow methods are needed, because all pickups are initially picked up by a @ref orxonox::Pawn "Pawn" and then handed down to the entity that effectively carries them. With the above mentioned two function just that is accomplished. A hierarchical structure is established with one parent and a set of children, where the @ref orxonox::Pawn "Pawn" is the root node of this hierarchical structure, the only entity with no parent.
    423     - Once you have done that you will also want to specify in your pickup which carriers can pick it up, this is done via the <code>addTarget()</code> function. So you have to make sure the target is added whenever one of your pickups is created (so, most conveniently somewhere in the constructor), with the following command.
    424     @code
    425     this->addTarget(ClassIdentifier<MyCarrierClass>::getIdentifier());
    426     @endcode
    427 
    428     @subsection CreatingTheInnerWorkings Creating the inner workings of your pickup
    429     Now that we have the skeleton of a pickup and we have defined which carriers are allowed to pick our pickup up we are going to take a look at all the methods we can (or sometimes have to) overload from @ref orxonox::Pickupable "Pickupable", for our pickup to work properly. But first I will introduce some more concepts to make the need for these methods more obvious.
    430     - Since one pickup class can by itself be many pickup types, we need a way to find out whether a particular instance of a pickup is of the same type as another instance of a pickup. To that end the @ref orxonox::PickupIdentifier "PickupIdentifier" was created. The @ref orxonox::PickupIdentifier "PickupIdentifier" accounts for the type of class your pickup is of and also for the parameters (and their values) that distinguish different types of pickups of the same class. Much of the functionality of the pickup module relies on this identifier being correct, thus it is very important to initialize it correctly. (We will see, how that is done in a short while.)
    431     - Every @ref orxonox::Pickupable "Pickupable" has at least two states which are very important. The first is, whether the @ref orxonox::Pickupable "Pickupable" is currently in use or not and the second is whether the pickup is currently picked up or not.
    432 
    433     Let's have a look at the important methods.
    434     - <b>changedUsed()</b> The <code>changedUsed()</code> method is called whenever the state of the @ref orxonox::Pickupable "Pickupable" transits from being used to not being used or the other way around. Which means this method is probably the most important method you have at your fingertips, since it enables you to apply the effect of your pickup when it gets used and remove the effect as soon as it is no longer in use.
    435     - <b>changedPickedUp()</b> The <code>changedPickedUp()</code> method is called whenever the state of the @ref orxonox::Pickupable "Pickupable" changes from being picked up to not being picked up or the other way around. For example if you want your pickup to be used as soon as it is picked up, this is the method you have to overload to achieve that behavior (or just let your pickup be derived from @ref orxonox::Pickup "Pickup", which implements exactly that behavior, if the <em>activationType</em> is set to <em>immediate</em>). You don't have to concern yourself with destroying the pickup or creating a spawner when it changes to not picked up, since that is already implemented with the @ref orxonox::Pickupable "Pickupable" and @ref orxonox::PickupCarrier "PickupCarrier" classes. If you want a different behavior, however, once again, this is the method.
    436     - <b>changedCarrier()</b> The <code>changedCarrier()</code> method is called whenever the carrier of the @ref orxonox::Pickupable "Pickupable" changes. And by that I don't mean the class that is allowed to carry the pickup, but the object that actually carries (or carried) the pickup. Please do not overload this class to implement behavior for picked up -> not picked up transitions, use <code>changedPickedUp()</code> for that. For most pickup classes this method doesn't need to be overloaded. Where it is used, however is in the @ref orxonox::PickupCollection "PickupCollection" class, where the new carrier needed to be communicated to all pickups the collection consists of, whenever the carrier was changed.
    437 
    438     Please be aware, that these three methods are methods registered with @ref Super.h "Super", meaning, that whenever overloading them, don't forget to call <code>SUPER(MyClass, myMethod);</code>.
    439     Also when implementing the above methods you should think of what should happen in unexpected situations, e.g. when your pickup is unused manually and set to used again.
    440     Additionally you should use the <code>destroy()</code> method of Pickupable instead of the method provided by @ref orxonox::OrxonoxClass "OrxonoxClass", meaning <code>Pickupable::destroy()</code> instead of plain <code>destroy()</code>.
    441 
    442     - <b>clone()</b> The <code>clone()</code> method creates a new pickup of the same type as the pickup it is cloned from. So the cloned pickup is not exactly the same, as it doesn't necessarily completely reflect the status of the pickup it is cloned from, but it reflects all the parameters and their values, that distinguish different types of this pickup class. It needs to be implemented by every pickup class. And it is best if this is done in a very specific way. Below is shown how:
    443     @code
    444     void MyPickup::clone(OrxonoxClass*& item)
    445     {
    446         if(item == NULL)
    447             item = new MyPickup(this);
    448 
    449         SUPER(MyPickup, clone, item);
    450 
    451         MyPickup* pickup = dynamic_cast<MyPickup*>(item);
    452         // Here you should set all the important parameters (that distinguish the different types of this pickup), e.g.
    453         pickup->setSomeParameter(this->getSomeParameter());
    454         // You must also initialize the identifier of the new pickup, this is normally done in a member function called in
    455         pickup->initializeIdentifier();
    456     }
    457     @endcode
    458     - <b>initializeIdentifier()</b> The <code>initializeIdentifier()</code> method initializes (or more simply put, creates) the @ref orxonox::PickupIdentifier "PickupIdentifier" of the instance of your pickup. Since the important values of the parameters are not yet available in the constructor of your pickup this <code>initializeIdentifier()</code> method must be called as soon as they are available, which normally is in the <code>XMLPort()</code> method, and the <code>clone()</code> method, as seen above. In the <code>initializeIdentifier()</code> method you need to register each parameter that is important for the type of your pickup to its identifier, this is normally done as follows:
    459     @code
    460     void Pickup::initializeIdentifier(void)
    461     {
    462         // If the get method returns a string.
    463         std::string val1 = this->getSomeParameter();
    464         std::string type1 = "someParameter";
    465         this->pickupIdentifier_->addParameter(type1, val1);
    466         // If the get method doesn't return a string
    467         std::stringstream stream;
    468         stream << this->getSomeOtherParameter();
    469         std::string type2 = "someOtherParameter";
    470         std::string val2 = stream.str();
    471         this->pickupIdentifier_->addParameter(type2, val2);
    472     }
    473     @endcode
    474 
    475     Be aware, this only works for parameters that are simple enough, meaning with pointers for example it will, naturally, not work, and other ways must be found (this is for example done in @ref orxonox::PickupCollection "PickupCollection" with a derived class of the @ref orxonox::PickupIdentifier "PickupIdentifier", the @ref orxonox::PickupCollectionIdentifier "PickupCollectionIdentifier") or in the @ref orxonox::DronePickup "DronePickup" class by using a @ref orxonox::Template "Template".
    476     - <b>createSpawner()</b> The <code>createSpawner()</code> method needs to be implemented by any pickup directly inheriting from @ref orxonox::Pickupable "Pickupable" (or directly from @ref orxonox::CollectiblePickup "CollectiblePickup"), so if you inherit from @ref orxonox::Pickup "Pickup", you don't need to implement this. It is used to create a @ref orxonox::PickupSpawner "PickupSpawner", when the pickup is dropped. A standard implementation would look like this.
    477     @code
    478     bool MyPickup::createSpawner(void)
    479     {
    480         new DroppedPickup(this, this, this->getCarrier());
    481         return true;
    482     }
    483     @endcode
    484 
    485     @section PickupTechnicalDetails Technical details
    486 
    487     @image html pickupmodule.png
    488 
    489     @defgroup PickupItems Items
    490     @ingroup Pickup
    491 
    492     The actual pickups can be found here.
    493145*/
    494146
     
    496148    @defgroup Pong Pong
    497149    @ingroup Modules
     150
     151    Pong is a minigame.
    498152*/
    499153
     
    501155    @defgroup Questsystem Questsystem
    502156    @ingroup Modules
    503 
    504     The Questsystem is a module that enhances Orxonox with @ref orxonox::Quest "Quests". @ref orxonox::Quest "Quests" are objects that challenge the player that receives such an object to fulfill some specific task (e.g. Rescue a princess, fetch some rare metal alloy, destroy the evil pirates den, ...). Upon having fulfilled that task the player can be rewarded with some kind of reward. Quests can be hierarchically structured, meaning that to fulfill some @ref orxonox::Quest "Quest" you first have to fulfill all (or some, depending on the quest) sub-quests.
    505 
    506     @section QuestsystemTechnicalDetails Technical details
    507     The Questsystem essentially consists of the @ref orxonox::Quest "Quest" entity which is the quest itself (and sub- or helper-entities, such as @ref orxonox::QuestHint "QuestHint" (hints for quests) or @ref orxonox::QuestDescription "QuestDescription" (descriptions for quests and hints, to separate content from function)), the @ref orxonox::QuestEffect "QuestEffect" and @ref orxonox::QuestListener "QuestListener" entities which are the only tools for quests to have any influence on the game world. By enabling quests to have @ref orxonox::QuestEffect "QuestEffects" they are able to (for example) fail or complete other quests, activate hints, give rewards or even add a quest to a player. @ref orxonox::QuestListener "QuestListeners" on the other hand can be used by any object to react to a status change of a quest. The @ref orxonox::QuestEffectBeacon "QuestEffectBeacon" is the physical entity which finally makes quests available for the player in the game, by being able to invoke a @ref orxonox::QuestEffect "QuestEffect" on a player (under some conditions).
    508     @image html questsystem.png
    509 
    510     @section CreatingQuests Creating Quests
    511 
    512     @subsection CreatingTheQuestHierarchy Creating the Quest-Hierarchy
    513     To start you have to create a Quest-Hierarchy in the XML-Levelfile by hierarchically nesting your quests. There are two types of Quests you can use, the LocalQuest and the GlobalQuest.
    514 
    515     @subsubsection LocalQuest LocalQuest
    516     A @ref orxonox::LocalQuest "LocalQuest" is a @ref orxonox::Quest "Quest" which has different states for each player, that means each @ref orxonox::LocalQuest "LocalQuest" can be obtained and completed (or failed) by each player in parallel. A questId is some string that uniquely identifies the quest, this can either be a name or, to ensure uniqueness, you can use a GUID generator (<a href="http://www.google.com/search?q=guid+generator">google</a> or you can use this <a href="http://www.famkruithof.net/uuid/uuidgen">generator</a>). The advantage of GUID is, that you can be quite sure that your id is unique, the drawback is, that it provides less overview and can be quite confusing when looking at the level file. So make your own choice.
    517 
    518     Creating a @ref orxonox::LocalQuest "LocalQuest" in XML goes as follows:
    519     @code
    520     <LocalQuest id="questId">
    521         <QuestDescription title="Title" description="Description." /> //The description of the quest.
    522         <subquests>
    523             <Quest id ="questId1" /> //A list of n subquest, be aware, each of the <Quest /> tags must have a description and so on and so forth as well.
    524             ...
    525             <Quest id="questIdn" />
    526         </subquests>
    527         <hints>
    528             <QuestHint id="hintId1" /> //A list of n QuestHints, see QuestHint for the full XML representation of those.
    529             ...
    530             <QuestHint id="hintIdn" />
    531         </hints>
    532         <fail-effects>
    533             <QuestEffect /> //A list of QuestEffects, invoked when the Quest is failed, see QuestEffect for the full XML representation.
    534             ...
    535             <QuestEffect />
    536         </fail-effects>
    537         <complete-effects>
    538             <QuestEffect /> //A list of QuestEffects, invoked when the Quest is completed, see QuestEffect for the full XML representation.
    539             ...
    540             <QuestEffect />
    541         </complete-effects>
    542     </LocalQuest>
    543     @endcode
    544 
    545     @subsubsection GlobalQuest GlobalQuest
    546     @ref orxonox::GlobalQuest "GlobalQuests" are different, they can be obtained by every player but the changes made to the @ref orxonox::Quest "Quest" (e.g. completion of the quest) affect all owners of the quest. A short example: There are 3 Players, A, B and C. Player A obtains the quest, a while later player B obtains the quest and completes it. Since it is a @ref orxonox::GlobalQuest "GlobalQuest" it is completed for all players having obtained the Quest which means it is also completed for player A. Player C though, never having obtained the quest, can now never complete it.
    547 
    548     Creating a @ref orxonox::GlobalQuest "GlobalQuest" in XML goes as follows:
    549     @code
    550     <GlobalQuest id="questId">
    551         <QuestDescription title="Title" description="Description." /> //The description of the quest.
    552         <subquests>
    553             <Quest id ="questId1" /> //A list of n subquest, be aware, each of the <Quest /> tags must have a description and so on and so forth as well.
    554             ...
    555             <Quest id="questIdn" />
    556         </subquests>
    557         <hints>
    558             <QuestHint id="hintId1" /> //A list of n QuestHints, see QuestHint for the full XML representation of those.
    559             ...
    560             <QuestHint id="hintIdn" />
    561         </hints>
    562         <fail-effects>
    563             <QuestEffect /> //A list of QuestEffects, invoked on all players possessing this quest, when the Quest is failed, see QuestEffect for the full XML representation.
    564             ...
    565             <QuestEffect />
    566         </fail-effects>
    567         <complete-effects>
    568             <QuestEffect /> //A list of QuestEffects, invoked on all players possessing this quest, when the Quest is completed, see QuestEffect for the full XML representation.
    569             ...
    570             <QuestEffect />
    571         </complete-effects>
    572         <reward-effects>
    573             <QuestEffect /> //A list of QuestEffects, invoked on the player completing this quest. See QuestEffect for the full XML representation.
    574             ...
    575             <QuestEffect />
    576         </reward-effects>
    577     </GlobalQuest>
    578     @endcode
    579 
    580     As you may see that another difference between a @ref orxonox::GlobalQuest "GlobalQuest" and a @ref orxonox::LocalQuest "LocalQuest" is, that with a @ref orxonox::GlobalQuest "GlobalQuest" having @ref orxonox::AddReward "RewardEffects", the RewardEffects are only executed on the player completing the quest. Additionally @ref orxonox::CompleteQuest "CompleteEffects" are executed on all players having obtained the quest before it was completed, when it is completed., while with a @ref orxonox::LocalQuest "LocalQuest" each player that completes a quest, completes it for himself alone, but also gets the reward, regardless whether another player completed the quest before him.
    581 
    582     @subsubsection QuestHint QuestHint
    583     @ref orxonox::QuestHint "QuestHints" can be used to give a player useful information for @ref orxonox::Quest "Quests" he is working on completing. @ref orxonox::QuestHint "QuestHints" cannot have any side effects, but also have an identifier which follows the same form as in the @ref orxonox::Quest "Quests".
    584 
    585     Creating a @ref orxonox::QuestHint "QuestHint" in XML goes as follows:
    586     @code
    587     <QuestHint id="hintId">
    588         <QuestDesctription title="" description="" />
    589     </QuestHint>
    590     @endcode
    591 
    592     @subsubsection QuestDescription QuestDescription
    593     Each @ref orxonox::Quest "Quest" (and also each @ref orxonox::QuestHint "QuestHint") must have a @ref orxonox::QuestDescription "QuestDescription" consisting of a title and description, and for @ref orxonox::Quest "Quests" also messages for the event the quest is either failed or completed. Of course these are (as is the title and the description) optional.
    594 
    595     Creating a @ref orxonox::QuestDescription "QuestDescription" in XML goes as follows:
    596     @code
    597     <QuestDescription title="Title" description="Description Text" failMessage="You fail." completeMessage="You win!" />
    598     @endcode
    599 
    600     @subsection CreatingSideEffects Creating side effects
    601     @ref orxonox::Quest "Quests" can have side effects, in fact that is mostly what they are about. This means that they can have an influence on the game world. @ref orxonox::Quest "Quests" do that through two distinct devices, @ref orxonox::QuestEffect "QuestEffects" (active) and @ref orxonox::QuestListener "QuestListeners" (passive).
    602 
    603     @subsubsection QuestEffect QuestEffect
    604     A @ref orxonox::QuestEffect "QuestEffect" is the first (and probably most important) device for @ref orxonox::Quest "Quests" to have side effects. There are two entities that can have @ref orxonox::QuestEffect "QuestEffects": @ref orxonox::Quest "Quests" and @ref orxonox::QuestEffectBeacon "QuestEffectBeacons" (which will be explained later on). @ref orxonox::QuestEffect "QuestEffects", for example, can start a @ref orxonox::Quest "Quest" for a player, complete/fail @ref orxonox::Quest "Quests" for a player, add a @ref orxonox::QuestHint "QuestHint" or a @ref orxonox::Rewardable "Reward" to a player, and potentially much, much more.
    605 
    606     These @ref orxonox::QuestEffect "QuestEffects" are implemented so far, but feel free to <a href="http://www.orxonox.net/wiki/DamianFrick">contact me</a> if you have suggestions for new @ref orxonox::QuestEffect "QuestEffects" or if you need help implementing a new one yourself.
    607 
    608     @paragraph AddQuest AddQuest
    609     This @ref orxonox::QuestEffect "QuestEffect" adds (respectively starts) a @ref orxonox::Quest "Quest" (identified by the given questId) to the player.
    610     @code
    611     <AddQuest questId="id" />  //Where id identifies the Quest that should be added.
    612     @endcode
    613 
    614     @paragraph FailQuest FailQuest
    615     This @ref orxonox::QuestEffect "QuestEffect" fails a @ref orxonox::Quest "Quest" (identified by the given questId) for the player.
    616     @code
    617     <FailQuest questId="id" />  //Where id identifies the Quest that should be added.
    618     @endcode
    619 
    620     @paragraph CompleteQuest CompleteQuest
    621     This @ref orxonox::QuestEffect "QuestEffect" completes a @ref orxonox::Quest "Quest" (identified by the given questId) for the player.
    622     @code
    623     <CompleteQuest questId="id" />  //Where id identifies the Quest that should be added.
    624     @endcode
    625 
    626     @paragraph AddQuestHint AddQuestHint
    627     This @ref orxonox::QuestEffect "QuestEffect" adds a @ref orxonox::QuestHint "QuestHint" to a @ref orxonox::Quest "Quest" (identified by the given questId) of a player.
    628     @code
    629     <AddQuestHint hintId="id" />  //Where id identifies the QuestHint that should be added.
    630     @endcode
    631 
    632     @paragraph AddReward AddReward
    633     This @ref orxonox::QuestEffect "QuestEffect" adds a @ref orxonox::Rewardable "Rewardable" (@ref orxonox::Rewardable "Rewardable" is an Interface which can be implemented by an object that its creator thinks should be able to be rewarded a player for completing (or failing for that matter) a @ref orxonox::Quest "Quest") to the player. @ref Pickup Pickups for example wold be good @ref orxonox::Rewardable "Rewardables".
    634     @code
    635     <AddReward>
    636         <Rewardable /> //A list of Rewardable objects to be rewarded the player, see the specific Rewardables for their respective XML representations.
    637         ...
    638         <Rewardable />
    639     </AddReward>
    640     @endcode
    641 
    642     @subsubsection QuestListener QuestListener
    643     The @ref orxonox::QuestListener "QuestListener" is the second device you can use to create side effects. As opposed to @ref orxonox::QuestEffect "QuestEffects" (that are executed (or invoked) either as a result of failing or completing a Quest or by a @ref orxonox::QuestEffectBeacon "QuestEffectBeacon"), @ref orxonox::QuestListener "QuestListeners" are passive, meaning that they relay information regarding status changes of @ref orxonox::Quest "Quests" rather than enforcing status changes. @ref orxonox::QuestListener "QuestListeners" have a certain mode (all, start, complete or fail) and a @ref orxonox::Quest "Quest" which they belong to (resp. to which they react). You then can use @ref orxonox::QuestListener "QuestListeners" to make basically any object aware of when the status of the given @ref orxonox::Quest "Quest" changes (the way you defined through the mode) and take any action you may think of.
    644 
    645     Here is an example of the usage of @ref orxonox::QuestListener "QuestListeners" in XML:
    646     @code
    647     <BaseObject> // The object that should react to the status change of a Quest.
    648         <events>
    649             <function> // Where function is the method of the object that schould be executed. Normally this would be visibility or activity.
    650                 <QuestListener questId="someQuestId" mode="someMode" /> // Where someQuestId is the identifier for the Quest the QuestListener is reacting to, and someMode is the kind of status change the QUestListener reacts to (all, start, complete or fail).
    651             </function>
    652         </events>
    653     </BaseObject>
    654     @endcode
    655 
    656     I hope this example has made the usage of @ref orxonox::QuestListener "QuestListeners" a little clearer. The @ref orxonox::QuestListener "QuestListener" actually reacts exactly as any @ref orxonox::Trigger "Trigger" or @ref orxonox::EventListener "EventListener" would (although the @ref orxonox::QuestListener "QuestListener" is really neighter the one nor the other) which means you can use it in exactly the same way you would use one of the above, it just reacts to a different thing. Namely to the change in a @ref orxonox::Quest "Quests" status.
    657 
    658     @subsection PuttingTheQuestsInTheGameWorld Putting the Quests in the game world
    659     As of now we know how to create @ref orxonox::Quest "Quests" and @ref orxonox::QuestHint "QuestHints", we have a way for quests to add new quests, or even complete/fail other quests. We also have a way of reacting to a status change in a @ref orxonox::Quest "Quest". In short we know how quests can be created, how they can influence other quests and how we can react to changes in quests. But our @ref orxonox::Quest "Quests" have no ties (well, not really at least) to the game world as of yet, meaning, that the game world cannot influence quests. For this we have @ref orxonox::QuestEffectBeacon "QuestEffectBeacons".
    660 
    661     @subsubsection QuestEffectBeacon QuestEffectBeacon
    662     The @ref orxonox::QuestEffectBeacon "QuestEffectBeacon" is a @ref orxonox::StaticEntity "StaticEntity" and has the ability to (when triggered trough some circumstance) invoke a specified list of @ref orxonox::QuestEffect "QuestEffects" on the player triggering the @ref orxonox::QuestEffectBeacon "QuestEffectBeacon".
    663 
    664     Creating a @ref orxonox::QuestEffectBeacon "QuestEffectBeacon" in XML goes as follows:
    665     @code
    666     <QuestEffectBeacon times=n> //Where 'n' is either a number >= 0, which means the QuestEffectBeacon can be executed n times. Or n = -1, which means the QuestEffectBeacon can be executed an infinite number of times.
    667         <effects>
    668             <QuestEffect /> //A list of QuestEffects, invoked when the QuestEffectBeacon is executed, see QuestEffect for the full XML representation.
    669             ...
    670             <QuestEffect />
    671         </effects>
    672         <events>
    673             <execute>
    674                 <EventListener event=eventIdString />
    675             </execute>
    676         </events>
    677         <attached>
    678             <PlayerTrigger name=eventIdString /> //A PlayerTrigger triggering the execution of the QuestEffectBeacon.
    679         </attached>
    680     </QuestEffectBeacon>
    681     @endcode
    682 
    683     The @ref orxonox::QuestEffectBeacon "QuestEffectBeacon" can only be executed a defined number of times (where -1 times stands for an infinite number of times) and the @ref orxonox::QuestEffect "QuestEffects" are invoked whenever the method 'execute' is called, which is (indirectly through an @ref orxonox::EventListener "EventListener", because I wanted to attach the @ref orxonox::PlayerTrigger "PlayerTrigger" so that its position is always relative to the @ref orxonox::QuestEffectBeacon "QuestEffectBeacons" position) done by the @ref orxonox::PlayerTrigger "PlayerTrigger".
    684 
    685     A @ref orxonox::PlayerTrigger "PlayerTrigger" is a special sort of @ref orxonox::Trigger "Trigger" that knows the player that triggered it and therefore can be asked who that was. This allows the @ref orxonox::QuestEffect "QuestEffects" to be executed on the right player.
    686 
    687     @section SampleQuest Sample quest
    688     To get your head around all of this and see some of the things mentioned here in action you might want to check out the "The Tale of Princess Aeryn"-Quest (Levelfile: princessAeryn.oxw) in the level-folder.
    689 */
    690 
    691 /**
    692     @defgroup QuestEffects Effects
    693     @ingroup Questsystem
    694 
    695     A @ref orxonox::QuestEffect "QuestEffect" is a device for @ref orxonox::Quest "Quests" to have side effects. There are two entities that can have @ref orxonox::QuestEffect "QuestEffects": @ref orxonox::Quest "Quests" and \ref orxonox::QuestEffectBeacon "QuestEffectBeacons". @ref orxonox::QuestEffect "QuestEffects", for example, can start a @ref orxonox::Quest "Quest" for a player, complete/fail @ref orxonox::Quest "Quests" for a player, add a @ref orxonox::QuestHint "QuestHint" or a @ref orxonox::Rewardable "Reward" to a player, and potentially much, much more.
    696157*/
    697158
  • code/trunk/src/libraries/core/Loader.cc

    r8079 r8108  
    144144    @param verbose
    145145        Whether the loader is verbose (prints its progress in a low output level) or not.
     146    @param bRemoveLuaTags
     147        If true lua tags are just ignored and removed. The default is false.
    146148    @return
    147149        Returns true if successful.
  • code/trunk/src/libraries/network/Host.cc

    r8079 r8108  
    7575  * @param packet Packet to be added
    7676  * @param clientID ID of the client the packet should be sent to
     77  * @param channelID ID of the channel.
    7778  * @return success?
    7879  */
  • code/trunk/src/libraries/network/MasterServerComm.h

    r7804 r8108  
    8989
    9090      /** \param callback The callback function to call with data received.
     91       *  \param delayms Delay in milliseconds.
    9192       * \return 0 for success, other for error
    9293       *
  • code/trunk/src/modules/designtools/ScreenshotManager.cc

    r8079 r8108  
    6161    @brief
    6262        Creates a screenshot with the given camera.
    63     @param camera
    64         Pointer to the camera "looking at" the scene of interest
    65     @param fileName
    66         the filename of the screenshot file.
    6763    */
    6864    void ScreenshotManager::makeScreenshot() const
  • code/trunk/src/modules/pickup/Pickup.h

    r7547 r8108  
    8181        The Pickup class offers (useful) base functionality for a wide range of pickups.
    8282
    83         Pickups ingeriting from this class can choose an activation type and a duration type.
     83        Pickups inheriting from this class can choose an activation type and a duration type.
    8484        - The <b>activationType</b> deals with what happens to the Pickup as soon as it is picked up. It can either be set to <em>immediate</em>, which means that the Pickup is activated/used immediately upon being picked up. Or to <em>onUse</em>, which means, that the Pickup will be activated/used if some outside entity (most commonly the player through the PickupInventory) decides to use it. Default is <em>immediate</em>.
    8585        - The <b>durationType</b> deals with whether the Pickup has a continuous effect or whether its effect is focused on a singular instant. It can either be set to <em>once</em>, which means, that the Pickup just has an effect (at a singular instant in time) and is done once that effect has been applied. Or to <em>continuous</em>, which means that the effect of the Pickup unfolds over some timespan. Default is <em>once</em>.
  • code/trunk/src/modules/pong/Pong.cc

    r7911 r8108  
    2727 */
    2828
     29/**
     30    @file Pong.cc
     31    @brief Implementation of the Pong class.
     32*/
     33
    2934#include "Pong.h"
    3035
     
    3237#include "core/EventIncludes.h"
    3338#include "core/command/Executor.h"
     39
     40#include "gamestates/GSLevel.h"
     41
    3442#include "PongCenterpoint.h"
    3543#include "PongBall.h"
     
    4048namespace orxonox
    4149{
     50    // Events to allow to react to scoring of a player, in the level-file.
    4251    CreateEventName(PongCenterpoint, right);
    4352    CreateEventName(PongCenterpoint, left);
     
    4554    CreateUnloadableFactory(Pong);
    4655
     56    /**
     57    @brief
     58        Constructor. Registers and initializes the object.
     59    */
    4760    Pong::Pong(BaseObject* creator) : Deathmatch(creator)
    4861    {
     
    5669        this->setHUDTemplate("PongHUD");
    5770
     71        // Pre-set the timer, but don't start it yet.
    5872        this->starttimer_.setTimer(1.0, false, createExecutor(createFunctor(&Pong::startBall, this)));
    5973        this->starttimer_.stopTimer();
    6074
     75        // Set the type of Bots for this particular Gametype.
    6176        this->botclass_ = Class(PongBot);
    6277    }
    6378
     79    /**
     80    @brief
     81        Destructor. Cleans up, if initialized.
     82    */
    6483    Pong::~Pong()
    6584    {
     
    6887    }
    6988
     89    /**
     90    @brief
     91        Cleans up the Gametype by destroying the ball and the bats.
     92    */
    7093    void Pong::cleanup()
    7194    {
    72         if (this->ball_)
     95        if (this->ball_ != NULL) // Destroy the ball, if present.
    7396        {
    7497            this->ball_->destroy();
     
    7699        }
    77100
     101        // Destroy both bats, if present.
    78102        for (size_t i = 0; i < 2; ++i)
    79103        {
    80             if (this->bat_[0])
     104            if (this->bat_[0] != NULL)
    81105            {
    82106                this->bat_[0]->destroy();
     
    86110    }
    87111
     112    /**
     113    @brief
     114        Starts the Pong minigame.
     115    */
    88116    void Pong::start()
    89117    {
    90         if (this->center_)
    91         {
    92             if (!this->ball_)
     118        if (this->center_ != NULL) // There needs to be a PongCenterpoint, i.e. the area the game takes place.
     119        {
     120            if (this->ball_ == NULL) // If there is no ball, create a new ball.
    93121            {
    94122                this->ball_ = new PongBall(this->center_);
     123                // Apply the template for the ball specified by the centerpoint.
    95124                this->ball_->addTemplate(this->center_->getBalltemplate());
    96125            }
    97126
     127            // Attach the ball to the centerpoint and set the parameters as specified in the centerpoint, the ball is attached to.
    98128            this->center_->attach(this->ball_);
    99129            this->ball_->setPosition(0, 0, 0);
     
    103133            this->ball_->setBatLength(this->center_->getBatLength());
    104134
    105             if (!this->bat_[0])
     135            // If one of the bats is missing, create it. Apply the template for the bats as specified in the centerpoint.
     136            for (size_t i = 0; i < 2; ++i)
    106137            {
    107                 this->bat_[0] = new PongBat(this->center_);
    108                 this->bat_[0]->addTemplate(this->center_->getBattemplate());
     138                if (this->bat_[i] == NULL)
     139                {
     140                    this->bat_[i] = new PongBat(this->center_);
     141                    this->bat_[i]->addTemplate(this->center_->getBattemplate());
     142                }
    109143            }
    110             if (!this->bat_[1])
    111             {
    112                 this->bat_[1] = new PongBat(this->center_);
    113                 this->bat_[1]->addTemplate(this->center_->getBattemplate());
    114             }
    115 
     144
     145            // Attach the bats to the centerpoint and set the parameters as specified in the centerpoint, the bats are attached to.
    116146            this->center_->attach(this->bat_[0]);
    117147            this->center_->attach(this->bat_[1]);
     
    127157            this->bat_[1]->setLength(this->center_->getBatLength());
    128158
     159            // Set the bats for the ball.
    129160            this->ball_->setBats(this->bat_);
    130161        }
    131         else
     162        else // If no centerpoint was specified, an error is thrown and the level is exited.
    132163        {
    133164            COUT(1) << "Error: No Centerpoint specified." << std::endl;
    134         }
    135 
     165            GSLevel::startMainMenu();
     166            return;
     167        }
     168
     169        // Start the timer. After it has expired the ball is started.
    136170        this->starttimer_.startTimer();
    137171
    138 
     172        // Set variable to temporarily force the player to spawn.
    139173        bool temp = this->bForceSpawn_;
    140174        this->bForceSpawn_ = true;
    141175
     176        // Call start for the parent class.
    142177        Deathmatch::start();
    143178
     179        // Reset the variable.
    144180        this->bForceSpawn_ = temp;
    145181    }
    146182
     183    /**
     184    @brief
     185        Ends the Pong minigame.
     186    */
    147187    void Pong::end()
    148188    {
    149189        this->cleanup();
    150190
     191        // Call end for the parent class.
    151192        Deathmatch::end();
    152193    }
    153194
     195    /**
     196    @brief
     197        Spawns players, and fills the rest up with bots.
     198    */
    154199    void Pong::spawnPlayersIfRequested()
    155200    {
     
    164209    }
    165210
     211    /**
     212    @brief
     213        Spawns the input player.
     214    @param player
     215        The player to be spawned.
     216    */
    166217    void Pong::spawnPlayer(PlayerInfo* player)
    167218    {
    168         if (!this->bat_[0]->getPlayer())
     219        assert(player);
     220
     221        // If the first (left) bat has no player.
     222        if (this->bat_[0]->getPlayer() == NULL)
    169223        {
    170224            player->startControl(this->bat_[0]);
    171225            this->players_[player].state_ = PlayerState::Alive;
    172226        }
    173         else if (!this->bat_[1]->getPlayer())
     227        // If the second (right) bat has no player.
     228        else if (this->bat_[1]->getPlayer() == NULL)
    174229        {
    175230            player->startControl(this->bat_[1]);
    176231            this->players_[player].state_ = PlayerState::Alive;
    177232        }
     233        // If both bats are taken.
    178234        else
    179235            return;
    180236
    181         if (player && player->getController() && player->getController()->isA(Class(PongAI)))
     237        // If the player is an AI, it receives a pointer to the ball.
     238        if (player->getController() != NULL && player->getController()->isA(Class(PongAI)))
    182239        {
    183240            PongAI* ai = orxonox_cast<PongAI*>(player->getController());
     
    186243    }
    187244
     245    /**
     246    @brief
     247        Is called when the player scored.
     248    */
    188249    void Pong::playerScored(PlayerInfo* player)
    189250    {
    190251        Deathmatch::playerScored(player);
    191252
    192         if (this->center_)
    193         {
     253        if (this->center_ != NULL) // If there is a centerpoint.
     254        {
     255            // Fire an event for the player that has scored, to be able to react to it in the level, e.g. by displaying fireworks.
    194256            if (player == this->getRightPlayer())
    195257                this->center_->fireEvent(FireEventName(PongCenterpoint, right));
     
    197259                this->center_->fireEvent(FireEventName(PongCenterpoint, left));
    198260
    199             if (player)
     261            // Also announce, that the player has scored.
     262            if (player != NULL)
    200263                this->gtinfo_->sendAnnounceMessage(player->getName() + " scored");
    201264        }
    202265
    203         if (this->ball_)
     266        // If there is a ball present, reset its position, velocity and acceleration.
     267        if (this->ball_ != NULL)
    204268        {
    205269            this->ball_->setPosition(Vector3::ZERO);
     
    209273        }
    210274
    211         if (this->bat_[0] && this->bat_[1])
     275        // If there are bats reset them to the middle position.
     276        if (this->bat_[0] != NULL && this->bat_[1] != NULL)
    212277        {
    213278            this->bat_[0]->setPosition(-this->center_->getFieldDimension().x / 2, 0, 0);
     
    215280        }
    216281
     282        // Restart the timer to start the ball.
    217283        this->starttimer_.startTimer();
    218284    }
    219285
     286    /**
     287    @brief
     288        Starts the ball with some default speed.
     289    */
    220290    void Pong::startBall()
    221291    {
    222         if (this->ball_ && this->center_)
     292        if (this->ball_ != NULL && this->center_ != NULL)
    223293            this->ball_->setSpeed(this->center_->getBallSpeed());
    224294    }
    225295
     296    /**
     297    @brief
     298        Get the left player.
     299    @return
     300        Returns a pointer to the player playing on the left. If there is no left player, NULL is returned.
     301    */
    226302    PlayerInfo* Pong::getLeftPlayer() const
    227303    {
    228         if (this->bat_ && this->bat_[0])
     304        if (this->bat_ != NULL && this->bat_[0] != NULL)
    229305            return this->bat_[0]->getPlayer();
    230306        else
     
    232308    }
    233309
     310    /**
     311    @brief
     312        Get the right player.
     313    @return
     314        Returns a pointer to the player playing on the right. If there is no right player, NULL is returned.
     315    */
    234316    PlayerInfo* Pong::getRightPlayer() const
    235317    {
    236         if (this->bat_ && this->bat_[1])
     318        if (this->bat_ != NULL && this->bat_[1] != NULL)
    237319            return this->bat_[1]->getPlayer();
    238320        else
  • code/trunk/src/modules/pong/Pong.h

    r7911 r8108  
    2727 */
    2828
     29/**
     30    @file Pong.h
     31    @brief Declaration of the Pong class.
     32    @ingroup Pong
     33*/
     34
    2935#ifndef _Pong_H__
    3036#define _Pong_H__
     
    3339
    3440#include "tools/Timer.h"
     41
    3542#include "gametypes/Deathmatch.h"
    3643
    3744namespace orxonox
    3845{
     46
     47    /**
     48    @brief
     49        Implements a Pong minigame (<a href="http://en.wikipedia.org/wiki/Pong">Wikipedia::Pong</a>).
     50        It connects the different entities present in a game of Pong.
     51
     52        - The @ref orxonox::PongCenterpoint "PongCenterpoint" is the playing field for the Pong minigame, it allows for configuration of the minigame, e.g. by setting the size of the playing field, or the length of the @ref orxonox::PongBat "PongBats". The playing field is always in the x,y-plane, the x-axis being the horizontal and the z-axis being the vertical axis.<br />
     53        The Pong class redistributes the important parameters defined in @ref orxonox::PongCenterpoint "PongCenterpoint" to the other entities, that need to know them, e.g. the @ref orxonox::PongBall "PongBall" and the @ref orxonox::PongBat "PongBats".<br />
     54        The @ref orxonox::PongCenterpoint "PongCenterpoint" needs to exist in a level with the @ref orxonox::Gametype "Gametype" <em>Pong</em>.
     55        - The @ref orxonox::PongBall "PongBall" is the ball both players play with. The @ref orxonox::PongBall "PongBall" both implements the movement of the ball, as well as the influence of the boundaries and consequently, also the bouncing (off the upper and lower delimiters, and as off the @ref orxonox::PongBat "PongBats") of the ball and the effects of the failure of a player to catch the ball (i.e. the scoring of the other player).
     56        - The two @ref orxonox::PongBat "PongBats" are the entities through which the players can actively participate in the game, by controlling them. The @ref orxonox::PongBat "PongBat" class manages the movement (and restrictions thereof) and the influence of the players on the bats.
     57
     58    @author
     59        Fabian 'x3n' Landau
     60
     61    @ingroup Pong
     62    */
    3963    class _PongExport Pong : public Deathmatch
    4064    {
    4165        public:
    42             Pong(BaseObject* creator);
    43             virtual ~Pong();
     66            Pong(BaseObject* creator); //!< Constructor. Registers and initializes the object.
     67            virtual ~Pong(); //!< Destructor. Cleans up, if initialized.
    4468
    45             virtual void start();
    46             virtual void end();
     69            virtual void start(); //!< Starts the Pong minigame.
     70            virtual void end(); ///!< Ends the Pong minigame.
    4771
    48             virtual void spawnPlayer(PlayerInfo* player);
     72            virtual void spawnPlayer(PlayerInfo* player); //!< Spawns the input player.
    4973
    50             virtual void playerScored(PlayerInfo* player);
     74            virtual void playerScored(PlayerInfo* player); //!< Is called when the player scored.
    5175
     76            /**
     77            @brief Set the PongCenterpoint (the playing field).
     78            @param center A pointer to the PongCenterpoint to be set.
     79            */
    5280            void setCenterpoint(PongCenterpoint* center)
    5381                { this->center_ = center; }
    5482
    55             PlayerInfo* getLeftPlayer() const;
    56             PlayerInfo* getRightPlayer() const;
     83            PlayerInfo* getLeftPlayer() const; //!< Get the left player.
     84            PlayerInfo* getRightPlayer() const; //!< Get the right player.
    5785
    5886        protected:
    59             virtual void spawnPlayersIfRequested();
     87            virtual void spawnPlayersIfRequested(); //!< Spawns players, and fills the rest up with bots.
    6088
    61             void startBall();
    62             void cleanup();
     89            void startBall(); //!< Starts the ball with some default speed.
     90            void cleanup(); //!< Cleans up the Gametype by destroying the ball and the bats.
    6391
    64             WeakPtr<PongCenterpoint> center_;
    65             WeakPtr<PongBall> ball_;
    66             WeakPtr<PongBat> bat_[2];
    67             Timer starttimer_;
     92            WeakPtr<PongCenterpoint> center_; //!< The playing field.
     93            WeakPtr<PongBall> ball_; //!< The Pong ball.
     94            WeakPtr<PongBat> bat_[2]; //!< The two bats.
     95            Timer starttimer_; //!< A timer to delay the start of the game.
    6896    };
    6997}
  • code/trunk/src/modules/pong/PongAI.cc

    r6417 r8108  
    2727 */
    2828
     29/**
     30    @file PongAI.cc
     31    @brief Implementation of the PongAI class.
     32*/
     33
    2934#include "PongAI.h"
    3035
     
    3237#include "core/ConfigValueIncludes.h"
    3338#include "tools/Timer.h"
     39
    3440#include "worldentities/ControllableEntity.h"
     41
    3542#include "PongBall.h"
    3643
     
    4148    const static float MAX_REACTION_TIME = 0.4f;
    4249
     50    /**
     51    @brief
     52        Constructor. Registers and initializes the object.
     53    */
    4354    PongAI::PongAI(BaseObject* creator) : Controller(creator)
    4455    {
     
    5970    }
    6071
     72    /**
     73    @brief
     74        Destructor. Cleans up the list fo reaction timers.
     75    */
    6176    PongAI::~PongAI()
    6277    {
     
    6580    }
    6681
     82    /**
     83    @brief
     84        Sets config values.
     85    */
    6786    void PongAI::setConfigValues()
    6887    {
     88        // Sets the strength of the PongAi as a config value.
    6989        SetConfigValue(strength_, 0.5).description("A value from 0 to 1 where 0 is weak and 1 is strong.");
    7090    }
    7191
     92    /**
     93    @brief
     94        Is called each tick.
     95        Implements the behavior of the PongAI (i.e. its intelligence).
     96    @param dt
     97        The time that has elapsed since the last tick.
     98    */
    7299    void PongAI::tick(float dt)
    73100    {
    74         if (!this->ball_ || !this->getControllableEntity())
     101        // If either the ball, or the controllable entity (i.e. the bat) don't exist (or aren't set).
     102        if (this->ball_  == NULL || this->getControllableEntity() == NULL)
    75103            return;
    76104
     
    109137            if (this->ballDirection_.x != 1)
    110138            {
    111                 // The ball just startet to approach, initialize all values
     139                // The ball just started to approach, initialize all values
    112140                this->ballDirection_.x = 1;
    113141                this->ballDirection_.y = sgn(ballvel.z);
     
    158186            {
    159187                // We had to correct our position because we moved too far
    160                 // (and delay ist false, so we're not in the wrong place because of a new end-position prediction)
     188                // (and delay is false, so we're not in the wrong place because of a new end-position prediction)
    161189                if (fabs(mypos.z - this->ballEndPosition_) < 0.5 * this->ball_->getBatLength() * this->ball_->getFieldDimension().y)
    162190                {
     
    173201    }
    174202
     203    /**
     204    @brief
     205        Calculates the random offset, that accounts for random errors the AI makes in order to be beatable.
     206        The higher the strength of the AI, the smaller the (expected value of the) error.
     207        The result of this method is stored in this->randomOffset_.
     208    */
    175209    void PongAI::calculateRandomOffset()
    176210    {
     
    184218                                          // exp < 1 -> position is more likely a large number
    185219
    186         // The position shouln't be larger than 0.5 (50% of the bat-length from the middle is the end)
     220        // The position shouldn't be larger than 0.5 (50% of the bat-length from the middle is the end)
    187221        position *= 0.48f;
    188222
     
    194228    }
    195229
     230    /**
     231    @brief
     232        Calculate the end position the ball will be in.
     233        The result of this calculation is stored in this->ballEndPosition_.
     234    */
    196235    void PongAI::calculateBallEndPosition()
    197236    {
     
    295334    }
    296335
     336    /**
     337    @brief
     338        Determine the movement the AI will undertake. (Either -1, 0 or 1)
     339        The result of this calculation is stored in this->movement_;
     340    @param direction
     341        The current direction of movement.
     342    @param bUseDelay
     343        The time by which this move is delayed. (Again, to make the AI less efficient)
     344    */
    297345    void PongAI::move(char direction, bool bUseDelay)
    298346    {
     
    321369    }
    322370
     371    /**
     372    @brief
     373        Is called, when a delayed move takes effect.
     374    */
    323375    void PongAI::delayedMove()
    324376    {
  • code/trunk/src/modules/pong/PongAI.h

    r5929 r8108  
    2727 */
    2828
     29/**
     30    @file PongAI.h
     31    @brief Declaration of the PongAI class.
     32    @ingroup Pong
     33*/
     34
    2935#ifndef _PongAI_H__
    3036#define _PongAI_H__
     
    3339
    3440#include <list>
     41
    3542#include "util/Math.h"
    3643#include "tools/interfaces/Tickable.h"
     44
    3745#include "controllers/Controller.h"
    3846
    3947namespace orxonox
    4048{
     49
     50    /**
     51    @brief
     52        The PongAI is an artificial intelligence for the @ref orxonox::Pong "Pong" gametype.
     53
     54    @author
     55        Fabian 'x3n' Landau
     56
     57    @ingroup Pong
     58    */
    4159    class _PongExport PongAI : public Controller, public Tickable
    4260    {
    4361        public:
    44             PongAI(BaseObject* creator);
     62            PongAI(BaseObject* creator); //!< Constructor. Registers and initializes the object.
    4563            virtual ~PongAI();
    4664
    4765            void setConfigValues();
    4866
    49             virtual void tick(float dt);
     67            virtual void tick(float dt); //!< Implements the behavior of the PongAI (i.e. its intelligence).
    5068
     69            /**
     70            @brief Set the ball for the AI.
     71            @param ball A pointer to the ball.
     72            */
    5173            void setPongBall(PongBall* ball)
    5274                { this->ball_ = ball; }
    5375
    5476        protected:
    55             void calculateRandomOffset();
    56             void calculateBallEndPosition();
    57             void move(char direction, bool bUseDelay);
    58             void delayedMove();
     77            void calculateRandomOffset(); //!< Calculates the random offset, that accounts for random errors the AI makes in order to be beatable.
     78            void calculateBallEndPosition(); //!< Calculate the end position the ball will be in.
     79            void move(char direction, bool bUseDelay); //!< Determine the movement the AI will undertake.
     80            void delayedMove(); //!< Is called, when a delayed move takes effect.
    5981
    60             PongBall* ball_;
    61             Vector2 ballDirection_;
    62             float ballEndPosition_;
    63             float randomOffset_;
    64             bool bChangedRandomOffset_;
    65             float relHysteresisOffset_;
    66             float strength_;
     82            PongBall* ball_; //!< A pointer to the ball.
     83            Vector2 ballDirection_; //!< Vector to store the (x,z) direction in which the ball is flying.
     84            float ballEndPosition_; //!< The calculated end position of the ball.
     85            float randomOffset_; //!< A random offset to introduce random errors (weighted by the strength of the AI) into the AI's behavior.
     86            bool bChangedRandomOffset_; //!< Helper boolean, to change the random offset more often.
     87            float relHysteresisOffset_; //!< A hysteresis offset.
     88            float strength_; //!< The strength of the AI. Ranging from 0 to 1.
    6789
    68             std::list<std::pair<Timer*, char> > reactionTimers_;
    69             char movement_;
    70             char oldMove_;
    71             bool bOscillationAvoidanceActive_;
     90            std::list<std::pair<Timer*, char> > reactionTimers_; //!< A list of reaction timers and the directions that take effect when their timer expires.
     91            char movement_; //!< The planned movement.
     92            char oldMove_; //!< The previous movement.
     93            bool bOscillationAvoidanceActive_; //!< Boolean, to avoid oscillations.
    7294    };
    7395}
  • code/trunk/src/modules/pong/PongBall.cc

    r7886 r8108  
    2727 */
    2828
     29/**
     30    @file PongBall.cc
     31    @brief Implementation of the PongBall class.
     32*/
     33
    2934#include "PongBall.h"
    3035
    3136#include "core/CoreIncludes.h"
    3237#include "core/GameMode.h"
     38
    3339#include "gametypes/Gametype.h"
     40
    3441#include "PongBat.h"
    3542
     
    4047    const float PongBall::MAX_REL_Z_VELOCITY = 1.5;
    4148
     49    /**
     50    @brief
     51        Constructor. Registers and initializes the object.
     52    */
    4253    PongBall::PongBall(BaseObject* creator)
    4354        : MovableEntity(creator)
     
    5768    }
    5869
     70    /**
     71    @brief
     72        Destructor.
     73    */
    5974    PongBall::~PongBall()
    6075    {
     
    6883    }
    6984
     85    /**
     86    @brief
     87        Register variables to synchronize over the network.
     88    */
    7089    void PongBall::registerVariables()
    7190    {
     
    7998    }
    8099
     100    /**
     101    @brief
     102        Is called every tick.
     103        Handles the movement of the ball and its interaction with the boundaries and bats.
     104    @param dt
     105        The time since the last tick.
     106    */
    81107    void PongBall::tick(float dt)
    82108    {
    83109        SUPER(PongBall, tick, dt);
    84110
     111        // Get the current position, velocity and acceleration of the ball.
    85112        Vector3 position = this->getPosition();
    86113        Vector3 velocity = this->getVelocity();
    87114        Vector3 acceleration = this->getAcceleration();
    88115
     116        // If the ball has gone over the top or bottom boundary of the playing field (i.e. the ball has hit the top or bottom delimiters).
    89117        if (position.z > this->fieldHeight_ / 2 || position.z < -this->fieldHeight_ / 2)
    90118        {
     119            // Its velocity in z-direction is inverted (i.e. it bounces off).
    91120            velocity.z = -velocity.z;
     121            // And its position is set as to not overstep the boundary it has just crossed.
    92122            if (position.z > this->fieldHeight_ / 2)
    93123                position.z = this->fieldHeight_ / 2;
     
    98128        }
    99129
     130        // If the ball has crossed the left or right boundary of the playing field (i.e. a player has just scored, if the bat isn't there to parry).
    100131        if (position.x > this->fieldWidth_ / 2 || position.x < -this->fieldWidth_ / 2)
    101132        {
    102133            float distance = 0;
    103134
    104             if (this->bat_)
     135            if (this->bat_ != NULL) // If there are bats.
    105136            {
    106                 if (position.x > this->fieldWidth_ / 2 && this->bat_[1])
     137                // If the right boundary has been crossed.
     138                if (position.x > this->fieldWidth_ / 2 && this->bat_[1] != NULL)
    107139                {
     140                    // Calculate the distance (in z-direction) between the ball and the center of the bat, weighted by half of the effective length of the bat (with additional 10%)
    108141                    distance = (position.z - this->bat_[1]->getPosition().z) / (this->fieldHeight_ * (this->batlength_ * 1.10f) / 2);
    109                     if (fabs(distance) <= 1)
    110                     {
     142                    if (fabs(distance) <= 1) // If the bat is there to parry.
     143                    {
     144                        // Set the ball to be exactly at the boundary.
    111145                        position.x = this->fieldWidth_ / 2;
     146                        // Invert its velocity in x-direction (i.e. it bounces off).
    112147                        velocity.x = -velocity.x;
     148                        // Adjust the velocity in the z-direction, depending on where the ball hit the bat.
    113149                        velocity.z = distance * distance * sgn(distance) * PongBall::MAX_REL_Z_VELOCITY * this->speed_;
    114150                        acceleration = this->bat_[1]->getVelocity() * this->accelerationFactor_ * -1;
     
    116152                        this->fireEvent();
    117153                    }
     154                    // If the left player scores.
    118155                    else if (GameMode::isMaster() && position.x > this->fieldWidth_ / 2 * (1 + this->relMercyOffset_))
    119156                    {
     
    125162                    }
    126163                }
    127                 if (position.x < -this->fieldWidth_ / 2 && this->bat_[0])
     164                // If the left boundary has been crossed.
     165                else if (position.x < -this->fieldWidth_ / 2 && this->bat_[0] != NULL)
    128166                {
     167                    // Calculate the distance (in z-direction) between the ball and the center of the bat, weighted by half of the effective length of the bat (with additional 10%)
    129168                    distance = (position.z - this->bat_[0]->getPosition().z) / (this->fieldHeight_ * (this->batlength_ * 1.10f) / 2);
    130                     if (fabs(distance) <= 1)
    131                     {
     169                    if (fabs(distance) <= 1) // If the bat is there to parry.
     170                    {
     171                        // Set the ball to be exactly at the boundary.
    132172                        position.x = -this->fieldWidth_ / 2;
     173                        // Invert its velocity in x-direction (i.e. it bounces off).
    133174                        velocity.x = -velocity.x;
     175                        // Adjust the velocity in the z-direction, depending on where the ball hit the bat.
    134176                        velocity.z = distance * distance * sgn(distance) * PongBall::MAX_REL_Z_VELOCITY * this->speed_;
    135177                        acceleration = this->bat_[0]->getVelocity() * this->accelerationFactor_ * -1;
     
    137179                        this->fireEvent();
    138180                    }
     181                    // If the right player scores.
    139182                    else if (GameMode::isMaster() && position.x < -this->fieldWidth_ / 2 * (1 + this->relMercyOffset_))
    140183                    {
     
    149192        }
    150193
     194        // Set the position, velocity and acceleration of the ball, if they have changed.
    151195        if (acceleration != this->getAcceleration())
    152196            this->setAcceleration(acceleration);
     
    157201    }
    158202
     203    /**
     204    @brief
     205        Set the speed of the ball (in x-direction).
     206    @param speed
     207        The speed to be set.
     208    */
    159209    void PongBall::setSpeed(float speed)
    160210    {
    161         if (speed != this->speed_)
     211        if (speed != this->speed_) // If the speed changes
    162212        {
    163213            this->speed_ = speed;
    164214
     215            // Set the speed in the direction of the balls current velocity.
    165216            Vector3 velocity = this->getVelocity();
    166217            if (velocity.x != 0)
    167218                velocity.x = sgn(velocity.x) * this->speed_;
    168             else
     219            else // If the balls current velocity is zero, the speed is set in a random direction.
    169220                velocity.x = this->speed_ * sgn(rnd(-1,1));
    170221
     
    173224    }
    174225
     226    /**
     227    @brief
     228        Set the bats for the ball.
     229    @param bats
     230        An array (of size 2) of weak pointers, to be set as the new bats.
     231    */
    175232    void PongBall::setBats(WeakPtr<PongBat>* bats)
    176233    {
    177         if (this->bDeleteBats_)
     234        if (this->bDeleteBats_) // If there are already some bats, delete them.
    178235        {
    179236            delete[] this->bat_;
     
    182239
    183240        this->bat_ = bats;
     241        // Also store their object IDs, for synchronization.
    184242        this->batID_[0] = this->bat_[0]->getObjectID();
    185243        this->batID_[1] = this->bat_[1]->getObjectID();
    186244    }
    187245
     246    /**
     247    @brief
     248        Get the bats over the network.
     249    */
    188250    void PongBall::applyBats()
    189251    {
    190         if (!this->bat_)
     252        // Make space for the bats, if they don't exist, yet.
     253        if (this->bat_ == NULL)
    191254        {
    192255            this->bat_ = new WeakPtr<PongBat>[2];
  • code/trunk/src/modules/pong/PongBall.h

    r7885 r8108  
    2727 */
    2828
     29/**
     30    @file PongBall.h
     31    @brief Declaration of the PongBall class.
     32    @ingroup Pong
     33*/
     34
    2935#ifndef _PongBall_H__
    3036#define _PongBall_H__
     
    3339
    3440#include "util/Math.h"
     41
    3542#include "worldentities/MovableEntity.h"
    3643
    3744namespace orxonox
    3845{
     46
     47    /**
     48    @brief
     49        This class manages the ball for @ref orxonox::Pong "Pong".
     50
     51        It is responsible for both the movement of the ball in the x,z-plane as well as its interaction with the boundaries of the playing field (defined by the @ref orxonox::PongCenterpoint "PongCenterpoint") and the @ref orxonox::PongBat "PongBats". Or more precisely, it makes the ball bounce off then upper and lower delimiters of the playing field, it makes the ball bounce off the bats and also detects when a player scores and takes appropriate measures.
     52
     53    @author
     54        Fabian 'x3n' Landau
     55
     56    @ingroup Pong
     57    */
    3958    class _PongExport PongBall : public MovableEntity
    4059    {
     
    4564            virtual void tick(float dt);
    4665
     66            /**
     67            @brief Set the dimensions of the playing field.
     68            @param width The width of the playing field.
     69            @param height The height of the playing field.
     70            */
    4771            void setFieldDimension(float width, float height)
    4872                { this->fieldWidth_ = width; this->fieldHeight_ = height; }
     73            /**
     74            @brief Get the dimensions of the playing field.
     75            @param dimension A vector with the width as the first and height as the second component.
     76            */
    4977            void setFieldDimension(const Vector2& dimension)
    5078                { this->setFieldDimension(dimension.x, dimension.y); }
     79            /**
     80            @brief Get the dimensions of the playing field.
     81            @return Returns a vector with the width as the first and height as the second component.
     82            */
    5183            Vector2 getFieldDimension() const
    5284                { return Vector2(this->fieldWidth_, this->fieldHeight_); }
    5385
    54             void setSpeed(float speed);
     86            void setSpeed(float speed); //!< Set the speed of the ball (in x-direction).
     87            /**
     88            @brief Get the speed of the ball (in x-direction).
     89            @return Returns the speed of the ball (in x-direction).
     90            */
    5591            float getSpeed() const
    5692                { return this->speed_; }
    5793
     94            /**
     95            @brief Set the acceleration factor of the ball.
     96            @param factor The factor the acceleration of the ball is set to.
     97            */
    5898            void setAccelerationFactor(float factor)
    5999                { this->accelerationFactor_ = factor; }
     100            /**
     101            @brief Get the acceleration factor of the ball.
     102            @return Returns the acceleration factor of the ball.
     103            */
    60104            float getAccelerationFactor() const
    61105                { return this->accelerationFactor_; }
    62106
     107            /**
     108            @brief Set the length of the bats.
     109            @param batlength The length of the bats (in z-direction) as percentage of the height of the playing field.
     110            */
    63111            void setBatLength(float batlength)
    64112                { this->batlength_ = batlength; }
     113            /**
     114            @brief Get the length of the bats.
     115            @return Returns the length of the bats (in z-direction) as percentage of the height of the playing field.
     116            */
    65117            float getBatLength() const
    66118                { return this->batlength_; }
    67119
    68             void setBats(WeakPtr<PongBat>* bats);
    69             void applyBats();
     120            void setBats(WeakPtr<PongBat>* bats); //!< Set the bats for the ball.
     121            void applyBats(); //!< Get the bats over the network.
    70122
    71123            static const float MAX_REL_Z_VELOCITY;
     
    74126            void registerVariables();
    75127
    76             float fieldWidth_;
    77             float fieldHeight_;
    78             float speed_;
    79             float accelerationFactor_;
    80             float batlength_;
    81             WeakPtr<PongBat>* bat_;
    82             bool bDeleteBats_;
    83             unsigned int* batID_;
    84             float relMercyOffset_;
     128            float fieldWidth_; //!< The width of the playing field.
     129            float fieldHeight_; //!< The height of the playing field.
     130            float speed_; //!< The speed (in x-direction) of the ball.
     131            float accelerationFactor_; //!< The acceleration factor of the ball.
     132            float batlength_; //!< The length of the bats (in z-direction) as percentage of the height of the playing field.
     133            WeakPtr<PongBat>* bat_; //!< An array with the two bats.
     134            bool bDeleteBats_; //!< Bool, to keep track, of whether this->bat_ exists or not.
     135            unsigned int* batID_; //!< The object IDs of the bats, to be able to synchronize them over the network.
     136            float relMercyOffset_; //!< Offset, that makes the player not loose, when, in all fairness, he would have.
    85137    };
    86138}
  • code/trunk/src/modules/pong/PongBat.cc

    r5781 r8108  
    2727 */
    2828
     29/**
     30    @file PongBat.cc
     31    @brief Implementation of the PongBat class.
     32*/
     33
    2934#include "PongBat.h"
    3035
     
    3641    CreateFactory(PongBat);
    3742
     43    /**
     44    @brief
     45        Constructor. Registers and initializes the object.
     46    */
    3847    PongBat::PongBat(BaseObject* creator) : ControllableEntity(creator)
    3948    {
     
    5059    }
    5160
     61    /**
     62    @brief
     63        Registers variables to be synchronized over the network.
     64    */
    5265    void PongBat::registerVariables()
    5366    {
     
    5770    }
    5871
     72    /**
     73    @brief
     74        Is called each tick.
     75        Moves the bat.
     76    @param dt
     77        The time since last tick.
     78    */
    5979    void PongBat::tick(float dt)
    6080    {
     81        // If the bat is controlled (but not over the network).
    6182        if (this->hasLocalController())
    6283        {
    6384            if (this->movement_ != 0)
    6485            {
     86                // The absolute value of the movement is restricted to be lesser or equal than the speed of the bat.
    6587                this->movement_ = clamp(this->movement_, -1.0f, 1.0f) * this->speed_;
    6688
     89                // If moveRightLeft() is used the movement is dependento on wehther it is the right or the left bat, so, it is i.e. dependent on the orientation of the bat.
    6790                if (this->bMoveLocal_)
    6891                    this->setVelocity(this->getOrientation() * Vector3(this->movement_, 0, 0));
     
    7396                this->bSteadiedPosition_ = false;
    7497            }
     98            // If there is no movement but the position has not been steadied, the velocity is set to zero and the position is reaffirmed.
    7599            else if (!this->bSteadiedPosition_)
    76100            {
     
    84108        SUPER(PongBat, tick, dt);
    85109
     110        // Restrict the position of the bats, for them to always be between the upper and lower delimiters. i.e. the bats stall if they reach the upper or lower boundary.
    86111        Vector3 position = this->getPosition();
    87112        if (position.z > this->fieldHeight_ / 2 - this->fieldHeight_ * this->length_ / 2)
     
    96121    }
    97122
     123    /**
     124    @brief
     125        Overloaded the function to steer the bat up and down.
     126    @param value
     127        A vector whose first component is the inverse direction in which we want to steer the bat.
     128    */
    98129    void PongBat::moveFrontBack(const Vector2& value)
    99130    {
     
    102133    }
    103134
     135    /**
     136    @brief
     137        Overloaded the function to steer the bat up and down.
     138    @param value
     139        A vector whose first component is the direction in which we wnat to steer the bat.
     140    */
    104141    void PongBat::moveRightLeft(const Vector2& value)
    105142    {
     
    108145    }
    109146
     147    /**
     148    @brief
     149        Is called when the player changed.
     150    */
    110151    void PongBat::changedPlayer()
    111152    {
  • code/trunk/src/modules/pong/PongBat.h

    r7163 r8108  
    2727 */
    2828
     29/**
     30    @file PongBat.h
     31    @brief Declaration of the PongBat class.
     32    @ingroup Pong
     33*/
     34
    2935#ifndef _PongBat_H__
    3036#define _PongBat_H__
    3137
    3238#include "pong/PongPrereqs.h"
     39
    3340#include "worldentities/ControllableEntity.h"
    3441
    3542namespace orxonox
    3643{
     44
     45    /**
     46    @brief
     47        The PongBat class manages the bats for @ref orxonox::Pong "Pong", which are the elements controlled by the players.
     48
     49        It is responsible for the movement (controlled by the players) of the bat.
     50
     51    @author
     52        Fabian 'x3n' Landau
     53
     54    @ingroup Pong
     55    */
    3756    class _PongExport PongBat : public ControllableEntity
    3857    {
    3958        public:
    40             PongBat(BaseObject* creator);
     59            PongBat(BaseObject* creator); //!< Constructor. Registers and initializes the object.
    4160            virtual ~PongBat() {}
    4261
    4362            virtual void tick(float dt);
    4463
    45             virtual void moveFrontBack(const Vector2& value);
    46             virtual void moveRightLeft(const Vector2& value);
     64            virtual void moveFrontBack(const Vector2& value); //!< Overloaded the function to steer the bat up and down.
     65            virtual void moveRightLeft(const Vector2& value); //!< Overloaded the function to steer the bat up and down.
    4766
    48             virtual void changedPlayer();
     67            virtual void changedPlayer(); //!< Is called when the player changed.
    4968
     69            /**
     70            @brief Set the speed of the bat.
     71            @param speed The speed to be set.
     72            */
    5073            void setSpeed(float speed)
    5174                { this->speed_ = speed; }
     75            /**
     76            @brief Get the speed of the bat.
     77            @return Returns the speed of the bat.
     78            */
    5279            float getSpeed() const
    5380                { return this->speed_; }
    5481
     82            /**
     83            @brief Set the height of the playing field.
     84            @param height The height of the playing field.
     85            */
    5586            void setFieldHeight(float height)
    5687                { this->fieldHeight_ = height; }
     88            /**
     89            @brief Get the height of the playing field.
     90            @return Returns the height of the playing field.
     91            */
    5792            float getFieldHeight() const
    5893                { return this->fieldHeight_; }
    5994
     95            /**
     96            @brief Set the length of the bat.
     97            @param length The length of the bat (in z-direction) as percentage of the height of the playing field.
     98            */
    6099            void setLength(float length)
    61100                { this->length_ = length; }
     101            /**
     102            @brief get the length of the bat.
     103            @return Returns the length of the bat (in z-direction) as percentage of the height of the playing field.
     104            */
    62105            float getLength() const
    63106                { return this->length_; }
    64107
    65108        private:
    66             void registerVariables();
     109            void registerVariables(); //!< Registers variables to be synchronized over the network.
    67110
    68             float movement_;
    69             bool bMoveLocal_;
    70             float speed_;
    71             float length_;
    72             float fieldHeight_;
    73             bool bSteadiedPosition_;
     111            float movement_; //!< The amount (and direction), in z-direction, of movement of the bat.
     112            bool bMoveLocal_; //!< Helper to know whether the movement is caused by moveFrontBack() or moveRightLeft().
     113            float speed_; //!< The movement speed of the bat.
     114            float length_; //!< The length of the bat (in z-direction) as percentage of the height of the playing field.
     115            float fieldHeight_; //!< The height of the playing field.
     116            bool bSteadiedPosition_; //!< Helper boolean, to keep track of when to steady the position, to ensure network synchronicity.
    74117    };
    75118}
  • code/trunk/src/modules/pong/PongBot.cc

    r5781 r8108  
    2727 */
    2828
     29/**
     30    @file PongBot.cc
     31    @brief Implementation of the PongBot class.
     32*/
     33
    2934#include "PongBot.h"
    3035
     
    3641    CreateFactory(PongBot);
    3742
     43    /**
     44    @brief
     45        Constructor. Registers the object and creates a PongAI controller.
     46    */
    3847    PongBot::PongBot(BaseObject* creator) : Bot(creator)
    3948    {
  • code/trunk/src/modules/pong/PongBot.h

    r5781 r8108  
    2727 */
    2828
     29/**
     30    @file PongBot.h
     31    @brief Declaration of the PongBot class.
     32    @ingroup Pong
     33*/
     34
    2935#ifndef _PongBot_H__
    3036#define _PongBot_H__
     
    3541namespace orxonox
    3642{
     43
     44    /**
     45    @brief
     46        A bot especially for @ref orxonox::Pong "Pong".
     47
     48        Uses the @ref orxonox::PongAI "PongAI".
     49
     50    @author
     51        Fabian 'x3n' Landau
     52
     53    @ingroup Pong
     54    */
    3755    class _PongExport PongBot : public Bot
    3856    {
  • code/trunk/src/modules/pong/PongCenterpoint.cc

    r5929 r8108  
    2727 */
    2828
     29/**
     30    @file PongCenterpoint.cc
     31    @brief Implementation of the PongCenterpoint class.
     32*/
     33
    2934#include "PongCenterpoint.h"
    3035
    3136#include "core/CoreIncludes.h"
    3237#include "core/XMLPort.h"
     38
    3339#include "Pong.h"
    3440
     
    3743    CreateFactory(PongCenterpoint);
    3844
     45    /**
     46    @brief
     47        Constructor. Registers and initializes the object and checks whether the gametype is actually Pong.
     48    */
    3949    PongCenterpoint::PongCenterpoint(BaseObject* creator) : StaticEntity(creator)
    4050    {
     
    5161    }
    5262
     63    /**
     64    @brief
     65        Method to create a PongCenterpoint through XML.
     66    */
    5367    void PongCenterpoint::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    5468    {
     
    6478    }
    6579
     80    /**
     81    @brief
     82        Is called when the gametype has changed.
     83    */
    6684    void PongCenterpoint::changedGametype()
    6785    {
    6886        SUPER(PongCenterpoint, changedGametype);
    6987
     88        // Check, whether it's still Pong.
    7089        this->checkGametype();
    7190    }
    7291
     92    /**
     93    @brief
     94        Checks whether the gametype is Pong and if it is, sets its centerpoint.
     95    */
    7396    void PongCenterpoint::checkGametype()
    7497    {
    75         if (this->getGametype() && this->getGametype()->isA(Class(Pong)))
     98        if (this->getGametype() != NULL && this->getGametype()->isA(Class(Pong)))
    7699        {
    77             Pong* pong_gametype = orxonox_cast<Pong*>(this->getGametype().get());
    78             pong_gametype->setCenterpoint(this);
     100            Pong* pongGametype = orxonox_cast<Pong*>(this->getGametype().get());
     101            pongGametype->setCenterpoint(this);
    79102        }
    80103    }
  • code/trunk/src/modules/pong/PongCenterpoint.h

    r5929 r8108  
    2727 */
    2828
     29/**
     30    @file PongCenterpoint.h
     31    @brief Declaration of the PongCenterpoint class.
     32    @ingroup Pong
     33*/
     34
    2935#ifndef _PongCenterpoint_H__
    3036#define _PongCenterpoint_H__
     
    3339
    3440#include <string>
     41
    3542#include <util/Math.h>
     43
    3644#include "worldentities/StaticEntity.h"
    3745
    3846namespace orxonox
    3947{
     48   
     49    /**
     50    @brief
     51        The PongCenterpoint implements the playing field @ref orxonox::Pong "Pong" takes place in and allows for many parameters of the minigame to be set.
     52        The playing field resides in the x,z-plane, with the x-axis being the horizontal axis and the z-axis being the vertical axis.
     53       
     54        Various parameters can be set:
     55        - The <b>dimension</b> is a vector, that defines the width and height of the playing field. The default is <em>(200, 120)</em>.
     56        - The <b>balltemplate</b> is a template that is applied to the @ref orxonox::PongBall "PongBall", it can be used to attach different things to it, e.g. its @ref orxonox::Model "Model". See below for a usage example.
     57        - The <b>battemplate</b> is a template that is applied to the @ref orxonox::PongBall "PongBat", it can be used to attach different things to it, e.g. its @ref orxonox::Model "Model". See below for a usage example.
     58        - The <b>ballspeed</b> is the speed with which the @ref orxonox::PongBall "PongBall" moves. The default is <em>100</em>.
     59        - The <b>ballaccfactor</b> is the acceleration factor for the @ref orxonox::PongBall "PongBall". The default is <em>1.0</em>.
     60        - The <b>batspeed</b> is the speed with which the @ref orxonox::PongBat "PongBats" move. The default is <em>60</em>.
     61        - The <b>batlength</b> is the length of the @ref orxonox::PongBat "PongBats" as the percentage of the height of the playing field. The default is <em>0.25</em>.
     62       
     63        An example in XML of the PongCenterpoint would be:
     64       
     65        First the needed templates:
     66        The template for the @ref orxonox::PongBall "PongBall".
     67        @code
     68        <Template name="pongball">
     69          <PongBall>
     70            <attached>
     71              <Model mesh="sphere.mesh" scale="2" />
     72              <ParticleSpawner name="hiteffect" position="0,0,0" source="Orxonox/sparks2" lifetime="0.01" autostart="0" mainstate="spawn" />
     73            </attached>
     74            <eventlisteners>
     75              <EventTarget target="hiteffect" />
     76            </eventlisteners>
     77          </PongBall>
     78        </Template>
     79        @endcode
     80        As can be seen, a sphere is attached as the @ref orxonox::Model "Model" for the @ref orxonox::PongBall "PongBall", and also an @ref orxonox::EventListener "EventListener" that triggers a @ref orxonox::ParticleSpawner "ParticleSpawner", whenever the ball hits the boundaries is attached.
     81       
     82        Additionally the template for the @ref orxonox::PongBat "PongBat".
     83        @code
     84        <Template name="pongbatcameras" defaults="0">
     85          <PongBat>
     86            <camerapositions>
     87              <CameraPosition position="0,200,0" pitch="-90" absolute="true" />
     88            </camerapositions>
     89          </PongBat>
     90        </Template>
     91
     92        <Template name="pongbat">
     93          <PongBat camerapositiontemplate=pongbatcameras>
     94            <attached>
     95              <Model position="0,0,3" mesh="cube.mesh" scale3D="14,2,2" />
     96            </attached>
     97          </PongBat>
     98        </Template>
     99        @endcode
     100        As can be seen, there are actually two templates. The first template is needed to set the camera for the @ref orxonox::PongBat "PongBat". The second template ist the actual template for the @ref orxonox::PongBat "PongBat", the template for the camera position is added and a @ref orxonox::Model "Model" for the @ref orxonox::PongBat "PongBat" is attached.
     101       
     102        Finally the PongCenterpoint is created.
     103        @code
     104        <PongCenterpoint name="pongcenter" dimension="200,120" balltemplate="pongball" battemplate="pongbat" ballspeed="200" ballaccfactor="1.0" batspeed="130" batlength="0.25">
     105          <attached>
     106            <Model position="0,0,60" mesh="cube.mesh" scale3D="105,1,1" />
     107            <Model position="0,0,-60" mesh="cube.mesh" scale3D="105,1,1" />
     108          </attached>
     109        </PongCenterpoint>
     110        @endcode
     111        All parameters are specified. And also two @ref orxonox::Model "Models" (for the upper and lower boundary) are attached.
     112       
     113        For a more elaborate example, have a look at the <code>pong.oxw</code> level file.
     114   
     115    @author
     116        Fabian 'x3n' Landau
     117       
     118    @ingroup Pong
     119    */
    40120    class _PongExport PongCenterpoint : public StaticEntity
    41121    {
    42122        public:
    43             PongCenterpoint(BaseObject* creator);
     123            PongCenterpoint(BaseObject* creator); //!< Constructor. Registers and initializes the object and checks whether the gametype is actually Pong.
    44124            virtual ~PongCenterpoint() {}
    45125
    46             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    47 
    48             virtual void changedGametype();
    49 
     126            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method to create a PongCenterpoint through XML.
     127
     128            virtual void changedGametype(); //!< Is called when the gametype has changed.
     129
     130            /**
     131            @brief Set the template for the ball. (e.g. to attach the model of the ball, but also to attach an EventListener to it to detect, when it hits the boundaries, and e.g. display some ParticleEffets, when it does.)
     132            @param balltemplate The name of the template to be set.
     133            */
    50134            void setBalltemplate(const std::string& balltemplate)
    51135                { this->balltemplate_ = balltemplate; }
     136            /**
     137            @brief Get the template of the ball.
     138            @return Returns the name of the template of the ball.
     139            */
    52140            const std::string& getBalltemplate() const
    53141                { return this->balltemplate_; }
    54142
     143            /**
     144            @brief Set the template for the bats. (e.g. to attach the model of the bat, but also to attach CameraPositions to it, to be able to view the game from the bats perspective)
     145            @param battemplate The name of the template to be set.
     146            */
    55147            void setBattemplate(const std::string& battemplate)
    56148                { this->battemplate_ = battemplate; }
     149            /**
     150            @brief Get the template of the bats.
     151            @return Returns the name of the template of the bats.
     152            */
    57153            const std::string& getBattemplate() const
    58154                { return this->battemplate_; }
    59155
     156            /**
     157            @brief Set the dimensions of the playing field.
     158            @param dimension A vector with the width of the playing field as first component and the height as second.
     159            */
    60160            void setFieldDimension(const Vector2& dimension)
    61161                { this->width_ = dimension.x; this->height_ = dimension.y; }
     162            /**
     163            @brief Get the dimensions of the playing field.
     164            @return Returns a vector with the width of the playing field as first component and the height as second.
     165            */
    62166            Vector2 getFieldDimension() const
    63167                { return Vector2(this->width_, this->height_); }
    64168
     169            /**
     170            @brief Set the speed of the ball.
     171            @param ballspeed The speed of the ball.
     172            */
    65173            void setBallSpeed(float ballspeed)
    66174                { this->ballspeed_ = ballspeed; }
     175            /**
     176            @brief Get the speed of the ball.
     177            @return Returns the speed of the ball.
     178            */
    67179            float getBallSpeed() const
    68180                { return this->ballspeed_; }
    69181
     182            /**
     183            @brief Set the ball's acceleration factor.
     184            @param ballaccfactor The ball's acceleration factor.
     185            */
    70186            void setBallAccelerationFactor(float ballaccfactor)
    71187                { this->ballaccfactor_ = ballaccfactor; }
     188            /**
     189            @brief Get the ball's acceleration factor
     190            @return Returns the ball's acceleration factor.
     191            */
    72192            float getBallAccelerationFactor() const
    73193                { return this->ballaccfactor_; }
    74194
     195            /**
     196            @brief Set the speed of the bats.
     197            @param batspeed The speed of the bats.
     198            */
    75199            void setBatSpeed(float batspeed)
    76200                { this->batspeed_ = batspeed; }
     201            /**
     202            @brief Get the speed of the bats.
     203            @return Returns the speed of the bats.
     204            */
    77205            float getBatSpeed() const
    78206                { return this->batspeed_; }
    79207
     208            /**
     209            @brief Set the length of the bats.
     210            @param batlength The length of the bats (in z-direction) as a percentage of the height of the playing field.
     211            */
    80212            void setBatLength(float batlength)
    81213                { this->batlength_ = batlength; }
     214            /**
     215            @brief Get the length of the bats.
     216            @return Returns the length of the bats (in z-direction) as a percentage of the height of the playing field.
     217            */
    82218            float getBatLength() const
    83219                { return this->batlength_; }
    84220
    85221        private:
    86             void checkGametype();
    87 
    88             std::string balltemplate_;
    89             std::string battemplate_;
    90 
    91             float ballspeed_;
    92             float ballaccfactor_;
    93             float batspeed_;
    94             float batlength_;
    95 
    96             float width_;
    97             float height_;
     222            void checkGametype(); //!< Checks whether the gametype is Pong and if it is, sets its centerpoint.
     223
     224            std::string balltemplate_; //!< The template for the ball.
     225            std::string battemplate_; //!< The template for the bats.
     226
     227            float ballspeed_; //!< The speed of then ball.
     228            float ballaccfactor_; //!< The acceleration factor of the ball.
     229            float batspeed_; //!< The speed of the bat.
     230            float batlength_; //!< The length of the bat (in z-direction) as a percentage of the height of the playing field.
     231
     232            float width_; //!< The height of the playing field.
     233            float height_; //!< The width of the playing field.
    98234    };
    99235}
  • code/trunk/src/modules/pong/PongScore.cc

    r6417 r8108  
    2727 */
    2828
     29/**
     30    @file PongScore.cc
     31    @brief Implementation of the PongScore class.
     32*/
     33
    2934#include "PongScore.h"
    3035
    31 #include "util/Convert.h"
    3236#include "core/CoreIncludes.h"
    3337#include "core/XMLPort.h"
     38#include "util/Convert.h"
     39
     40#include "infos/PlayerInfo.h"
     41
    3442#include "Pong.h"
    35 #include "infos/PlayerInfo.h"
    3643
    3744namespace orxonox
     
    3946    CreateFactory(PongScore);
    4047
     48    /**
     49    @brief
     50        Constructor. Registers and initializes the object.
     51    */
    4152    PongScore::PongScore(BaseObject* creator) : OverlayText(creator)
    4253    {
     
    5162    }
    5263
     64    /**
     65    @brief
     66        Destructor.
     67    */
    5368    PongScore::~PongScore()
    5469    {
    5570    }
    5671
     72    /**
     73    @brief
     74        Method to create a PongScore through XML.
     75    */
    5776    void PongScore::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    5877    {
     
    6584    }
    6685
     86    /**
     87    @brief
     88        Is called each tick.
     89        Creates and sets the caption to be displayed by the PongScore.
     90    @param dt
     91        The time that has elapsed since the last tick.
     92    */
    6793    void PongScore::tick(float dt)
    6894    {
    6995        SUPER(PongScore, tick, dt);
    7096
    71         if (this->owner_)
     97        // If the owner is set. The owner being a Pong game.
     98        if (this->owner_ != NULL)
    7299        {
     100            // Get the two players.
    73101            PlayerInfo* player1 = this->owner_->getLeftPlayer();
    74102            PlayerInfo* player2 = this->owner_->getRightPlayer();
     
    80108            std::string score2("0");
    81109
    82             if (player1)
     110            // Save the name and score of each player as a string.
     111            if (player1 != NULL)
    83112            {
    84113                name1 = player1->getName();
    85114                score1 = multi_cast<std::string>(this->owner_->getScore(player1));
    86115            }
    87 
    88             if (player2)
     116            if (player2 != NULL)
    89117            {
    90118                name2 = player2->getName();
     
    92120            }
    93121
     122            // Assemble the strings, depending on what should all be displayed.
    94123            std::string output1;
    95124            if (this->bShowLeftPlayer_)
    96125            {
    97                 if (this->bShowName_ && this->bShowScore_ && player1)
     126                if (this->bShowName_ && this->bShowScore_ && player1 != NULL)
    98127                    output1 = name1 + " - " + score1;
    99128                else if (this->bShowScore_)
     
    106135            if (this->bShowRightPlayer_)
    107136            {
    108                 if (this->bShowName_ && this->bShowScore_ && player2)
     137                if (this->bShowName_ && this->bShowScore_ && player2 != NULL)
    109138                    output2 = score2 + " - " + name2;
    110139                else if (this->bShowScore_)
     
    127156    }
    128157
    129 
     158    /**
     159    @brief
     160        Is called when the owner changes.
     161        Sets the owner to NULL, if it is not a pointer to a Pong game.
     162    */
    130163    void PongScore::changedOwner()
    131164    {
    132165        SUPER(PongScore, changedOwner);
    133166
    134         if (this->getOwner() && this->getOwner()->getGametype())
     167        if (this->getOwner() != NULL && this->getOwner()->getGametype())
    135168            this->owner_ = orxonox_cast<Pong*>(this->getOwner()->getGametype().get());
    136169        else
  • code/trunk/src/modules/pong/PongScore.h

    r5781 r8108  
    2727 */
    2828
     29/**
     30    @file PongScore.h
     31    @brief Declaration of the PongScore class.
     32    @ingroup Pong
     33*/
     34
    2935#ifndef _PongScore_H__
    3036#define _PongScore_H__
     
    3339
    3440#include "tools/interfaces/Tickable.h"
     41
    3542#include "overlays/OverlayText.h"
    3643
    3744namespace orxonox
    3845{
     46
     47    /**
     48    @brief
     49        The PongScore class displays the score for a game of @ref orxonox::Pong "Pong".
     50
     51    @author
     52        Fabian 'x3n' Landau
     53
     54    @ingroup Pong
     55    */
    3956    class _PongExport PongScore : public OverlayText, public Tickable
    4057    {
     
    4360            virtual ~PongScore();
    4461
    45             virtual void tick(float dt);
     62            virtual void tick(float dt); //!< Creates and sets the caption to be displayed by the PongScore.
    4663            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    47             virtual void changedOwner();
     64            virtual void changedOwner(); //!< Is called when the owner changes.
    4865
     66            /**
     67            @brief Set whether the PongScore displays the players' names.
     68            @param value If true the players' names are displayed.
     69            */
    4970            inline void setShowName(bool value)
    5071                { this->bShowName_ = value; }
     72            /**
     73            @brief Get whether the PongScore displays the players' names.
     74            @return Returns true if the players' names are displayed, false otherwise.
     75            */
    5176            inline bool getShowName() const
    5277                { return this->bShowName_; }
    5378
     79            /**
     80            @brief Set whether the PongScore displays the players' scores.
     81            @param value If true the players' scores are displayed.
     82            */
    5483            inline void setShowScore(bool value)
    5584                { this->bShowScore_ = value; }
     85            /**
     86            @brief Get whether the PongScore displays the players' scores.
     87            @return Returns true if the players' scores are displayed, false otherwise.
     88            */
    5689            inline bool getShowScore() const
    5790                { return this->bShowScore_; }
    5891
     92            /**
     93            @brief Set whether the PongScore displays the left player.
     94            @param value If true the left player is displayed.
     95            */
    5996            inline void setShowLeftPlayer(bool value)
    6097                { this->bShowLeftPlayer_ = value; }
     98            /**
     99            @brief Get whether the PongScore displays the left player.
     100            @return Returns true if the left player is displayed, false otherwise.
     101            */
    61102            inline bool getShowLeftPlayer() const
    62103                { return this->bShowLeftPlayer_; }
    63104
     105            /**
     106            @brief Set whether the PongScore displays the right player.
     107            @param value If true the right player is displayed.
     108            */
    64109            inline void setShowRightPlayer(bool value)
    65110                { this->bShowRightPlayer_ = value; }
     111            /**
     112            @brief Get whether the PongScore displays the right player.
     113            @return Returns true if the right player is displayed, false otherwise.
     114            */
    66115            inline bool getShowRightPlayer() const
    67116                { return this->bShowRightPlayer_; }
    68117
    69118        private:
    70             Pong* owner_;
    71             bool bShowName_;
    72             bool bShowScore_;
    73             bool bShowLeftPlayer_;
    74             bool bShowRightPlayer_;
     119            Pong* owner_; //!< The Pong game that owns this PongScore.
     120            bool bShowName_; //!< Whether the names of the players are shown.
     121            bool bShowScore_; //!< Whether the score of the players is shown.
     122            bool bShowLeftPlayer_; //!< Whether the left player is shown.
     123            bool bShowRightPlayer_; //!< Whether the right player is shown.
    75124    };
    76125}
Note: See TracChangeset for help on using the changeset viewer.