Пример #1
0
 internal Tuple <Color, bool[, ]> GetDefaultSprinklerHighlight(Item item, int itemID, string itemName)
 {
     if (itemName.Contains("sprinkler"))
     {
         bool hasPressureNozzleAttached = false;
         if (item is StardewValley.Object obj)
         {
             var heldObj = obj.heldObject.Value;
             if (heldObj != null && heldObj.ParentSheetIndex == 915)
             {
                 hasPressureNozzleAttached = true;
             }
         }
         return(new Tuple <Color, bool[, ]>(config.SprinklerRangeTint, defaultShapes.GetSprinkler(itemName, hasPressureNozzleAttached)));
     }
     else
     {
         return(null);
     }
 }
Пример #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
                    {
                        return(null);
                    }
                });
            }
            if (config.ShowSprinklerRange)
            {
                api.AddItemRangeHighlighter("jltaylor-us.RangeHighlight/sprinkler", config.ShowSprinklerRangeKey,
                                            config.ShowOtherSprinklersWhenHoldingSprinkler,
                                            (item, itemID, itemName) => {
                    if (itemName.Contains("sprinkler"))
                    {
                        return(new Tuple <Color, bool[, ]>(config.SprinklerRangeTint, defaultShapes.GetSprinkler(itemName)));
                    }
                    else
                    {
                        return(null);
                    }
                });
            }
            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)
            {
                api.AddItemRangeHighlighter("jltaylor-us.RangeHighlight/bomb", null, true,
                                            (item, itemID, itemName) => {
                    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:
                            return(null);
                        }
                        return(bombHelper(range,
                                          (int)(sprite.position.X / Game1.tileSize), (int)(sprite.position.Y / Game1.tileSize)));
                    });
                }
            }
        }