Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/graphics/UnitAnimation.cpp
/* Copyright (C) 2016 Wildfire Games. | /* Copyright (C) 2018 Wildfire Games. | ||||
* This file is part of 0 A.D. | * This file is part of 0 A.D. | ||||
* | * | ||||
* 0 A.D. is free software: you can redistribute it and/or modify | * 0 A.D. is free software: you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation, either version 2 of the License, or | * the Free Software Foundation, either version 2 of the License, or | ||||
* (at your option) any later version. | * (at your option) any later version. | ||||
* | * | ||||
* 0 A.D. is distributed in the hope that it will be useful, | * 0 A.D. is distributed in the hope that it will be useful, | ||||
▲ Show 20 Lines • Show All 70 Lines • ▼ Show 20 Lines | void CUnitAnimation::AddModel(CModel* model, const CObjectEntry* object) | ||||
for (const CModel::Prop& prop : props) | for (const CModel::Prop& prop : props) | ||||
{ | { | ||||
CModel* propModel = prop.m_Model->ToCModel(); | CModel* propModel = prop.m_Model->ToCModel(); | ||||
if (propModel) | if (propModel) | ||||
AddModel(propModel, prop.m_ObjectEntry); | AddModel(propModel, prop.m_ObjectEntry); | ||||
} | } | ||||
} | } | ||||
void CUnitAnimation::ReloadAnimation() | |||||
{ | |||||
UpdateAnimationID(); | |||||
ReloadUnit(m_Model, m_Object); | |||||
} | |||||
void CUnitAnimation::ReloadUnit(CModel* model, const CObjectEntry* object) | void CUnitAnimation::ReloadUnit(CModel* model, const CObjectEntry* object) | ||||
{ | { | ||||
m_Model = model; | m_Model = model; | ||||
m_Object = object; | m_Object = object; | ||||
m_AnimStates.clear(); | m_AnimStates.clear(); | ||||
m_AnimStatesAreStatic = true; | m_AnimStatesAreStatic = true; | ||||
AddModel(m_Model, m_Object); | AddModel(m_Model, m_Object); | ||||
} | } | ||||
void CUnitAnimation::SetAnimationState(const CStr& name, bool once, float speed, float desync, const CStrW& actionSound) | void CUnitAnimation::SetAnimationState(const CStr& name, bool once, float speed, float desync, const CStrW& actionSound) | ||||
{ | { | ||||
m_Looping = !once; | m_Looping = !once; | ||||
m_OriginalSpeed = speed; | m_OriginalSpeed = speed; | ||||
m_Desync = desync; | m_Desync = desync; | ||||
m_ActionSound = actionSound; | m_ActionSound = actionSound; | ||||
m_Speed = DesyncSpeed(m_OriginalSpeed, m_Desync); | m_Speed = DesyncSpeed(m_OriginalSpeed, m_Desync); | ||||
m_SyncRepeatTime = 0.f; | m_SyncRepeatTime = 0.f; | ||||
if (name != m_State) | if (name != m_State) | ||||
{ | { | ||||
m_State = name; | m_State = name; | ||||
UpdateAnimationID(); | ReloadAnimation(); | ||||
ReloadUnit(m_Model, m_Object); | |||||
} | } | ||||
} | } | ||||
void CUnitAnimation::SetAnimationSyncRepeat(float repeatTime) | void CUnitAnimation::SetAnimationSyncRepeat(float repeatTime) | ||||
{ | { | ||||
m_SyncRepeatTime = repeatTime; | m_SyncRepeatTime = repeatTime; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 161 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator