Changeset View
Changeset View
Standalone View
Standalone View
source/graphics/Unit.h
Show All 12 Lines | |||||
* | * | ||||
* You should have received a copy of the GNU General Public License | * 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/>. | * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>. | ||||
*/ | */ | ||||
#ifndef INCLUDED_UNIT | #ifndef INCLUDED_UNIT | ||||
#define INCLUDED_UNIT | #define INCLUDED_UNIT | ||||
#include <map> | |||||
#include <set> | |||||
#include "ps/CStr.h" | #include "ps/CStr.h" | ||||
#include "simulation2/system/Entity.h" // entity_id_t | #include "simulation2/system/Entity.h" // entity_id_t | ||||
#include <map> | |||||
#include <memory> | |||||
#include <set> | |||||
#include <vector> | |||||
class CActorDef; | class CActorDef; | ||||
class CModelAbstract; | class CModelAbstract; | ||||
class CObjectEntry; | class CObjectEntry; | ||||
class CObjectManager; | class CObjectManager; | ||||
class CSkeletonAnim; | class CSkeletonAnim; | ||||
class CUnitAnimation; | class CUnitAnimation; | ||||
Show All 14 Lines | public: | ||||
static CUnit* Create(const CStrW& actorName, uint32_t seed, const std::set<CStr>& selections, CObjectManager& objectManager); | static CUnit* Create(const CStrW& actorName, uint32_t seed, const std::set<CStr>& selections, CObjectManager& objectManager); | ||||
// destructor | // destructor | ||||
~CUnit(); | ~CUnit(); | ||||
// get unit's template object | // get unit's template object | ||||
const CObjectEntry& GetObject() const { return *m_Object; } | const CObjectEntry& GetObject() const { return *m_Object; } | ||||
// get unit's model data | // get unit's model data | ||||
CModelAbstract& GetModel() const { return *m_Model; } | CModelAbstract& GetModel() const { return *m_Model->get(); } | ||||
CUnitAnimation* GetAnimation() { return m_Animation; } | CUnitAnimation* GetAnimation() { return m_Animation.get(); } | ||||
/** | /** | ||||
* Update the model's animation. | * Update the model's animation. | ||||
* @param frameTime time in seconds | * @param frameTime time in seconds | ||||
*/ | */ | ||||
void UpdateModel(float frameTime); | void UpdateModel(float frameTime); | ||||
void UpdateQualityLevel(u8 quality); | |||||
// Sets the entity-selection, and updates the unit to use the new | // Sets the entity-selection, and updates the unit to use the new | ||||
// actor variation. Either set one key at a time, or a complete map. | // actor variation. Either set one key at a time, or a complete map. | ||||
void SetEntitySelection(const CStr& key, const CStr& selection); | void SetEntitySelection(const CStr& key, const CStr& selection); | ||||
void SetEntitySelection(const std::map<CStr, CStr>& selections); | void SetEntitySelection(const std::map<CStr, CStr>& selections); | ||||
// Most units have a hopefully-unique ID number, so they can be referred to | // Most units have a hopefully-unique ID number, so they can be referred to | ||||
// persistently despite saving/loading maps. Default for new units is -1; should | // persistently despite saving/loading maps. Default for new units is -1; should | ||||
// usually be set to CUnitManager::GetNewID() after creation. | // usually be set to CUnitManager::GetNewID() after creation. | ||||
entity_id_t GetID() const { return m_ID; } | entity_id_t GetID() const { return m_ID; } | ||||
void SetID(entity_id_t id); | void SetID(entity_id_t id); | ||||
const std::set<CStr>& GetActorSelections() const { return m_ActorSelections; } | const std::set<CStr>& GetActorSelections() const { return m_ActorSelections; } | ||||
void SetActorSelections(const std::set<CStr>& selections); | void SetActorSelections(const std::set<CStr>& selections); | ||||
private: | private: | ||||
// Actor for the unit | // Actor for the unit | ||||
const CActorDef& m_Actor; | const CActorDef& m_Actor; | ||||
// object from which unit was created; never NULL once fully created. | |||||
// Objects at varying quality levels. Never nullptr after initialization. | |||||
std::vector<CObjectEntry*> m_Objects; | |||||
// Models at varying quality levels. A particular model may be nullptr if the quality level has not yet been used. | |||||
std::vector<std::unique_ptr<CModelAbstract>> m_Models; | |||||
// Current object entry, never nullptr after initialization. | |||||
CObjectEntry* m_Object = nullptr; | CObjectEntry* m_Object = nullptr; | ||||
// object model representation; never NULL once fully created. | // Current model. Always point to a real element after initialization. | ||||
CModelAbstract* m_Model = nullptr; | std::vector<std::unique_ptr<CModelAbstract>>::iterator m_Model; | ||||
CUnitAnimation* m_Animation = nullptr; | std::unique_ptr<CUnitAnimation> m_Animation; | ||||
// unique (per map) ID number for units created in the editor, as a | // unique (per map) ID number for units created in the editor, as a | ||||
// permanent way of referencing them. | // permanent way of referencing them. | ||||
entity_id_t m_ID; | entity_id_t m_ID; | ||||
// seed used when creating unit | // seed used when creating unit | ||||
uint32_t m_Seed; | uint32_t m_Seed; | ||||
// actor-level selections for this unit | // actor-level selections for this unit | ||||
// TODO: this is actually completely useless at the moment, it should be deleted or turned into something useful. | |||||
std::set<CStr> m_ActorSelections; | std::set<CStr> m_ActorSelections; | ||||
Stan: What's this? | |||||
Done Inline ActionsIt's supposed to be used for atlas to select variants, but it's not actually implemented... since 2006/2010 wraitii: It's supposed to be used for atlas to select variants, but it's not actually implemented... | |||||
Not Done Inline ActionsRight D2042 Stan: Right D2042 | |||||
// entity-level selections for this unit | // entity-level selections for this unit | ||||
std::map<CStr, CStr> m_EntitySelections; | std::map<CStr, CStr> m_EntitySelections; | ||||
u8 m_QualityLevel = 255; | |||||
// object manager which looks after this unit's objectentry | // object manager which looks after this unit's objectentry | ||||
CObjectManager& m_ObjectManager; | CObjectManager& m_ObjectManager; | ||||
void ReloadObject(); | void ReloadObject(); | ||||
u8 GetIndexForQuality(u8 quality); | |||||
void UpdateCurrentModel(const std::unique_ptr<CModelAbstract>& oldModel); | |||||
friend class CUnitAnimation; | friend class CUnitAnimation; | ||||
}; | }; | ||||
#endif | #endif |
Wildfire Games · Phabricator
What's this?