SDK/StateMachine: Fixed ignored transitiions

This commit is contained in:
Lynix 2019-04-07 21:36:08 +02:00
parent 793c5abfe3
commit d234d2084d
2 changed files with 7 additions and 1 deletions

View File

@ -178,6 +178,7 @@ Nazara Engine:
- Added Collider2D::ForEachPolygon method
- Added RigidBody::[Get|Set]PositionOffset allowing set an offset between body logic position and body physics position (center of mass position)
- ⚠ Default TextureSampler WrapMode is now Clamp (instead of Repeat)
- Fixed StateMachine ignoring transitions made in Enter/Leave events of states
Nazara Development Kit:
- Added ImageWidget (#139)

View File

@ -159,8 +159,13 @@ namespace Ndk
*/
inline bool StateMachine::Update(float elapsedTime)
{
for (StateTransition& transition : m_transitions)
// Use a classic for instead of a range-for because some state may push/pop on enter/leave, adding new transitions as we iterate
// (range-for is a problem here because it doesn't handle mutable containers)
for (std::size_t i = 0; i < m_transitions.size(); ++i)
{
StateTransition& transition = m_transitions[i];
switch (transition.type)
{
case TransitionType::Pop: