00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "pent_include.h"
00020
00021 #include "EggHatcherProcess.h"
00022 #include "Egg.h"
00023 #include "MainActor.h"
00024 #include "TeleportEgg.h"
00025 #include "getObject.h"
00026
00027 #include "IDataSource.h"
00028 #include "ODataSource.h"
00029
00030 DEFINE_RUNTIME_CLASSTYPE_CODE(EggHatcherProcess,Process);
00031
00032 EggHatcherProcess::EggHatcherProcess()
00033 {
00034
00035 }
00036
00037
00038 EggHatcherProcess::~EggHatcherProcess()
00039 {
00040
00041 }
00042
00043 void EggHatcherProcess::addEgg(uint16 egg)
00044 {
00045 eggs.push_back(egg);
00046 }
00047
00048 void EggHatcherProcess::addEgg(Egg* egg)
00049 {
00050 assert(egg);
00051 eggs.push_back(egg->getObjId());
00052 }
00053
00054 bool EggHatcherProcess::run(const uint32 )
00055 {
00056 bool nearteleporter = false;
00057 MainActor* av = getMainActor();
00058 assert(av);
00059
00060 for (unsigned int i = 0; i < eggs.size(); i++) {
00061 uint16 eggid = eggs[i];
00062 Egg* egg = p_dynamic_cast<Egg*>(getObject(eggid));
00063 if (!egg) continue;
00064
00065 sint32 x,y,z;
00066 egg->getLocation(x,y,z);
00067
00069 sint32 x1 = x - 32 * egg->getXRange();
00070 sint32 x2 = x + 32 * egg->getXRange();
00071 sint32 y1 = y - 32 * egg->getYRange();
00072 sint32 y2 = y + 32 * egg->getYRange();
00073
00074
00075 sint32 ax,ay,az;
00076 sint32 axs,ays,azs;
00077 av->getLocation(ax,ay,az);
00078 av->getFootpadWorld(axs,ays,azs);
00079
00080
00081
00082
00083
00084 TeleportEgg* tegg = p_dynamic_cast<TeleportEgg*>(egg);
00085
00086 if (x1 <= ax && ax-axs < x2 && y1 <= ay && ay-ays < y2 &&
00087 z - 48 < az && az <= z + 48) {
00088 if (tegg && tegg->isTeleporter()) nearteleporter = true;
00089
00090 if (tegg && av->hasJustTeleported()) continue;
00091
00092 egg->hatch();
00093 }
00094 }
00095
00096 if (!nearteleporter) av->setJustTeleported(false);
00097
00098 return false;
00099 }
00100
00101 void EggHatcherProcess::saveData(ODataSource* ods)
00102 {
00103 Process::saveData(ods);
00104 }
00105
00106
00107 bool EggHatcherProcess::loadData(IDataSource* ids, uint32 version)
00108 {
00109 if (!Process::loadData(ids, version)) return false;
00110
00111
00112
00113
00114 return true;
00115 }