internal void EvaluateTrigger(RSTriggerId inTriggerId, ExecutionScope inScope) { if (!m_Entity.IsAlive()) { return; } if (OnTrigger != null) { object arg = RSInterop.ToObject(inScope.Argument, inScope); OnTrigger.Invoke(inTriggerId, arg); } RSRuleData[] rules = m_Table?.Rules; int ruleCount; if (rules == null || (ruleCount = rules.Length) <= 0) { return; } using (PooledSet <string> triggeredGroups = PooledSet <string> .Alloc()) { for (int i = 0; i < ruleCount; ++i) { RSRuleData rule = rules[i]; if (rule.TriggerId != inTriggerId) { continue; } if (m_States[i].HasFlag(RuleState.Disabled)) { continue; } if (rule.DontInterrupt && m_Routines[i]) { continue; } if (!inScope.EvaluateConditions(rule.Conditions, rule.ConditionSubset)) { continue; } if (!string.IsNullOrEmpty(rule.RoutineGroup)) { if (!triggeredGroups.Add(rule.RoutineGroup)) { continue; } StopRuleGroup(rule.RoutineGroup); } if (rule.OnlyOnce) { m_States[i] |= RuleState.Disabled; } if (rule.Actions != null) { ExecutionScope scope = inScope; scope.m_Environment.CloneScopeIfNecessary(scope, rule.Flags, out scope); m_Routines[i].Replace(m_Entity.ProxyObject, scope.PerformActions(rule.Actions)) .ExecuteWhileDisabled().SetPhase(m_Entity.ExecutionPhase) .TryManuallyUpdate(0); } } } }