Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
ObjectEntry.h
Go to the documentation of this file.
1/* Copyright (C) 2026 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"
23#include "lib/code_annotation.h"
25#include "ps/CStr.h"
26
27#include <map>
28#include <memory>
29#include <set>
30#include <string>
31#include <vector>
32
33class CModelAbstract;
34class CObjectManager;
35class CSimulation2;
36class CSkeletonAnim;
37
39{
41
42public:
43 CObjectEntry(const std::shared_ptr<CObjectBase>& base, const CSimulation2& simulation);
45
46 // Construct this actor, using the specified variation selections
47 bool BuildVariation(const std::vector<const std::set<CStr>*>& completeSelections,
48 const std::vector<std::uint8_t>& variationKey, CObjectManager& objectManager);
49
50 // Base actor. Contains all the things that don't change between
51 // different variations of the actor.
52 std::shared_ptr<CObjectBase> m_Base;
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
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
81 std::unique_ptr<CModelAbstract> m_Model;
82
83private:
85
86 using SkeletonAnimMap = std::multimap<CStr, std::unique_ptr<CSkeletonAnim>>;
88 // TODO: something more memory-efficient than storing loads of similar strings for each unit?
89};
90
91#endif // INCLUDED_OBJECTENTRY
Abstract base class for graphical objects that are used by units, or as props attached to other CMode...
Definition: ModelAbstract.h:56
Definition: ObjectEntry.h:39
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:315
CColor m_Color
Definition: ObjectEntry.h:59
std::shared_ptr< CObjectBase > m_Base
Definition: ObjectEntry.h:52
std::vector< CObjectBase::Samp > m_Samplers
Definition: ObjectEntry.h:55
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:336
VfsPath m_ModelName
Definition: ObjectEntry.h:57
std::wstring m_ProjectileModelName
Definition: ObjectEntry.h:64
std::unique_ptr< CModelAbstract > m_Model
Definition: ObjectEntry.h:81
bool BuildVariation(const std::vector< const std::set< CStr > * > &completeSelections, const std::vector< std::uint8_t > &variationKey, CObjectManager &objectManager)
Definition: ObjectEntry.cpp:77
CObjectEntry(const std::shared_ptr< CObjectBase > &base, const CSimulation2 &simulation)
Definition: ObjectEntry.cpp:70
SkeletonAnimMap m_Animations
Definition: ObjectEntry.h:87
const CSimulation2 & m_Simulation
Definition: ObjectEntry.h:84
std::multimap< CStr, std::unique_ptr< CSkeletonAnim > > SkeletonAnimMap
Definition: ObjectEntry.h:86
Definition: ObjectManager.h:46
Public API for simulation system.
Definition: Simulation2.h:57
Definition: SkeletonAnim.h:34
Definition: path.h:84
Definition: Color.h:46