public ListeningComponentSolver(TwitchModule module) : base(module) { Component component = module.BombComponent.GetComponent("Listening"); if (component == null) { throw new NotSupportedException("Could not get Listening Component from bombComponent"); } _component = component; Type componentType = component.GetType(); if (componentType == null) { throw new NotSupportedException("Could not get componentType from Listening Component"); } FieldInfo playField = componentType.GetField("PlayButton", BindingFlags.Public | BindingFlags.Instance); FieldInfo dollarField = componentType.GetField("DollarButton", BindingFlags.Public | BindingFlags.Instance); FieldInfo poundField = componentType.GetField("PoundButton", BindingFlags.Public | BindingFlags.Instance); FieldInfo starField = componentType.GetField("StarButton", BindingFlags.Public | BindingFlags.Instance); FieldInfo ampersandField = componentType.GetField("AmpersandButton", BindingFlags.Public | BindingFlags.Instance); if (playField == null || dollarField == null || poundField == null || starField == null || ampersandField == null) { throw new NotSupportedException("Could not find the KMSelectable fields in component Type"); } _buttons = new MonoBehaviour[4]; _play = (MonoBehaviour)playField.GetValue(component); _buttons[0] = (MonoBehaviour)dollarField.GetValue(component); _buttons[1] = (MonoBehaviour)poundField.GetValue(component); _buttons[2] = (MonoBehaviour)starField.GetValue(component); _buttons[3] = (MonoBehaviour)ampersandField.GetValue(component); if (_play == null || _buttons.Any(x => x == null)) { throw new NotSupportedException("Component had null KMSelectables."); } ModInfo = ComponentSolverFactory.GetModuleInfo(GetModuleType(), "Listen to the sound with !{0} press play. Enter the response with !{0} press $ & * * #."); }
public ListeningComponentSolver(BombCommander bombCommander, BombComponent bombComponent, IRCConnection ircConnection, CoroutineCanceller canceller) : base(bombCommander, bombComponent, ircConnection, canceller) { Component component = bombComponent.GetComponent("Listening"); if (component == null) { throw new NotSupportedException("Could not get Listening Component from bombComponent"); } Type componentType = component.GetType(); if (componentType == null) { throw new NotSupportedException("Could not get componentType from Listening Component"); } FieldInfo playField = componentType.GetField("PlayButton", BindingFlags.Public | BindingFlags.Instance); FieldInfo dollarField = componentType.GetField("DollarButton", BindingFlags.Public | BindingFlags.Instance); FieldInfo poundField = componentType.GetField("PoundButton", BindingFlags.Public | BindingFlags.Instance); FieldInfo starField = componentType.GetField("StarButton", BindingFlags.Public | BindingFlags.Instance); FieldInfo ampersandField = componentType.GetField("AmpersandButton", BindingFlags.Public | BindingFlags.Instance); if (playField == null || dollarField == null || poundField == null || starField == null || ampersandField == null) { throw new NotSupportedException("Could not find the KMSelectable fields in component Type"); } _buttons = new MonoBehaviour[4]; _play = (MonoBehaviour)playField.GetValue(component); _buttons[0] = (MonoBehaviour)dollarField.GetValue(component); _buttons[1] = (MonoBehaviour)poundField.GetValue(component); _buttons[2] = (MonoBehaviour)starField.GetValue(component); _buttons[3] = (MonoBehaviour)ampersandField.GetValue(component); if (_play == null || _buttons.Any(x => x == null)) { throw new NotSupportedException("Component had null KMSelectables."); } modInfo = ComponentSolverFactory.GetModuleInfo(GetModuleType()); }