Пример #1
0
 public DefaultShapes(IRangeHighlightAPI api)
 {
     this.api                   = api;
     qualitySprinkler           = api.GetSquareCircle(1);
     iridiumSprinkler           = api.GetSquareCircle(2);
     iridiumSprinklerWithNozzle = api.GetSquareCircle(3);
     prismaticSprinkler         = api.GetSquareCircle(3);
     radioactiveSprinkler       = api.GetSquareCircle(3);
     beehouse                   = api.GetManhattanCircle(5);
     scarecrow                  = api.GetCartesianCircleWithTruncate(scarecrowRadius);
     deluxeScarecrow            = api.GetCartesianCircleWithTruncate(deluxeScarecrowRadius);
     SetJunimoRange(8);
     cherryBomb = new BombRange(
         api.GetCartesianCircleWithRound(3, false),
         new bool[, ] {
         { false, true, false },
         { true, true, true },
         { false, true, false }
     },
         api.GetSquareCircle(3, false));
     bomb = new BombRange(
         api.GetCartesianCircleWithRound(5, false),
         api.GetCartesianCircleWithRound(2, false),
         api.GetSquareCircle(5, false));
     bool[,] mb = api.GetCartesianCircleWithRound(7, false);
     // yeah, it's strange; but I have the screenshots showing this shape
     mb[1, 5]  = mb[1, 6] = mb[1, 7] = mb[1, 8] = mb[1, 9] = false;
     mb[13, 5] = mb[13, 6] = mb[13, 7] = mb[13, 8] = mb[13, 9] = false;
     megaBomb  = new BombRange(
         mb,
         cherryBomb.range,
         api.GetSquareCircle(7, false));
 }
Пример #2
0
        private void installDefaultHighlights()
        {
            if (config.ShowJunimoRange)
            {
                api.AddBuildingRangeHighlighter("jltaylor-us.RangeHighlight/junimoHut", config.ShowJunimoRangeKey,
                                                blueprint => {
                    if (blueprint.name == "Junimo Hut")
                    {
                        return(new Tuple <Color, bool[, ], int, int>(config.JunimoRangeTint, defaultShapes.junimoHut, 1, 1));
                    }
                    else
                    {
                        return(null);
                    }
                },
                                                building => {
                    if (building is JunimoHut)
                    {
                        return(new Tuple <Color, bool[, ], int, int>(config.JunimoRangeTint, defaultShapes.junimoHut, 1, 1));
                    }
                    else
                    {
                        return(null);
                    }
                });
            }
            if (config.ShowScarecrowRange)
            {
                api.AddItemRangeHighlighter("jltaylor-us.RangeHighlight/scarecrow", config.ShowScarecrowRangeKey,
                                            config.ShowOtherScarecrowsWhenHoldingScarecrow,
                                            (item, itemID, itemName) => {
                    if (itemName.Contains("arecrow"))
                    {
                        return(new Tuple <Color, bool[, ]>(config.ScarecrowRangeTint,
                                                           itemName.Contains("deluxe") ? defaultShapes.deluxeScarecrow : defaultShapes.scarecrow));
                    }
                    else
                    {
                        if ((item is StardewValley.Object) && (item as StardewValley.Object).IsScarecrow())
                        {
                            int r = (item as StardewValley.Object).GetRadiusForScarecrow() - 1;
                            if (r < 0)
                            {
                                return(null);           // shouldn't happen?
                            }
                            return(new Tuple <Color, bool[, ]>(config.ScarecrowRangeTint,
                                                               r == DefaultShapes.scarecrowRadius ? defaultShapes.scarecrow
                                        : r == DefaultShapes.deluxeScarecrowRadius ? defaultShapes.deluxeScarecrow
                                        : api.GetCartesianCircleWithTruncate((uint)r)));
                        }
                        else
                        {
                            return(null);
                        }
                    }
                });
            }
            if (config.ShowSprinklerRange)
            {
                api.AddItemRangeHighlighter("jltaylor-us.RangeHighlight/sprinkler", config.ShowSprinklerRangeKey,
                                            config.ShowOtherSprinklersWhenHoldingSprinkler, GetDefaultSprinklerHighlight);
            }
            if (config.ShowBeehouseRange)
            {
                api.AddItemRangeHighlighter("jltaylor-us.RangeHighlight/beehouse", config.ShowBeehouseRangeKey,
                                            config.ShowOtherBeehousesWhenHoldingBeehouse,
                                            (item, itemID, itemName) => {
                    if (itemName.Contains("bee house"))
                    {
                        return(new Tuple <Color, bool[, ]>(config.BeehouseRangeTint, defaultShapes.beehouse));
                    }
                    else
                    {
                        return(null);
                    }
                });
            }
            if (config.ShowBombRange)
            {
                if (config.showHeldBombRange)
                {
                    api.AddItemRangeHighlighter("jltaylor-us.RangeHighlight/bomb", new KeybindList(), true,
                                                (item, itemID, itemName) => {
                        if (!Utility.IsNormalObjectAtParentSheetIndex(item, item.ParentSheetIndex))
                        {
                            return(null);
                        }
                        DefaultShapes.BombRange range;
                        switch (itemID)
                        {
                        case 286:
                            range = defaultShapes.cherryBomb;
                            break;

                        case 287:
                            range = defaultShapes.bomb;
                            break;

                        case 288:
                            range = defaultShapes.megaBomb;
                            break;

                        default:
                            return(null);
                        }
                        // This relies on the fact that placed bombs are not an item, so this
                        // can use the cursor position for the location
                        var cursorTile = highlighter.GetCursorTile();
                        return(bombHelper(range, (int)cursorTile.X, (int)cursorTile.Y));
                    });
                }

                if (config.showPlacedBombRange)
                {
                    // not sure about this API yet, so keeping it private for now
                    highlighter.AddTemporaryAnimatedSpriteHighlighter("jltaylor-us.RangeHighlight/bomb",
                                                                      sprite => {
                        DefaultShapes.BombRange range;
                        switch (sprite.initialParentTileIndex)
                        {
                        case 286:
                            range = defaultShapes.cherryBomb;
                            break;

                        case 287:
                            range = defaultShapes.bomb;
                            break;

                        case 288:
                            range = defaultShapes.megaBomb;
                            break;

                        default:
                            if (sprite.bombRadius > 0)
                            {
                                range = new DefaultShapes.BombRange(api.GetCartesianCircleWithRound((uint)sprite.bombRadius, false), new bool[0, 0], api.GetSquareCircle((uint)sprite.bombRadius, false));
                                break;
                            }
                            else
                            {
                                return(null);
                            }
                        }
                        return(bombHelper(range,
                                          (int)(sprite.position.X / Game1.tileSize), (int)(sprite.position.Y / Game1.tileSize)));
                    });
                }
            }
        }