public UniformCelLMatcher(ITileTagEntrySelectionFactory <TSelector> owner, Dictionary <ITileTagEntrySelection <TSelector>, GridMatcher> matchers) { Owner = owner; Cardinality = owner.Count; this.matchers = matchers; }
public CardinalTileRegistry(ITileRegistry <TRenderTile> baseRegistry, ITileTagEntrySelectionFactory <bool> tags = null, string tagFormat = null) { this.baseRegistry = baseRegistry ?? throw new ArgumentNullException(nameof(baseRegistry)); this.suffixMapping = CardinalTileSelectorKey.Values.Select(e => Format(e, tags, tagFormat)).ToArray(); }
public CornerTileRegistry(ITileRegistry <TRenderTile> baseRegistry, ITileTagEntrySelectionFactory <bool> booleanFormats, ITileTagEntrySelectionFactory <Direction> directions, string suffixFormat, string format) : this(baseRegistry, booleanFormats, directions, ProduceCombinedFormatString(suffixFormat, format)) { }
public LookupMatcher(IMap2D <TerrainData> map, ITileTagEntrySelectionFactory factory, ITileTagEntrySelection[] selections) { this.Owner = factory; this.map = map; this.selections = selections; }
public DiagonalTileRegistry(ITileRegistry <TRenderTile> baseRegistry, ITileTagEntrySelectionFactory <bool> tags = null, string tagFormat = null) { this.baseRegistry = baseRegistry ?? throw new ArgumentNullException(nameof(baseRegistry)); var tagProvider = tags ?? TileTagEntries.CreateFlagTagEntries(); var formatString = tagFormat ?? "{{0}}_nw{0}ne{1}se{2}sw{3}"; this.suffixMapping = DiagonalTileSelectionKey.Values.Select(e => Format(e, tagProvider, formatString)).ToArray(); }
public CornerTileRegistry(ITileRegistry <TRenderTile> baseRegistry, ITileTagEntrySelectionFactory <bool> booleanFormats = null, ITileTagEntrySelectionFactory <Direction> directions = null, string format = null) { this.baseRegistry = baseRegistry; this.suffixMapping = GenerateSuffixes(booleanFormats ?? TileTagEntries.CreateFlagTagEntries(), directions ?? TileTagEntries.CreateDirectionTagEntries(), format ?? "{{0}}_{0}{1}{2}{3}"); }
string Format(DiagonalTileSelectionKey k, ITileTagEntrySelectionFactory <bool> formatProvider, string tagFormat) { var n = formatProvider.Lookup(k.NorthWest).Tag; var e = formatProvider.Lookup(k.NorthEast).Tag; var s = formatProvider.Lookup(k.SouthEast).Tag; var w = formatProvider.Lookup(k.SouthWest).Tag; return(string.Format(tagFormat, n, e, s, w)); }
protected internal TileTagEntrySelection(ITileTagEntrySelectionFactory <TSelector> factory, TSelector selector, ushort index, string tag) { Owner = factory ?? throw new ArgumentNullException(); Selector = selector; SelectorText = selector?.ToString() ?? ""; Index = index; Tag = tag; }
public NeighbourIndexTileRegistry(ITileRegistry <TRenderTile> baseRegistry, ITileTagEntrySelectionFactory <NeighbourMatchPosition> suffixMapping, string format = null) { this.format = format ?? "{0}_{1}"; this.baseRegistry = baseRegistry ?? throw new ArgumentNullException(); this.suffixMapping = suffixMapping ?? throw new ArgumentNullException(); if (suffixMapping.Count != 9) { throw new ArgumentException(); } }
public CardinalIndexTileRegistry(ITileRegistry <TRenderTile> baseRegistry, ITileTagEntrySelectionFactory <CardinalIndex> suffixMapping, string format = null) { this.format = format ?? DefaultFormat; this.baseRegistry = baseRegistry ?? throw new ArgumentNullException(); this.suffixMapping = suffixMapping ?? throw new ArgumentNullException(); if (suffixMapping.Count != 4) { throw new ArgumentException(); } }
static string Format(CardinalTileSelectorKey k, ITileTagEntrySelectionFactory <bool> formatProvider = null, string format = null) { formatProvider ??= TileTagEntries.CreateFlagTagEntries(); format ??= "{{0}}_n{0}e{1}s{2}w{3}"; var n = formatProvider.Lookup(k.North).Tag; var e = formatProvider.Lookup(k.East).Tag; var s = formatProvider.Lookup(k.South).Tag; var w = formatProvider.Lookup(k.West).Tag; return(string.Format(format, n, e, s, w)); }
string[] GenerateSuffixes(ITileTagEntrySelectionFactory <bool> booleanFormats, ITileTagEntrySelectionFactory <Direction> directions, string suffixFormat) { var keys = CornerTileSelectionKey.Values; var retval = new string[keys.Length]; for (var i = 0; i < keys.Length; i++) { var key = keys[i]; var m0 = booleanFormats.Lookup(key.M0).Tag; var m1 = booleanFormats.Lookup(key.M1).Tag; var m2 = booleanFormats.Lookup(key.M2).Tag; var p = directions.Lookup(key.Pos).Tag; retval[i] = string.Format(suffixFormat, p, m0, m1, m2); } return(retval); }
public CornerCellSelector(ICellMatcher matchers, GridMatcher selfMatcher, IMapNavigator <GridDirection> gridNavigator, ITileRegistryEx <CellMapTileSelectorKey, TRenderTile> registry, string prefix, Func <int, int, TContext> contextProvider = null) { this.registry = registry; this.prefix = prefix; this.selfMatcher = selfMatcher ?? throw new ArgumentNullException(nameof(selfMatcher)); Matchers = matchers ?? throw new ArgumentNullException(); GridNavigator = gridNavigator; this.contextProvider = contextProvider ?? DefaultContextProvider; directionTileTagSelection = TileTagEntries.CreateDirectionTagEntries(); selectors = PrepareSelectors(); Prepare(out tiles, out tileExists); }
public CardinalTileRegistry(ITileRegistry <TRenderTile> baseRegistry, ITileTagEntrySelectionFactory <bool> tags, string tagFormat, string format) : this(baseRegistry, tags, ProduceCombinedFormatString(tagFormat, format)) { }
public static ICellMatcher FromGridMatcher <TSelector>(ITileTagEntrySelectionFactory <TSelector> owner, Dictionary <ITileTagEntrySelection <TSelector>, GridMatcher> matchers) { return(new UniformCelLMatcher <TSelector>(owner, matchers)); }
public static ITileTagEntrySelection <TSelector>[] ToSelectionArray <TSelector>(this ITileTagEntrySelectionFactory <TSelector> factory) { var retval = new ITileTagEntrySelection <TSelector> [factory.Count]; for (var i = 0; i < retval.Length; i++) { retval[i] = factory[i]; } return(retval); }