2009-04-18 19:00:33 +02:00
|
|
|
/* Copyright (C) 2009 Wildfire Games.
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2007-05-07 18:33:24 +02:00
|
|
|
#ifndef INCLUDED_OBJECTMANAGER
|
|
|
|
#define INCLUDED_OBJECTMANAGER
|
2004-05-29 22:56:24 +02:00
|
|
|
|
2004-05-30 02:46:58 +02:00
|
|
|
#include <vector>
|
2005-03-23 00:31:30 +01:00
|
|
|
#include <map>
|
2007-09-03 01:38:58 +02:00
|
|
|
#include <set>
|
2010-06-03 03:29:43 +02:00
|
|
|
|
2006-06-02 04:10:27 +02:00
|
|
|
#include "ps/CStr.h"
|
2010-06-03 03:29:43 +02:00
|
|
|
#include "lib/file/vfs/vfs_path.h"
|
2005-03-23 00:31:30 +01:00
|
|
|
|
2007-01-08 02:56:46 +01:00
|
|
|
class CMeshManager;
|
2007-02-04 15:56:38 +01:00
|
|
|
class CObjectBase;
|
|
|
|
class CObjectEntry;
|
2007-03-01 19:52:53 +01:00
|
|
|
class CSkeletonAnimManager;
|
2010-06-03 03:29:43 +02:00
|
|
|
class CSimulation2;
|
2004-05-30 02:46:58 +02:00
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// CObjectManager: manager class for all possible actor types
|
2009-01-03 19:40:28 +01:00
|
|
|
class CObjectManager
|
2004-05-29 22:56:24 +02:00
|
|
|
{
|
2009-01-03 19:40:28 +01:00
|
|
|
NONCOPYABLE(CObjectManager);
|
2004-05-29 22:56:24 +02:00
|
|
|
public:
|
2010-06-03 03:29:43 +02:00
|
|
|
// Unique identifier of an actor variation
|
2005-03-22 18:09:36 +01:00
|
|
|
struct ObjectKey
|
|
|
|
{
|
2010-06-03 03:29:43 +02:00
|
|
|
ObjectKey(const CStrW& name, const std::vector<u8>& var)
|
2005-03-22 18:09:36 +01:00
|
|
|
: ActorName(name), ActorVariation(var) {}
|
|
|
|
|
2008-01-18 00:07:26 +01:00
|
|
|
bool operator< (const CObjectManager::ObjectKey& a) const;
|
2010-06-03 03:29:43 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
CStrW ActorName;
|
|
|
|
std::vector<u8> ActorVariation;
|
2005-03-22 18:09:36 +01:00
|
|
|
};
|
|
|
|
|
2004-05-30 02:46:58 +02:00
|
|
|
public:
|
2005-03-30 07:43:22 +02:00
|
|
|
|
2004-05-29 22:56:24 +02:00
|
|
|
// constructor, destructor
|
2010-06-03 03:29:43 +02:00
|
|
|
CObjectManager(CMeshManager& meshManager, CSkeletonAnimManager& skeletonAnimManager, CSimulation2& simulation);
|
2004-05-30 02:46:58 +02:00
|
|
|
~CObjectManager();
|
2004-05-29 22:56:24 +02:00
|
|
|
|
2007-03-01 19:52:53 +01:00
|
|
|
// Provide access to the manager classes for meshes and animations - they're
|
|
|
|
// needed when objects are being created and so this seems like a convenient
|
|
|
|
// place to centralise access.
|
2007-01-08 02:56:46 +01:00
|
|
|
CMeshManager& GetMeshManager() const { return m_MeshManager; }
|
2007-03-01 19:52:53 +01:00
|
|
|
CSkeletonAnimManager& GetSkeletonAnimManager() const { return m_SkeletonAnimManager; }
|
2007-01-08 02:56:46 +01:00
|
|
|
|
2005-11-06 06:05:07 +01:00
|
|
|
void UnloadObjects();
|
2004-05-29 22:56:24 +02:00
|
|
|
|
2009-11-03 22:46:35 +01:00
|
|
|
CObjectEntry* FindObject(const wchar_t* objname);
|
2004-05-29 22:56:24 +02:00
|
|
|
void DeleteObject(CObjectEntry* entry);
|
2005-03-22 18:09:36 +01:00
|
|
|
|
2009-11-03 22:46:35 +01:00
|
|
|
CObjectBase* FindObjectBase(const wchar_t* objname);
|
2004-05-29 22:56:24 +02:00
|
|
|
|
2009-11-03 22:46:35 +01:00
|
|
|
CObjectEntry* FindObjectVariation(const wchar_t* objname, const std::vector<std::set<CStr> >& selections);
|
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 19:36:42 +02:00
|
|
|
CObjectEntry* FindObjectVariation(CObjectBase* base, const std::vector<std::set<CStr> >& selections);
|
2005-04-03 07:02:00 +02:00
|
|
|
|
2010-06-03 03:29:43 +02:00
|
|
|
/**
|
|
|
|
* Reload any scripts that were loaded from the given filename.
|
|
|
|
* (This is used to implement hotloading.)
|
|
|
|
*/
|
|
|
|
LibError ReloadChangedFile(const VfsPath& path);
|
2007-01-08 02:56:46 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
CMeshManager& m_MeshManager;
|
2007-03-01 19:52:53 +01:00
|
|
|
CSkeletonAnimManager& m_SkeletonAnimManager;
|
2010-06-03 03:29:43 +02:00
|
|
|
CSimulation2& m_Simulation;
|
2005-03-30 07:43:22 +02:00
|
|
|
|
2006-09-22 19:43:00 +02:00
|
|
|
std::map<ObjectKey, CObjectEntry*> m_Objects;
|
2009-11-03 22:46:35 +01:00
|
|
|
std::map<CStrW, CObjectBase*> m_ObjectBases;
|
2004-05-29 22:56:24 +02:00
|
|
|
};
|
|
|
|
|
2004-06-02 16:24:37 +02:00
|
|
|
#endif
|