| 182 | } |
| 183 | |
| 184 | void AnimatedPartSet::update(float dt) { |
| 185 | for (auto& pair : m_stateTypes) { |
| 186 | auto& stateType = pair.second; |
| 187 | auto const& state = *stateType.activeStatePointer; |
| 188 | |
| 189 | stateType.activeState.timer += dt; |
| 190 | if (stateType.activeState.timer > state.cycle) { |
| 191 | if (state.animationMode == End) { |
| 192 | stateType.activeState.timer = state.cycle; |
| 193 | } else if (state.animationMode == Loop) { |
| 194 | stateType.activeState.timer = std::fmod(stateType.activeState.timer, state.cycle); |
| 195 | } else if (state.animationMode == Transition) { |
| 196 | stateType.activeState.stateName = state.transitionState; |
| 197 | stateType.activeState.timer = 0.0f; |
| 198 | stateType.activeStatePointer = stateType.states.get(state.transitionState).get(); |
| 199 | } |
| 200 | } |
| 201 | |
| 202 | stateType.activeStateDirty = true; |
| 203 | } |
| 204 | |
| 205 | for (auto& pair : m_parts) |
| 206 | pair.second.activePartDirty = true; |
| 207 | } |
| 208 | |
| 209 | void AnimatedPartSet::finishAnimations() { |
| 210 | for (auto& pair : m_stateTypes) { |