Пример #1
0
        public LogicTreeStrategy(IActor actor, LogicStateTree stateTree)
        {
            Actor         = actor;
            _stateTree    = stateTree;
            _strategyData = new LogicTreeStrategyData();

            CurrentState = _stateTree.StartState;
        }
Пример #2
0
        public LogicTreeStrategy(IActor actor, LogicStateTree stateTree)
        {
            Actor      = actor ?? throw new ArgumentNullException(nameof(actor));
            _stateTree = stateTree ?? throw new ArgumentNullException(nameof(stateTree));

            _strategyData = new LogicTreeStrategyData();

            CurrentState = _stateTree.StartState;
        }
Пример #3
0
        private void ResetLogicStates(LogicStateTree logicStateTree)
        {
            foreach (var transition in logicStateTree.Transitions)
            {
                transition.Key.Reset();

                foreach (var trigger in transition.Value)
                {
                    trigger.Trigger.Reset();
                }
            }
        }
        private static bool ValidateTree(LogicStateTree tree)
        {
            foreach (var item in tree.Transitions)
            {
                foreach (var transition in item.Value)
                {
                    if (!tree.Transitions.ContainsKey(item.Key))
                    {
                        // TODO Выбрасывать более конкретный тип исключения
                        throw new Exception($"{item} {transition} ссылается на несуществующую логику");
                    }
                }
            }

            return(true);
        }