Beispiel #1
0
        public void AddStep(WorkflowStepData data)
        {
            IStepItem stepItem = m_StepFactory.Create(data, m_StepItemPrefab);

            m_StepItems.Add(stepItem);
            stepsChanged?.Invoke(m_StepItems);
        }
Beispiel #2
0
        private ITrigger CreateCVTrigger(WorkflowStepData param)
        {
            WorkflowStepTrigger trigger   = m_Instantiator.Instantiate <WorkflowStepTrigger>();
            QCCondition         condition = m_Instantiator.Instantiate <QCCondition>();

            condition.triggerId = param.triggerId;
            trigger.AddCondition(condition, true);
            trigger.advance = true;
            trigger.mode    = ConditionMode.and;
            m_DisposalService.Register(trigger, param.id);
            m_DisposalService.Register(condition, param.id);
            return(trigger);
        }
Beispiel #3
0
        private ITrigger CreateAutoTrigger(WorkflowStepData param)
        {
            WorkflowStepTrigger trigger   = m_Instantiator.Instantiate <WorkflowStepTrigger>();
            TimeCondition       condition = m_Instantiator.Instantiate <TimeCondition>();

            condition.time = TimeSpan.FromSeconds(param.durations[0]);
            trigger.AddCondition(condition, true);
            trigger.advance = true;
            trigger.mode    = ConditionMode.and;
            m_DisposalService.Register(trigger, param.id);
            m_DisposalService.Register(condition, param.id);
            return(trigger);
        }
Beispiel #4
0
        public List <ITrigger> Create(WorkflowStepData param)
        {
            List <ITrigger> triggerList = new List <ITrigger>();

            if (param.automatic)
            {
                triggerList.Add(CreateAutoTrigger(param));
            }
            else if (param.triggerId != -1)
            {
                triggerList.Add(CreateCVTrigger(param));
            }

            return(triggerList);
        }
Beispiel #5
0
        private int3 EvaluateStreakBadge(WorkflowStepEndedArgs arg)
        {
            int3 buffer = int3.zero;

            if (arg.lastStep < arg.newStep)
            {
                WorkflowStepData data = m_WorkflowService.currentWorkflowData.steps[arg.lastDataStep];
                if (data.automatic)
                {
                    return(buffer);
                }
                ++m_StreakCounter;
                int streakLevel = Array.LastIndexOf <int>(m_StreakLevels, m_StreakCounter);
                if (streakLevel != -1)
                {
                    //remove previous streak badge
                    if (streakLevel > 0)
                    {
                        buffer[streakLevel - 1] -= 1;
                    }
                    buffer[streakLevel] += 1;
                    if (streakLevel > m_StreakLevels.Length)
                    {
                        m_StreakCounter = 0;
                    }
                }
            }
            else if (arg.lastStep > arg.newStep)
            {
                WorkflowStepData data = m_WorkflowService.currentWorkflowData.steps[arg.newDataStep];
                if (data.automatic)
                {
                    return(buffer);
                }
                int streakLevel = Array.LastIndexOf <int>(m_StreakLevels, m_StreakCounter);
                if (streakLevel != -1)
                {
                    // readd previous streak badge
                    if (streakLevel > 0)
                    {
                        buffer[streakLevel - 1] += 1;
                    }
                    buffer[streakLevel] -= 1;
                }
                m_StreakCounter -= m_StreakCounter == 0 ? 0 : 1;
            }
            return(buffer);
        }
Beispiel #6
0
        private int3 EvaluateFastBadge(WorkflowStepEndedArgs arg)
        {
            int3 buffer = int3.zero;

            if (arg.lastStep < arg.newStep)
            {
                WorkflowStepData data = m_WorkflowService.currentWorkflowData.steps[arg.lastDataStep];
                float            time = m_TimeRepo.currentTime.durationsPerStep[arg.lastStep] / data.durations[1];
                if (!data.automatic && time < 0.8f)
                {
                    ++m_FastCounter;
                }
            }
            else if (arg.lastStep > arg.newStep)
            {
                WorkflowStepData data = m_WorkflowService.currentWorkflowData.steps[arg.newDataStep];
                float            time = m_TimeRepo.currentTime.durationsPerStep[arg.newStep] / data.durations[1];
                if (!data.automatic && time < 0.8f)
                {
                    --m_FastCounter;
                }
            }
            if (m_PrevRepetitions == arg.executedRepetitions)
            {
                return(buffer);
            }
            if (arg.lastStep < arg.newStep)
            {
                int fastLevel = 0;
                while (m_FastCounter > m_FastLevels[fastLevel])
                {
                    ++fastLevel;
                }
                if (fastLevel != -1)
                {
                    buffer[fastLevel] += 1;
                }
                m_FastCounter = 0;
            }
            //recalculate the entire past history to properly subtract fast badge
            else if (arg.lastStep > arg.newStep)
            {
                int stepCount = arg.newDataStep - arg.lastDataStep;
                int startStep = arg.newStep - stepCount;
                m_FastCounter = 0;
                for (int i = 0; i < stepCount; ++i)
                {
                    WorkflowStepData step = m_WorkflowService.currentWorkflowData.steps[arg.lastDataStep + i];
                    float            time = m_TimeRepo.currentTime.durationsPerStep[startStep + i] / step.durations[1];
                    if (!step.automatic && time < 0.8f)
                    {
                        ++m_FastCounter;
                    }
                    int fastLevel = 0;
                    while (m_FastCounter < m_FastLevels[fastLevel])
                    {
                        ++fastLevel;
                    }
                    if (fastLevel != -1)
                    {
                        buffer[fastLevel] -= 1;
                        --m_FastCounter;
                    }
                }
            }
            return(buffer);
        }