Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/graphics/Unit.h
Show All 36 Lines | |||||
class CUnit | class CUnit | ||||
{ | { | ||||
NONCOPYABLE(CUnit); | NONCOPYABLE(CUnit); | ||||
private: | private: | ||||
// Private constructor. Needs complete list of selections for the variation. | // Private constructor. Needs complete list of selections for the variation. | ||||
CUnit(CObjectManager& objectManager, const CActorDef& actor, uint32_t seed); | CUnit(CObjectManager& objectManager, const CActorDef& actor, uint32_t seed); | ||||
public: | public: | ||||
// Attempt to create a unit with the given actor, with a set of | // Attempt to create a unit with the given actor. | ||||
// suggested selections (with the rest being randomised using the | // If specific selections are wanted, call SetEntitySelection or SetActorSelections after creation. | ||||
// given random seed). | |||||
// Returns NULL on failure. | // Returns NULL on failure. | ||||
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, 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; } | ||||
Show All 14 Lines | public: | ||||
// 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; } | ||||
/** | |||||
* Overwrite the seed-selected actor selections. Likely only useful for Atlas or debugging. | |||||
*/ | |||||
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. | // object from which unit was created; never NULL once fully created. | ||||
CObjectEntry* m_Object = nullptr; | CObjectEntry* m_Object = nullptr; | ||||
// object model representation; never NULL once fully created. | // object model representation; never NULL once fully created. | ||||
CModelAbstract* m_Model = nullptr; | CModelAbstract* m_Model = nullptr; | ||||
CUnitAnimation* m_Animation = nullptr; | CUnitAnimation* m_Animation = nullptr; | ||||
// 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. This is normally set at init time, | ||||
// so that we always re-use the same aesthetic variants. | |||||
// These have lower priority than entity-level selections. | |||||
std::set<CStr> m_ActorSelections; | std::set<CStr> m_ActorSelections; | ||||
// entity-level selections for this unit | // Entity-level selections for this unit (used for e.g. animation variants). | ||||
std::map<CStr, CStr> m_EntitySelections; | std::map<CStr, CStr> m_EntitySelections; | ||||
// 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(); | ||||
friend class CUnitAnimation; | friend class CUnitAnimation; | ||||
}; | }; | ||||
#endif | #endif |
Wildfire Games · Phabricator