1
0
forked from 0ad/0ad
0ad/source/graphics/UnitManager.h
Matei 603401dc09 # Bug fixes.
- Fixed a crash that was happening in pathfinding on maps where some
tiles had invalid texture names (from earlier versions of the game).
- Releasing the mouse over the minimap while dragging a selection band
will no longer cause the view to move there. Unfortunately, the bandbox
still won't properly "release". The bandbox input routine should ideally
be placed at a higher priority than the GUI, separate from the other
Interact.cpp routines.

This was SVN commit r4711.
2006-12-20 05:41:54 +00:00

67 lines
1.8 KiB
C++

///////////////////////////////////////////////////////////////////////////////
//
// Name: UnitManager.h
// Author: Rich Cross
// Contact: rich@wildfiregames.com
//
///////////////////////////////////////////////////////////////////////////////
#ifndef _UNITMANAGER_H
#define _UNITMANAGER_H
#include <vector>
#include <set>
#include "ps/Singleton.h"
class CUnit;
class CModel;
class CVector3D;
class CEntity;
class CStr;
// access to sole CUnitManager object
#define g_UnitMan CUnitManager::GetSingleton()
///////////////////////////////////////////////////////////////////////////////
// CUnitManager: simple container class holding all units within the world
class CUnitManager : public Singleton<CUnitManager>
{
public:
// constructor, destructor
CUnitManager();
~CUnitManager();
// add given unit to world
void AddUnit(CUnit* unit);
// remove given unit from world, but don't delete it
void RemoveUnit(CUnit* unit);
// remove given unit from world and delete it
void DeleteUnit(CUnit* unit);
// remove and delete all units
void DeleteAll();
// creates a new unit and adds it to the world
CUnit* CreateUnit(const CStr& actorName, CEntity* entity, const std::set<CStr>& selections);
// return the units
const std::vector<CUnit*>& GetUnits() const { return m_Units; }
// iterate through units testing given ray against bounds of each unit;
// return the closest unit, or null if everything missed
CUnit* PickUnit(const CVector3D& origin, const CVector3D& dir, bool entitiesOnly) const;
CUnit* FindByID(int id) const;
int GetNewID() { return m_NextID++; }
void SetNextID(int n) { m_NextID = n; }
private:
// list of all known units
std::vector<CUnit*> m_Units;
// next ID number to be assigned to a unit created in the editor
int m_NextID;
};
#endif