Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
ObjectEntry.h
Go to the documentation of this file.
1/* Copyright (C) 2023 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#include "graphics/Color.h"
22#include "graphics/ObjectBase.h"
24#include "ps/CStr.h"
25
26#include <map>
27#include <memory>
28#include <set>
29#include <vector>
30
31class CModelAbstract;
32class CSkeletonAnim;
33class CObjectBase;
34class CObjectManager;
35class CSimulation2;
36
38{
40
41public:
42 CObjectEntry(const std::shared_ptr<CObjectBase>& base, const CSimulation2& simulation);
44
45 // Construct this actor, using the specified variation selections
46 bool BuildVariation(const std::vector<const std::set<CStr>*>& completeSelections,
47 const std::vector<u8>& variationKey, CObjectManager& objectManager);
48
49 // Base actor. Contains all the things that don't change between
50 // different variations of the actor.
51 std::shared_ptr<CObjectBase> m_Base;
52
53 // samplers list
54 std::vector<CObjectBase::Samp> m_Samplers;
55 // model name
57 // color (used when doing alpha-channel coloring, but not doing player-color)
59 // (probable TODO: make color a per-model thing, rather than per-objectEntry,
60 // so we can have lots of color variations without wasting memory on
61 // lots of objectEntries)
62
64
65 /**
66 * Returns a randomly-chosen animation matching the given ID, or animationName if ID is empty.
67 * The chosen animation is picked randomly from the GetAnimations list
68 * with the frequencies as weights (if there are any defined).
69 * This method should always return an animation
70 */
71 CSkeletonAnim* GetRandomAnimation(const CStr& animationName, const CStr& ID = "") const;
72
73 /**
74 * Returns all the animations matching the given ID or animationName if ID is empty.
75 * If none found returns Idle animations (which are always added)
76 */
77 std::vector<CSkeletonAnim*> GetAnimations(const CStr& animationName, const CStr& ID = "") const;
78
79 // corresponding model
80 std::unique_ptr<CModelAbstract> m_Model;
81
82private:
84
85 using SkeletonAnimMap = std::multimap<CStr, std::unique_ptr<CSkeletonAnim>>;
87 // TODO: something more memory-efficient than storing loads of similar strings for each unit?
88};
89
90#endif // INCLUDED_OBJECTENTRY
Abstract base class for graphical objects that are used by units, or as props attached to other CMode...
Definition: ModelAbstract.h:50
Maintains the tree of possible objects from a specific actor definition at a given quality level.
Definition: ObjectBase.h:47
Definition: ObjectEntry.h:38
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:274
CColor m_Color
Definition: ObjectEntry.h:58
std::shared_ptr< CObjectBase > m_Base
Definition: ObjectEntry.h:51
std::vector< CObjectBase::Samp > m_Samplers
Definition: ObjectEntry.h:54
NONCOPYABLE(CObjectEntry)
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:295
VfsPath m_ModelName
Definition: ObjectEntry.h:56
std::wstring m_ProjectileModelName
Definition: ObjectEntry.h:63
std::unique_ptr< CModelAbstract > m_Model
Definition: ObjectEntry.h:80
bool BuildVariation(const std::vector< const std::set< CStr > * > &completeSelections, const std::vector< u8 > &variationKey, CObjectManager &objectManager)
Definition: ObjectEntry.cpp:53
CObjectEntry(const std::shared_ptr< CObjectBase > &base, const CSimulation2 &simulation)
Definition: ObjectEntry.cpp:46
SkeletonAnimMap m_Animations
Definition: ObjectEntry.h:86
const CSimulation2 & m_Simulation
Definition: ObjectEntry.h:83
std::multimap< CStr, std::unique_ptr< CSkeletonAnim > > SkeletonAnimMap
Definition: ObjectEntry.h:85
Definition: ObjectManager.h:42
Public API for simulation system.
Definition: Simulation2.h:47
Definition: SkeletonAnim.h:33
Definition: path.h:80
Definition: Color.h:43