Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/orxonox/worldentities/SpaceBoundaries.h @ 8602

Last change on this file since 8602 was 8458, checked in by smerkli, 14 years ago

merged spaceboundaries

File size: 5.8 KB
RevLine 
[8087]1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Maurus Kaufmann
24 *   Co-authors:
25 *      ...
26 *
27 */
[8201]28 
[8404]29 /* TODO:   - Textmessages und Billboards sollen teils nur bei einem humanPlayer angezeigt werden, nicht bei allen (vgl. Netzwerk-Spiel mit mehreren humanPlayers)
30                beachte hierzu folgende statische Funktion: 'static unsigned int  Host::getPlayerID()'
31                (file:///home/kmaurus/orxonox/spaceBoundaries/build/doc/api/html/classorxonox_1_1_host.html#9c1e3b39e3b42e467dfbf42902911ce2)
32               
33            - Kommentieren (Betrachte als Beispiel/Vorbild 'libraries/core/WeakPtr.h')
34           
35            - Wiki-SpaceBoundaries-Eintrag aktualisieren
[8201]36 */
[8087]37
38#ifndef _SpaceBoundaries_H__
39#define _SpaceBoundaries_H__
40
[8404]41
[8110]42#include "core/CoreIncludes.h"
[8404]43#include "core/WeakPtr.h"
[8110]44#include "tools/interfaces/Tickable.h"
[8201]45#include "interfaces/RadarViewable.h"
[8110]46#include "worldentities/StaticEntity.h"
47#include "worldentities/WorldEntity.h"
[8087]48
[8164]49#include <string>
[8281]50#include <list>
[8301]51#include <map>
52#include <vector>
[8164]53
[8404]54namespace orxonox
55{
56
[8201]57/**
[8404]58@brief SpaceBoundaries gives level creators the possibility to bar Pawns from leaving a defined area (until now this area is a ball).
[8164]59
[8244]60       Five attributes can/should be defined in the XML-File:
[8237]61       - 'warnDistance' : If the distance between the pawn of the human player and 'position' is bigger than 'warnDistance', a message is displayed to
62                          inform the player that he'll soon be leaving the allowed area.
63       - 'maxDistance' : defines the area, where a pawn is allowed to be (radius of a ball).
[8244]64       - 'showDistance' : If the distance between the pawn and the boundary of the allowed area is smaller than 'showDistance', the boundary is shown.
[8404]65       - 'healthDecrease' : a measure to define how fast the health of a pawn should decrease after leaving the allowed area (unnecessary if 'reactionMode' == 0).
66                            Recommended values: 0.1 (slow health decrease) to 5 (very fast health decrease)
67       - 'reactionMode' : Integer-Value. Defines what effect appears if a space ship has crossed the boundaries.
68                            0: Reflect the space ship (default).
69                            1: Decrease Health of the space ship after having left the allowed area.
[8201]70*/
71
[8087]72    class _OrxonoxExport SpaceBoundaries : public StaticEntity, public Tickable
73    {
74        public:
75            SpaceBoundaries(BaseObject* creator);
[8110]76            ~SpaceBoundaries();
77           
[8301]78            void checkWhoIsIn(); //!< Update the list 'pawnsIn_'.
[8281]79           
[8404]80            void positionBillboard(const Vector3 position); //!< Display a Billboard at the position 'position'.
[8301]81            void setBillboardOptions(Billboard *billy);
[8404]82            void removeAllBillboards(); //!< Hide all all elements of '*billboard_' and set their attribute 'usedYet' to 0.
[8301]83           
[8244]84            void setMaxDistance(float r);
[8110]85            float getMaxDistance();
86           
87            void setWarnDistance(float r);
88            float getWarnDistance();
[8201]89           
[8244]90            void setShowDistance(float r);
91            float getShowDistance();
92           
[8201]93            void setHealthDecrease(float amount);
94            float getHealthDecrease();
[8404]95           
96            void setReaction(int mode);
97            int getReaction();
[8087]98
[8110]99            void XMLPort(Element& xmlelement, XMLPort::Mode mode);
100           
101            void tick(float dt);
[8087]102
103        private:
[8301]104            struct billboardAdministration{ bool usedYet; Billboard* billy; };
105           
[8404]106            std::list<WeakPtr<Pawn> > pawnsIn_; //!< List of the pawns that this instance of SpaceBoundaries has to handle.
[8301]107           
108            std::vector<billboardAdministration> billboards_;
[8281]109       
[8404]110            int reaction_; //!< Werte: 0, 1. 0: Reflektion an Boundaries (Standard). 1: Health-Abzug-Modus.
[8201]111            float maxDistance_; //!< maximal zulaessige Entfernung von 'this->getPosition()'.
112            float warnDistance_; //!< Entfernung von 'this->getPosition()', ab der eine Warnung angezeigt wird, dass man bald das zulaessige Areal verlaesst.
[8244]113            float showDistance_; //!< Definiert, wann die Grenzen visualisiert werden sollen.
[8201]114           
115            float healthDecrease_; //!< Mass fuer die Anzahl Health-Points, die nach ueberschreiten der Entfernung 'maxDistance_' von 'this->getPosition()' abgezogen werden.
116                                   //!< Empfohlene Werte: 0.1 (langsame Health-Verminderung) bis 5 (sehr schnelle Health-Verminderung)
117           
[8237]118            RadarViewable* centerRadar_; //!< Repraesentation von SpaceBoundaries auf dem Radar.
[8087]119       
[8201]120            float computeDistance(WorldEntity *item); //!< Auf den Mittelpunkt 'this->getPosition()' bezogen.
[8164]121            void displayWarning(const std::string warnText);
[8244]122            void displayBoundaries(Pawn *item);
[8404]123            void conditionalBounceBack(Pawn *item, float currentDistance, float dt);
[8164]124            bool isHumanPlayer(Pawn *item);
[8201]125           
[8087]126    };
127}
128
129#endif /* _SpaceBoundaries_H__ */
Note: See TracBrowser for help on using the repository browser.