Exemple #1
0
        private StardewObjectInfo CreateSOI(FarmAnimal animal, GameLocation loc, Action action)
        {
            var soi = new StardewObjectInfo();

            soi.Coordinate = animal.getStandingPosition();
            soi.Location   = loc;
            switch (action)
            {
            case Action.Pet:
                soi.NeedAction = !animal.wasPet;
                break;

            case Action.Milk:
                soi.NeedAction = animal.currentProduce > 0 && animal.toolUsedForHarvest == "Milk Pail";
                break;

            case Action.Shear:
                soi.NeedAction = animal.currentProduce > 0 && animal.toolUsedForHarvest == "Shears";
                break;

            default:
                throw new NotImplementedException();
            }

            return(soi);
        }
Exemple #2
0
        protected override void UpdateObjectInfoList()
        {
            this.ObjectInfoList.Clear();

            // Outside animals
            var outsideAnimals = Game1.getFarm().animals.Values.ToList <FarmAnimal>();

            foreach (FarmAnimal animal in outsideAnimals)
            {
                StardewObjectInfo soi = this.CreateSOI(animal, Game1.getFarm(), this.action);
                this.ObjectInfoList.Add(soi);
            }

            // Inside animals
            var farmBuildings = Game1.getFarm().buildings;

            foreach (Building building in farmBuildings)
            {
                if (building.indoors != null && building.indoors.GetType() == typeof(AnimalHouse))
                {
                    var animalHouse = (AnimalHouse)building.indoors;
                    foreach (FarmAnimal animal in animalHouse.animals.Values.ToList())
                    {
                        StardewObjectInfo soi = this.CreateSOI(animal, animalHouse, this.action);
                        this.ObjectInfoList.Add(soi);
                    }
                }
            }

            this.TaskDone = this.CountNeedAction == 0;
        }
Exemple #3
0
        protected override void UpdateObjectInfoList()
        {
            this.ObjectInfoList.Clear();
            var farmBuildings = Game1.getFarm().buildings;

            foreach (Building building in farmBuildings)
            {
                var indoors = building.indoors.Value;
                if (indoors != null && indoors is AnimalHouse)
                {
                    var animalHouse = (AnimalHouse)indoors;
                    foreach (KeyValuePair <Vector2, StardewValley.Object> obj in animalHouse.Objects.Pairs)
                    {
                        if (obj.Value.IsSpawnedObject)
                        {
                            StardewObjectInfo soi = this.CreateSOI(obj, animalHouse);
                            this.ObjectInfoList.Add(soi);
                        }
                    }
                }
            }

            var taskDone = true;

            foreach (StardewObjectInfo soi in this.ObjectInfoList)
            {
                if (soi.NeedAction)
                {
                    taskDone = false;
                    break;
                }
            }

            this.TaskDone = taskDone;
        }
Exemple #4
0
        private void UpdateObjectInfoList(AnimalHouse animalHouse)
        {
            this.ObjectInfoList.RemoveAll(soi => soi.Location == animalHouse);
            foreach (KeyValuePair <Vector2, StardewValley.Object> o in animalHouse.Objects.Pairs)
            {
                if (o.Value.Name.Equals("Hay"))
                {
                    var soi = new StardewObjectInfo();
                    soi.Coordinate = o.Key * Game1.tileSize + new Vector2(Game1.tileSize / 2, Game1.tileSize / 2);
                    soi.Location   = animalHouse;
                }
            }

            var houseWidth  = animalHouse.map.Layers[0].LayerWidth;
            var houseHeight = animalHouse.map.Layers[0].LayerHeight;

            for (int tileX = 0; tileX < houseWidth; tileX++)
            {
                for (int tileY = 0; tileY < houseWidth; tileY++)
                {
                    bool tileIsTrough = animalHouse.doesTileHaveProperty(tileX, tileY, "Trough", "Back") != null;
                    if (tileIsTrough)
                    {
                        bool tileHasHay = animalHouse.Objects.ContainsKey(new Vector2(tileX, tileY));
                        var  soi        = new StardewObjectInfo();
                        soi.Coordinate = new Vector2((tileX + 0.5f) * Game1.tileSize, (tileY + 0.5f) * Game1.tileSize);
                        soi.Location   = animalHouse;
                        soi.NeedAction = !tileHasHay;
                        this.ObjectInfoList.Add(soi);
                    }
                }
            }
        }
Exemple #5
0
        private void UpdateObjectInfoList(GameLocation loc)
        {
            this.ObjectInfoList.RemoveAll(soi => soi.Location == loc);

            foreach (KeyValuePair <Vector2, StardewValley.Object> o in loc.Objects)
            {
                if (o.Value is CrabPot)
                {
                    CrabPot currentCrabPot = (CrabPot)o.Value;
                    var     soi            = new StardewObjectInfo();
                    soi.Coordinate = o.Key * Game1.tileSize + new Vector2(Game1.tileSize / 2, Game1.tileSize / 2);
                    soi.Location   = loc;
                    if (currentCrabPot.readyForHarvest)
                    {
                        soi.NeedAction = true;
                    }

                    // if player is luremaster, crab pots dont need bait
                    if (currentCrabPot.bait == null && !Game1.player.professions.Contains(11))
                    {
                        soi.NeedAction = true;
                    }

                    this.ObjectInfoList.Add(soi);
                }
            }
        }
