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 void PlayRandomomponent(ComponentInstance zComponentInstance) { if (_playMode == RandomComponentPlayMode.Random) { int index = _shuffleBag.get(); _selectedComponent = _components[index]; } else { int num = -1; if (!_shareRandomNoRepeatHistory) { num = GetNextRandomNoRepeatIndex(); } else { RandomComponent randomComponent = base.ComponentHolder as RandomComponent; if ((bool)randomComponent) { num = randomComponent.GetNextRandomNoRepeatIndex(); } } if (num < 0) { return; } _selectedComponent = _components[num]; } if (_selectedComponent != null) { _selectedComponent.PlayInternal(zComponentInstance, 0f, 0.5f); } }
private void DoSwitch(double time) { if (_defferedSelectedComponent != null) { if (_selectedComponent != null) { _selectedComponent.StopInternal(stopInstances: false, forceStop: false, 0f, 0.5f, time); } _componentInstance._instance.SetPlayScheduled(time, 0.0); _defferedSelectedComponent.PlayInternal(_componentInstance, 0f, 0.5f); _selectedComponent = _defferedSelectedComponent; _defferedSelectedComponent = null; } }
public void OnMidiHandler(Fabric.Component component, MidiEvent midiEvent, double offset) { if (component != null) { if (midiEvent.midiChannelEvent == MidiHelper.MidiChannelEvent.Note_On) { _componentInstance._instance.SetPlayScheduled(offset, 0.0); _componentInstance._instance.SetMIDIEvent(midiEvent); component.PlayInternal(_componentInstance, 0f, 0.5f); } else if (midiEvent.midiChannelEvent == MidiHelper.MidiChannelEvent.Note_Off && !_ignoreNoteOff) { component.StopInternal(stopInstances: false, forceStop: false, 0f, 0.5f, offset); } } }
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; } Fabric.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); }
private void SetSwitch(string name, bool ignoreActiveFlag = false) { int num = 0; Fabric.Component component; while (true) { if (num < _components.Count) { component = _components[num]; if (component != null && component.Name == name && component != _selectedComponent) { break; } num++; continue; } return; } bool flag = ignoreActiveFlag || _isComponentActive; if (_selectedComponent != null) { _selectedComponent.StopInternal(stopInstances: false, forceStop: false, 0f, 0.5f); } _selectedComponent = component; if (_startOnSwitch && flag && !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); } }
private bool PlayNextEntry(double offset = 0.0, double scheduledStop = 0.0) { if (_playlist != null && _playlist.Length > 0) { int num = _playlist.Length - 1; if (_playingComponentIndex > num) { if (_sequencePlayMode != SequenceComponentPlayMode.Loop) { return(false); } _playingComponentIndex = 0; if (HasValidEventNotifier()) { NotifyEvent(EventNotificationType.OnSequenceEnd, this); } } if (_currentlyPlayingComponent != null && _sequenceType == SequenceComponentType.PlayOnAdvance) { _currentlyPlayingComponent.StopInternal(stopInstances: false, forceStop: false, 0f, 0.5f, scheduledStop); } _prevPlayingComponentIndex = _playingComponentIndex; _currentlyPlayingComponent = _playlist[_playingComponentIndex++]; if (HasValidEventNotifier()) { NotifyEvent(EventNotificationType.OnSequenceNextEntry, _currentlyPlayingComponent); } } if (_currentlyPlayingComponent != null && _componentInstance != null) { _currentlyPlayingComponent.PlayInternal(_componentInstance, 0f, 0.5f); if (_componentStatus == ComponentStatus.Stopping && _onlyStopOnce && _sequenceType != SequenceComponentType.PlayOnAdvance) { StopInternal(stopInstances: false, forceStop: false, _fadeParameter.GetTimeRemaining(FabricTimer.Get()), _fadeOutCurve); _onlyStopOnce = false; } } return(true); }