private void LoadStates()
        {
            var states = _builder.GetStates();

            if (states != null)
            {
                _metadata = _builder.GetMetadata <HierarchicalStateMachineBuilderMetadata>(MetadataKey);

                var initialStateId = _builder.GetInitialStateId();

                for (int i = 0; i < states.Length; i++)
                {
                    var current = states[i];

                    for (int j = 0; j < _metadata.StateNodesMetadata.Count; j++)
                    {
                        if (HierarchicalStateMachineBuilderHelper.AreEquals(_metadata.StateNodesMetadata[j].StateId, current.StateId))
                        {
                            AddNodeFrom(states[i], _metadata.StateNodesMetadata[j]);
                            break;
                        }
                    }
                }

                var initialNode = StateNodeOf(initialStateId);

                if (initialNode != null)
                {
                    SetInitialStateNode(initialNode);
                }
            }
        }
        private StateNode GetNodeOf(StateInfo stateInfo)
        {
            for (int i = 0; i < _nodes.Count; i++)
            {
                var current = _nodes[i];

                if (HierarchicalStateMachineBuilderHelper.AreEquals(current.StateId, stateInfo.StateId))
                {
                    return(current);
                }
            }

            return(null);
        }
        private void LoadParentConnections()
        {
            for (int i = 0; i < _nodes.Count; i++)
            {
                var childs         = _builder.GetChildsOf(_nodes[i].StateId);
                var initialChildId = _builder.GetInitialChildOf(_nodes[i].StateId);

                if (childs != null)
                {
                    for (int j = 0; j < childs.Length; j++)
                    {
                        var childNode = StateNodeOf(childs[j]);

                        if (HierarchicalStateMachineBuilderHelper.AreEquals(childs[j], initialChildId))
                        {
                            childNode.AsInitialChild();
                        }

                        AddParentConnectionFrom(_nodes[i], childNode);
                    }
                }
            }
        }
 private bool AreEquals(object obj1, object obj2)
 {
     return(HierarchicalStateMachineBuilderHelper.AreEquals(obj1, obj2));
 }