Exemple #1
0
 static void Postfix(SelectFeature __instance, ref StateReplacer __state)
 {
     if (__state != null)
     {
         __state.Restore();
     }
 }
 static void Postfix(SelectFeature __instance, ref StateReplacer __state)
 {
     if (!settings.toggleMulticlass)
     {
         return;
     }
     if (__state != null)
     {
         __state.Restore();
     }
 }
 static void Prefix(SelectFeature __instance, LevelUpState state, UnitDescriptor unit)
 {
     if (IsAvailable())
     {
         BlueprintCharacterClass sourceClass = (GetMethodDel <SelectFeature, Func <SelectFeature, LevelUpState, FeatureSelectionState> >
                                                    ("GetSelectionState")(__instance, state)?.Source as BlueprintProgression)?.GetSourceClass(unit);
         if (sourceClass == null)
         {
             Core.Debug($" - {nameof(SelectFeature)}.{nameof(SelectFeature.Apply)}({state.SelectedClass}[{state.NextClassLevel}], {unit}) - {__instance.Selection}, {__instance.Item}");
         }
         else
         {
             Core.Debug($" - {nameof(SelectFeature)}.{nameof(SelectFeature.Apply)}({sourceClass}[{unit.Progression.GetClassLevel(sourceClass)}], {unit}) - {__instance.Selection}, {__instance.Item}");
         }
     }
 }
Exemple #4
0
 static void Prefix(SelectFeature __instance, LevelUpState state, UnitDescriptor unit, ref StateReplacer __state)
 {
     if (IsAvailable())
     {
         if (__instance.Item != null)
         {
             FeatureSelectionState selectionState =
                 GetMethodDel <SelectFeature, Func <SelectFeature, LevelUpState, FeatureSelectionState> >
                     ("GetSelectionState")(__instance, state);
             if (selectionState != null)
             {
                 BlueprintCharacterClass sourceClass = (selectionState.Source as BlueprintFeature)?.GetSourceClass(unit);
                 if (sourceClass != null)
                 {
                     __state = new StateReplacer(state);
                     __state.Replace(sourceClass, unit.Progression.GetClassLevel(sourceClass));
                 }
             }
         }
     }
 }
Exemple #5
0
        /// <summary>
        /// AlignmentSensor校正
        /// </summary>
        /// <param name="selectCamera"></param>
        /// <param name="nowX"></param>
        /// <param name="nowY"></param>
        /// <param name="nowθ"></param>
        /// <param name="point"></param>
        /// <param name="Action"></param>
        /// <param name="CheckAlarm"></param>
        /// <param name="timeOut"></param>
        /// <returns></returns>
        public ushort AlignmentCalibration_ChkRet(SelectCamera selectCamera, double nowX, double nowY, double nowθ, ushort point, bool Action = true, bool CheckAlarm = true, double timeOut = 3000)
        {
            lock (Lock_AlignmentCalibration_ChkRet)
            {
                ushort nValue   = conProg.process.Busy;
                string strError = string.Empty;

                if (RunMode.Pause_f == true || AlarmMessage.Alarm_SW)
                {
                    return(nValue);
                }

                if (Action == false)
                {
                    AlignmentCalibration_ChkRet_p = 9999;
                }

                SelectFeature         selectFeature   = SelectFeature.Feature_1;
                CognexAS200Coordinate inputCoordinate = new CognexAS200Coordinate();
                inputCoordinate.X = nowX;
                inputCoordinate.Y = nowY;
                inputCoordinate.Z = 0;
                inputCoordinate.A = nowθ;
                inputCoordinate.B = 0;
                inputCoordinate.C = 0;

                switch (AlignmentCalibration_ChkRet_p)
                {
                case 0:
                    nValue = conProg.process.Busy;
                    calibrationTable.Clear();
                    if (GoToAbsPosition(inputCoordinate.X, inputCoordinate.Y, inputCoordinate.A, point, false) == conProg.process.Success)
                    {
                        AlignmentCalibration_ChkRet_p = 10;
                    }
                    break;

                case 10:
                    if (GoToAbsPosition(inputCoordinate.X, inputCoordinate.Y, inputCoordinate.A, point) == conProg.process.Success)
                    {
                        calibrationTable.Rows.Add(inputCoordinate.X, inputCoordinate.Y, inputCoordinate.A);
                        AlignmentCalibration_ChkRet_p = 20;
                    }
                    break;

                case 20:
                    if (alignmentSensor.Functions.AutoCalibrationBegin_ChkRet(selectCamera, selectFeature, inputCoordinate, ref status, ref outputCoordinate, false) == conProg.process.Success)
                    {
                        AlignmentCalibration_ChkRet_p = 30;
                    }
                    break;

                case 30:
                    if (alignmentSensor.Functions.AutoCalibrationBegin_ChkRet(selectCamera, selectFeature, inputCoordinate, ref status, ref outputCoordinate) == conProg.process.Success)
                    {
                        if (status == CognexAS200CommandStatus.Fail)
                        {
                            strError = "AutoCalibrationBegin_失敗";
                            AlignmentCalibration_ChkRet_p = 8000;
                        }
                        else
                        {
                            AlignmentCalibration_ChkRet_p = 40;
                        }
                    }
                    break;

                case 40:
                    if (GoToAbsPosition(outputCoordinate.X, outputCoordinate.Y, outputCoordinate.A, point, false) == conProg.process.Success)
                    {
                        AlignmentCalibration_ChkRet_p = 50;
                    }
                    break;

                case 50:
                    if (GoToAbsPosition(outputCoordinate.X, outputCoordinate.Y, outputCoordinate.A, point) == conProg.process.Success)
                    {
                        calibrationTable.Rows.Add(outputCoordinate.X, outputCoordinate.Y, outputCoordinate.A);
                        AlignmentCalibration_ChkRet_p = 60;
                    }
                    break;

                case 60:
                    if (alignmentSensor.Functions.AutoCalibration_ChkRet(selectCamera, selectFeature, outputCoordinate, ref status, ref outputCoordinate, false) == conProg.process.Success)
                    {
                        AlignmentCalibration_ChkRet_p = 70;
                    }
                    break;

                case 70:
                    if (alignmentSensor.Functions.AutoCalibration_ChkRet(selectCamera, selectFeature, outputCoordinate, ref status, ref outputCoordinate) == conProg.process.Success)
                    {
                        switch (status)
                        {
                        case CognexAS200CommandStatus.Fail:
                            strError = "AutoCalibration_失敗";
                            AlignmentCalibration_ChkRet_p = 8000;
                            break;

                        case CognexAS200CommandStatus.Success:
                            AlignmentCalibration_ChkRet_p = 9999;
                            break;

                        case CognexAS200CommandStatus.KeepExecution:
                            AlignmentCalibration_ChkRet_p = 40;
                            break;
                        }
                    }
                    break;

                case 8000:     //報警流程選擇
                    nValue = conProg.process.Fail;
                    if (AlarmMessage.Alarm_ButtonSelection == conProg.btnRetry)
                    {
                        AlignmentCalibration_ChkRet_p = 0;
                    }
                    else if (AlarmMessage.Alarm_ButtonSelection == conProg.btnIgnore)
                    {
                        AlignmentCalibration_ChkRet_p = 9999;
                    }
                    break;

                case 9999:     //流程初始化
                    nValue = conProg.process.Success;
                    if (Action == false)
                    {
                        AlignmentCalibration_ChkRet_p = 0;
                    }
                    break;
                }

                if (strError != string.Empty) //顯示報警
                {
                    AlignmentCalibration_ChkRet_p = CheckAlarm == true ? 8000 : 9999;
                    DeviceAlarmMessage(MethodBase.GetCurrentMethod().Name, strError, false, CheckAlarm);
                }
                return(nValue);
            }
        }
