GlobEgg.cpp

Go to the documentation of this file.
00001 /*
00002 Copyright (C) 2003-2006 The Pentagram team
00003 
00004 This program is free software; you can redistribute it and/or
00005 modify it under the terms of the GNU General Public License
00006 as published by the Free Software Foundation; either version 2
00007 of the License, or (at your option) any later version.
00008 
00009 This program is distributed in the hope that it will be useful,
00010 but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 GNU General Public License for more details.
00013 
00014 You should have received a copy of the GNU General Public License
00015 along with this program; if not, write to the Free Software
00016 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017 */
00018 
00019 #include "pent_include.h"
00020 
00021 #include "GlobEgg.h"
00022 #include "MapGlob.h"
00023 #include "GameData.h"
00024 #include "ItemFactory.h"
00025 #include "CurrentMap.h"
00026 #include "CoreApp.h"
00027 #include "IDataSource.h"
00028 #include "ODataSource.h"
00029 
00030 // p_dynamic_cast stuff
00031 DEFINE_RUNTIME_CLASSTYPE_CODE(GlobEgg,Item);
00032 
00033 GlobEgg::GlobEgg()
00034 {
00035 
00036 }
00037 
00038 GlobEgg::~GlobEgg()
00039 {
00040 
00041 }
00042 
00043 
00044 // Called when an item has entered the fast area
00045 void GlobEgg::enterFastArea()
00046 {
00047         uint32 coordmask = ~0x1FF;
00048         unsigned int coordshift = 1;
00049         if (GAME_IS_CRUSADER) {
00050                 coordmask = ~0x3FF;
00051                 coordshift = 2;
00052         }
00053 
00054         // Expand it
00055         if (!(flags & FLG_FASTAREA)) 
00056         {
00057                 MapGlob* glob = GameData::get_instance()->getGlob(quality);
00058                 if (!glob) return;
00059 
00060                 std::vector<GlobItem>::iterator iter;
00061                 for (iter = glob->contents.begin(); iter!=glob->contents.end(); ++iter)
00062                 {
00063                         GlobItem& globitem = *iter;
00064                         Item* item = ItemFactory::createItem(globitem.shape,globitem.frame,
00065                                                                                                  0,
00066                                                                                                  FLG_DISPOSABLE|FLG_FAST_ONLY,
00067                                                                                                  0, 0, 0, true);
00068 
00069 
00070                         // calculate object's world position
00071                         sint32 itemx = (x & coordmask) + (globitem.x << coordshift) + 1;
00072                         sint32 itemy = (y & coordmask) + (globitem.y << coordshift) + 1;
00073                         sint32 itemz = z + globitem.z;
00074 
00075                         item->move(itemx, itemy, itemz);
00076                 }
00077         }
00078 
00079         Item::enterFastArea();
00080 }
00081 
00082 void GlobEgg::saveData(ODataSource* ods)
00083 {
00084         Item::saveData(ods);
00085 }
00086 
00087 bool GlobEgg::loadData(IDataSource* ids, uint32 version)
00088 {
00089         if (!Item::loadData(ids, version)) return false;
00090 
00091         return true;
00092 }

Generated on Fri Jul 27 22:27:16 2007 for pentagram by  doxygen 1.4.7