use transition only when it has been selected

fix for randomized transitions.
When transitions are selected at random we only have to consume the triggers on the transition that has been selected of out the random candidates.
If we consume the first one, the remaining ones are no longer candidates if they share the same trigger.

Diffs=
6d8854ec04 use transition only when it has been selected (#8921)

Co-authored-by: hernan <hernan@rive.app>
diff --git a/include/rive/animation/state_transition.hpp b/include/rive/animation/state_transition.hpp
index feca116..79b9fff 100644
--- a/include/rive/animation/state_transition.hpp
+++ b/include/rive/animation/state_transition.hpp
@@ -134,6 +134,10 @@
     /// correct time to the animation instance in the stateFrom, when
     /// applicable (when it's an AnimationState).
     bool applyExitCondition(StateInstance* stateFrom) const;
+
+    /// Marks any trigger based condition as used for this layer
+    void useLayerInConditions(StateMachineInstance* stateMachineInstance,
+                              StateMachineLayerInstance* layerInstance) const;
 };
 } // namespace rive
 
diff --git a/src/animation/state_machine_instance.cpp b/src/animation/state_machine_instance.cpp
index 114e9b1..ad51844 100644
--- a/src/animation/state_machine_instance.cpp
+++ b/src/animation/state_machine_instance.cpp
@@ -238,6 +238,10 @@
                     }
                 }
             }
+            else
+            {
+                transition->evaluatedRandomWeight(0);
+            }
         }
         if (totalWeight > 0)
         {
@@ -251,6 +255,8 @@
                 auto transitionWeight = transition->evaluatedRandomWeight();
                 if (currentWeight + transitionWeight > randomWeight)
                 {
+                    transition->useLayerInConditions(m_stateMachineInstance,
+                                                     this);
                     return transition;
                 }
                 currentWeight += transitionWeight;
@@ -284,6 +290,8 @@
                 {
                     transition->evaluatedRandomWeight(
                         transition->randomWeight());
+                    transition->useLayerInConditions(m_stateMachineInstance,
+                                                     this);
                     return transition;
                 }
                 else
diff --git a/src/animation/state_transition.cpp b/src/animation/state_transition.cpp
index 8ebb202..35e7c70 100644
--- a/src/animation/state_transition.cpp
+++ b/src/animation/state_transition.cpp
@@ -202,15 +202,6 @@
             }
         }
     }
-    for (auto condition : m_Conditions)
-    {
-        if (condition->is<TransitionTriggerCondition>())
-        {
-            condition->as<TransitionTriggerCondition>()->useInLayer(
-                stateMachineInstance,
-                layerInstance);
-        }
-    }
     return AllowTransition::yes;
 }
 
@@ -227,4 +218,19 @@
         return true;
     }
     return useExitTime;
+}
+
+void StateTransition::useLayerInConditions(
+    StateMachineInstance* stateMachineInstance,
+    StateMachineLayerInstance* layerInstance) const
+{
+    for (auto condition : m_Conditions)
+    {
+        if (condition->is<TransitionTriggerCondition>())
+        {
+            condition->as<TransitionTriggerCondition>()->useInLayer(
+                stateMachineInstance,
+                layerInstance);
+        }
+    }
 }
\ No newline at end of file