Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/modules/objects/SpaceBoundaries.h @ 8822

Last change on this file since 8822 was 8767, checked in by dafrick, 13 years ago

Some cleanup…

  • Property svn:eol-style set to native
File size: 5.7 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 */
28
29#ifndef _SpaceBoundaries_H__
30#define _SpaceBoundaries_H__
31
[8632]32#include "objects/ObjectsPrereqs.h"
[8404]33
[8632]34#include <string>
35#include <list>
36#include <vector>
37
[8110]38#include "core/CoreIncludes.h"
[8404]39#include "core/WeakPtr.h"
[8632]40
[8110]41#include "tools/interfaces/Tickable.h"
42#include "worldentities/StaticEntity.h"
[8087]43
[8404]44namespace orxonox
45{
46
[8767]47    /**
48    @brief SpaceBoundaries gives level creators the possibility to bar Pawns from leaving a defined area (until now this area is a ball).
[8164]49
[8767]50        Some attributes can/should be defined in the XML-File:
51        - 'position' : absolute position of the object of SpaceBoundaries in the level (usually 0,0,0)
52        - 'maxDistance' : defines the area, where a pawn is allowed to be (radius of a ball).
53        - 'warnDistance' : If the distance between the pawn of the human player and 'position' is bigger than 'warnDistance', a message is displayed to
54                            inform the player that he'll soon be leaving the allowed area. (not implemented yet!)
55        - 'showDistance' : If the distance between the pawn and the boundary of the allowed area is smaller than 'showDistance', the boundary is shown.
56        - 'reactionMode' : Integer-Value. Defines what effect appears if a space ship has crossed the boundaries.
57                                0: Reflect the space ship (default).
58                                1: Decrease Health of the space ship after having left the allowed area.
59                                2: Inverted Version of 0. Prohibit to fly INTO a defined area.
60        - 'healthDecrease' : a measure to define how fast the health of a pawn should decrease after leaving the allowed area (unnecessary if 'reactionMode' == 0).
61                                Recommended values: 0.1 (slow health decrease) to 5 (very fast health decrease)
[8614]62
[8767]63        Follow http://www.orxonox.net/wiki/SpaceBoundaries to get some further information.
[8614]64
[8767]65        Examples:
66        Two examples how one could include SpaceBoundaries in the XML-File. The first one uses reflection, the second one health decrease.
67        @code
68        <SpaceBoundaries position="0,0,0" maxDistance="1000" warnDistance="800" showDistance="100" reactionMode="0" />
69        @endcode
[8614]70
[8767]71        @code
72        <SpaceBoundaries position="0,0,0" maxDistance="1000" warnDistance="800" showDistance="100" reactionMode="1" healthDecrease="0.2" />
73        @endcode
74    */
[8632]75    class _ObjectsExport SpaceBoundaries : public StaticEntity, public Tickable
[8087]76    {
77        public:
78            SpaceBoundaries(BaseObject* creator);
[8110]79            ~SpaceBoundaries();
[8767]80
[8244]81            void setMaxDistance(float r);
[8110]82            float getMaxDistance();
[8767]83
[8110]84            void setWarnDistance(float r);
85            float getWarnDistance();
[8767]86
[8244]87            void setShowDistance(float r);
88            float getShowDistance();
[8767]89
[8201]90            void setHealthDecrease(float amount);
91            float getHealthDecrease();
[8767]92
[8404]93            void setReaction(int mode);
94            int getReaction();
[8087]95
[8110]96            void XMLPort(Element& xmlelement, XMLPort::Mode mode);
[8767]97
[8110]98            void tick(float dt);
[8087]99
100        private:
[8660]101            struct BillboardAdministration{ bool usedYet; Billboard* billy; };
[8767]102
[8614]103            // Variabeln::
[8404]104            std::list<WeakPtr<Pawn> > pawnsIn_; //!< List of the pawns that this instance of SpaceBoundaries has to handle.
[8767]105
[8660]106            std::vector<BillboardAdministration> billboards_;
[8767]107
[8614]108            int reaction_; //!< Values: 0, 1, 2.
109                           //!< 0: Reflection on boundary (Standard).
110                           //!< 1: Decrease-Health-Mode.
111                           //!< 2: Inverted Version of 0. Prohibit to fly INTO a defined area.
112            float maxDistance_; //!<  Maximum allowed distance.
113            float warnDistance_; //!< Distance in which a warning is displayed.
114            float showDistance_; //!< Distance at which the boundaries are displayed.
[8767]115
[8614]116            float healthDecrease_; //!< Rate of health loss.
[8767]117
[8614]118            //RadarViewable* centerRadar_; //!< Representation of the space boundary in the radar.
[8767]119
[8614]120            // Funktionen::
121            float computeDistance(WorldEntity *item); //!< Compute distance to center point.
122            void displayWarning(const std::string warnText); //!< TODO: Implement.
[8660]123            void displayBoundaries(Pawn *item, float alpha);
[8404]124            void conditionalBounceBack(Pawn *item, float currentDistance, float dt);
[8614]125            void bounceBack(Pawn *item, Vector3 *normal, Vector3 *velocity);
[8164]126            bool isHumanPlayer(Pawn *item);
[8767]127
[8614]128            void checkWhoIsIn(); //!< Update the list 'pawnsIn_'.
[8767]129
[8660]130            void positionBillboard(const Vector3& position, float alpha); //!< Display a Billboard at the position 'position'.
[8614]131            void setBillboardOptions(Billboard *billy);
132            void removeAllBillboards(); //!< Hide all elements of '*billboard_' and set their attribute 'usedYet' to 0.
[8087]133    };
134}
135
136#endif /* _SpaceBoundaries_H__ */
Note: See TracBrowser for help on using the repository browser.