PosComponent.hpp

Go to the documentation of this file.
00001 /*
00002 SagaEngine library
00003 Copyright (c) 2002-2006 Skalden Studio AS
00004 
00005 This software is provided 'as-is', without any express or implied 
00006 warranty. In no event will the authors be held liable for any 
00007 damages arising from the use of this software.
00008 
00009 Permission is granted to distribute the library under the terms of the 
00010 Q Public License version 1.0. Be sure to read and understand the license
00011 before using the library. It should be included here, or you may read it
00012 at http://www.trolltech.com/products/qt/licenses/licensing/qpl
00013 
00014 The original version of this library can be located at:
00015 http://www.sagaengine.com/
00016 
00017 Rune Myrland
00018 rune@skalden.com
00019 */
00020 
00021 
00022 #ifndef sim_PosComponent_hpp
00023 #define sim_PosComponent_hpp
00024 
00025 #include "comp/Component.hpp"
00026 #include "comp/Composite.hpp"
00027 #include "../sim.hpp"
00028 #include "Pos.hpp"
00029 #include "../config/sim_config.hpp"
00030 #include "util/type/util_type.hpp"
00031 #include "util/type/String.hpp"
00032 
00033 
00034 namespace se_core {
00044     class _SeCoreExport PosComponent : public Component {
00045     public:
00046         typedef ComponentPtr<PosComponent, sct_POS> Ptr;
00047 
00048         PosComponent(Composite* owner);
00049         virtual ~PosComponent();
00050 
00051         static PosComponent* get(Composite* composite) {
00052             if(!composite)
00053                 return 0;
00054             PosComponent* c = static_cast<PosComponent*>(composite->component(se_core::sct_POS));
00055             return c;
00056         }
00057 
00058         static PosComponent* get(Composite& composite) {
00059             PosComponent* c = static_cast<PosComponent*>(composite.component(se_core::sct_POS));
00060             return c;
00061         }
00062 
00063         static const PosComponent* get(const Composite& composite) {
00064             const PosComponent* c = static_cast<const PosComponent*>(composite.component(se_core::sct_POS));
00065             return c;
00066         }
00067 
00068         static PosComponent* get(Component& component) {
00069             PosComponent* c = static_cast<PosComponent*>(component.owner()->component(se_core::sct_POS));
00070             return c;
00071         }
00072 
00073         static const PosComponent* get(const Component& component) {
00074             const PosComponent* c = static_cast<const PosComponent*>(component.owner()->component(se_core::sct_POS));
00075             return c;
00076         }
00077 
00090         inline const Pos& pos() const {
00091             return position_;
00092         }
00093 
00096         bool didMove() const {
00097             return didMove_;
00098         }
00099 
00104         inline void resetFutureCoor() { didMove_ = false; nextPos().setPos(position_); }
00105 
00106         inline void resetFutureXZCoor() {
00107             // Revert back to original area if necessary
00108             nextPosition_.setXZ(position_);
00109         }
00110 
00111 
00117         inline Pos& nextPos() {
00118             return nextPosition_;
00119         }
00120 
00121         inline const Pos& nextPos() const {
00122             return nextPosition_;
00123         }
00124 
00131         void flip();
00132 
00138         virtual void leaveCurrentParent();
00139 
00145         virtual bool changeParent();
00146 
00147 
00149 
00154         void updateWorldViewPoint();
00155 
00161         void worldCoor(scale_t alpha, Point3& dest) const;
00162 
00168         void worldViewPoint(scale_t alpha, ViewPoint& dest) const;
00169 
00170 
00171     protected:
00172         virtual void cleanup();
00173 
00174 
00176         Pos position_;
00177 
00179         Pos nextPosition_;
00180 
00182         bool didMove_;
00183 
00187         bool isCollideable_;
00188     };
00189 
00190 }
00191 
00192 #endif

Home Page | SagaEngine trunk (updated nightly) reference generated Sun Dec 2 20:06:11 2007 by Doxygen version 1.3.9.1.

SourceForge.net Logo