[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 | |
---|
[8468] | 33 | Mich finde ich unter humanPlayer ... |
---|
| 34 | |
---|
| 35 | - Kommentieren (Betrachte als Beispiel/Vorbild 'libraries/core/WeakPtr.h') |
---|
| 36 | oder brauche groups-file. |
---|
[8201] | 37 | */ |
---|
[8087] | 38 | |
---|
| 39 | #ifndef _SpaceBoundaries_H__ |
---|
| 40 | #define _SpaceBoundaries_H__ |
---|
| 41 | |
---|
[8404] | 42 | |
---|
[8110] | 43 | #include "core/CoreIncludes.h" |
---|
[8404] | 44 | #include "core/WeakPtr.h" |
---|
[8110] | 45 | #include "tools/interfaces/Tickable.h" |
---|
[8201] | 46 | #include "interfaces/RadarViewable.h" |
---|
[8110] | 47 | #include "worldentities/StaticEntity.h" |
---|
| 48 | #include "worldentities/WorldEntity.h" |
---|
[8087] | 49 | |
---|
[8164] | 50 | #include <string> |
---|
[8281] | 51 | #include <list> |
---|
[8301] | 52 | #include <vector> |
---|
[8164] | 53 | |
---|
[8404] | 54 | namespace 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 | |
---|
[8468] | 60 | Some attributes can/should be defined in the XML-File: |
---|
| 61 | - 'position' : absolute position of the object of SpaceBoundaries in the level (usually 0,0,0) |
---|
| 62 | - 'maxDistance' : defines the area, where a pawn is allowed to be (radius of a ball). |
---|
[8237] | 63 | - 'warnDistance' : If the distance between the pawn of the human player and 'position' is bigger than 'warnDistance', a message is displayed to |
---|
| 64 | inform the player that he'll soon be leaving the allowed area. |
---|
[8244] | 65 | - 'showDistance' : If the distance between the pawn and the boundary of the allowed area is smaller than 'showDistance', the boundary is shown. |
---|
[8404] | 66 | - 'reactionMode' : Integer-Value. Defines what effect appears if a space ship has crossed the boundaries. |
---|
| 67 | 0: Reflect the space ship (default). |
---|
| 68 | 1: Decrease Health of the space ship after having left the allowed area. |
---|
[8468] | 69 | - 'healthDecrease' : a measure to define how fast the health of a pawn should decrease after leaving the allowed area (unnecessary if 'reactionMode' == 0). |
---|
| 70 | Recommended values: 0.1 (slow health decrease) to 5 (very fast health decrease) |
---|
| 71 | |
---|
| 72 | Follow http://www.orxonox.net/wiki/SpaceBoundaries to get some further information. |
---|
| 73 | |
---|
| 74 | Examples: |
---|
| 75 | Two examples how one could include SpaceBoundaries in the XML-File. The first one uses reflection, the second one health decrease. |
---|
| 76 | @code |
---|
| 77 | <SpaceBoundaries position="0,0,0" maxDistance="1000" warnDistance="800" showDistance="100" reactionMode="0" /> |
---|
| 78 | @endcode |
---|
| 79 | |
---|
| 80 | @code |
---|
| 81 | <SpaceBoundaries position="0,0,0" maxDistance="1000" warnDistance="800" showDistance="100" reactionMode="1" healthDecrease="0.2" /> |
---|
| 82 | @endcode |
---|
[8201] | 83 | */ |
---|
| 84 | |
---|
[8087] | 85 | class _OrxonoxExport SpaceBoundaries : public StaticEntity, public Tickable |
---|
| 86 | { |
---|
| 87 | public: |
---|
| 88 | SpaceBoundaries(BaseObject* creator); |
---|
[8110] | 89 | ~SpaceBoundaries(); |
---|
| 90 | |
---|
[8301] | 91 | void checkWhoIsIn(); //!< Update the list 'pawnsIn_'. |
---|
[8281] | 92 | |
---|
[8404] | 93 | void positionBillboard(const Vector3 position); //!< Display a Billboard at the position 'position'. |
---|
[8301] | 94 | void setBillboardOptions(Billboard *billy); |
---|
[8506] | 95 | void removeAllBillboards(); //!< Hide all elements of '*billboard_' and set their attribute 'usedYet' to 0. |
---|
[8301] | 96 | |
---|
[8244] | 97 | void setMaxDistance(float r); |
---|
[8110] | 98 | float getMaxDistance(); |
---|
| 99 | |
---|
| 100 | void setWarnDistance(float r); |
---|
| 101 | float getWarnDistance(); |
---|
[8201] | 102 | |
---|
[8244] | 103 | void setShowDistance(float r); |
---|
| 104 | float getShowDistance(); |
---|
| 105 | |
---|
[8201] | 106 | void setHealthDecrease(float amount); |
---|
| 107 | float getHealthDecrease(); |
---|
[8404] | 108 | |
---|
| 109 | void setReaction(int mode); |
---|
| 110 | int getReaction(); |
---|
[8087] | 111 | |
---|
[8110] | 112 | void XMLPort(Element& xmlelement, XMLPort::Mode mode); |
---|
| 113 | |
---|
| 114 | void tick(float dt); |
---|
[8087] | 115 | |
---|
| 116 | private: |
---|
[8301] | 117 | struct billboardAdministration{ bool usedYet; Billboard* billy; }; |
---|
| 118 | |
---|
[8404] | 119 | std::list<WeakPtr<Pawn> > pawnsIn_; //!< List of the pawns that this instance of SpaceBoundaries has to handle. |
---|
[8301] | 120 | |
---|
| 121 | std::vector<billboardAdministration> billboards_; |
---|
[8281] | 122 | |
---|
[8404] | 123 | int reaction_; //!< Werte: 0, 1. 0: Reflektion an Boundaries (Standard). 1: Health-Abzug-Modus. |
---|
[8201] | 124 | float maxDistance_; //!< maximal zulaessige Entfernung von 'this->getPosition()'. |
---|
| 125 | float warnDistance_; //!< Entfernung von 'this->getPosition()', ab der eine Warnung angezeigt wird, dass man bald das zulaessige Areal verlaesst. |
---|
[8244] | 126 | float showDistance_; //!< Definiert, wann die Grenzen visualisiert werden sollen. |
---|
[8201] | 127 | |
---|
| 128 | float healthDecrease_; //!< Mass fuer die Anzahl Health-Points, die nach ueberschreiten der Entfernung 'maxDistance_' von 'this->getPosition()' abgezogen werden. |
---|
| 129 | //!< Empfohlene Werte: 0.1 (langsame Health-Verminderung) bis 5 (sehr schnelle Health-Verminderung) |
---|
| 130 | |
---|
[8237] | 131 | RadarViewable* centerRadar_; //!< Repraesentation von SpaceBoundaries auf dem Radar. |
---|
[8087] | 132 | |
---|
[8201] | 133 | float computeDistance(WorldEntity *item); //!< Auf den Mittelpunkt 'this->getPosition()' bezogen. |
---|
[8164] | 134 | void displayWarning(const std::string warnText); |
---|
[8244] | 135 | void displayBoundaries(Pawn *item); |
---|
[8404] | 136 | void conditionalBounceBack(Pawn *item, float currentDistance, float dt); |
---|
[8164] | 137 | bool isHumanPlayer(Pawn *item); |
---|
[8201] | 138 | |
---|
[8087] | 139 | }; |
---|
| 140 | } |
---|
| 141 | |
---|
| 142 | #endif /* _SpaceBoundaries_H__ */ |
---|