Pyrogenesis  trunk
ObjectEntry.h
Go to the documentation of this file.
1 /* Copyright (C) 2016 Wildfire Games.
2  * This file is part of 0 A.D.
3  *
4  * 0 A.D. is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * 0 A.D. is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef INCLUDED_OBJECTENTRY
19 #define INCLUDED_OBJECTENTRY
20 
21 class CModelAbstract;
22 class CSkeletonAnim;
23 class CObjectBase;
24 class CObjectManager;
25 class CSimulation2;
26 struct SPropPoint;
27 
28 #include <map>
29 #include <set>
30 #include <vector>
31 
32 #include "lib/file/vfs/vfs_path.h"
33 #include "ps/CStr.h"
34 #include "ps/Shapes.h"
35 
36 #include "graphics/ObjectBase.h"
37 
39 {
41 
42 public:
43  CObjectEntry(CObjectBase* base, CSimulation2& simulation);
44  ~CObjectEntry();
45 
46  // Construct this actor, using the specified variation selections
47  bool BuildVariation(const std::vector<std::set<CStr> >& selections,
48  const std::vector<u8>& variationKey, CObjectManager& objectManager);
49 
50  // Base actor. Contains all the things that don't change between
51  // different variations of the actor.
53 
54  // samplers list
55  std::vector<CObjectBase::Samp> m_Samplers;
56  // model name
58  // color (used when doing alpha-channel coloring, but not doing player-color)
60  // (probable TODO: make color a per-model thing, rather than per-objectEntry,
61  // so we can have lots of color variations without wasting memory on
62  // lots of objectEntries)
63 
64  std::wstring m_ProjectileModelName;
65 
66  /**
67  * Returns a randomly-chosen animation matching the given ID, or animationName if ID is empty.
68  * The chosen animation is picked randomly from the GetAnimations list
69  * with the frequencies as weights (if there are any defined).
70  * This method should always return an animation
71  */
72  CSkeletonAnim* GetRandomAnimation(const CStr& animationName, const CStr& ID = "") const;
73 
74  /**
75  * Returns all the animations matching the given ID or animationName if ID is empty.
76  * If none found returns Idle animations (which are always added)
77  */
78  std::vector<CSkeletonAnim*> GetAnimations(const CStr& animationName, const CStr& ID = "") const;
79 
80  // corresponding model
82 
83  // Whether this object is outdated, due to hotloading of its base object.
84  // (If true then CObjectManager won't reuse this object from its cache.)
85  bool m_Outdated;
86 
87 private:
88 
90 
91  typedef std::multimap<CStr, CSkeletonAnim*> SkeletonAnimMap;
92  SkeletonAnimMap m_Animations;
93  // TODO: something more memory-efficient than storing loads of similar strings for each unit?
94 };
95 
96 
97 #endif
bool BuildVariation(const std::vector< std::set< CStr > > &selections, const std::vector< u8 > &variationKey, CObjectManager &objectManager)
Definition: ObjectEntry.cpp:56
Describes the position of a prop point within its parent model.
Definition: ModelDef.h:48
std::wstring m_ProjectileModelName
Definition: ObjectEntry.h:64
Definition: Shapes.h:36
CObjectBase * m_Base
Definition: ObjectEntry.h:52
Definition: ObjectManager.h:37
std::vector< CObjectBase::Samp > m_Samplers
Definition: ObjectEntry.h:55
Public API for simulation system.
Definition: Simulation2.h:47
std::vector< CSkeletonAnim * > GetAnimations(const CStr &animationName, const CStr &ID="") const
Returns all the animations matching the given ID or animationName if ID is empty. ...
Definition: ObjectEntry.cpp:279
Definition: path.h:77
VfsPath m_ModelName
Definition: ObjectEntry.h:57
~CObjectEntry()
Definition: ObjectEntry.cpp:47
CColor m_Color
Definition: ObjectEntry.h:59
SkeletonAnimMap m_Animations
Definition: ObjectEntry.h:92
CObjectEntry(CObjectBase *base, CSimulation2 &simulation)
Definition: ObjectEntry.cpp:42
std::multimap< CStr, CSkeletonAnim * > SkeletonAnimMap
Definition: ObjectEntry.h:91
Abstract base class for graphical objects that are used by units, or as props attached to other CMode...
Definition: ModelAbstract.h:36
Definition: ObjectBase.h:37
CModelAbstract * m_Model
Definition: ObjectEntry.h:81
NONCOPYABLE(CObjectEntry)
CSkeletonAnim * GetRandomAnimation(const CStr &animationName, const CStr &ID="") const
Returns a randomly-chosen animation matching the given ID, or animationName if ID is empty...
Definition: ObjectEntry.cpp:258
CSimulation2 & m_Simulation
Definition: ObjectEntry.h:89
Definition: ObjectEntry.h:38
bool m_Outdated
Definition: ObjectEntry.h:85
Definition: SkeletonAnim.h:32