public ICellMatcher CreateMatcher(int layerIndex, RenderLayerDefinition rd) { // In cell matching with multiple targets, the matcher must include a self-match. var matchSpecs = new List <string>(); if (rd.MatchAs != null) { matchSpecs.Add(rd.MatchAs); } matchSpecs.AddRange(rd.MatchWith); // tagname -> List of matching ITerrains var otherGraphicTags = ComputeMatchingTerrains(layerIndex, matchSpecs); var factory = TileTagEntrySelectionFactory.FromTagsAsSingleCharKey(otherGraphicTags.Keys.ToArray()); var rules = Context.GameData.Rules; var terrainsByKey = new ITileTagEntrySelection[rules.TerrainTypes.Count]; foreach (var pair in otherGraphicTags) { var key = factory.Lookup(pair.Key); foreach (var terrain in pair.Value) { var b = rules.TerrainTypes.IndexOf(terrain); terrainsByKey[b] = key; } } var map = Context.GameData.Terrain; return(new LookupMatcher(map, factory, terrainsByKey)); }
public GridMatcher CreateMatcher(int layerIndex, RenderLayerDefinition rd) { var otherGraphicTags = ComputeMatchingTerrains(layerIndex, rd.MatchWith); var terrainTypes = Context.GameData.Rules.TerrainTypes; var terrainsByKey = new bool[terrainTypes.Count]; foreach (var pair in otherGraphicTags) { foreach (var terrain in pair.Value) { var b = terrainTypes.IndexOf(terrain); terrainsByKey[b] = true; } } var map = Context.GameData.Terrain; bool MatchOthers(int x, int y) { return(terrainsByKey[map[x, y].TerrainIdx]); } return(MatchOthers); }
public ITileMatcher <TTile, Nothing> GenerateCellGroupLayer(int layerIndex, RenderLayerDefinition rd) { if (rd.MatchWith.Count == 0) { throw new Exception(); } return(new CellMapTileSelector <TTile, Nothing>(cellRendering.CreateMatcher(layerIndex, rd), RenderingConfig.MatcherNavigator, new CellMapTileRegistry <TTile>(Tiles), rd.Tag)); }
ITileMatcher <TTile, Nothing> GenerateCardinalLayer(int layerIndex, byte terrainIndex, RenderLayerDefinition rd) { if (rd.MatchWith.Count == 0) { throw new Exception(); } return(new CardinalTileSelector <TTile, Nothing> (boolRendering.CreateMatcher(layerIndex, rd), CreateSelfMatcher(terrainIndex), RenderingConfig.MatcherNavigator, new CardinalTileRegistry <TTile>(Tiles), rd.Tag)); }
ITileMatcher <TTile, Nothing> GenerateBasicLayer(byte terrainIndex, RenderLayerDefinition rd) { return(new BasicTileSelector <TTile, Nothing>(CreateSelfMatcher(terrainIndex), RenderingConfig.MatcherNavigator, Tiles, rd.Tag)); }