Changeset 6142 in orxonox.OLD for trunk/src/story_entities/world.cc
- Timestamp:
- Dec 16, 2005, 7:13:57 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/story_entities/world.cc
r6074 r6142 38 38 #include "shell.h" 39 39 40 #include "garbage_collector.h"41 40 #include "fast_factory.h" 42 41 #include "animation_player.h" … … 123 122 PRINTF(3)("World::~World() - deleting current world\n"); 124 123 125 126 // here everything that is alocated by the World is deleted127 delete this->entities;128 State::setWorldEntityList(NULL);129 130 124 delete this->localPlayer; 131 125 … … 141 135 SoundEngine::getInstance()->flushAllSources(); 142 136 143 137 if (State::getObjectManager() == &this->objectManager) 138 State::setObjectManager(NULL); 144 139 // erease everything that is left. 145 140 delete PNode::getNullParent(); … … 180 175 this->music = NULL; 181 176 this->shell = NULL; 182 this->entities = NULL;183 177 this->localPlayer = NULL; 184 178 this->localCamera = NULL; … … 214 208 ErrorMessage World::preLoad() 215 209 { 216 State::set WorldEntityList(this->entities = new tList<WorldEntity>());210 State::setObjectManager(&this->objectManager); 217 211 this->cycle = 0; 218 212 … … 233 227 234 228 GraphicsEngine::getInstance()->displayFPS(true); 235 236 CDEngine::getInstance()->setEntityList( this->entities);237 229 } 238 230 … … 588 580 589 581 /** 590 * gets the list of entities from the world591 * @returns entity list592 */593 tList<WorldEntity>* World::getEntities()594 {595 return this->entities;596 }597 598 599 /**600 582 * this returns the current game time 601 583 * @returns elapsed game time … … 605 587 return this->gameTime; 606 588 } 607 608 609 /**610 * function to put your own debug stuff into it. it can display informations about611 the current class/procedure612 */613 void World::debug()614 {615 PRINTF(0)("Printing out the List of alive WorldEntities:\n");616 tIterator<WorldEntity>* iterator = this->entities->getIterator();617 WorldEntity* entity = iterator->firstElement();618 while( entity != NULL)619 {620 PRINTF(0)("%s::%s\n", entity->getClassName(), entity->getName());621 entity = iterator->nextElement();622 }623 delete iterator;624 }625 626 589 627 590 /** … … 640 603 { 641 604 ++this->cycle; 642 PRINTF(4)("World::mainloop() - number of entities: %i\n", this->entities->getSize());643 605 // Network 644 606 this->synchronize (); … … 685 647 } 686 648 649 void World::tick(std::list<WorldEntity*> entityList, float dt) 650 { 651 std::list<WorldEntity*>::iterator entity; 652 for (entity = entityList.begin(); entity != entityList.end(); entity++) 653 (*entity)->tick(dt); 654 655 } 687 656 688 657 /** … … 721 690 this->gameTime += this->dtS; 722 691 723 tIterator<WorldEntity>* iterator = this->entities->getIterator(); 724 WorldEntity* entity = iterator->firstElement(); 725 while( entity != NULL) 726 { 727 entity->tick (this->dtS); 728 entity = iterator->nextElement(); 729 } 730 delete iterator; 692 /* this->tick(this->objectManager.getObjectList(OM_DEAD_TICK), this->dtS); 693 this->tick(this->objectManager.getObjectList(OM_COMMON), this->dtS); 694 this->tick(this->objectManager.getObjectList(OM_GROUP_00), this->dtS);*/ 695 this->tick(this->objectManager.getObjectList(OM_GROUP_01), this->dtS); 696 this->tick(this->objectManager.getObjectList(OM_GROUP_01_PROJ), this->dtS); 731 697 732 698 /* update tick the rest */ … … 738 704 739 705 ParticleEngine::getInstance()->tick(this->dtS); 740 GarbageCollector::getInstance()->tick(this->dtS);741 706 742 707 … … 763 728 void World::update() 764 729 { 765 GarbageCollector::getInstance()->update();766 730 GraphicsEngine::getInstance()->update(this->dtS); 767 731 PNode::getNullParent()->updateNode (this->dtS); … … 774 738 void World::collide() 775 739 { 776 CDEngine::getInstance()->checkCollisions(); 740 CDEngine::getInstance()->checkCollisions(this->objectManager.getObjectList(OM_GROUP_00), 741 this->objectManager.getObjectList(OM_GROUP_01_PROJ)); 742 CDEngine::getInstance()->checkCollisions(this->objectManager.getObjectList(OM_GROUP_01), 743 this->objectManager.getObjectList(OM_COMMON)); 777 744 } 778 745 … … 804 771 void World::draw () 805 772 { 806 /* draw entities */ 807 WorldEntity* entity; 808 glLoadIdentity(); 809 tIterator<WorldEntity>* iterator = this->entities->getIterator(); 810 entity = iterator->firstElement(); 811 while( entity != NULL ) 812 { 813 if( entity->isVisible() ) entity->draw(); 814 if( unlikely( this->showBV)) entity->drawBVTree(3, 226); // to draw the bounding boxes of the objects at level 2 for debug purp 815 entity = iterator->nextElement(); 816 } 817 delete iterator; 773 GraphicsEngine* engine = GraphicsEngine::getInstance(); 774 engine->draw(State::getObjectManager()->getObjectList(OM_ENVIRON_NOTICK)); 775 engine->draw(State::getObjectManager()->getObjectList(OM_ENVIRON)); 776 engine->draw(State::getObjectManager()->getObjectList(OM_COMMON)); 777 engine->draw(State::getObjectManager()->getObjectList(OM_GROUP_00)); 778 engine->draw(State::getObjectManager()->getObjectList(OM_GROUP_01)); 779 engine->draw(State::getObjectManager()->getObjectList(OM_GROUP_01_PROJ)); 780 781 // { 782 // if( entity->isVisible() ) entity->draw(); 783 //FIXME 784 // if( unlikely( this->showBV)) entity->drawBVTree(3, 226); // to draw the bounding boxes of the objects at level 2 for debug purp 785 // entity = iterator->nextElement(); 786 // } 818 787 819 788 glCallList (objectList); … … 824 793 PNode::getNullParent()->debugDraw(0); 825 794 826 GraphicsEngine::getInstance()->draw();795 engine->draw(); 827 796 //TextEngine::getInstance()->draw(); 828 797 } … … 834 803 void World::spawn(WorldEntity* entity) 835 804 { 836 this->entities->add (entity);805 // this->entities->add (entity); 837 806 entity->postSpawn (); 838 807 } … … 847 816 void World::spawn(WorldEntity* entity, Vector* absCoor, Quaternion* absDir) 848 817 { 849 this->entities->add (entity);818 // this->entities->add (entity); 850 819 851 820 entity->setAbsCoor (*absCoor); … … 873 842 entity->setRelDir (*relDir); 874 843 875 this->entities->add (entity);844 // this->entities->add (entity); 876 845 877 846 entity->postSpawn ();
Note: See TracChangeset
for help on using the changeset viewer.