public override void PlayInternal(ComponentInstance zComponentInstance, float target, float curve, bool dontPlayComponents) { if (!CheckMIDI(zComponentInstance)) { return; } base.PlayInternal(zComponentInstance, target, curve, dontPlayComponents: true); if (_switchComponentSwitchType == SwitchComponentSwitchType.OnPlay && _defferedSelectedComponent != null) { _selectedComponent = _defferedSelectedComponent; _defferedSelectedComponent = null; } if (_useGlobalSwitch && _globalSwitch != null) { GlobalSwitch globalSwitch = EventManager.Instance._globalParameterManager._globalSwitches.FindItem(_globalSwitch); if (globalSwitch != null) { GlobalSwitchContainer globalSwitchContainer = GetGlobalSwitchContainer(globalSwitch.GetActiveSwitch()); if (globalSwitchContainer != null) { _selectedComponent = globalSwitchContainer._components[0]; } } } if (_selectedComponent != null) { if (_activeMusicTimeSettings != null && IsMusicSyncEnabled() && _syncToMusicOnFirstPlay && !_musicTimeResetOnPlay) { _componentInstance._instance.SetPlayScheduledAdditive(_activeMusicTimeSettings.GetDelay(this), 0.0); } _selectedComponent.PlayInternal(zComponentInstance, 0f, 0.5f); } }
private GlobalSwitchContainer GetGlobalSwitchContainer(GlobalSwitch.Switch globalSwitch) { for (int i = 0; i < _globalSwitchMap.Count; i++) { GlobalSwitchContainer globalSwitchContainer = _globalSwitchMap[i]; if (globalSwitch._name == globalSwitchContainer._switchName) { return(globalSwitchContainer); } } return(null); }
bool GlobalSwitch.IListener.OnSwitch(GlobalSwitch.Switch _switch) { for (int i = 0; i < _componentInstances.Length; i++) { ComponentInstance componentInstance = _componentInstances[i]; if (componentInstance == null) { continue; } GlobalSwitchContainer globalSwitchContainer = GetGlobalSwitchContainer(_switch); if (globalSwitchContainer == null) { continue; } Component component = globalSwitchContainer._components[0]; if (!(component != null) || !(component != _selectedComponent)) { continue; } bool isComponentActive = _isComponentActive; if (_selectedComponent != null) { _selectedComponent.StopInternal(stopInstances: false, forceStop: false, 0f, 0.5f); } _selectedComponent = component; if (_startOnSwitch && isComponentActive && !IsMusicSyncEnabled()) { _componentInstance._instance.ResetPlayScheduled(); _selectedComponent.PlayInternal(_componentInstance, 0f, 0.5f); if (_componentStatus == ComponentStatus.Stopping) { StopInternal(stopInstances: false, forceStop: false, _fadeParameter.GetTimeRemaining(FabricTimer.Get()), _fadeOutCurve); } } if (HasValidEventNotifier()) { NotifyEvent(EventNotificationType.OnSwitch, _selectedComponent); } } return(true); }