Beispiel #1
0
        public override void VisitStateStatement(StateStatement state)
        {
            base.VisitStateStatement(state);
            //make string "ClassName::onEnterStateName" to search CPP
            if(!state.NoEnter)
                PrintFunc("void", ClassName + "::onEnter" + state.name, "()");

            //make string "ClassName::onExitStateName" to search CPP
            if (!state.NoExit)
                PrintFunc("void", ClassName + "::onExit" + state.name, "()");

            if (state.HasStatement(typeof(UpdateStatement)))
            {
                PrintFunc("void", ClassName + "::update" + state.name, "(float dt)", "\tdt;");
            }
        }
Beispiel #2
0
        public override void VisitStateStatement(StateStatement state)
        {
            base.VisitStateStatement(state);

            if (ClassName == null)
                throw new MalformedFSMException("No class statement found before state implementation.", state.line);

            stream.WriteLine("\tFSM::StateDelegateT<" + ClassName + "> " + state.name + "Delegate;");
            stream.WriteLine("\tFSM::State " + state.name + ";");
            if(!state.NoEnter)
                stream.WriteLine("\tvoid onEnter" + state.name + "();");
            if(!state.NoExit)
                stream.WriteLine("\tvoid onExit" + state.name + "();");
            if (state.HasStatement(typeof(UpdateStatement)))
            {
                stream.WriteLine("\tvoid update" + state.name + "(float dt);");
            }
            stream.WriteLine();
        }
        public override void VisitStateStatement(StateStatement state)
        {
            base.VisitStateStatement(state);
            if (ClassName == null)
                throw new MalformedFSMException("No class statement found before state implementation.", state.line);

            bool initial = state.HasStatement(typeof(InitialStatement));
            bool update = state.HasStatement(typeof(UpdateStatement));

            string parent = null;

            try
            {
                parent = GetParent();
            }
            catch (Exception)
            {
                parent = "FSM";
            }

            stream.WriteLine("\t\tFSM_INIT_STATE_EXPLICIT(" + state.name + ", " +
                (initial ? "true, " : "false, ") +
                (state.NoEnter ? "NULL, " : "&" + ClassName + "::onEnter"+state.name+ ", ") +
                (state.NoExit ? "NULL, " : "&" + ClassName + "::onExit" + state.name + ", ") +
                (!update ? "NULL" : "&" + ClassName + "::update" + state.name) +
                ");");
            //if (update)
            //{
            //    stream.WriteLine("\t\tFSM_INIT_STATE_UPDATE(" + ClassName + ", " + state.name + ", " + (initial ? "true" : "false") + ");");
            //}
            //else
            //{
            //    stream.WriteLine("\t\tFSM_INIT_STATE(" + ClassName + ", " + state.name + ", " + (initial ? "true" : "false") + ");");
            //}

            stream.WriteLine("\t\t" + parent + ".addChild(" + state.name + ");");

            stream.WriteLine();
        }