[2072] | 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 | * Fabian 'x3n' Landau |
---|
[2662] | 24 | * Reto Grieder |
---|
[2072] | 25 | * Co-authors: |
---|
| 26 | * ... |
---|
| 27 | * |
---|
| 28 | */ |
---|
| 29 | |
---|
| 30 | #ifndef _MovableEntity_H__ |
---|
| 31 | #define _MovableEntity_H__ |
---|
| 32 | |
---|
| 33 | #include "OrxonoxPrereqs.h" |
---|
| 34 | |
---|
[2662] | 35 | #include "MobileEntity.h" |
---|
[2072] | 36 | #include "network/ClientConnectionListener.h" |
---|
[2662] | 37 | #include "tools/Timer.h" |
---|
[2072] | 38 | |
---|
| 39 | namespace orxonox |
---|
| 40 | { |
---|
[2662] | 41 | class _OrxonoxExport MovableEntity : public MobileEntity, public ClientConnectionListener |
---|
[2072] | 42 | { |
---|
| 43 | public: |
---|
| 44 | MovableEntity(BaseObject* creator); |
---|
| 45 | virtual ~MovableEntity(); |
---|
| 46 | |
---|
| 47 | virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); |
---|
[3033] | 48 | virtual bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint); |
---|
[2072] | 49 | void registerVariables(); |
---|
| 50 | |
---|
| 51 | using WorldEntity::setPosition; |
---|
| 52 | using WorldEntity::setOrientation; |
---|
| 53 | |
---|
[2662] | 54 | inline void setPosition(const Vector3& position) |
---|
| 55 | { MobileEntity::setPosition(position); this->overwrite_position_ = this->getPosition(); } |
---|
| 56 | inline void setOrientation(const Quaternion& orientation) |
---|
| 57 | { MobileEntity::setOrientation(orientation); this->overwrite_orientation_ = this->getOrientation(); } |
---|
[2072] | 58 | |
---|
[3033] | 59 | inline void setOwner(Pawn* owner) |
---|
| 60 | { this->owner_ = owner; } |
---|
| 61 | inline Pawn* getOwner() const |
---|
| 62 | { return this->owner_; } |
---|
| 63 | |
---|
| 64 | inline void setCollisionDamage(float c) |
---|
| 65 | { this->collisionDamage_ = c; } |
---|
| 66 | |
---|
| 67 | inline float getCollisionDamage() |
---|
| 68 | { return this->collisionDamage_; } |
---|
| 69 | |
---|
| 70 | inline void setEnableCollisionDamage(bool c) |
---|
| 71 | { |
---|
| 72 | this->enableCollisionDamage_ = c; |
---|
| 73 | this->enableCollisionCallback(); |
---|
| 74 | } |
---|
| 75 | |
---|
| 76 | inline bool getEnableCollisionDamage() |
---|
| 77 | { return this->enableCollisionDamage_; } |
---|
| 78 | |
---|
[2072] | 79 | private: |
---|
| 80 | void clientConnected(unsigned int clientID); |
---|
| 81 | void clientDisconnected(unsigned int clientID); |
---|
| 82 | void resynchronize(); |
---|
| 83 | |
---|
[2662] | 84 | inline void processLinearVelocity() |
---|
| 85 | { this->setVelocity(this->linearVelocity_); } |
---|
| 86 | inline void processAngularVelocity() |
---|
| 87 | { this->setAngularVelocity(this->angularVelocity_); } |
---|
[2072] | 88 | |
---|
[2662] | 89 | inline void overwritePosition() |
---|
| 90 | { this->setPosition(this->overwrite_position_); } |
---|
| 91 | inline void overwriteOrientation() |
---|
| 92 | { this->setOrientation(this->overwrite_orientation_); } |
---|
[2072] | 93 | |
---|
[2662] | 94 | Vector3 overwrite_position_; |
---|
[2072] | 95 | Quaternion overwrite_orientation_; |
---|
[2662] | 96 | |
---|
| 97 | Timer<MovableEntity> resynchronizeTimer_; |
---|
| 98 | Timer<MovableEntity>* continuousResynchroTimer_; |
---|
[3033] | 99 | |
---|
| 100 | Pawn* owner_; |
---|
| 101 | float collisionDamage_; |
---|
| 102 | bool enableCollisionDamage_; |
---|
[2072] | 103 | }; |
---|
| 104 | } |
---|
| 105 | |
---|
| 106 | #endif /* _MovableEntity_H__ */ |
---|