public TileMatchControl(ITileMatcher <TTexureTile, TContext> matcher, Action <IPlotOperation> cacheControl = null) { Matcher = matcher ?? throw new ArgumentNullException(nameof(matcher)); Cachable = true; CacheControl = cacheControl ?? CacheControlNoOp; }
public PlotOperation(ITileMatcher <TRenderTile, TContext> matcher, RenderType renderType, IRenderCallback <TRenderTile, TContext> renderer = null) { this.matcher = matcher; adapter = new RendererAdapter <TRenderTile, TContext>(renderType, renderer); onMatchFound = adapter.MatchFound; }
protected IPlotOperation CreatePlot <TContext, TRenderParameter>(IRenderCallbackFactory <TRenderParameter, TTile> renderer, ITileMatcher <TTile, TContext> matcher, TRenderParameter sortingLayer) { var p = PlotOperations.FromContext(RenderingConfig) .Create(matcher) .WithCache() .ForViewport() .WithRenderer(renderer.CreateRenderer <TContext>(this, sortingLayer)); return(p.Build()); }
public bool TryBuildBlendLayer(out ITileMatcher <TTile, Nothing> result) { var blendSelf = new bool[GameData.Rules.TerrainTypes.Count]; var blendGraphics = new string[GameData.Rules.TerrainTypes.Count]; // Precompute the blending information .. // // This locates the declared blend texture for all terrain types and foreach (var t in GameData.Rules.TerrainTypes) { var graphic = mappingHelper.Find(t); var tilename = graphic.GetBlendGraphicFor(tileSet.BlendLayer); if (tilename == null || !tileRegistry.TryFind(tilename, out var _)) { continue; } var indexOf = GameData.Rules.TerrainTypes.IndexOf(t); blendGraphics[indexOf] = tilename; blendSelf[indexOf] = graphic.DrawInBlendLayer; } var terrain = GameData.Terrain; string MapQuery(int x, int y) => blendGraphics[terrain[x, y].TerrainIdx]; bool IsBlending(int x, int y) => blendSelf[terrain[x, y].TerrainIdx]; if (BlendingTileGeneratorRegistry.TryCreate(out var reg, tileRegistry, tileSet.RenderType, textureOperations, tileProducer, tileSet.TileSize)) { var p = reg.Populate(blendGraphics); result = new BlendNeighboursSelector2 <TTile, Nothing>(p, renderingConfig.MatcherNavigator, MapQuery, IsBlending); return(true); } result = default; return(false); }
public TileMatchControl(ITileMatcher <TTile, Nothing> matcher, Action <IPlotOperation> cacheControl = null) : base(matcher, cacheControl) { }
public void Add(TKey key, ITileMatcher <TTile, TContext> matcher) { matchers.Add(key, matcher); }
public FilteringTileMatcher(Func <int, int, bool> filterCondition, ITileMatcher <TRenderTile, TContext> matcher) { this.filterCondition = filterCondition ?? throw new ArgumentNullException(nameof(filterCondition)); this.matcher = matcher ?? throw new ArgumentNullException(nameof(matcher)); }
public TransformingTileMatcher(ITileMatcher <TRenderTile, TContextSource> parent, Func <int, int, TRenderTile, TContextSource, TContextTarget> converter) : base(parent) { this.converter = converter; }
protected TransformingTileMatcherBase(ITileMatcher <TRenderTile, TContextSource> parent) { this.parent = parent ?? throw new ArgumentNullException(nameof(parent)); }
public void Add(ITileMatcher <TRenderTile, TContext> m) { matchers.Add(m); }