Пример #1
0
 public void DisposeTilemap(ExtrudedTilemap tilemap)
 {
     if (tilemap == null)
     {
         throw new ArgumentNullException(nameof(tilemap));
     }
     RemoveChild(tilemap);
 }
Пример #2
0
        public EtmWindow(string name, ExtrudedTilemap tilemap, int maxCount, bool transparent)
        {
            Name            = name;
            RenderOrder     = transparent ? DrawLayer.TranslucentTerrain : DrawLayer.OpaqueTerrain;
            Tilemap         = tilemap ?? throw new ArgumentNullException(nameof(tilemap));
            ActiveInstances = new MultiBuffer <ushort>(maxCount, BufferUsage.VertexBuffer, $"B:EtmActive_{name}");
            ActiveCount     = maxCount;
            AttachChild(ActiveInstances);
            On <RenderEvent>(e =>
            {
                if (_version >= Tilemap.Version)
                {
                    return; // Up to date
                }
                _version = Tilemap.Version;

                if (Tilemap.TileCount != ActiveInstances.Count)
                {
                    ActiveInstances.Resize(Tilemap.TileCount);
                }

                int j      = 0;
                var active = ActiveInstances.Borrow();
                for (int i = 0; i < Tilemap.TileCount; i++)
                {
                    bool isTransparent = (Tilemap.Tiles[i].Flags & DungeonTileFlags.Transparent) != 0;
                    if (isTransparent == transparent)
                    {
                        active[j++] = (ushort)i;
                    }
                }

                ActiveCount = j;

                // var frustum = new BoundingFrustum(e.Camera.ProjectionMatrix * e.Camera.ViewMatrix);
                // TODO: Frustum culling? occlusion culling? worth bothering?
                // TODO: Sort
            });
        }
Пример #3
0
        public IExtrudedTilemap CreateTilemap(TilemapRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }
            if (request.Id == null)
            {
                throw new ArgumentException("The tilemap request did not have an id set", nameof(request));
            }

            var properties = new DungeonTileMapProperties(
                request.Scale, request.Rotation, request.Origin,
                request.HorizontalSpacing, request.VerticalSpacing,
                request.Width,
                request.AmbientLightLevel, request.FogColor,
                request.ObjectYScaling);

            var result = new ExtrudedTilemap(this, request.Id, request.Id.ToString(), request.TileCount, properties, request.DayPalette, request.NightPalette);

            AttachChild(result);
            return(result);
        }