Exemplo n.º 1
0
        public static BTFsm CreateFromOwnerTemplate(BTFsm targetFsm, BTTemplate source)
        {
            for (int i = 0; i < source.totalEvent.Count; i++)
            {
                targetFsm.totalEvent[i].Owner = targetFsm;
            }
            targetFsm.totalState.Clear();

            for (int i = 0; i < source.totalState.Count; i++)
            {
                BTState.Create(targetFsm, source.totalState[i]);
            }

            for (int i = 0; i < targetFsm.totalState.Count; i++)
            {
                var state = targetFsm.totalState[i];
                for (int j = 0; j < state.totalEvent.Count; j++)
                {
                    if (state.totalEvent[j].TargetState != null)
                    {
                        state.totalEvent[j].TargetState = targetFsm.FindState(state.totalEvent[j].TargetState.Name);
                    }
                }
            }
            targetFsm.totalVariable.Clear();
            for (int i = 0; i < source.totalVariable.Count; i++)
            {
                BTVariable.Create(targetFsm, source.totalVariable[i]);
            }

            targetFsm.startEvent = targetFsm.FindGlobalEvent(targetFsm.startEvent.Name);
            return(targetFsm);
        }
Exemplo n.º 2
0
        public static BTFsm CreateFromOtherTemplate(BTFsm targetFsm, BTTemplate source)
        {
            for (int i = 0; i < source.totalEvent.Count; i++)
            {
                BTEvent.Create(targetFsm, source.totalEvent[i]);
            }

            for (int i = 0; i < source.totalState.Count; i++)
            {
                BTState.Create(targetFsm, source.totalState[i]);
            }
            for (int i = 0; i < source.totalState.Count; i++)
            {
                var state = targetFsm.totalState[i];
                state.ReFindEvent();
            }

            for (int i = 0; i < source.totalVariable.Count; i++)
            {
                BTVariable.Create(targetFsm, source.totalVariable[i]);
            }

            targetFsm.startEvent = targetFsm.FindGlobalEvent(source.startEvent.Name);

            return(targetFsm);
        }