Beispiel #1
0
        public TransformBlock <LoadedScene, BuiltSceneMetadata> CreateTransform(ExecutionDataflowBlockOptions options, ProgressStep progressStep) =>
        new TransformBlock <LoadedScene, BuiltSceneMetadata>(loadedScene =>
        {
            var scene     = loadedScene.Scene.Scene;
            var mapTiler  = loadedScene.Scene.MapTiler;
            var mapBounds = mapTiler.TileUnitBoundsFor(mapTiler.Tiles.First());

            var metadata = new SceneMetadata()
            {
                ID   = scene.dataset.sceneId,
                Name = scene.dataset.nameUID == 0xFFFFFFFF
                        ? "<none>"
                        : mappedDb.GetText(new UID(scene.dataset.nameUID)).Text,
                MinZoom           = mapTiler.MinZoomLevel,
                MaxZoom           = mapTiler.MaxZoomLevel,
                BasePixelsPerUnit = mapTiler.BasePixelsPerUnit,
                TilePixelSize     = mapTiler.TilePixelSize,
                MinBounds         = mapBounds.Min,
                MaxBounds         = mapBounds.Max,
                Origin            = scene.sceneOrigin,
                BackgroundColor   = background.AsColor(scene),
                Triggers          = scene.triggers,
                NPCs = CreateNPCMetadata(scene)
            };

            var metadataJson = JsonSerializer.Serialize(metadata, new JsonSerializerOptions()
            {
                IncludeFields = true
            });
            progressStep.Increment();
            return(new BuiltSceneMetadata(loadedScene.SceneName, metadataJson));
        });
Beispiel #2
0
 public IPropagatorBlock <LoadedScene, RenderedSceneTile <Rgba32> > CreateTransform(ExecutionDataflowBlockOptions options, ProgressStep progressStep) =>
 new TransformBlock <LoadedScene, RenderedSceneTile <Rgba32> >(loadedScene =>
 {
     var zzcolor = background.AsColor(loadedScene.Scene.Scene);
     var image   = new Image <Rgba32>(imageSize, imageSize, new Rgba32(zzcolor.r, zzcolor.g, zzcolor.b, zzcolor.a));
     progressStep.Increment();
     return(new RenderedSceneTile <Rgba32>(
                loadedScene.SceneName,
                layer: -1, new TileID(0, 0, 0),
                image));
 });