コード例 #1
0
        public void ActivateSprinkler(SObject sprinkler, GameLocation location)
        {
            if (SprinklerBehavior is not ISprinklerBehavior.Independent)
            {
                throw new InvalidOperationException("Current sprinkler behavior does not allow independent sprinkler activation.");
            }
            if (Game1.player.team.SpecialOrderRuleActive("NO_SPRINKLER"))
            {
                return;
            }
            if (!sprinkler.IsSprinkler())
            {
                return;
            }

            foreach (var sprinklerTile in GetModifiedSprinklerCoverage(sprinkler, location))
            {
                sprinkler.ApplySprinkler(location, new Vector2(sprinklerTile.X, sprinklerTile.Y));
            }
            sprinkler.ApplySprinklerAnimation(location);
        }
コード例 #2
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);
 }