Beispiel #1
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)
        {
            RendererId = request.Pipeline
        };

        AttachChild(result);
        return(result);
    }
Beispiel #2
0
    public ExtrudedTilemap(EtmManager manager, IAssetId id, string name, int tileCount, DungeonTileMapProperties properties, IPalette dayPalette, IPalette nightPalette)
    {
        if (dayPalette == null)
        {
            throw new ArgumentNullException(nameof(dayPalette));
        }
        _manager = manager ?? throw new ArgumentNullException(nameof(manager));

        _tiles = new MultiBuffer <DungeonTile>(tileCount, BufferUsage.VertexBuffer)
        {
            Name = $"B_Inst{name}"
        };
        _properties = new SingleBuffer <DungeonTileMapProperties>(properties, BufferUsage.UniformBuffer)
        {
            Name = $"B_TileProps:{name}"
        };
        AttachChild(_tiles);
        AttachChild(_properties);

        Name       = name;
        _dayFloors = new CompositedTexture(id, "FloorTiles:" + name, dayPalette);
        _dayWalls  = new CompositedTexture(id, "WallTiles:" + name, dayPalette);
        if (nightPalette != null)
        {
            _nightFloors = new CompositedTexture(id, "FloorTiles:" + name, nightPalette);
            _nightWalls  = new CompositedTexture(id, "WallTiles:" + name, nightPalette);
        }

        OpaqueWindow = new EtmWindow($"{Name}_Opaque", this, tileCount, false);
        AlphaWindow  = new EtmWindow($"{Name}_Alpha", this, tileCount, true);
        AttachChild(OpaqueWindow);
        AttachChild(AlphaWindow);
    }