コード例 #1
0
        protected ComponentSolverShim(BombCommander bombCommander, BombComponent bombComponent) : base(bombCommander, bombComponent)
        {
            string modType = GetModuleType();

            if (!SolverShims.TryGetValue(modType, out ShimData))
            {
                ShimData = new ShimData();
                ShimData.ProcessMethod = ComponentSolverFactory.FindProcessCommandMethod(bombComponent, out ShimData.ModCommandType, out ShimData.ComponentType);
                if (ShimData.ComponentType == null)
                {
                    throw new NotSupportedException(string.Format("Currently {0} is not supported by 'Twitch Plays'.", bombComponent.GetModuleDisplayName()));
                }
                ShimData.ForcedSolveMethod = ComponentSolverFactory.FindSolveMethod(ShimData.ComponentType);
                ShimData.TryCancelField    = ComponentSolverFactory.FindCancelBool(ShimData.ComponentType);
                ShimData.ZenModeField      = ComponentSolverFactory.FindZenModeBool(ShimData.ComponentType);
                ShimData.HelpMessageFound  = ComponentSolverFactory.FindHelpMessage(bombComponent, ShimData.ComponentType, out ShimData.HelpMessage);
                ComponentSolverFactory.FindManualCode(bombComponent, ShimData.ComponentType, out ShimData.ManualCode);
                SolverShims[modType] = ShimData;
            }

            ProcessMethod     = ShimData.ProcessMethod;
            CommandComponent  = bombComponent.GetComponent(ShimData.ComponentType);
            ForcedSolveMethod = ShimData.ForcedSolveMethod;
            TryCancelField    = ShimData.TryCancelField;
            ZenModeField      = ShimData.ZenModeField;
            ZenMode           = OtherModes.ZenModeOn;
            modInfo           = !ShimData.HelpMessageFound
                                ? ComponentSolverFactory.GetModuleInfo(modType)
                                : ComponentSolverFactory.GetModuleInfo(modType, ShimData.HelpMessage, ShimData.ManualCode);
        }