Area.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_area_Area_hpp
00023 #define sim_area_Area_hpp
00024 
00025 #include "sim_area.hpp"
00026 #include "comp/Component.hpp"
00027 #include "comp/ComponentFactory.hpp"
00028 #include "../sim.hpp"
00029 #include "../action/sim_action.hpp"
00030 #include "../stat/sim_stat.hpp"
00031 #include "../thing/sim_thing.hpp"
00032 #include "util/type/util_type.hpp"
00033 #include "util/math/CoorT.hpp"
00034 #include "util/bounds/BoundingBox.hpp"
00035 #include "util/vecmath/util_vecmath.hpp"
00036 #include "sim/config/sim_config.hpp"
00037 #include "../pos/PosComponent.hpp"
00038 #include "../physics/sim_physics.hpp"
00039 #include "../spawn/sim_spawn.hpp"
00040 #include "../script/sim_script.hpp"
00041 #include "../react/sim_react.hpp"
00042 #include "../signal/sim_signal.hpp"
00043 #include "../zone/sim_zone.hpp"
00044 
00045 
00046 namespace se_core {
00047 
00048     class _SeCoreExport Area : public Component {
00049     public:
00050         typedef ComponentPtr<Area, sct_BLOB> Ptr;
00051 
00055         Area(Composite* owner, const ComponentFactory* factory, coor_tile_t w, coor_tile_t h);
00056 
00060         virtual ~Area();
00061 
00065         virtual coor_t groundHeight(const Point3& coor, short index = -1) const = 0;
00066 
00070         virtual short index(const Point3& wc, short oldIndex = -1) const = 0;
00071 
00072         virtual bool doesTouchVoid(const Point3& wc, short index, coor_t radius) const = 0;
00073 
00078         void saveThings(/* stream */);
00079 
00080 
00081     public:
00082         virtual void force(const Point3& coor, Vector3& dest) const = 0;
00083         coor_tile_t width() const { return width_; }
00084         coor_tile_t height() const { return height_; }
00085 
00086         coor_world_t pagePosX() const {
00087             //TODO: Fixed point overflows possible
00088             return posComponent_->pos().localCoor().x_;
00089         }
00090         coor_world_t pagePosZ() const {
00091             //TODO: Fixed point overflows possible
00092             return posComponent_->pos().localCoor().z_;
00093         }
00094 
00095         bool isLegalCoor(coor_tile_t x, coor_tile_t y) const {
00096             return (x >= 0 && y >= 0 && x < width_ && y < height_);
00097         }
00098 
00099         bool isLegalLocalCoor(const Point3& localCoor) const {
00100             //return pos().bounds_.hasInside(worldCoor);
00101             const Point3& c = posComponent_->nextPos().localCoor();
00102             return (localCoor.x_ >= c.x_
00103                     && localCoor.z_ >= c.z_
00104                     && localCoor.xTile() < c.xTile() + width_
00105                     && localCoor.zTile() < c.zTile() + height_);
00106         }
00107 
00108         bool isLegalWorldCoor(const Point3& worldCoor) const {
00109             const Point3& c = posComponent_->nextPos().worldCoor();
00110             return (worldCoor.x_ >= c.x_
00111                     && worldCoor.z_ >= c.z_
00112                     && worldCoor.xTile() < c.xTile() + width_
00113                     && worldCoor.zTile() < c.zTile() + height_);
00114         }
00115 
00116         virtual short terrainStyle(const Point3& coor, short index = -1) const = 0;
00117         virtual short nextTerrainStyle(bray_t direction, const Point3& coor) = 0;
00118         static inline long tsMask(short ts) { return (1L << ts); }
00119 
00121         virtual long touchedTerrain(const Point3& centre, coor_t radius) const;
00123         virtual long touchedTerrain(const Point3& from, const Point3& to) const;
00124 
00125         //Thing* findPickTarget(Player& actor) const;
00126         //Thing* findDefaultActionTarget(Player& actor) const;
00127         Composite* findTarget(const char* factoryName, const Point3& worldCoor) const;
00128 
00129         void reset();
00130 
00136         Area* neighbour(short relX, short relY, short relZ);
00137         const Area* neighbour(short relX, short relY, short relZ) const;
00138 
00139         Area* neighbour(const Point3& worldCoor);
00140         const Area* neighbour(const Point3& worldCoor) const;
00141 
00147         bool addNeighbour(Area* area);
00148         virtual bool isNeighbour(const Area& area) const;
00149 
00156         void flipSpawns(void);
00157 
00163         Composite* spawn(const char* thingName, const ViewPoint& coor, long deniedTsMask = 0, PosComponent* parent = 0);
00164 
00165 
00166     protected:
00167         coor_tile_t width_, height_;
00168 
00169         PosComponent* posComponent_;
00170         SpawnAreaComponent* spawnAreaComponent_;
00171         ScriptComponent* scriptComponent_;
00172         ActionComponent* actionComponent_;
00173         CollisionAreaComponent* collisionAreaComponent_;
00174         PhysicsAreaComponent* physicsAreaComponent_;
00175         SignalAreaComponent* signalAreaComponent_;
00176         ZoneAreaComponent* zoneAreaComponent_;
00177     };
00178 
00179 }
00180 
00181 #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