2010-06-03 03:29:43 +02:00
|
|
|
/* Copyright (C) 2010 Wildfire Games.
|
2009-04-18 19:00:33 +02:00
|
|
|
* This file is part of 0 A.D.
|
|
|
|
*
|
|
|
|
* 0 A.D. 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 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* 0 A.D. is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2009-04-18 19:51:05 +02:00
|
|
|
/*
|
|
|
|
* Container that owns all units
|
2007-05-07 18:33:24 +02:00
|
|
|
*/
|
2004-05-30 02:46:58 +02:00
|
|
|
|
2007-05-07 18:33:24 +02:00
|
|
|
#ifndef INCLUDED_UNITMANAGER
|
|
|
|
#define INCLUDED_UNITMANAGER
|
2004-05-30 02:46:58 +02:00
|
|
|
|
|
|
|
#include <vector>
|
2006-04-19 07:30:02 +02:00
|
|
|
#include <set>
|
2004-05-30 02:46:58 +02:00
|
|
|
|
2004-12-12 20:43:55 +01:00
|
|
|
class CUnit;
|
2004-05-30 02:46:58 +02:00
|
|
|
class CVector3D;
|
2007-01-08 02:56:46 +01:00
|
|
|
class CObjectManager;
|
2010-03-28 20:21:48 +02:00
|
|
|
class CStr8;
|
2010-04-17 13:34:40 +02:00
|
|
|
class CStrW;
|
2004-05-30 02:46:58 +02:00
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// CUnitManager: simple container class holding all units within the world
|
2007-01-08 02:56:46 +01:00
|
|
|
class CUnitManager
|
2004-05-30 02:46:58 +02:00
|
|
|
{
|
|
|
|
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);
|
2004-10-06 20:45:59 +02:00
|
|
|
// remove given unit from world and delete it
|
|
|
|
void DeleteUnit(CUnit* unit);
|
2004-05-30 02:46:58 +02:00
|
|
|
// remove and delete all units
|
|
|
|
void DeleteAll();
|
|
|
|
|
2005-03-19 12:55:27 +01:00
|
|
|
// creates a new unit and adds it to the world
|
2011-04-02 14:51:42 +02:00
|
|
|
CUnit* CreateUnit(const CStrW& actorName, uint32_t seed, const std::set<CStr8>& selections);
|
2005-03-19 12:55:27 +01:00
|
|
|
|
2004-05-30 02:46:58 +02:00
|
|
|
// 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
|
2010-07-29 23:04:07 +02:00
|
|
|
CUnit* PickUnit(const CVector3D& origin, const CVector3D& dir) const;
|
2005-12-09 04:15:00 +01:00
|
|
|
|
2007-01-08 02:56:46 +01:00
|
|
|
void SetObjectManager(CObjectManager& objectManager) { m_ObjectManager = &objectManager; }
|
|
|
|
|
2004-05-30 02:46:58 +02:00
|
|
|
private:
|
|
|
|
// list of all known units
|
|
|
|
std::vector<CUnit*> m_Units;
|
2007-01-08 02:56:46 +01:00
|
|
|
// graphical object manager; may be NULL if not set up
|
|
|
|
CObjectManager* m_ObjectManager;
|
2004-05-30 02:46:58 +02:00
|
|
|
};
|
|
|
|
|
2004-06-02 17:03:17 +02:00
|
|
|
#endif
|