[Orxonox-commit 4096] r8767 - in code/trunk/src/modules: gametypes objects portals weapons/projectiles
dafrick at orxonox.net
dafrick at orxonox.net
Wed Jul 20 23:27:45 CEST 2011
Author: dafrick
Date: 2011-07-20 23:27:45 +0200 (Wed, 20 Jul 2011)
New Revision: 8767
Modified:
code/trunk/src/modules/gametypes/RaceCheckPoint.cc
code/trunk/src/modules/gametypes/RaceCheckPoint.h
code/trunk/src/modules/gametypes/SpaceRace.cc
code/trunk/src/modules/gametypes/SpaceRace.h
code/trunk/src/modules/objects/SpaceBoundaries.cc
code/trunk/src/modules/objects/SpaceBoundaries.h
code/trunk/src/modules/portals/PortalEndPoint.cc
code/trunk/src/modules/portals/PortalEndPoint.h
code/trunk/src/modules/portals/PortalLink.cc
code/trunk/src/modules/portals/PortalLink.h
code/trunk/src/modules/weapons/projectiles/BasicProjectile.cc
Log:
Some cleanup...
Modified: code/trunk/src/modules/gametypes/RaceCheckPoint.cc
===================================================================
--- code/trunk/src/modules/gametypes/RaceCheckPoint.cc 2011-07-19 20:27:15 UTC (rev 8766)
+++ code/trunk/src/modules/gametypes/RaceCheckPoint.cc 2011-07-20 21:27:45 UTC (rev 8767)
@@ -30,13 +30,14 @@
#include "core/CoreIncludes.h"
#include "core/XMLPort.h"
-#include "SpaceRace.h"
#include "util/Convert.h"
+#include "SpaceRace.h"
+
namespace orxonox
{
CreateFactory(RaceCheckPoint);
-
+
RaceCheckPoint::RaceCheckPoint(BaseObject* creator): DistanceTrigger(creator), RadarViewable(creator, static_cast<WorldEntity*>(this))
{
RegisterObject(RaceCheckPoint);
@@ -49,23 +50,23 @@
this->setRadarObjectShape(RadarViewable::Triangle);
this->setRadarVisibility(false);
}
-
+
RaceCheckPoint::~RaceCheckPoint()
{
}
-
+
void RaceCheckPoint::tick(float dt)
{
SUPER(RaceCheckPoint, tick, dt);
SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get());
+ assert(gametype);
if (this->getCheckpointIndex() == gametype->getCheckpointsReached())
this->setRadarVisibility(true);
else
this->setRadarVisibility(false);
}
-
void RaceCheckPoint::XMLPort(Element& xmlelement, XMLPort::Mode mode)
{
SUPER(RaceCheckPoint, XMLPort, xmlelement, mode);
@@ -74,7 +75,7 @@
XMLPortParam(RaceCheckPoint, "islast", setLast, getLast, xmlelement, mode).defaultValues(false);
XMLPortParam(RaceCheckPoint, "timelimit", setTimelimit, getTimeLimit, xmlelement, mode).defaultValues(0);
}
-
+
void RaceCheckPoint::triggered(bool bIsTriggered)
{
DistanceTrigger::triggered(bIsTriggered);
@@ -98,7 +99,7 @@
}
}
}
-
+
void RaceCheckPoint::setTimelimit(float timeLimit)
{
this->bTimeLimit_ = timeLimit;
@@ -114,5 +115,5 @@
}
}
}
-
+
}
Modified: code/trunk/src/modules/gametypes/RaceCheckPoint.h
===================================================================
--- code/trunk/src/modules/gametypes/RaceCheckPoint.h 2011-07-19 20:27:15 UTC (rev 8766)
+++ code/trunk/src/modules/gametypes/RaceCheckPoint.h 2011-07-20 21:27:45 UTC (rev 8767)
@@ -33,15 +33,14 @@
#include "objects/triggers/DistanceTrigger.h"
#include "interfaces/RadarViewable.h"
-//#include <boost/concept_check.hpp>
namespace orxonox
{
- /**
- @brief
- The RaceCheckPoint class enables the creation of a check point to use in a SpaceRace level.
- !!! Don't forget to control the indexes of your check points and to set one last check point!!!
- */
+ /**
+ @brief
+ The RaceCheckPoint class enables the creation of a check point to use in a SpaceRace level.
+ !!! Don't forget to control the indexes of your check points and to set one last check point!!!
+ */
class _GametypesExport RaceCheckPoint : public DistanceTrigger, public RadarViewable
{
public:
Modified: code/trunk/src/modules/gametypes/SpaceRace.cc
===================================================================
--- code/trunk/src/modules/gametypes/SpaceRace.cc 2011-07-19 20:27:15 UTC (rev 8766)
+++ code/trunk/src/modules/gametypes/SpaceRace.cc 2011-07-20 21:27:45 UTC (rev 8767)
@@ -30,37 +30,35 @@
#include "core/CoreIncludes.h"
#include "network/Host.h"
-#include <util/Clock.h>
-#include <util/Math.h>
#include "util/Convert.h"
+#include "util/Math.h"
namespace orxonox
{
CreateUnloadableFactory(SpaceRace);
-
+
SpaceRace::SpaceRace(BaseObject* creator) : Gametype(creator)
{
RegisterObject(SpaceRace);
- this->bCheckpointsReached_ = 0;
+ this->checkpointsReached_ = 0;
this->bTimeIsUp_ = false;
this->numberOfBots_ = 0;
}
-
+
void SpaceRace::end()
{
this->Gametype::end();
-
+
if (this->bTimeIsUp_)
{
this->clock_.capture();
int s = this->clock_.getSeconds();
int ms = this->clock_.getMilliseconds()-1000*s;
const std::string& message = multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms) + " seconds !!\n"
- + "You didn't reach the check point " + multi_cast<std::string>(this->bCheckpointsReached_+1)
+ + "You didn't reach the check point " + multi_cast<std::string>(this->checkpointsReached_+1)
+ " before the time limit. You lose!";
COUT(3) << message;
const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
- Host::Broadcast(message);
}
else
{
@@ -71,7 +69,6 @@
+ "." + multi_cast<std::string>(ms) + " seconds.";
COUT(3) << message << std::endl;
const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
- Host::Broadcast(message);
float time = this->clock_.getSecondsPrecise();
this->scores_.insert(time);
std::set<float>::iterator it;
@@ -86,12 +83,12 @@
std::string message("The match has started! Reach the check points as quickly as possible!");
COUT(3) << message << std::endl;
- Host::Broadcast(message);
+ const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
}
-
+
void SpaceRace::newCheckpointReached()
{
- this->bCheckpointsReached_++;
+ this->checkpointsReached_++;
this->clock_.capture();
int s = this->clock_.getSeconds();
int ms = this->clock_.getMilliseconds()-1000*s;
@@ -100,7 +97,6 @@
+ " seconds.\n";
COUT(3) << message;
const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
- Host::Broadcast(message);
}
}
\ No newline at end of file
Modified: code/trunk/src/modules/gametypes/SpaceRace.h
===================================================================
--- code/trunk/src/modules/gametypes/SpaceRace.h 2011-07-19 20:27:15 UTC (rev 8766)
+++ code/trunk/src/modules/gametypes/SpaceRace.h 2011-07-20 21:27:45 UTC (rev 8767)
@@ -29,14 +29,17 @@
#ifndef _SpaceRace_H__
#define _SpaceRace_H__
-#include "gametypes/Gametype.h"
#include "gametypes/GametypesPrereqs.h"
-#include "RaceCheckPoint.h"
-#include <boost/concept_check.hpp>
-#include <util/Clock.h>
-#include <string.h>
+
#include <set>
+#include <string>
+#include <util/Clock.h>
+
+#include "gametypes/Gametype.h"
+
+#include "RaceCheckPoint.h"
+
namespace orxonox
{
/**
@@ -46,27 +49,27 @@
class _GametypesExport SpaceRace : public Gametype
{
friend class RaceCheckPoint;
-
+
public:
SpaceRace(BaseObject* creator);
virtual ~SpaceRace() {}
virtual void start();
- virtual void end();
+ virtual void end();
virtual void newCheckpointReached();
inline void setCheckpointsReached(int n)
- { this->bCheckpointsReached_ = n;}
+ { this->checkpointsReached_ = n;}
inline int getCheckpointsReached()
- { return this->bCheckpointsReached_; }
+ { return this->checkpointsReached_; }
inline void timeIsUp()
- { this->bTimeIsUp_ = true;}
+ { this->bTimeIsUp_ = true;}
protected:
private:
- int bCheckpointsReached_; //The current number of check points reached by the player.
+ int checkpointsReached_; //The current number of check points reached by the player.
std::set<float> scores_; //The times of the players are saved in a set.
bool bTimeIsUp_; //True if one of the check points is reached too late.
Clock clock_; //The clock starts running at the beginning of the game. It is used to give the time at each check point, the give the time at the end of the game, and to stop the game if a check point is reached too late.
Modified: code/trunk/src/modules/objects/SpaceBoundaries.cc
===================================================================
--- code/trunk/src/modules/objects/SpaceBoundaries.cc 2011-07-19 20:27:15 UTC (rev 8766)
+++ code/trunk/src/modules/objects/SpaceBoundaries.cc 2011-07-20 21:27:45 UTC (rev 8767)
@@ -57,7 +57,7 @@
if (this->isInitialized())
{
this->pawnsIn_.clear();
-
+
for( std::vector<BillboardAdministration>::iterator current = this->billboards_.begin(); current != this->billboards_.end(); current++)
{
if( current->billy != NULL)
@@ -68,7 +68,7 @@
this->billboards_.clear();
}
}
-
+
void SpaceBoundaries::checkWhoIsIn()
{
pawnsIn_.clear();
@@ -93,7 +93,7 @@
}
}
}
-
+
void SpaceBoundaries::positionBillboard(const Vector3& position, float alpha)
{
size_t current;
@@ -123,7 +123,7 @@
upVector.normalise();
this->billboards_[current].billy->setCommonUpVector(upVector);
}
-
+
void SpaceBoundaries::setBillboardOptions(Billboard *billy)
{
if(billy != NULL)
@@ -134,7 +134,7 @@
billy->setVisible(true);
}
}
-
+
void SpaceBoundaries::removeAllBillboards()
{
for( std::vector<BillboardAdministration>::iterator current = this->billboards_.begin(); current != this->billboards_.end(); current++ )
@@ -143,7 +143,7 @@
current->billy->setVisible(false);
}
}
-
+
void SpaceBoundaries::setMaxDistance(float r)
{
this->maxDistance_ = r;
@@ -152,7 +152,7 @@
{
return this->maxDistance_;
}
-
+
void SpaceBoundaries::setWarnDistance(float r)
{
this->warnDistance_ = r;
@@ -161,7 +161,7 @@
{
return this->warnDistance_;
}
-
+
void SpaceBoundaries::setShowDistance(float r)
{
this->showDistance_ = r;
@@ -170,7 +170,7 @@
{
return this->showDistance_;
}
-
+
void SpaceBoundaries::setHealthDecrease(float amount)
{
this->healthDecrease_ = amount/1000;
@@ -179,7 +179,7 @@
{
return this->healthDecrease_;
}
-
+
void SpaceBoundaries::setReaction(int mode)
{
this->reaction_ = mode;
@@ -199,12 +199,12 @@
XMLPortParam(SpaceBoundaries, "healthDecrease", setHealthDecrease, getHealthDecrease, xmlelement, mode);
XMLPortParam(SpaceBoundaries, "reactionMode", setReaction, getReaction, xmlelement, mode);
}
-
+
void SpaceBoundaries::tick(float dt)
{
this->checkWhoIsIn();
this->removeAllBillboards();
-
+
float distance;
bool humanItem;
for( std::list<WeakPtr<Pawn> >::iterator current = pawnsIn_.begin(); current != pawnsIn_.end(); current++ )
@@ -246,7 +246,7 @@
}
}
}
-
+
float SpaceBoundaries::computeDistance(WorldEntity *item)
{
if(item != NULL)
@@ -257,30 +257,30 @@
return -1;
}
}
-
+
void SpaceBoundaries::displayWarning(const std::string warnText)
- {
+ {
// TODO
}
-
+
void SpaceBoundaries::displayBoundaries(Pawn *item, float alpha)
{
-
+
Vector3 direction = item->getPosition() - this->getPosition();
direction.normalise();
-
+
Vector3 boundaryPosition = this->getPosition() + direction * this->maxDistance_;
-
+
this->positionBillboard(boundaryPosition, alpha);
}
-
+
void SpaceBoundaries::conditionalBounceBack(Pawn *item, float currentDistance, float dt)
{
Vector3 normal = item->getPosition() - this->getPosition();
normal.normalise();
Vector3 velocity = item->getVelocity();
float normalSpeed = item->getVelocity().dotProduct(normal);
-
+
/* Check, whether the Pawn would leave the boundary in the next tick, if so send it back. */
if( this->reaction_ == 0 && currentDistance + normalSpeed * dt > this->maxDistance_ - 10 ) // -10: "security measure"
{
@@ -291,22 +291,22 @@
bounceBack(item, &normal, &velocity);
}
}
-
+
void SpaceBoundaries::bounceBack(Pawn *item, Vector3 *normal, Vector3 *velocity)
{
float dampingFactor = 0.5;
*velocity = velocity->reflect(*normal);
Vector3 acceleration = item->getAcceleration();
acceleration = acceleration.reflect(*normal);
-
+
item->lookAt( *velocity + this->getPosition() );
-
+
item->setAcceleration(acceleration * dampingFactor);
item->setVelocity(*velocity * dampingFactor);
-
+
item->setPosition( item->getPosition() - *normal * 10 ); // Set the position of the Pawn to be well inside the boundary.
}
-
+
bool SpaceBoundaries::isHumanPlayer(Pawn *item)
{
if(item != NULL)
@@ -318,5 +318,5 @@
}
return false;
}
-
+
}
Modified: code/trunk/src/modules/objects/SpaceBoundaries.h
===================================================================
--- code/trunk/src/modules/objects/SpaceBoundaries.h 2011-07-19 20:27:15 UTC (rev 8766)
+++ code/trunk/src/modules/objects/SpaceBoundaries.h 2011-07-20 21:27:45 UTC (rev 8767)
@@ -44,68 +44,67 @@
namespace orxonox
{
-/**
- at brief SpaceBoundaries gives level creators the possibility to bar Pawns from leaving a defined area (until now this area is a ball).
+ /**
+ @brief SpaceBoundaries gives level creators the possibility to bar Pawns from leaving a defined area (until now this area is a ball).
- Some attributes can/should be defined 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).
- - 'warnDistance' : If the distance between the pawn of the human player and 'position' is bigger than 'warnDistance', a message is displayed to
- inform the player that he'll soon be leaving the allowed area. (not implemented yet!)
- - 'showDistance' : If the distance between the pawn and the boundary of the allowed area is smaller than 'showDistance', the boundary is shown.
- - 'reactionMode' : Integer-Value. Defines what effect appears if a space ship has crossed 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 a defined area.
- - 'healthDecrease' : a measure to define how fast the health of a pawn should decrease after leaving the allowed area (unnecessary if 'reactionMode' == 0).
- Recommended values: 0.1 (slow health decrease) to 5 (very fast health decrease)
+ Some attributes can/should be defined 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).
+ - 'warnDistance' : If the distance between the pawn of the human player and 'position' is bigger than 'warnDistance', a message is displayed to
+ inform the player that he'll soon be leaving the allowed area. (not implemented yet!)
+ - 'showDistance' : If the distance between the pawn and the boundary of the allowed area is smaller than 'showDistance', the boundary is shown.
+ - 'reactionMode' : Integer-Value. Defines what effect appears if a space ship has crossed 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 a defined area.
+ - 'healthDecrease' : a measure to define how fast the health of a pawn should decrease after leaving the allowed area (unnecessary if 'reactionMode' == 0).
+ Recommended values: 0.1 (slow health decrease) to 5 (very fast health decrease)
-Follow http://www.orxonox.net/wiki/SpaceBoundaries to get some further information.
+ Follow http://www.orxonox.net/wiki/SpaceBoundaries to get some further information.
-Examples:
-Two examples how one could include SpaceBoundaries in the XML-File. The first one uses reflection, the second one health decrease.
- at code
-<SpaceBoundaries position="0,0,0" maxDistance="1000" warnDistance="800" showDistance="100" reactionMode="0" />
- at endcode
+ Examples:
+ Two examples how one could include SpaceBoundaries in the XML-File. The first one uses reflection, the second one health decrease.
+ @code
+ <SpaceBoundaries position="0,0,0" maxDistance="1000" warnDistance="800" showDistance="100" reactionMode="0" />
+ @endcode
- at code
-<SpaceBoundaries position="0,0,0" maxDistance="1000" warnDistance="800" showDistance="100" reactionMode="1" healthDecrease="0.2" />
- at endcode
-*/
-
+ @code
+ <SpaceBoundaries position="0,0,0" maxDistance="1000" warnDistance="800" showDistance="100" reactionMode="1" healthDecrease="0.2" />
+ @endcode
+ */
class _ObjectsExport SpaceBoundaries : public StaticEntity, public Tickable
{
public:
SpaceBoundaries(BaseObject* creator);
~SpaceBoundaries();
-
+
void setMaxDistance(float r);
float getMaxDistance();
-
+
void setWarnDistance(float r);
float getWarnDistance();
-
+
void setShowDistance(float r);
float getShowDistance();
-
+
void setHealthDecrease(float amount);
float getHealthDecrease();
-
+
void setReaction(int mode);
int getReaction();
void XMLPort(Element& xmlelement, XMLPort::Mode mode);
-
+
void tick(float dt);
private:
struct BillboardAdministration{ bool usedYet; Billboard* billy; };
-
+
// Variabeln::
std::list<WeakPtr<Pawn> > pawnsIn_; //!< List of the pawns that this instance of SpaceBoundaries has to handle.
-
+
std::vector<BillboardAdministration> billboards_;
-
+
int reaction_; //!< Values: 0, 1, 2.
//!< 0: Reflection on boundary (Standard).
//!< 1: Decrease-Health-Mode.
@@ -113,11 +112,11 @@
float maxDistance_; //!< Maximum allowed distance.
float warnDistance_; //!< Distance in which a warning is displayed.
float showDistance_; //!< Distance at which the boundaries are displayed.
-
+
float healthDecrease_; //!< Rate of health loss.
-
+
//RadarViewable* centerRadar_; //!< Representation of the space boundary in the radar.
-
+
// Funktionen::
float computeDistance(WorldEntity *item); //!< Compute distance to center point.
void displayWarning(const std::string warnText); //!< TODO: Implement.
@@ -125,13 +124,12 @@
void conditionalBounceBack(Pawn *item, float currentDistance, float dt);
void bounceBack(Pawn *item, Vector3 *normal, Vector3 *velocity);
bool isHumanPlayer(Pawn *item);
-
+
void checkWhoIsIn(); //!< Update the list 'pawnsIn_'.
-
+
void positionBillboard(const Vector3& position, float alpha); //!< Display a Billboard at the position 'position'.
void setBillboardOptions(Billboard *billy);
void removeAllBillboards(); //!< Hide all elements of '*billboard_' and set their attribute 'usedYet' to 0.
-
};
}
Modified: code/trunk/src/modules/portals/PortalEndPoint.cc
===================================================================
--- code/trunk/src/modules/portals/PortalEndPoint.cc 2011-07-19 20:27:15 UTC (rev 8766)
+++ code/trunk/src/modules/portals/PortalEndPoint.cc 2011-07-20 21:27:45 UTC (rev 8767)
@@ -27,16 +27,22 @@
*/
#include "PortalEndPoint.h"
+
+#include <ctime>
+
+#include "core/CoreIncludes.h"
#include "core/XMLPort.h"
+
+#include "worldentities/MobileEntity.h"
+
#include "objects/triggers/MultiTriggerContainer.h"
+
#include "portals/PortalLink.h"
-#include "worldentities/MobileEntity.h"
-#include <ctime>
namespace orxonox
{
CreateFactory(PortalEndPoint);
-
+
/*static*/ const std::string PortalEndPoint::EVENTFUNCTIONNAME = "execute";
std::map<unsigned int, PortalEndPoint *> PortalEndPoint::idMap_s;
@@ -44,16 +50,16 @@
PortalEndPoint::PortalEndPoint(BaseObject* creator) : StaticEntity(creator), RadarViewable(creator, static_cast<WorldEntity*>(this)), id_(0), trigger_(NULL), reenterDelay_(0)
{
RegisterObject(PortalEndPoint);
-
+
this->trigger_ = new DistanceMultiTrigger(this);
this->trigger_->setName("portal");
- this->attach(trigger_);
+ this->attach(this->trigger_);
this->setRadarObjectColour(ColourValue::White);
this->setRadarObjectShape(RadarViewable::Dot);
this->setRadarVisibility(true);
}
-
+
PortalEndPoint::~PortalEndPoint()
{
if(this->isInitialized() && this->trigger_ != NULL)
@@ -63,16 +69,16 @@
void PortalEndPoint::XMLPort(Element& xmlelement, XMLPort::Mode mode)
{
SUPER(PortalEndPoint, XMLPort, xmlelement, mode);
-
+
XMLPortParam(PortalEndPoint, "id", setID, getID, xmlelement, mode);
XMLPortParam(PortalEndPoint, "design", setTemplate, getTemplate, xmlelement, mode);
XMLPortParam(PortalEndPoint, "reenterDelay", setReenterDelay, getReenterDelay, xmlelement, mode);
XMLPortParamExtern(PortalEndPoint, DistanceMultiTrigger, this->trigger_, "distance", setDistance, getDistance, xmlelement, mode);
XMLPortParamLoadOnly(PortalEndPoint, "target", setTarget, xmlelement, mode).defaultValues("Pawn");
-
+
// Add the DistanceMultiTrigger as event source.
this->addEventSource(this->trigger_, EVENTFUNCTIONNAME);
-
+
if(mode == XMLPort::LoadObject)
{
PortalEndPoint::idMap_s[this->id_] = this;
@@ -82,7 +88,7 @@
void PortalEndPoint::XMLEventPort(Element& xmlelement, XMLPort::Mode mode)
{
SUPER(PortalEndPoint, XMLEventPort, xmlelement, mode);
-
+
XMLPortEventSink(PortalEndPoint, BaseObject, EVENTFUNCTIONNAME, execute, xmlelement, mode);
}
@@ -90,21 +96,21 @@
{
if(!this->isActive())
return true;
-
+
MultiTriggerContainer * cont = orxonox_cast<MultiTriggerContainer *>(trigger);
if(cont == 0)
return true;
-
+
DistanceMultiTrigger * originatingTrigger = orxonox_cast<DistanceMultiTrigger *>(cont->getOriginator());
if(originatingTrigger == 0)
{
return true;
}
-
+
MobileEntity * entity = orxonox_cast<MobileEntity *>(cont->getData());
if(entity == 0)
return true;
-
+
if(bTriggered)
{
if(this->letsEnter(entity)) // only enter the portal if not just (this very moment) jumped out of it, or if the reenterDelay expired
@@ -116,14 +122,14 @@
{
this->recentlyJumpedOut_.erase(entity);
}
-
+
return true;
}
void PortalEndPoint::changedActivity(void)
{
SUPER(PortalEndPoint, changedActivity);
-
+
this->setRadarVisibility(this->isActive());
}
Modified: code/trunk/src/modules/portals/PortalEndPoint.h
===================================================================
--- code/trunk/src/modules/portals/PortalEndPoint.h 2011-07-19 20:27:15 UTC (rev 8766)
+++ code/trunk/src/modules/portals/PortalEndPoint.h 2011-07-20 21:27:45 UTC (rev 8767)
@@ -37,38 +37,37 @@
#include "portals/PortalsPrereqs.h"
+#include <map>
#include <set>
#include <string>
-#include <map>
+#include "core/EventIncludes.h"
+
#include "worldentities/StaticEntity.h"
#include "interfaces/RadarViewable.h"
-#include "graphics/Billboard.h"
#include "objects/triggers/DistanceMultiTrigger.h"
-#include "core/EventIncludes.h"
-#include <ctime>
namespace orxonox
{
/**
@brief
A PortalEndPoint serves as portal entrance and/or exit.
-
+
@ingroup Portals
*/
-
+
class _PortalsExport PortalEndPoint : public StaticEntity, public RadarViewable
{
public:
PortalEndPoint(BaseObject* creator);
virtual ~PortalEndPoint();
-
+
virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
virtual void changedActivity(void);
-
+
inline void setTarget(const std::string & target) //!< add types which are allowed to activate the PortalEndPoint
{ this->trigger_->addTarget(target); }
-
+
void XMLEventPort(Element& xmlelement, XMLPort::Mode mode);
static std::map<unsigned int, PortalEndPoint *> idMap_s; //!< Maps the id of each PortalEndPoint to a pointer to that PortalEndPoint
inline void setReenterDelay(unsigned int seconds)
@@ -77,10 +76,10 @@
{ return this->reenterDelay_; }
inline void setID(unsigned int id)
{ this->id_ = id; }
-
+
inline unsigned int getID() const
{ return this->id_; }
-
+
/// \brief Set templateName_ (the name of the design Template) and add that Template to this Object
inline void setTemplate(const std::string & name)
{ this->templateName_ = name; this->addTemplate(name); }
@@ -98,16 +97,16 @@
/*! \brief Let an Entity jump out of this portal no matter where it was before
* \param entity The Entity which should jump out of this portal */
void jumpOut(MobileEntity * entity);
-
+
/** \brief Tells wether a certain Entity is allowed to enter the PortalEndPoint?
@return @c true if the entity not just came out of this portal and the reenterDelay has expired for it, @c false otherwise
*/
bool letsEnter(MobileEntity* entity);
protected:
-
+
private:
static const std::string EVENTFUNCTIONNAME; //!< = "execute"
-
+
unsigned int id_; //!< the hopefully (depends on the writer of the levelfile) unique id, which is used to establish links between PortalEndPoints
DistanceMultiTrigger * trigger_; //!< the DistanceMultiTrigger which notices near entities of the defined type
std::string templateName_; //!< The name of the design template used for this endpoint
Modified: code/trunk/src/modules/portals/PortalLink.cc
===================================================================
--- code/trunk/src/modules/portals/PortalLink.cc 2011-07-19 20:27:15 UTC (rev 8766)
+++ code/trunk/src/modules/portals/PortalLink.cc 2011-07-20 21:27:45 UTC (rev 8767)
@@ -27,8 +27,10 @@
*/
#include "PortalLink.h"
+
+#include "core/CoreIncludes.h"
#include "core/XMLPort.h"
-#include "objects/triggers/MultiTriggerContainer.h"
+
#include "worldentities/MobileEntity.h"
namespace orxonox
@@ -36,23 +38,24 @@
CreateFactory(PortalLink);
std::map<PortalEndPoint *, PortalEndPoint *> PortalLink::links_s;
-
+
PortalLink::PortalLink(BaseObject* creator) : BaseObject(creator), fromID_(0), toID_(0), from_(0), to_(0)
{
RegisterObject(PortalLink);
}
-
+
PortalLink::~PortalLink()
{
-
+
}
-
+
void PortalLink::XMLPort(Element& xmlelement, XMLPort::Mode mode)
{
SUPER(PortalLink, XMLPort, xmlelement, mode);
XMLPortParam(PortalLink, "fromID", setFromID, getFromID, xmlelement, mode);
XMLPortParam(PortalLink, "toID", setToID, getToID, xmlelement, mode);
+ // Beware: This means, that the PortalEndPoints must exist before the PortalLink is created.
if(mode == XMLPort::LoadObject)
{
PortalEndPoint * from = PortalEndPoint::idMap_s[this->fromID_];
@@ -64,12 +67,9 @@
void PortalLink::use(MobileEntity* entity, PortalEndPoint * entrance)
{
if(entrance == 0)
- {
return;
- }
-
+
std::map<PortalEndPoint *, PortalEndPoint *>::iterator endpoints = PortalLink::links_s.find(entrance);
-
if(endpoints == PortalLink::links_s.end()) // entrance has no corresponding exit
return;
Modified: code/trunk/src/modules/portals/PortalLink.h
===================================================================
--- code/trunk/src/modules/portals/PortalLink.h 2011-07-19 20:27:15 UTC (rev 8766)
+++ code/trunk/src/modules/portals/PortalLink.h 2011-07-20 21:27:45 UTC (rev 8767)
@@ -36,13 +36,13 @@
#define _PortalLink_H__
#include "portals/PortalsPrereqs.h"
-#include "tools/interfaces/Tickable.h"
-#include "core/BaseObject.h"
-#include "PortalEndPoint.h"
-#include "objects/eventsystem/EventListener.h"
#include <map>
+#include "PortalEndPoint.h"
+
+#include "core/BaseObject.h"
+
namespace orxonox
{
/**
@@ -56,22 +56,15 @@
PortalLink(BaseObject* creator);
virtual ~PortalLink();
virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+
inline void setFromID(unsigned int from) //!< set the ID of the PortalEndPoint which should act as the entrance of this link
- {
- this->fromID_ = from;
- }
+ { this->fromID_ = from; }
inline unsigned int getFromID(unsigned int) const
- {
- return this->fromID_;
- }
+ { return this->fromID_; }
inline void setToID(unsigned int to) //!< set the ID of the PortalEndPoint which should act as the exit of this link
- {
- this->toID_ = to;
- }
+ { this->toID_ = to; }
inline unsigned int getToID(unsigned int) const
- {
- return this->toID_;
- }
+ { return this->toID_; }
/*! \brief Let an entity enter a certain PortalEndPoint
\param entity pointer to the entity which is entering a PortalEndPoint
\param entrance pointer to the PortalEndPoint to enter
Modified: code/trunk/src/modules/weapons/projectiles/BasicProjectile.cc
===================================================================
--- code/trunk/src/modules/weapons/projectiles/BasicProjectile.cc 2011-07-19 20:27:15 UTC (rev 8766)
+++ code/trunk/src/modules/weapons/projectiles/BasicProjectile.cc 2011-07-20 21:27:45 UTC (rev 8767)
@@ -51,9 +51,9 @@
// Default damage must be zero, otherwise it would be above zero if no settings are made in the weaponsettings xml file.
// same thing for all weaponmodes files
- this->damage_ = 0;
- this->healthdamage_ = 0;
- this->shielddamage_ = 0;
+ this->damage_ = 0.0f;
+ this->healthdamage_ = 0.0f;
+ this->shielddamage_ = 0.0f;
}
BasicProjectile::~BasicProjectile()
More information about the Orxonox-commit
mailing list