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 #include "SimpleAreaFactory.hpp" 00023 #include "SimpleArea.hpp" 00024 #include "sim/zone/ZoneAreaComponent.hpp" 00025 #include "util/type/ByteArray.hpp" 00026 00027 00028 using namespace se_core; 00029 00030 namespace se_basic { 00031 00032 SimpleAreaFactory 00033 ::SimpleAreaFactory(String* name, coor_tile_t w, coor_tile_t h, se_core::ByteArray* data) 00034 : AreaFactory(name), data_(data), width_(w), height_(h) { 00035 } 00036 00037 00038 SimpleAreaFactory 00039 ::~SimpleAreaFactory() { 00040 delete data_; 00041 } 00042 00043 00044 Composite* SimpleAreaFactory 00045 ::create(String* name, int pageX, int pageY, int pageZ, int gridId) const { 00046 Composite* c = new Composite(this, name->copyValue()); 00047 delete name; 00048 SimpleArea* a = new SimpleArea(c, 0, width_, height_); 00049 createComponents(c); 00050 createGenericComponents(c); 00051 00052 PosComponent::Ptr aPos(*c); 00053 ZoneAreaComponent::Ptr aZone(*c); 00054 aZone->page().set(pageX, pageY, pageZ, gridId); 00055 aPos->nextPos().localCoor().x_ = CoorT::fromTile(pageX * a->width()); 00056 aPos->nextPos().localCoor().z_ = CoorT::fromTile(pageZ * a->height()); 00057 aPos->nextPos().world_.setViewPoint(aPos->nextPos().local_); 00058 aPos->flip(); 00059 00060 return c; 00061 } 00062 00063 void SimpleAreaFactory 00064 ::release(Composite* c) const { 00065 delete c->component(se_core::sct_BLOB); 00066 delete c; 00067 } 00068 }
Home Page | SagaEngine trunk (updated nightly) reference generated Sun Dec 2 20:06:02 2007 by Doxygen version 1.3.9.1.