2016-05-30 04:53:19 -07:00
|
|
|
/* Copyright (C) 2016 Wildfire Games.
|
2009-04-18 10:00:33 -07: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/>.
|
|
|
|
|
*/
|
|
|
|
|
|
2007-05-07 09:33:24 -07:00
|
|
|
#ifndef INCLUDED_OBJECTENTRY
|
|
|
|
|
#define INCLUDED_OBJECTENTRY
|
2004-05-29 17:46:58 -07:00
|
|
|
|
2011-03-13 12:22:05 -07:00
|
|
|
class CModelAbstract;
|
2004-05-29 17:46:58 -07:00
|
|
|
class CSkeletonAnim;
|
2006-04-23 15:22:18 -07:00
|
|
|
class CObjectBase;
|
2007-01-13 14:44:42 -08:00
|
|
|
class CObjectManager;
|
2013-07-11 15:53:31 -07:00
|
|
|
class CSimulation2;
|
2005-05-10 00:13:25 -07:00
|
|
|
struct SPropPoint;
|
2004-05-29 17:46:58 -07:00
|
|
|
|
2005-06-20 08:14:36 -07:00
|
|
|
#include <map>
|
2006-11-11 20:02:36 -08:00
|
|
|
#include <set>
|
2004-05-29 17:46:58 -07:00
|
|
|
#include <vector>
|
2006-11-18 10:15:31 -08:00
|
|
|
|
2009-11-03 13:46:35 -08:00
|
|
|
#include "lib/file/vfs/vfs_path.h"
|
2006-06-01 19:10:27 -07:00
|
|
|
#include "ps/CStr.h"
|
2015-03-15 11:06:32 -07:00
|
|
|
#include "ps/Shapes.h"
|
2004-05-29 17:46:58 -07:00
|
|
|
|
2012-07-23 15:49:46 -07:00
|
|
|
#include "graphics/ObjectBase.h"
|
|
|
|
|
|
2004-05-29 17:46:58 -07:00
|
|
|
class CObjectEntry
|
|
|
|
|
{
|
2013-07-11 20:46:40 -07:00
|
|
|
NONCOPYABLE(CObjectEntry);
|
|
|
|
|
|
2004-05-29 17:46:58 -07:00
|
|
|
public:
|
2013-07-11 15:53:31 -07:00
|
|
|
CObjectEntry(CObjectBase* base, CSimulation2& simulation);
|
2004-05-29 17:46:58 -07:00
|
|
|
~CObjectEntry();
|
|
|
|
|
|
2006-05-30 22:27:02 -07:00
|
|
|
// Construct this actor, using the specified variation selections
|
2007-01-07 17:56:46 -08:00
|
|
|
bool BuildVariation(const std::vector<std::set<CStr> >& selections,
|
|
|
|
|
const std::vector<u8>& variationKey, CObjectManager& objectManager);
|
2004-05-29 17:46:58 -07:00
|
|
|
|
2005-04-02 21:02:00 -08:00
|
|
|
// Base actor. Contains all the things that don't change between
|
2005-03-22 09:09:36 -08:00
|
|
|
// different variations of the actor.
|
|
|
|
|
CObjectBase* m_Base;
|
2005-03-19 03:55:27 -08:00
|
|
|
|
2012-07-23 15:49:46 -07:00
|
|
|
// samplers list
|
|
|
|
|
std::vector<CObjectBase::Samp> m_Samplers;
|
2004-05-29 17:46:58 -07:00
|
|
|
// model name
|
2009-11-03 13:46:35 -08:00
|
|
|
VfsPath m_ModelName;
|
2015-03-15 16:59:48 -07:00
|
|
|
// color (used when doing alpha-channel coloring, but not doing player-color)
|
2005-04-06 21:29:07 -07:00
|
|
|
CColor m_Color;
|
2015-03-15 16:59:48 -07:00
|
|
|
// (probable TODO: make color a per-model thing, rather than per-objectEntry,
|
|
|
|
|
// so we can have lots of color variations without wasting memory on
|
2005-05-20 18:40:32 -07:00
|
|
|
// lots of objectEntries)
|
2004-11-10 23:09:32 -08:00
|
|
|
|
2011-03-23 06:36:20 -07:00
|
|
|
std::wstring m_ProjectileModelName;
|
2010-04-17 04:34:40 -07:00
|
|
|
|
2016-05-30 04:53:19 -07:00
|
|
|
/**
|
|
|
|
|
* Returns a randomly-chosen animation matching the given name.
|
|
|
|
|
* The chosen animation is picked randomly from the GetAnimations list
|
|
|
|
|
* with the frequencies as weights (if there are any defined).
|
|
|
|
|
* This method should always return an animation
|
|
|
|
|
*/
|
2010-06-04 17:49:14 -07:00
|
|
|
CSkeletonAnim* GetRandomAnimation(const CStr& animationName) const;
|
|
|
|
|
|
2016-05-30 04:53:19 -07:00
|
|
|
/**
|
|
|
|
|
* Returns all the animations matching the given name.
|
|
|
|
|
* - Prefers the animations names like the animationName
|
|
|
|
|
* - Second choice are animations with a frequency
|
|
|
|
|
* - Last choice are the Idle animations (which are always added)
|
|
|
|
|
*/
|
2010-06-04 17:49:14 -07:00
|
|
|
std::vector<CSkeletonAnim*> GetAnimations(const CStr& animationName) const;
|
2005-05-20 18:40:32 -07:00
|
|
|
|
2004-05-29 17:46:58 -07:00
|
|
|
// corresponding model
|
2011-03-13 12:22:05 -07:00
|
|
|
CModelAbstract* m_Model;
|
2005-05-20 18:40:32 -07:00
|
|
|
|
2011-04-03 12:15:15 -07:00
|
|
|
// Whether this object is outdated, due to hotloading of its base object.
|
|
|
|
|
// (If true then CObjectManager won't reuse this object from its cache.)
|
|
|
|
|
bool m_Outdated;
|
|
|
|
|
|
2005-05-20 18:40:32 -07:00
|
|
|
private:
|
2013-07-11 15:53:31 -07:00
|
|
|
CSimulation2& m_Simulation;
|
|
|
|
|
|
2005-05-20 18:40:32 -07:00
|
|
|
typedef std::multimap<CStr, CSkeletonAnim*> SkeletonAnimMap;
|
|
|
|
|
SkeletonAnimMap m_Animations;
|
|
|
|
|
// TODO: something more memory-efficient than storing loads of similar strings for each unit?
|
2004-05-29 17:46:58 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|