示例#1
0
        /// <summary>
        /// Updates a single property texture, possibly asynchronously.
        /// </summary>
        /// <param name="property">The property to update.</param>
        /// <param name="buffers">The texture buffers for locally generated textures.</param>
        /// <param name="min">The minimum cell coordinates to update.</param>
        /// <param name="max">The maximum cell coordinates to update.</param>
        private void UpdateProperty(SimProperty property, TextureBuffer[] buffers,
                                    Vector2I min, Vector2I max)
        {
            int cells = Grid.CellCount, p = (int)property;

            switch (property)
            {
            case SimProperty.Flow:
                UpdateSimProperty(p, PropertyTextures.externalFlowTex, 8 * cells);
                break;

            case SimProperty.Liquid:
                UpdateSimProperty(p, PropertyTextures.externalLiquidTex, 4 * cells);
                break;

            case SimProperty.ExposedToSunlight:
                UpdateSimProperty(p, PropertyTextures.externalExposedToSunlight, cells);
                break;

            default:
                if (p < buffers.Length)
                {
                    StartTextureUpdate(property, buffers[p], min, max);
                }
                break;
            }
        }
示例#2
0
        /// <summary>
        /// Starts a multithreaded texture update. Uses the asynchronous job manager.
        /// </summary>
        /// <param name="property">The property to update.</param>
        /// <param name="buffer">The texture where the updates will be stored.</param>
        /// <param name="min">The minimum cell coordinates to update.</param>
        /// <param name="max">The maximum cell coordinates to update.</param>
        private void StartTextureUpdate(SimProperty property, TextureBuffer buffer,
                                        Vector2I min, Vector2I max)
        {
            UpdateTexture updater;

            switch (property)
            {
            case SimProperty.StateChange:
                updater = PropertyTextures.UpdateStateChange;
                break;

            case SimProperty.GasPressure:
                updater = PropertyTextures.UpdatePressure;
                break;

            case SimProperty.GasColour:
                updater = PropertyTextures.UpdateGasColour;
                break;

            case SimProperty.GasDanger:
                updater = PropertyTextures.UpdateDanger;
                break;

            case SimProperty.FogOfWar:
                updater = PropertyTextures.UpdateFogOfWar;
                break;

            case SimProperty.SolidDigAmount:
                updater = PropertyTextures.UpdateSolidDigAmount;
                break;

            case SimProperty.SolidLiquidGasMass:
                updater = PropertyTextures.UpdateSolidLiquidGasMass;
                break;

            case SimProperty.WorldLight:
                updater = PropertyTextures.UpdateWorldLight;
                break;

            case SimProperty.Temperature:
                updater = PropertyTextures.UpdateTemperature;
                break;

            case SimProperty.FallingSolid:
                updater = PropertyTextures.UpdateFallingSolidChange;
                break;

            case SimProperty.Radiation:
                updater = PropertyTextures.UpdateRadiation;
                break;

            default:
                throw new ArgumentException("No updater for property: " + property);
            }
            if (updater == null)
            {
                throw new InvalidOperationException("Missing texture updater: " + property);
            }
            else
            {
                running.Add(new TextureWorkItemCollection(this, buffer, min, max, updater));
            }
        }