Esempio n. 1
0
        public PureDataContainerItemInternal GetRandomItem(PureDataContainer container, List <int> childrenIds, object source)
        {
            PureDataContainerItemInternal randomAudioItem = new PureDataContainerItemInternal(container.Name, pureData);
            List <PureDataSubContainer>   childcontainers = new List <PureDataSubContainer>();
            List <float> weights = new List <float>();

            for (int i = 0; i < childrenIds.Count; i++)
            {
                PureDataSubContainer childContainer = container.GetSubContainerWithID(childrenIds[i]);
                if (childContainer != null)
                {
                    childcontainers.Add(childContainer);
                    weights.Add(childContainer.weight);
                }
            }

            PureDataSubContainer randomChildContainer = HelperFunctions.WeightedRandom(childcontainers, weights);

            if (randomAudioItem != null)
            {
                PureDataSourceOrContainerItem childAudioItem = GetSubContainerItem(container, randomChildContainer, source);
                if (childAudioItem != null)
                {
                    randomAudioItem.AddItem(childAudioItem);
                }
            }

            return(randomAudioItem);
        }
Esempio n. 2
0
        public PureDataContainerItemInternal GetSwitchItem(PureDataContainer container, List <int> childrenIds, object source)
        {
            PureDataContainerItemInternal switchAudioItem = new PureDataContainerItemInternal(container.Name, pureData);
            int stateIndex = int.MinValue;

            PureDataSubContainer[] childrenSubContainers = container.IdsToSubContainers(childrenIds);

            if (childrenSubContainers[0].parentId == 0)
            {
                stateIndex = container.switchSettings.GetCurrentStateIndex();
            }
            else
            {
                PureDataSubContainer parentSubContainer = container.GetSubContainerWithID(childrenSubContainers[0].parentId);
                stateIndex = parentSubContainer.switchSettings.GetCurrentStateIndex();
            }

            if (stateIndex != int.MinValue)
            {
                foreach (PureDataSubContainer childSubContainer in childrenSubContainers)
                {
                    if (childSubContainer.switchSettings.stateIndex == stateIndex)
                    {
                        PureDataSourceOrContainerItem childAudioItem = GetSubContainerItem(container, childSubContainer, source);

                        if (childAudioItem != null)
                        {
                            switchAudioItem.AddItem(childAudioItem);
                        }
                    }
                }
            }

            return(switchAudioItem);
        }
Esempio n. 3
0
        public PureDataSourceOrContainerItem GetSubContainerItem(PureDataContainer container, PureDataSubContainer subContainer, object source)
        {
            PureDataSourceOrContainerItem item = null;

            if (subContainer.IsSource)
            {
                item = GetSourceItem(subContainer, source);
            }
            else
            {
                item = GetContainerItem(container, subContainer, source);
            }
            return(item);
        }
Esempio n. 4
0
        public PureDataContainerItemInternal GetMixItem(PureDataContainer container, List <int> childrenIds, object source)
        {
            PureDataContainerItemInternal mixAudioItem = new PureDataContainerItemInternal(container.Name, pureData);

            foreach (int childrenId in childrenIds)
            {
                PureDataSourceOrContainerItem childItem = GetSubContainerItem(container, container.GetSubContainerWithID(childrenId), source);
                if (childItem != null)
                {
                    mixAudioItem.AddItem(childItem);
                }
            }

            return(mixAudioItem);
        }
        protected override void ExecuteOnItems(Action <PureDataSourceOrContainerItem> action)
        {
            for (int i = items.Count - 1; i >= 0; i--)
            {
                PureDataSourceOrContainerItem item = items[i];

                if (item.State == PureDataStates.Stopped)
                {
                    RemoveItem(item);
                }
                else
                {
                    action(item);
                }
            }
        }
 public void RemoveItem(PureDataSourceOrContainerItem item)
 {
     items.Remove(item);
 }
 public void AddItem(PureDataSourceOrContainerItem item)
 {
     items.Add(item);
 }