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); } }
public void UnloadAsset(string componentName, bool ignoreUnloadUnusedAssets = false) { if (_globalComponentTable.ContainsKey(componentName)) { Fabric.Component component = _globalComponentTable[componentName]; if (component != null) { _components.Remove(component); if (component.ParentComponent != null) { component.ParentComponent.RemoveComponent(component); } RemoveChildComponentsFromGlobalTable(component, componentName); component.Destroy(); UnityEngine.Object.Destroy(component.gameObject); if (!ignoreUnloadUnusedAssets) { Resources.UnloadUnusedAssets(); } DebugLog.Print("Assets [" + componentName + "] unloaded succesfuly"); } else { DebugLog.Print("Assets [" + componentName + "] failed to unload", DebugLevel.Error); } } else { DebugLog.Print("Target Component [" + componentName + "] not found", DebugLevel.Error); } }
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); } }
public void FadeOutComponent(string destinationComponent, float targetMS, float curve) { if (_globalComponentTable.ContainsKey(destinationComponent)) { Fabric.Component component = _globalComponentTable[destinationComponent]; component.FadeOut(targetMS, curve); } }
void FadeOutMusic(string n) { Fabric.Component component = Fabric.FabricManager.Instance.GetComponentByName(n); if (component != null) { component.FadeOut(0.1f, 0.5f); } }
public void Pause(bool pause) { DebugLog.Print("Pause all components"); for (int i = 0; i < _components.Count; i++) { Fabric.Component component = _components[i]; component.Pause(pause); } }
public void Stop(float fadeOut = 0f) { DebugLog.Print("Stop all components"); for (int i = 0; i < _components.Count; i++) { Fabric.Component component = _components[i]; component.Stop(stopInstances: true, forceStop: true, ignoreFade: true, 0f); } }
public bool IsComponentPresent(Fabric.Component component) { for (int i = 0; i < _eventList.Count; i++) { if (_eventList[i]._component == component) { return(true); } } return(false); }
private void OnDestroy() { if (FabricManager._componentPreviewerUpdateIsActive) { Fabric.Component component = base.gameObject.GetComponent <Fabric.Component>(); if (component != null) { component.UnregisterEventListeners(); } } }
public void CleanBakedComponentInstances() { int childCount = base.transform.childCount; for (int i = 0; i < childCount; i++) { Fabric.Component component = base.transform.GetChild(i).GetComponent <Fabric.Component>(); if (component != null) { component.CleanBakedComponentInstances(); } } }
public void Set(Fabric.Component component, float fadeInTime) { if (!(_audioSource == null)) { _fadeParameter.SetTarget(FabricTimer.Get(), 1f, fadeInTime, 0.5f); _audioSource.volume = 0f; _component = component; if (_vrAudio != null) { _vrAudio.Set(component); } _state = AudioVoiceState.Playing; } }
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 Fabric.Component[] GetComponents() { List <Fabric.Component> list = new List <Fabric.Component>(); int childCount = base.transform.childCount; for (int i = 0; i < childCount; i++) { Fabric.Component component = base.transform.GetChild(i).GetComponent <Fabric.Component>(); if ((bool)component) { list.Add(component); } } return(list.ToArray()); }
private void InitialiseComponents() { int childCount = base.transform.childCount; _components.Clear(); for (int i = 0; i < childCount; i++) { Fabric.Component component = base.transform.GetChild(i).GetComponent <Fabric.Component>(); if (component != null) { component.Initialise(null, isComponentInstance: false); _components.Add(component); } } }
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); } } }
public bool IsComponentPresent(Fabric.Component component) { if (_cachedComponent != null && component == _cachedComponent) { return(true); } for (int i = 0; i < _eventList.Count; i++) { if (_eventList[i].IsComponentPresent(component)) { _cachedComponent = component; return(true); } } return(false); }
public AudioSource Alloc(Fabric.Component component) { if (_audioVoicePool == null || _audioVoicePool.Count == 0) { return(null); } AudioVoice audioVoice = _audioVoicePool.Dequeue(); if (audioVoice == null) { return(null); } _allocatedList.Add(audioVoice); Generic.SetGameObjectActive(audioVoice.gameObject, active: true); audioVoice.Set(component, _fadeInTime); return(audioVoice._audioSource); }
public double GetDelay(Fabric.Component instance, int numBeats = 0) { double num = 0.0; if (_syncTarget != null) { float num2 = (float)_syncTarget.GetCurrentTime(); num = GetDelay(num2); float num3 = num2 + (float)num; instance.SetPlayScheduledTime(num3); } else { num = GetDelay(numBeats); } return(num); }
bool IRTPPropertyListener.UpdateProperty(RTPProperty property, float value, RTPPropertyType type) { if (UpdateProperty(property, value, type)) { return(true); } if (property._property == 8 && property._name == "Switch" && _components.Count > 0) { int index = (int)(value * (float)_components.Count); Fabric.Component component = _components[index]; if (component != _selectedComponent) { SetSwitch(component.Name, (_componentInstance != null) ? true : false); } return(true); } return(false); }
private void StopAudioVoice() { if (!(_audioSource == null)) { if (_callStop) { _audioSource.Stop(); } _component = null; _audioSource.clip = null; if (_vrAudio != null) { _vrAudio.Unset(); } _audioSource.rolloffMode = AudioRolloffMode.Logarithmic; _state = AudioVoiceState.Stopped; } }
private void DrawComponent(Fabric.Component component, ref float x, float y) { if (component.ToString().Contains("GroupComponent")) { GroupComponent groupComponent = (GroupComponent)component; if (!_soloComponents.Contains(groupComponent)) { _soloComponents.Add(groupComponent); } component.ToString().LastIndexOf("."); string name = component.name; int num = name.Length * 10; float num2 = slotHeight; if (num < 120) { num = 120; } VolumeMeter component2 = groupComponent.GetComponent <VolumeMeter>(); if ((bool)component2) { num2 += 120f; } SideChain component3 = groupComponent.GetComponent <SideChain>(); if ((bool)component3) { num2 += 120f; } GUILayout.BeginArea(new Rect(x, y, num, GetActualSize(num2)), name, GUI.skin.window); MixerSlot(name, groupComponent); if ((bool)component2) { DrawVolumeMeters(component2, GetActualSize(num - 10)); } if ((bool)component3) { DrawSideChain(component3, GetActualSize(num - 30)); } GUILayout.EndArea(); x += num + 20; } }
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); }
public void LoadAsset(string prefabName, string destinationComponent) { if (_globalComponentTable.ContainsKey(destinationComponent)) { Fabric.Component component = _globalComponentTable[destinationComponent]; UnityEngine.Object @object = Resources.Load(prefabName); if (@object != null) { GameObject gameObject = UnityEngine.Object.Instantiate(@object) as GameObject; gameObject.name = gameObject.name.Replace("(Clone)", ""); string key = destinationComponent + "_" + gameObject.name; if (_globalComponentTable.ContainsKey(key)) { UnityEngine.Object.Destroy(gameObject); return; } gameObject.transform.parent = component.transform; Fabric.Component component2 = gameObject.GetComponent <Fabric.Component>(); if (component2 != null) { component2.Initialise(component, isComponentInstance: false); component.AddComponent(component2); AddChildComponentsToGlobalTable(component2, destinationComponent); } VolumeMeter component3 = component.GetComponent <VolumeMeter>(); if (component3 != null) { component3.CollectAudioComponents(); } DebugLog.Print("Asset [" + prefabName + "] loaded succesfuly"); } else { DebugLog.Print("Asset [" + prefabName + "] name not found", DebugLevel.Error); } } else { DebugLog.Print("Target Component [" + destinationComponent + "] not found", DebugLevel.Error); } }
private void SetDefferedSwitch(string name) { int num = 0; Fabric.Component component; while (true) { if (num < _components.Count) { component = _components[num]; if (component.name == name) { break; } num++; continue; } return; } _defferedSelectedComponent = component; }
private void AddChildComponentsToGlobalTable(Fabric.Component component, string path) { if (!(component == null)) { string text = path + "_" + component.name; if (!_globalComponentTable.ContainsKey(text)) { _globalComponentTable.Add(text, component); } AudioComponent audioComponent = component as AudioComponent; if (audioComponent != null && !_audioComponents.ContainsKey(text)) { _audioComponents.Add(text, audioComponent); } Fabric.Component[] childComponents = component.GetChildComponents(); for (int i = 0; i < childComponents.Length; i++) { AddChildComponentsToGlobalTable(childComponents[i], text); } } }
private void RemoveChildComponentsFromGlobalTable(Fabric.Component component, string path) { if (!(component == null)) { if (_globalComponentTable.ContainsKey(path)) { _globalComponentTable.Remove(path); } AudioComponent x = component as AudioComponent; if (x != null && _audioComponents.ContainsKey(path)) { _audioComponents.Remove(path); } Fabric.Component[] childComponents = component.GetChildComponents(); for (int i = 0; i < childComponents.Length; i++) { string path2 = path + "_" + childComponents[i].name; RemoveChildComponentsFromGlobalTable(childComponents[i], path2); } } }
public Fabric.Component[] GetComponentsByName(string destinationComponent, GameObject parentGameObject) { if (_globalComponentTable.ContainsKey(destinationComponent)) { Fabric.Component component = _globalComponentTable[destinationComponent]; if (component != null) { List <ComponentInstance> list = component.FindInstances(parentGameObject, createIfNoneFound: false); if (list != null && list.Count > 0) { Fabric.Component[] array = new Fabric.Component[list.Count]; for (int i = 0; i < list.Count; i++) { array[i] = list[i]._instance; } return(array); } } } return(null); }
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); } }
public void LoadAsset(GameObject component, string destinationComponent) { if (_globalComponentTable.ContainsKey(destinationComponent)) { Fabric.Component component2 = _globalComponentTable[destinationComponent]; if (component != null) { component.name = component.name.Replace("(Clone)", ""); string key = destinationComponent + "_" + component.name; if (_globalComponentTable.ContainsKey(key)) { UnityEngine.Object.DestroyImmediate(component); return; } component.transform.parent = component2.transform; Fabric.Component component3 = component.GetComponent <Fabric.Component>(); if (component3 != null) { component3.Initialise(component2, isComponentInstance: false); component2.AddComponent(component3); AddChildComponentsToGlobalTable(component3, destinationComponent); VolumeMeter component4 = component2.GetComponent <VolumeMeter>(); if (component4 != null) { component4.CollectAudioComponents(); } } DebugLog.Print("Asset [" + component.name + "] loaded succesfuly"); } else { DebugLog.Print("Asset [" + component.name + "] name not found", DebugLevel.Error); } } else { DebugLog.Print("Target Component [" + destinationComponent + "] not found", DebugLevel.Error); } }
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); }