Exemple #6
0
        private StardewObjectInfo CreateSOI(KeyValuePair <Vector2, StardewValley.Object> obj, GameLocation loc)
        {
            var soi = new StardewObjectInfo();

            soi.Coordinate = obj.Key * Game1.tileSize + new Vector2(Game1.tileSize / 2, Game1.tileSize / 2);
            soi.Location   = loc;
            soi.NeedAction = true;
            return(soi);
        }
Exemple #7
0
 private void UpdateObjectInfoList(GameLocation loc)
 {
     foreach (KeyValuePair <Vector2, TerrainFeature> entry in loc.terrainFeatures)
     {
         var terrainFeature = entry.Value;
         if (terrainFeature is HoeDirt)
         {
             var coordinate        = entry.Key;
             var hoeDirt           = (HoeDirt)terrainFeature;
             StardewObjectInfo soi = this.CreateSOI(hoeDirt, coordinate, loc, this.action);
             this.ObjectInfoList.Add(soi);
         }
     }
 }
Exemple #8
0
        private StardewObjectInfo CreateSOI(HoeDirt hoeDirt, Vector2 coordinate, GameLocation loc, Action action)
        {
            var soi = new StardewObjectInfo();

            soi.Coordinate = coordinate * Game1.tileSize + new Vector2(Game1.tileSize / 2, Game1.tileSize / 2);
            soi.Location   = loc;
            switch (action)
            {
            case Action.Water:
                var isWatered = hoeDirt.state == HoeDirt.watered;
                soi.NeedAction = hoeDirt.needsWatering() && !isWatered && !hoeDirt.crop.dead;
                break;

            case Action.Harvest:
                soi.NeedAction = hoeDirt.readyForHarvest();
                break;

            default:
                throw new NotImplementedException();
            }

            return(soi);
        }
Exemple #9
0
        public void Draw(SpriteBatch b)
        {
            if (!this.TaskExistedAtStartOfDay && !this.TaskExistsNow && this.CountNeedAction > 0)
            {
                this.TaskExistsNow = true;
            }

            if (this.OverlayActive)
            {
                var currentPlayerLocation = Game1.currentLocation;
                var viewport = Game1.viewport;
                var smallestDistanceFromPlayer = float.PositiveInfinity;
                StardewObjectInfo closestSOI   = null;
                bool anyOnScreen = false;
                foreach (StardewObjectInfo objectInfo in this.ObjectInfoList)
                {
                    if (objectInfo.NeedAction)
                    {
                        if (objectInfo.IsOnScreen())
                        {
                            anyOnScreen = true;
                        }

                        if (objectInfo.Location == currentPlayerLocation)
                        {
                            var drawLoc               = new Vector2(objectInfo.Coordinate.X - viewport.X, objectInfo.Coordinate.Y - viewport.Y - Game1.tileSize / 2);
                            var spriteBox             = new Rectangle((int)drawLoc.X - this.ImageTexture.Width / 4 * Game1.pixelZoom, (int)drawLoc.Y - this.ImageTexture.Height / 4 * Game1.pixelZoom - Game1.tileSize / 2, this.ImageTexture.Width * Game1.pixelZoom / 2, this.ImageTexture.Height * Game1.pixelZoom / 2);
                            var spriteBoxSpeechBubble = new Rectangle((int)drawLoc.X - OverlayTextures.SpeechBubble.Width / 4 * Game1.pixelZoom, (int)drawLoc.Y - OverlayTextures.SpeechBubble.Height / 4 * Game1.pixelZoom - Game1.tileSize / 2, OverlayTextures.SpeechBubble.Width * Game1.pixelZoom / 2, OverlayTextures.SpeechBubble.Height * Game1.pixelZoom / 2);
                            spriteBoxSpeechBubble.Offset(0, Game1.pixelZoom / 2);
                            if (this.config.ShowOverlay)
                            {
                                Game1.spriteBatch.Draw(OverlayTextures.SpeechBubble, spriteBoxSpeechBubble, Color.White);
                                Game1.spriteBatch.Draw(this.ImageTexture, spriteBox, Color.White);
                            }

                            var distanceFromPlayer = objectInfo.GetDistance(Game1.player);
                            if (distanceFromPlayer < smallestDistanceFromPlayer)
                            {
                                smallestDistanceFromPlayer = distanceFromPlayer;
                                closestSOI = objectInfo;
                            }
                        }
                    }
                }

                if (this.config.ShowArrow && smallestDistanceFromPlayer == float.PositiveInfinity)
                {
                    if (this.path != null)
                    {
                        Step nextStep = this.path.GetNextStep(Game1.currentLocation);
                        var  warpSOI  = new StardewObjectInfo();
                        warpSOI.Coordinate = nextStep.Position * Game1.tileSize;
                        DrawArrow(warpSOI.GetDirection(Game1.player), 3 * Game1.tileSize);
                    }
                }

                if (this.config.ShowArrow && !(closestSOI == null) && !anyOnScreen)
                {
                    DrawArrow(closestSOI.GetDirection(Game1.player), 3 * Game1.tileSize);
                }
            }
        }