mirror of
https://github.com/openmoh/openmohaa.git
synced 2025-04-28 21:57:57 +03:00
Added and implemented TargetList
This commit is contained in:
parent
b4bce3431b
commit
cebb351505
2 changed files with 65 additions and 0 deletions
|
@ -1197,3 +1197,49 @@ bool WithinFarplaneDistance(const Vector& org)
|
|||
|
||||
return org.lengthSquared() < (Square(distance) * Square(0.828f));
|
||||
}
|
||||
|
||||
CLASS_DECLARATION(Class, TargetList, NULL) {
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
TargetList::TargetList() {}
|
||||
|
||||
TargetList::TargetList(const str& tname)
|
||||
: targetname(tname)
|
||||
{}
|
||||
|
||||
void TargetList::AddEntity(Listener *ent)
|
||||
{
|
||||
list.AddObject(static_cast<SimpleEntity *>(ent));
|
||||
}
|
||||
|
||||
void TargetList::AddEntityAt(Listener *ent, int i)
|
||||
{
|
||||
list.AddObjectAt(i, static_cast<SimpleEntity *>(ent));
|
||||
}
|
||||
|
||||
int TargetList::GetEntityIndex(Listener *ent)
|
||||
{
|
||||
return list.IndexOfObject(static_cast<SimpleEntity *>(ent));
|
||||
}
|
||||
|
||||
void TargetList::RemoveEntity(Listener *ent)
|
||||
{
|
||||
list.RemoveObject(static_cast<SimpleEntity *>(ent));
|
||||
}
|
||||
|
||||
SimpleEntity *TargetList::GetNextEntity(SimpleEntity *ent)
|
||||
{
|
||||
int index;
|
||||
|
||||
for (index = list.IndexOfObject(ent); index <= list.NumObjects(); index++) {
|
||||
Listener *objptr;
|
||||
|
||||
objptr = list.ObjectAt(index);
|
||||
if (objptr->isSubclassOf(SimpleEntity)) {
|
||||
return static_cast<SimpleEntity *>(objptr);
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -39,6 +39,25 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
|
||||
typedef Container<SafePtr<SimpleEntity>> ConSimple;
|
||||
|
||||
class TargetList : public Class {
|
||||
public:
|
||||
CLASS_PROTOTYPE(TargetList);
|
||||
|
||||
public:
|
||||
ConSimple list;
|
||||
str targetname;
|
||||
|
||||
public:
|
||||
TargetList();
|
||||
TargetList(const str& tname);
|
||||
|
||||
void AddEntity(Listener* ent);
|
||||
void AddEntityAt(Listener* ent, int i);
|
||||
int GetEntityIndex(Listener* ent);
|
||||
void RemoveEntity(Listener* ent);
|
||||
SimpleEntity* GetNextEntity(SimpleEntity* ent);
|
||||
};
|
||||
|
||||
class World : public Entity
|
||||
{
|
||||
con_set<const_str, ConSimple> m_targetList; // moh could have used con_set instead of TargetList
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue