1
0
forked from 0ad/0ad

Fix entity ID association with animations. Fixes #790.

This was SVN commit r9286.
This commit is contained in:
Ykkrosh 2011-04-20 00:04:05 +00:00
parent 6d946cc58d
commit 91ad17c685
4 changed files with 19 additions and 1 deletions

View File

@ -70,6 +70,13 @@ void CUnit::UpdateModel(float frameTime)
m_Animation->Update(frameTime*1000.0f); m_Animation->Update(frameTime*1000.0f);
} }
void CUnit::SetID(entity_id_t id)
{
m_ID = id;
if (m_Animation)
m_Animation->SetEntityID(id);
}
void CUnit::SetEntitySelection(const CStr& selection) void CUnit::SetEntitySelection(const CStr& selection)
{ {
CStr selection_lc = selection.LowerCase(); CStr selection_lc = selection.LowerCase();

View File

@ -71,7 +71,7 @@ public:
// 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) { m_ID = 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; }

View File

@ -47,6 +47,11 @@ CUnitAnimation::CUnitAnimation(entity_id_t ent, CModel* model, CObjectEntry* obj
ReloadUnit(model, object); ReloadUnit(model, object);
} }
void CUnitAnimation::SetEntityID(entity_id_t ent)
{
m_Entity = ent;
}
void CUnitAnimation::AddModel(CModel* model, const CObjectEntry* object) void CUnitAnimation::AddModel(CModel* model, const CObjectEntry* object)
{ {
SModelAnimState state; SModelAnimState state;

View File

@ -41,6 +41,12 @@ public:
*/ */
CUnitAnimation(entity_id_t ent, CModel* model, CObjectEntry* object); CUnitAnimation(entity_id_t ent, CModel* model, CObjectEntry* object);
/**
* Change the entity ID associated with this animation
* (currently used for playing locational sound effects).
*/
void SetEntityID(entity_id_t ent);
/** /**
* Start playing an animation. * Start playing an animation.
* The unit's actor defines the available animations, and if more than one is available * The unit's actor defines the available animations, and if more than one is available