Beispiel #1
0
 private void UseghostWaterCan(GameLocation location, int x, int y)
 {
     Game1.player.toolPower = Game1.player.toolPower >= (_ghostWaterCan).UpgradeLevel ? (_ghostWaterCan).UpgradeLevel : Game1.player.toolPower;
     _ghostWaterCan.DoFunction(location, x, y, _powerLevel, Game1.player);
     if (!_toolConfig.ShowWaterLeftMessage || _ghostWaterCan.WaterLeft <= 0)
     {
         return;
     }
     Game1.showGlobalMessage("Water:" + _ghostWaterCan.WaterLeft);
 }
Beispiel #2
0
 private void DoAction()
 {
     if (Helper.Input.GetState(SButton.MouseRight) == SButtonState.Pressed)
     {
         Vector2 tile = Game1.currentCursorTile;
         if (Game1.currentLocation.objects.TryGetValue(tile, out StardewValley.Object check))
         {
             if (check.name.ToLower().Contains("sprinkler"))
             {
                 //Defines radius & checks for pressure nozzle
                 int sprinklerRadius = 0;
                 if (check.heldObject.Value != null && Utility.IsNormalObjectAtParentSheetIndex(check.heldObject, 915))
                 {
                     sprinklerRadius++;
                 }
                 //Determines sprinkler type, adjusts radius accordingly
                 if (check.name.ToLower().Contains("iridium"))
                 {
                     sprinklerRadius += 2;
                 }
                 else if (check.name.ToLower().Contains("quality"))
                 {
                     sprinklerRadius++;
                 }
                 //Creates area that needs to be watered
                 List <Vector2> tileNeedWater = MakeVector2TileGrid(tile, sprinklerRadius);
                 //Waters the area specified
                 WateringCan waterCan = new WateringCan
                 {
                     WaterLeft = 100
                 };
                 float stamina = Game1.player.Stamina;
                 foreach (Vector2 waterTile in tileNeedWater)
                 {
                     waterCan.DoFunction(Game1.currentLocation, (int)(waterTile.X * Game1.tileSize), (int)(waterTile.Y * Game1.tileSize), 1, Game1.player);
                     waterCan.WaterLeft++;
                     Game1.player.Stamina = stamina;
                 }
             }
         }
     }
 }
        private void UseTool(Vector2 startPos, Vector2 endPos, GameLocation loc)
        {
            var player = Game1.player;

            Axe fakeAxe = new Axe {
                UpgradeLevel = 4
            };
            Pickaxe fakePick = new Pickaxe {
                UpgradeLevel = 4
            };
            MeleeWeapon fakeSickle = new MeleeWeapon {
                UpgradeLevel = 4
            };
            Hoe fakeHoe = new Hoe {
                UpgradeLevel = 4
            };
            WateringCan fakeCan = new WateringCan {
                UpgradeLevel = 4
            };

            Game1.player.MagneticRadius = 650;

            for (int xTile = Convert.ToInt32(startPos.X); xTile <= Convert.ToInt32(endPos.X); ++xTile)
            {
                for (int yTile = Convert.ToInt32(startPos.Y); yTile <= Convert.ToInt32(endPos.Y); ++yTile)
                {
                    Vector2 useAt = (new Vector2(xTile, yTile) * Game1.tileSize) + new Vector2(Game1.tileSize / 2f);
                    Game1.player.lastClick = useAt;

                    loc.objects.TryGetValue(new Vector2(xTile, yTile), out var obj);
                    loc.terrainFeatures.TryGetValue(new Vector2(xTile, yTile), out var ter);

                    //Check obj
                    if (obj != null)
                    {
                        bool forage = obj.IsSpawnedObject;//checkForAction(Game1.player);
                        if (forage)
                        {
                            DoForageHarvest(obj, loc, player);
                        }
                        if (obj.Name.ToLower().Contains("twig"))
                        {
                            fakeAxe.DoFunction(loc, (int)useAt.X, (int)useAt.Y, 0, player);
                        }
                        if (obj.Name.ToLower().Contains("stone"))
                        {
                            fakePick.DoFunction(loc, (int)useAt.X, (int)useAt.Y, 0, player);
                        }
                        if (obj.Name.ToLower().Contains("weed"))
                        {
                            fakeAxe.DoFunction(loc, (int)useAt.X, (int)useAt.Y, 0, player);
                        }
                    }
                    //Check ter
                    if (ter != null)
                    {
                        if (ter is Tree tree)
                        {
                            fakeAxe.DoFunction(loc, (int)useAt.X, (int)useAt.Y, 0, player);
                        }

                        if (ter is Grass)
                        {
                            Random rdn = new Random();
                            loc.terrainFeatures.Remove(new Vector2(xTile, yTile));
                            Game1.createMultipleObjectDebris(178, xTile, yTile, rdn.Next(2), loc);
                        }
                    }

                    if (ter != null && ter is HoeDirt dirt)
                    {
                        if (dirt.crop == null &&
                            player.ActiveObject != null &&
                            ((player.ActiveObject.Category == SObject.SeedsCategory || player.ActiveObject.Category == -19) &&
                             dirt.canPlantThisSeedHere(player.ActiveObject.ParentSheetIndex, (int)useAt.X, (int)useAt.Y, player.ActiveObject.Category == -19)))
                        {
                            if ((dirt.plant(player.ActiveObject.ParentSheetIndex, (int)useAt.X, (int)useAt.Y, player, player.ActiveObject.Category == -19, loc) && player.IsLocalPlayer))
                            {
                                player.reduceActiveItemByOne();
                            }
                            Game1.haltAfterCheck = false;
                        }
                        else if (dirt.crop != null)
                        {
                            if (dirt.crop.fullyGrown.Value)
                            {
                                dirt.crop.harvest((int)useAt.X, (int)useAt.Y, dirt);
                            }
                            else if (player.ActiveObject != null && player.ActiveObject.Category == -19)
                            {
                                dirt.fertilizer.Value = player.ActiveObject.ParentSheetIndex;
                                player.reduceActiveItemByOne();
                            }
                            else
                            {
                                fakeCan.DoFunction(loc, (int)useAt.X, (int)useAt.Y, 0, Game1.player);
                            }
                        }
                        else
                        {
                            fakePick.DoFunction(loc, (int)useAt.X, (int)useAt.Y, 0, Game1.player);
                        }
                    }
                    else
                    {
                        fakeHoe.DoFunction(loc, (int)useAt.X, (int)useAt.Y, 1, Game1.player);
                    }


                    //Lets try bush shit
                    Rectangle rectangle = new Rectangle((int)useAt.X + 32, (int)useAt.Y - 32, 4, 192);
                    foreach (LargeTerrainFeature largeTerrainFeature in loc.largeTerrainFeatures)
                    {
                        if (largeTerrainFeature is Bush bush && bush.getBoundingBox().Intersects(rectangle))
                        {
                            bush.performUseAction(bush.tilePosition.Value, loc);
                        }
                    }

                    //Resource Clumps
                    ResourceClump clump = GetResourceClumpCoveringTile(loc, new Vector2(useAt.X, useAt.Y));
                    if (clump != null)
                    {
                        if (clump.parentSheetIndex.Value == 600)
                        {
                            clump.health.Value = 1;
                            fakeAxe.DoFunction(loc, (int)useAt.X, (int)useAt.Y, 1, Game1.player);
                        }

                        if (clump.parentSheetIndex.Value == 602)
                        {
                            clump.health.Value = 1;
                            fakeAxe.DoFunction(loc, (int)useAt.X, (int)useAt.Y, 1, Game1.player);
                        }

                        if (clump.parentSheetIndex.Value == 672)
                        {
                            clump.health.Value = 1;
                            fakePick.DoFunction(loc, (int)useAt.X, (int)useAt.Y, 1, Game1.player);
                        }
                    }

                    Game1.player.Stamina = Game1.player.MaxStamina;//So we dont passout lol
                }
            }
        }
