コード例 #1
0
        private void ActivateVanillaSprinkler(StardewValley.Object sprinkler)
        {
            Vector2 sprinklerTile = sprinkler.TileLocation;
            int     range         = sprinkler.GetModifiedRadiusForSprinkler();

            if (range < 0)
            {
                Monitor.Log($"Invalid sprinkler range: {range}", LogLevel.Error);
                return;
            }
            List <Vector2> coverage = sprinkler.GetSprinklerTiles();

            foreach (Vector2 v in coverage)
            {
                WaterTile(v);
            }
            switch (range)
            {
            case 0:
                playAnimation(sprinklerTile, animSize.SMALL);
                break;

            case 1:
                playAnimation(sprinklerTile, animSize.MEDIUM);
                break;

            default:
                playAnimation(sprinklerTile, animSize.LARGE);
                break;
            }
        }
コード例 #2
0
        private void ActivateVanillaSprinkler(StardewValley.Object sprinkler)
        {
            if (!sprinkler.IsSprinkler())
            {
                return;
            }

            foreach (Vector2 current in sprinkler.GetSprinklerTiles())
            {
                sprinkler.ApplySprinkler(Game1.currentLocation, current);
            }

            ApplySprinklerAnimation(Game1.currentLocation, sprinkler);
        }
コード例 #3
0
        public Vector2[] GetModifiedSprinklerCoverage(SObject sprinkler, GameLocation location)
        {
            if (SprinklerBehavior is not ISprinklerBehavior.Independent)
            {
                throw new InvalidOperationException("Current sprinkler behavior does not allow independent sprinkler activation.");
            }

            var wasVanillaQueryInProgress = VanillaPatches.IsVanillaQueryInProgress;

            VanillaPatches.IsVanillaQueryInProgress = false;
            VanillaPatches.CurrentLocation          = location;
            var layout = sprinkler.GetSprinklerTiles().ToArray();

            VanillaPatches.IsVanillaQueryInProgress = wasVanillaQueryInProgress;
            return(layout);
        }
コード例 #4
0
 // Make sprinklers that are held by objects, do sprinkler things overnight
 public static bool DayUpdate_Prefix(StardewValley.Object __instance, GameLocation location)
 {
     StardewValley.Object obj = __instance.heldObject;
     if (obj != null && new[] { 599, 621, 645 }.Contains(obj.ParentSheetIndex))
     {
         location.postFarmEventOvernightActions.Add(delegate
         {
             if (!Game1.player.team.SpecialOrderRuleActive("NO_SPRINKLER"))
             {
                 string tiles_string = "";
                 foreach (Vector2 current in obj.GetSprinklerTiles())
                 {
                     Vector2 current_modified = new Vector2(current.X + __instance.TileLocation.X, current.Y + __instance.TileLocation.Y);
                     obj.ApplySprinkler(location, current_modified);
                     tiles_string += $"({current_modified.X},{current_modified.Y}), ";
                 }
                 obj.ApplySprinklerAnimation(location);
             }
         });
     }
     return(true);
 }