Esempio n. 1
0
 public void Dispose()
 {
     foreach (var r in AbilityRules.ToArray())
     {
         r.Dispose();
     }
     foreach (var sos in StellarObjectSizes.ToArray())
     {
         sos.Dispose();
     }
     foreach (var x in StellarAbilityTemplates.ToArray())
     {
         x.Dispose();
     }
     foreach (var sot in StellarObjectTemplates.ToArray())
     {
         sot.Dispose();
     }
     foreach (var t in Traits.ToArray())
     {
         t.Dispose();
     }
     foreach (var t in Technologies.ToArray())
     {
         t.Dispose();
     }
     foreach (var f in FacilityTemplates.ToArray())
     {
         f.Dispose();
     }
     foreach (var h in Hulls.ToArray())
     {
         h.Dispose();
     }
     foreach (var c in ComponentTemplates.ToArray())
     {
         c.Dispose();
     }
     foreach (var m in Mounts.ToArray())
     {
         m.Dispose();
     }
     foreach (var sst in StarSystemTemplates.ToArray())
     {
         sst.Dispose();
     }
     foreach (var gt in GalaxyTemplates.ToArray())
     {
         gt.Dispose();
     }
     foreach (var h in HappinessModels.ToArray())
     {
         h.Dispose();
     }
     foreach (var c in Cultures.ToArray())
     {
         c.Dispose();
     }
     foreach (var ai in EmpireAIs.ToArray())
     {
         ai.Dispose();
     }
     if (this == Current)
     {
         Current = null;
     }
 }
Esempio n. 2
0
        public void Render()
        {
            // Update hulls internal data structures.
            Hulls.Update();

            // We want to use clamping sampler state throughout the lightmap rendering process.
            // This is required when drawing lights. Since light rendering and alpha clearing is done
            // in a single step, light is rendered with slightly larger quad where tex coords run out of the [0..1] range.
            Device.SamplerStates[0] = SamplerState.LinearClamp;

            // Switch render target to lightmap.
            Device.SetRenderTargets(Textures.LightmapBindings);

            // Clear lightmap color, depth and stencil data.
            Device.Clear(ClearOptions.DepthBuffer | ClearOptions.Stencil | ClearOptions.Target, _ambientColor, 1f, 0);

            // Set per frame shader data.
            ShadowRenderer.PreRender();

            // Generate lightmap. For each light, mask the shadowed areas determined by hulls and render light.
            int lightCount = Lights.Count;

            for (int i = 0; i < lightCount; i++)
            {
                Light light = Lights[i];

                // Continue only if light is enabled and not inside any hull.
                if (!light.Enabled || Hulls.Contains(light))
                {
                    continue;
                }

                // Update light's internal data structures.
                light.Update();

                // Continue only if light is within camera view.
                if (!light.Intersects(Camera))
                {
                    continue;
                }

                // Set scissor rectangle to clip any shadows outside of light's range.
                BoundingRectangle scissor;
                Camera.GetScissorRectangle(light, out scissor);
                Device.SetScissorRectangle(ref scissor);

                // Mask shadowed areas by reducing alpha.
                ShadowRenderer.Render(light);

                // Draw light and clear alpha (reset it to 1 [fully lit] for next light).
                LightRenderer.Render(light);

                // Clear light's dirty flag.
                light.Dirty = false;
            }

            // Switch render target back to default.
            Device.SetRenderTargets(Textures.GetOriginalRenderTargetBindings());

            // Blend original scene and lightmap and present to backbuffer.
            LightMapRenderer.Present();

            // Clear hulls dirty flag.
            Hulls.Dirty = false;
        }