Пример #1
0
        public int FlagActionAs(MAction action, ExecutionState state)
        {
            bool found = false;

            for (int i = _lastIndex[state]; i < actionsQueue.Count; i++)
            {
                if (actionsQueue[i].Id == action.Id)
                {
                    actionsQueue[i].State = state;
                    found             = true;
                    _lastIndex[state] = i;
                    if (state == ExecutionState.Executed)
                    {
                        FlagNextActionAsExecuting(i);
                    }
                    return(i);
                }
            }

            // If something went wrong with indexing, give it another round just in case
            if (!found)
            {
                Logger.Debug($"Second round on FlagActionAs {state} for {action}");
                for (int i = 0; i < actionsQueue.Count; i++)
                {
                    if (actionsQueue[i].Id == action.Id)
                    {
                        actionsQueue[i].State = state;
                        found             = true;
                        _lastIndex[state] = i;
                        if (state == ExecutionState.Executed)
                        {
                            FlagNextActionAsExecuting(i);
                            ClearExecutedExcess();
                        }
                        return(i);
                    }
                }
            }

            // Very quick and dirty

            return(-1);
        }
Пример #2
0
        /// <summary>
        /// Searches the action queue for an Action by id, and changes its display state.
        /// </summary>
        /// <param name="action"></param>
        /// <param name="state"></param>
        /// <returns></returns>
        public int FlagActionAs(MAction action, ExecutionState state)
        {
            // Since ids are usually correlative, start by last state index to quickly find the searched action,
            // and loop back into start if necessary.
            int it = _lastIndex[state];

            if (it >= _actionsQueue.Count)
            {
                it = 0;
            }
            for (int i = 0; i < _actionsQueue.Count; i++)
            {
                if (_actionsQueue[it].Id == action.Id)
                {
                    _actionsStateCount[_actionsQueue[it].State]--;
                    _actionsStateCount[state]++;

                    _actionsQueue[it].State = state;
                    _lastIndex[state]       = i;

                    if (state == ExecutionState.Executed)
                    {
                        FlagNextActionAsExecuting(it);
                    }

                    return(it);
                }

                it++;
                if (it >= _actionsQueue.Count)
                {
                    it = 0;
                }
            }

            return(-1);
        }
Пример #3
0
        private int _textMode = 1;  // 0 for .ToString, 1 for ToInstruction

        public ActionWrapper(MAction action)
        {
            this._action = action;
        }