Version 17 (modified by landauf, 8 years ago) (diff) |
---|
Space Boundaries
Concept
See ticket: Space Boundaries
Implementation
SpaceBoundaries is a class that is derived from static entity. It checks if there is a pawn that is outside of a defined area or tries to leave this area (at the moment this area can only be a ball) and reacts on such events.
The reaction to such events can be defined by the map creator, who can add boundaries to a level via its XML file. At the moment there are two implemented behaviors:
- Let the Pawns that want to cross the boundaries bounce back.
- Let the Pawns cross the boundaries but decrease their health when they do so.
The SpaceBoundaries object does its work in the tick function, using an Iterator of type Pawn. Via the interface of Pawn, we can then control the pawns away from the boundary or do damage to them.
Attributes
These attributes can be set for a SpaceBoundaries static entity in the XML file:
- position - absolute position of the object of SpaceBoundaries in the level (usually 0,0,0)
- maxDistance - defines the area, where a pawn is allowed to be (radius of a ball with center 'position').
- warnDistance - If the distance between the pawn of a human player and 'position' is bigger than 'warnDistance', a message is displayed to inform the player that he's close to the boundary. (not implemented yet!!!)
- showDistance - If the distance between the pawn and the boundary of the allowed area is smaller than 'showDistance', a graphical representation of the boundary is displayed.
- reactionMode - Integer-Value. Defines what effect appears if a space ship has crossed receptively wants to cross the boundaries.
- 0: Reflect the space ship (default).
- 1: Decrease Health of the space ship after having left the allowed area.
- 2: Inverted Version of 0. Prohibit to fly INTO the defined area.
- healthDecrease - a measure to define how fast the health of a pawn should decrease after leaving the allowed area (unnecessary if 'reactionMode' isn't 1). Recommended values: 0.1 (slow health decrease) to 5 (very fast health decrease).
Notes to above attributes
Until now, warnDistance has no effect because the function to display a message (void SpaceBoundaries::displayWarning(const std::string warnText)) hasn't been implemented yet.
Special Features
If reactionMode is 0, there can be several SpaceBoundaries objects in one level. To get from one to another the map creator could provide portals.