Exemple #6
0
        private void PerformSelections(LevelUpController controller, Dictionary <SelectionEntry, HashSet <int> > selectionsHistory, LevelUpActionPriority?maxPriority = null)
        {
            SelectionEntry[] selections = instance.Selections;
            int i = 0;

            while (i < selections.Length)
            {
                SelectionEntry selectionEntry = selections[i];
                if (maxPriority == null)
                {
                    goto IL_66;
                }
                if (selectionEntry.IsParametrizedFeature)
                {
                    if (SelectFeature.CalculatePriority(selectionEntry.ParametrizedFeature) <= maxPriority.Value)
                    {
                        goto IL_66;
                    }
                }
                else if (SelectFeature.CalculatePriority(selectionEntry.Selection) <= maxPriority.Value)
                {
                    goto IL_66;
                }
                IL_253:
                i++;
                continue;
                IL_66:
                HashSet <int> hashSet;
                if (!selectionsHistory.TryGetValue(selectionEntry, out hashSet))
                {
                    hashSet = new HashSet <int>();
                    selectionsHistory[selectionEntry] = hashSet;
                }
                if (selectionEntry.IsParametrizedFeature)
                {
                    FeatureSelectionState featureSelectionState = controller.State.FindSelection(selectionEntry.ParametrizedFeature, false);
                    if (featureSelectionState != null)
                    {
                        FeatureUIData item;
                        switch (selectionEntry.ParametrizedFeature.ParameterType)
                        {
                        case FeatureParameterType.Custom:
                        case FeatureParameterType.SpellSpecialization:
                            item = new FeatureUIData(selectionEntry.ParametrizedFeature, selectionEntry.ParamObject, string.Empty, string.Empty, null, selectionEntry.ParamObject.ToString());
                            break;

                        case FeatureParameterType.WeaponCategory:
                            item = new FeatureUIData(selectionEntry.ParametrizedFeature, selectionEntry.ParamWeaponCategory, string.Empty, string.Empty, null, selectionEntry.ParamWeaponCategory.ToString());
                            break;

                        case FeatureParameterType.SpellSchool:
                            item = new FeatureUIData(selectionEntry.ParametrizedFeature, selectionEntry.ParamSpellSchool, string.Empty, string.Empty, null, selectionEntry.ParamSpellSchool.ToString());
                            break;

                        case FeatureParameterType.LearnSpell:
                            goto IL_1BD;

                        case FeatureParameterType.Skill:
                            item = new FeatureUIData(selectionEntry.ParametrizedFeature, selectionEntry.Stat, string.Empty, string.Empty, null, selectionEntry.Stat.ToString());
                            break;

                        default:
                            goto IL_1BD;
                        }
                        controller.SelectFeature(featureSelectionState, item);
                        goto IL_1CE;
IL_1BD:
                        throw new ArgumentOutOfRangeException();
                    }
IL_1CE:
                    goto IL_253;
                }
                for (int j = 0; j < selectionEntry.Features.Length; j++)
                {
                    if (!hashSet.Contains(j))
                    {
                        BlueprintFeature      blueprintFeature       = selectionEntry.Features[j];
                        FeatureSelectionState featureSelectionState2 = controller.State.FindSelection(selectionEntry.Selection, false);
                        if (featureSelectionState2 != null && blueprintFeature != null && controller.SelectFeature(featureSelectionState2, blueprintFeature))
                        {
                            hashSet.Add(j);
                        }
                    }
                }
                goto IL_253;
            }
        }