1 | /* |
---|
2 | orxonox - the future of 3D-vertical-scrollers |
---|
3 | |
---|
4 | Copyright (C) 2004 orx |
---|
5 | |
---|
6 | This program is free software; you can redistribute it and/or modify |
---|
7 | it under the terms of the GNU General Public License as published by |
---|
8 | the Free Software Foundation; either version 2, or (at your option) |
---|
9 | any later version. |
---|
10 | |
---|
11 | ### File Specific: |
---|
12 | main-programmer: ... |
---|
13 | co-programmer: ... |
---|
14 | */ |
---|
15 | |
---|
16 | //#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY |
---|
17 | |
---|
18 | #include "object_manager.h" |
---|
19 | #include "class_list.h" |
---|
20 | |
---|
21 | #include "p_node.h" |
---|
22 | #include "world_entity.h" |
---|
23 | #include "list.h" |
---|
24 | |
---|
25 | using namespace std; |
---|
26 | |
---|
27 | |
---|
28 | /** |
---|
29 | * standard constructor |
---|
30 | */ |
---|
31 | ObjectManager::ObjectManager () |
---|
32 | { |
---|
33 | this->setClassID(CL_OBJECT_MANAGER, "ObjectManager"); |
---|
34 | this->setName("ObjectManager"); |
---|
35 | |
---|
36 | pNodeList = NULL; |
---|
37 | } |
---|
38 | |
---|
39 | /** |
---|
40 | * the singleton reference to this class |
---|
41 | */ |
---|
42 | ObjectManager* ObjectManager::singletonRef = NULL; |
---|
43 | |
---|
44 | /** |
---|
45 | @brief standard deconstructor |
---|
46 | */ |
---|
47 | ObjectManager::~ObjectManager () |
---|
48 | { |
---|
49 | ObjectManager::singletonRef = NULL; |
---|
50 | } |
---|
51 | |
---|
52 | /** |
---|
53 | * returns a new List with a list of WorldEntities of distance Radius from center |
---|
54 | */ |
---|
55 | std::list<WorldEntity*>* ObjectManager::distanceFromObject(const PNode& center, float radius, ClassID classID) |
---|
56 | { |
---|
57 | const tList<BaseObject>* objectList = ClassList::getList(classID); |
---|
58 | if (objectList != NULL) |
---|
59 | { |
---|
60 | std::list<WorldEntity*>* newList = new std::list<WorldEntity*>; |
---|
61 | |
---|
62 | tIterator<BaseObject>* iter = objectList->getIterator(); |
---|
63 | WorldEntity* tmp = dynamic_cast<WorldEntity*>(iter->firstElement()); |
---|
64 | while (tmp != NULL) |
---|
65 | { |
---|
66 | if ((tmp->getAbsCoor() - center.getAbsCoor()).len() < radius) |
---|
67 | newList->push_back(dynamic_cast<WorldEntity*>(tmp)); |
---|
68 | |
---|
69 | tmp = dynamic_cast<WorldEntity*>(iter->nextElement()); |
---|
70 | } |
---|
71 | delete iter; |
---|
72 | return newList; |
---|
73 | |
---|
74 | } |
---|
75 | return NULL; |
---|
76 | } |
---|