/* orxonox - the future of 3D-vertical-scrollers Copyright (C) 2004 orx This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. ### File Specific: main-programmer: Patrick Boenzli co-programmer: */ #include "spawning_point.h" #include "util/loading/load_param.h" #include "util/loading/factory.h" #include "world_entity.h" #include "compiler.h" #include /** * constructor */ SpawningPoint::SpawningPoint (ClassID classid, const Vector& position) { this->setAbsCoor(position); this->classid = classid; this->mode = SPT_ALL_AT_ONCE; this->delay = 0; this->init(); } /** * standard constructor */ SpawningPoint::SpawningPoint (const Vector& position, ClassID classid, SpawningPointMode mode, float delay) { this->setAbsCoor(position); this->classid = classid; this->mode = mode; this->delay = delay; this->init(); } void SpawningPoint::init() { this->setClassID(CL_SPAWNING_POINT, "SpawningPoint"); } /** * deconstructor */ SpawningPoint::~SpawningPoint () {} /** * loads the WorldEntity Specific Parameters. * @param root: the XML-Element to load the Data From */ void SpawningPoint::loadParams(const TiXmlElement* root) { /* let the world entity its stuff first */ WorldEntity::loadParams(root); /* now load the frequency */ LoadParam(root, "delay", this, SpawningPoint, setSpawningDelay) .describe("sets the delay of the spawning point"); /* now load the seed */ // LoadParam(root, "entity", this, SpawningPoint, setSpawningEntity) // .describe("sets the spawning entity"); /* now load the seed */ /* LoadParam(root, "classid", this, SpawningPoint, setSpawningEntity) .describe("sets the class id of the entity to spawn") .defaultValues(CL_WORLD_ENTITY);*/ } /** * pushes a world entity to the spawning queue * @param entity WorldEntity to be added */ void SpawningPoint::pushEntity(WorldEntity* entity, float delay) { this->queue[entity] = this->localTimer + delay; } /** * spawn the entity */ void SpawningPoint::spawn(WorldEntity* entity) { PRINTF(1)("Spawningpoint spawns new Entity (%s)\n", entity->getClassName()); //BaseObject* spawningEntity = Factory::fabricate(this->classID); // if( likely(this->world != NULL)) // this->world->spawn(dynamic_cast(spawningEntity)); } /** * this method is called every frame * @param time: the time in seconds that has passed since the last tick * * Handle all stuff that should update with time inside this method (movement, animation, etc.) */ void SpawningPoint::tick(float dt) { this->localTimer += dt; std::map::iterator it = this->queue.begin(); for( ; it != this->queue.end(); it++) { // if( it->second <= this->localTimer) { //spawn the player this->spawn(it->first); } } } /** * the entity is drawn onto the screen with this function * * This is a central function of an entity: call it to let the entity painted to the screen. * Just override this function with whatever you want to be drawn. */ void SpawningPoint::draw() {}