Example #1
0
        internal bool RemoveRenderObject(List<RenderObject> renderObjects, RenderObject renderObject)
        {
            if (renderObject.RenderFeature == null)
                renderObjectsWithoutFeatures.Remove(renderObject);

            RenderSystem.RemoveRenderObject(renderObject);

            // Get and clear ordered node index
            var orderedRenderNodeIndex = renderObject.VisibilityObjectNode.Index;
            if (renderObject.VisibilityObjectNode == StaticObjectNodeReference.Invalid)
                return false;

            renderObject.VisibilityObjectNode = StaticObjectNodeReference.Invalid;

            // SwapRemove each items in dataArrays
            RenderData.SwapRemoveItem(DataType.StaticObject, orderedRenderNodeIndex, renderObjects.Count - 1);

            // Remove entry from ordered node index
            renderObjects.SwapRemoveAt(orderedRenderNodeIndex);

            // If last item was moved, update its index
            if (orderedRenderNodeIndex < renderObjects.Count)
            {
                renderObjects[orderedRenderNodeIndex].VisibilityObjectNode = new StaticObjectNodeReference(orderedRenderNodeIndex);
            }

            return true;
        }
Example #2
0
        private static bool AllowedStealing(InAudioNode audioNode, List<InstanceInfo> currentInstances)
        {
            var data = (InAudioNodeData) audioNode._nodeData;
            if (data.LimitInstances && currentInstances.Count >= data.MaxInstances)
            {
                InPlayer player = null;
                var stealType = data.InstanceStealingTypes;
                if (stealType == InstanceStealingTypes.NoStealing)
                    return false;

                int index = 0;
                InstanceInfo foundInfo;
                if (stealType == InstanceStealingTypes.Newest)
                {
                    double newestTime = 0;

                    for (int i = 0; i < currentInstances.Count; i++)
                    {
                        InstanceInfo instanceInfo = currentInstances[i];
                        if (instanceInfo.Timestamp > newestTime)
                        {
                            newestTime = instanceInfo.Timestamp;
                            index = i;
                        }
                    }
                }
                else if (stealType == InstanceStealingTypes.Oldest)
                {
                    double oldestTime = Double.MaxValue;
                    for (int i = 0; i < currentInstances.Count; i++)
                    {
                        InstanceInfo instanceInfo = currentInstances[i];
                        if (instanceInfo.Timestamp < oldestTime)
                        {
                            oldestTime = instanceInfo.Timestamp;
                            index = i;
                        }
                    }
                }

                foundInfo = currentInstances[index];
                player = foundInfo.Player;
                currentInstances.SwapRemoveAt(ref index);
                if (player != null)
                    player.Stop();
            }
            return true;
        }