Beispiel #4
0
        private void ActivateSprinklerz(KeyboardState keyboardState, MouseState mouseState)
        {
            if (Game1.currentLocation == null || !Context.IsWorldReady)
            {
                return;
            }
            Vector2     currentTile = Game1.currentCursorTile;
            SObject     @object;
            WateringCan waterCan = new WateringCan();

            if (mouseState.RightButton == ButtonState.Pressed)
            {
                if (Game1.currentLocation.objects.TryGetValue(currentTile, out @object))
                {
                    if (@object.name.ToLower().Contains("sprinkler"))
                    {
                        waterCan.WaterLeft = 100;
                        float          stamina           = Game1.player.Stamina;
                        Vector2        sprinklerLocation = @object.tileLocation;
                        List <Vector2> tileNeedWater     = new List <Vector2>();
                        bool           setup             = false;
                        //Cycle through the custom sprinklers. Then go default if nothing else is found.
                        if (BetterSprinklersLoaded)
                        {
                            DoBetterSprinklers();                //Gathers Better Sprinklers tiles that are set up.
                            if (@object.parentSheetIndex == 599) //Regular Sprinkler
                            {
                                foreach (Vector2 water in sprinkler)
                                {
                                    int x = (int)sprinklerLocation.X;
                                    int y = (int)sprinklerLocation.Y;
                                    x += (int)water.X;
                                    y += (int)water.Y;
                                    waterCan.DoFunction(Game1.currentLocation, x * Game1.tileSize, y * Game1.tileSize, 1, Game1.player);
                                    waterCan.WaterLeft++;
                                    Game1.player.Stamina = stamina;
                                }
                            }
                            else if (@object.parentSheetIndex == 621)//Quality Sprinkler
                            {
                                foreach (Vector2 water in quality_sprinkler)
                                {
                                    int x = (int)sprinklerLocation.X;
                                    int y = (int)sprinklerLocation.Y;
                                    x += (int)water.X;
                                    y += (int)water.Y;
                                    waterCan.DoFunction(Game1.currentLocation, x * Game1.tileSize, y * Game1.tileSize, 1, Game1.player);
                                    waterCan.WaterLeft++;
                                    Game1.player.Stamina = stamina;
                                }
                            }
                            else if (@object.parentSheetIndex == 645)//Iridium Sprinkler
                            {
                                foreach (Vector2 water in iridium_sprinkler)
                                {
                                    int x = (int)sprinklerLocation.X;
                                    int y = (int)sprinklerLocation.Y;
                                    x += (int)water.X;
                                    y += (int)water.Y;
                                    waterCan.DoFunction(Game1.currentLocation, x * Game1.tileSize, y * Game1.tileSize, 1, Game1.player);
                                    waterCan.WaterLeft++;
                                    Game1.player.Stamina = stamina;
                                }
                            }
                        }
                        else if (SimpleSprinklerLoaded)
                        {
                            DoSimpleSprinklers();
                            if (@object.parentSheetIndex == 599)//Regular Sprinkler
                            {
                                foreach (Vector2 water in sprinkler)
                                {
                                    int x = (int)sprinklerLocation.X;
                                    int y = (int)sprinklerLocation.Y;
                                    x += (int)water.X;
                                    y += (int)water.Y;
                                    waterCan.DoFunction(Game1.currentLocation, x * Game1.tileSize, y * Game1.tileSize, 1, Game1.player);
                                    waterCan.WaterLeft++;
                                    Game1.player.Stamina = stamina;
                                }
                            }
                            else if (@object.parentSheetIndex == 621)//Quality Sprinkler
                            {
                                foreach (Vector2 water in quality_sprinkler)
                                {
                                    int x = (int)sprinklerLocation.X;
                                    int y = (int)sprinklerLocation.Y;
                                    x += (int)water.X;
                                    y += (int)water.Y;
                                    waterCan.DoFunction(Game1.currentLocation, x * Game1.tileSize, y * Game1.tileSize, 1, Game1.player);
                                    waterCan.WaterLeft++;
                                    Game1.player.Stamina = stamina;
                                }
                            }
                            else if (@object.parentSheetIndex == 645)//Iridium Sprinkler
                            {
                                foreach (Vector2 water in iridium_sprinkler)
                                {
                                    int x = (int)sprinklerLocation.X;
                                    int y = (int)sprinklerLocation.Y;
                                    x += (int)water.X;
                                    y += (int)water.Y;
                                    waterCan.DoFunction(Game1.currentLocation, x * Game1.tileSize, y * Game1.tileSize, 1, Game1.player);
                                    waterCan.WaterLeft++;
                                    Game1.player.Stamina = stamina;
                                }
                            }
                        }
                        else
                        {
                            if (@object.name.ToLower().Contains("quality") && setup == false)
                            {
                                tileNeedWater = Vector2TileGrid(currentTile, 1);
                                setup         = true;
                            }
                            if (@object.name.ToLower().Contains("iridium") && setup == false)
                            {
                                tileNeedWater = Vector2TileGrid(currentTile, 2);
                                setup         = true;
                            }
                            if (setup == false)
                            {
                                tileNeedWater.Add(new Vector2(currentTile.X + 1, currentTile.Y));
                                tileNeedWater.Add(new Vector2(currentTile.X - 1, currentTile.Y));
                                tileNeedWater.Add(new Vector2(currentTile.X, currentTile.Y + 1));
                                tileNeedWater.Add(new Vector2(currentTile.X, currentTile.Y - 1));
                                setup = true;
                            }
                            foreach (Vector2 waterTile in tileNeedWater)
                            {
                                waterCan.DoFunction(Game1.currentLocation, (int)(waterTile.X * Game1.tileSize), (int)(waterTile.Y * Game1.tileSize), 1, Game1.player);
                                waterCan.WaterLeft++;
                                Game1.player.stamina = stamina;
                            }
                        }
                    }
                }
            }
        }