Exemple #1
0
        private string GetStateIgnoreEvents(FsmModel model, FsmStateModel state, VarNames varNames)
        {
            var sb    = new System.Text.StringBuilder();
            int count = 0;

            foreach (var ignore in state.ignoreEvents)
            {
                count++;

                sb.Append(PostIndent(ignoreEventTrue
                                     .Replace("{{event}}", varNames.eventNameToEnum[ignore.name]),
                                     options.padding * 2, false));
            }

            return(sb.ToString());
        }
Exemple #2
0
        private string GetStateInternalActions(FsmModel model, FsmStateModel state, VarNames varNames)
        {
            var sb    = new System.Text.StringBuilder();
            int count = 0;

            foreach (var action in state.internalActions)
            {
                count++;

                sb.Append(PostIndent(internalActionsEventTemplate
                                     .Replace("{{event}}", varNames.eventNameToEnum[action.evt.name])
                                     .Replace("{{methodcall}}", MakeMethodCall(action._delegate, varNames)),
                                     options.padding * 2, false));
            }

            return(sb.ToString());
        }
        private static void ToDebugStringAppendState(System.Text.StringBuilder sb, FsmStateModel state, int indent)
        {
            ToDebugStringIndent(sb, indent);

            sb.Append("s[ ");
            sb.Append(state.name);
            sb.Append(" ]\n");

            foreach (var onEnter in state.onEnter)
            {
                ToDebugStringIndent(sb, 4);
                sb.Append("OnEnter -> ");
                sb.Append(onEnter._delegate.delegateDisplayName);
                sb.Append("\n");
            }

            foreach (var action in state.internalActions)
            {
                ToDebugStringAppendInternalAction(sb, action, 4);
                sb.Append("\n");
            }

            foreach (var transition in state.transitions)
            {
                ToDebugStringAppendTransition(sb, transition, 4);
                sb.Append("\n");
            }

            foreach (var onExit in state.onExit)
            {
                ToDebugStringIndent(sb, 4);
                sb.Append("OnExit -> ");
                sb.Append(onExit._delegate.delegateDisplayName);
                sb.Append("\n");
            }

            foreach (var ignore in state.ignoreEvents)
            {
                ToDebugStringIndent(sb, 4);
                sb.Append("e[ ");
                sb.Append(ignore.name);
                sb.Append(" ] -> Ignore");
                sb.Append("\n");
            }
        }
Exemple #4
0
        private string GetTransitions(FsmModel model, FsmStateModel state, VarNames varNames, out bool needDefaultBreak)
        {
            var sb    = new System.Text.StringBuilder();
            int count = 0;

            foreach (var transition in state.transitions)
            {
                count++;
                sb.Append(PostIndent(stateTransitionTemplate
                                     .Replace("{{event}}", varNames.eventNameToEnum[transition.evt.name])
                                     .Replace("{{tostate}}", varNames.stateNameToEnum[transition.to.name]),
                                     options.padding * 2, false));
            }

            needDefaultBreak = count != model.events.Count;

            return(sb.ToString());
        }
Exemple #5
0
        private string GetDispatchMethodCalls(FsmModel model, FsmStateModel state, VarNames varNames, List <FsmOnEnterExitModel> calls)
        {
            var sb = new System.Text.StringBuilder();

            if (calls.Count > 0)
            {
                sb.Append("\n");
            }
            for (int i = 0; i < calls.Count; i++)
            {
                var call = calls[i];
                PreIndent(sb, options.padding * 2);
                sb.Append("context.");
                sb.Append(varNames.interfaceContextCall[call._delegate._interface]);
                sb.Append(".");
                sb.Append(varNames.methodInvoke[call._delegate.method]);
                sb.Append(";");
                if (i != calls.Count - 1)
                {
                    sb.Append("\n");
                }
            }
            return(sb.ToString());
        }