コード例 #1
0
 public UniformCelLMatcher(ITileTagEntrySelectionFactory <TSelector> owner,
                           Dictionary <ITileTagEntrySelection <TSelector>, GridMatcher> matchers)
 {
     Owner         = owner;
     Cardinality   = owner.Count;
     this.matchers = matchers;
 }
コード例 #2
0
 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();
 }
コード例 #3
0
 public CornerTileRegistry(ITileRegistry <TRenderTile> baseRegistry,
                           ITileTagEntrySelectionFactory <bool> booleanFormats,
                           ITileTagEntrySelectionFactory <Direction> directions,
                           string suffixFormat,
                           string format) : this(baseRegistry, booleanFormats, directions,
                                                 ProduceCombinedFormatString(suffixFormat, format))
 {
 }
コード例 #4
0
 public LookupMatcher(IMap2D <TerrainData> map,
                      ITileTagEntrySelectionFactory factory,
                      ITileTagEntrySelection[] selections)
 {
     this.Owner      = factory;
     this.map        = map;
     this.selections = selections;
 }
コード例 #5
0
        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();
        }
コード例 #6
0
 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}");
 }
コード例 #7
0
        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));
        }
コード例 #8
0
 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;
 }
コード例 #9
0
 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();
     }
 }
コード例 #10
0
 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();
     }
 }
コード例 #11
0
        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));
        }
コード例 #12
0
        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);
        }
コード例 #13
0
        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);
        }
コード例 #14
0
 public CardinalTileRegistry(ITileRegistry <TRenderTile> baseRegistry,
                             ITileTagEntrySelectionFactory <bool> tags,
                             string tagFormat,
                             string format) : this(baseRegistry, tags, ProduceCombinedFormatString(tagFormat, format))
 {
 }
コード例 #15
0
 public static ICellMatcher FromGridMatcher <TSelector>(ITileTagEntrySelectionFactory <TSelector> owner,
                                                        Dictionary <ITileTagEntrySelection <TSelector>,
                                                                    GridMatcher> matchers)
 {
     return(new UniformCelLMatcher <TSelector>(owner, matchers));
 }
コード例 #16
0
        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);
        }