private void SetupSwitchMapping() { // hook-up game switches if (GameEngine is IGamelogicEngineWithSwitches) { var config = Table.Mappings; _keyAssignments.Clear(); foreach (var switchData in config.Data.Switches) { switch (switchData.Source) { case SwitchSource.Playfield when !string.IsNullOrEmpty(switchData.PlayfieldItem) && _switches.ContainsKey(switchData.PlayfieldItem): { var element = _switches[switchData.PlayfieldItem]; element.AddSwitchId(switchData.Id, switchData.PulseDelay); break; } case SwitchSource.InputSystem: if (!_keyAssignments.ContainsKey(switchData.InputAction)) { _keyAssignments[switchData.InputAction] = new List <string>(); } _keyAssignments[switchData.InputAction].Add(switchData.Id); break; case SwitchSource.Playfield: Logger.Warn($"Cannot find switch \"{switchData.PlayfieldItem}\" on playfield!"); break; case SwitchSource.Constant: break; default: Logger.Warn($"Unknown switch source \"{switchData.Source}\"."); break; } } if (_keyAssignments.Count > 0) { _inputManager.Enable(HandleKeyInput); } } GameEngine.OnInit(_tableApi, BallManager); }
private void Start() { // bootstrap table script(s) var tableScripts = GetComponents <VisualPinballScript>(); foreach (var tableScript in tableScripts) { tableScript.OnAwake(TableApi, BallManager); } // trigger init events now foreach (var i in _initializables) { i.OnInit(BallManager); } // hook up mapping configuration SetupSwitchMapping(); SetupCoilMapping(); SetupWireMapping(); GameEngine?.OnInit(TableApi, BallManager); }