public static void Postfix(HoeDirt __instance, GameLocation environment, Vector2 tileLocation) { __instance.fertilizer.Value = 0; }
/// <summary>The method to call after <see cref="HoeDirt.dayUpdate"/>.</summary> private static void After_DayUpdate(HoeDirt __instance, GameLocation environment, Vector2 tileLocation) { __instance.fertilizer.Value = 0; }
internal static void ProcessHazardousCropWeather(WeatherConditions curr, int timeOfDay, MersenneTwister Dice) { //frost works at night, heatwave works during the day if (timeOfDay == 1700) { if (curr.HasWeather(CurrentWeather.Heatwave) || curr.HasWeather(CurrentWeather.Sandstorm)) { ClimatesOfFerngill.Logger.Log("Beginning Heatwave code"); ExpireTime = 2000; Farm f = Game1.getFarm(); int count = 0, maxCrops = (int)Math.Floor(SDVUtilities.CropCountInFarm(f) * ClimatesOfFerngill.WeatherOpt.DeadCropPercentage); foreach (KeyValuePair <Vector2, TerrainFeature> tf in f.terrainFeatures.Pairs) { if (count >= maxCrops) { break; } if (tf.Value is HoeDirt dirt && dirt.crop != null) { if (Dice.NextDouble() <= ClimatesOfFerngill.WeatherOpt.CropResistance) { if (ClimatesOfFerngill.WeatherOpt.Verbose) { ClimatesOfFerngill.Logger.Log($"Dewatering crop at {tf.Key}. Crop is {dirt.crop.indexOfHarvest}"); } CropList.Add(tf.Key); dirt.state.Value = HoeDirt.dry; count++; } } } if (CropList.Count > 0) { if (ClimatesOfFerngill.WeatherOpt.AllowCropDeath) { if (curr.HasWeather(CurrentWeather.Heatwave) && !curr.HasWeather(CurrentWeather.Sandstorm)) { SDVUtilities.ShowMessage(ClimatesOfFerngill.Translator.Get("hud-text.desc_heatwave_kill", new { crops = count }), 3); } if (curr.HasWeather(CurrentWeather.Sandstorm)) { SDVUtilities.ShowMessage(ClimatesOfFerngill.Translator.Get("hud-text.desc_sandstorm_kill", new { crops = count }), 3); } } else { if (curr.HasWeather(CurrentWeather.Heatwave) && !curr.HasWeather(CurrentWeather.Sandstorm)) { SDVUtilities.ShowMessage(ClimatesOfFerngill.Translator.Get("hud-text.desc_heatwave_dry", new { crops = count }), 3); } if (curr.HasWeather(CurrentWeather.Sandstorm)) { SDVUtilities.ShowMessage(ClimatesOfFerngill.Translator.Get("hud-text.desc_sandstorm_dry", new { crops = count }), 3); } } } else { SDVUtilities.ShowMessage(ClimatesOfFerngill.Translator.Get("hud-text.desc_heatwave"), 3); } } } if (Game1.timeOfDay == ExpireTime && ClimatesOfFerngill.WeatherOpt.AllowCropDeath) { ClimatesOfFerngill.Logger.Log("Beginning Crop Death code"); //if it's still de watered - kill it. Farm f = Game1.getFarm(); bool cDead = false; foreach (Vector2 v in CropList) { HoeDirt hd = (HoeDirt)f.terrainFeatures[v]; if (hd.state.Value == HoeDirt.dry) { if (ClimatesOfFerngill.WeatherOpt.Verbose) { ClimatesOfFerngill.Logger.Log($"Killing crop at {v}. Crop is {hd.crop.indexOfHarvest}"); } hd.crop.dead.Value = true; cDead = true; } } CropList.Clear(); //clear the list if (cDead) { SDVUtilities.ShowMessage(ClimatesOfFerngill.Translator.Get("hud-text.desc_heatwave_cropdeath"), 3); } } }
/********* ** Public methods *********/ /// <summary>Construct an instance.</summary> /// <param name="codex">Provides subject entries</param> /// <param name="gameHelper">Provides utility methods for interacting with the game code.</param> /// <param name="progressionMode">Whether to only show content once the player discovers it.</param> /// <param name="highlightUnrevealedGiftTastes">Whether to highlight item gift tastes which haven't been revealed in the NPC profile.</param> /// <param name="item">The underlying target.</param> /// <param name="context">The context of the object being looked up.</param> /// <param name="knownQuality">Whether the item quality is known. This is <c>true</c> for an inventory item, <c>false</c> for a map object.</param> /// <param name="getCropSubject">Get a lookup subject for a crop.</param> /// <param name="fromCrop">The crop associated with the item (if applicable).</param> /// <param name="fromDirt">The dirt containing the crop (if applicable).</param> public ItemSubject(ISubjectRegistry codex, GameHelper gameHelper, bool progressionMode, bool highlightUnrevealedGiftTastes, Item item, ObjectContext context, bool knownQuality, Func <Crop, ObjectContext, HoeDirt, ISubject> getCropSubject, Crop fromCrop = null, HoeDirt fromDirt = null) : base(gameHelper) { this.Codex = codex; this.ProgressionMode = progressionMode; this.HighlightUnrevealedGiftTastes = highlightUnrevealedGiftTastes; this.Target = item; this.DisplayItem = this.GetMenuItem(item); this.FromCrop = fromCrop ?? fromDirt?.crop; this.FromDirt = fromDirt; if ((item as SObject)?.Type == "Seeds" && this.FromCrop == null) // fromCrop == null to exclude unplanted coffee beans { this.SeedForCrop = new Crop(item.ParentSheetIndex, 0, 0); } this.Context = context; this.KnownQuality = knownQuality; this.GetCropSubject = getCropSubject; this.Initialize(this.DisplayItem.DisplayName, this.GetDescription(this.DisplayItem), this.GetTypeValue(this.DisplayItem)); }
public bool harvest(int xTile, int yTile, HoeDirt soil, JunimoHarvester junimoHarvester = null) { if (this.dead) { return(junimoHarvester != null); } if (this.forageCrop) { ModularCropObject @object = (ModularCropObject)null; int howMuch = 3; if (this.whichForageCrop == 1) { //@object = new ModularCropObject(399, 1, false, -1, 0); if (Game1.player.professions.Contains(16)) { @object.Quality = 4; } else if (Game1.random.NextDouble() < (double)Game1.player.ForagingLevel / 30.0) { @object.Quality = 2; } else if (Game1.random.NextDouble() < (double)Game1.player.ForagingLevel / 15.0) { @object.Quality = 1; } } Game1.stats.ItemsForaged += (uint)@object.Stack; if (junimoHarvester != null) { junimoHarvester.tryToAddItemToHut((Item)@object); return(true); } if (Game1.player.addItemToInventoryBool((Item)@object, false)) { Vector2 vector2 = new Vector2((float)xTile, (float)yTile); // Game1.player.animateOnce(279 + Game1.player.facingDirection); Game1.player.canMove = false; Game1.playSound("harvest"); DelayedAction.playSoundAfterDelay("coin", 260); if (this.regrowAfterHarvest == -1) { Game1.currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite(17, new Vector2(vector2.X * (float)Game1.tileSize, vector2.Y * (float)Game1.tileSize), Color.White, 7, Game1.random.NextDouble() < 0.5, 125f, 0, -1, -1f, -1, 0)); Game1.currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite(14, new Vector2(vector2.X * (float)Game1.tileSize, vector2.Y * (float)Game1.tileSize), Color.White, 7, Game1.random.NextDouble() < 0.5, 50f, 0, -1, -1f, -1, 0)); } Game1.player.gainExperience(2, howMuch); return(true); } Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:Crop.cs.588")); } else if (this.currentPhase >= this.phaseDays.Count - 1 && (!this.fullyGrown || this.dayOfCurrentPhase <= 0)) { int num1 = 1; int num2 = 0; int num3 = 0; if (this.indexOfHarvest == 0) { return(true); } Random random = new Random(xTile * 7 + yTile * 11 + (int)Game1.stats.DaysPlayed + (int)Game1.uniqueIDForThisGame); switch (soil.fertilizer.Value) { case 368: num3 = 1; break; case 369: num3 = 2; break; } double num4 = 0.2 * ((double)Game1.player.FarmingLevel / 10.0) + 0.2 * (double)num3 * (((double)Game1.player.FarmingLevel + 2.0) / 12.0) + 0.01; double num5 = Math.Min(0.75, num4 * 2.0); if (random.NextDouble() < num4) { num2 = 2; } else if (random.NextDouble() < num5) { num2 = 1; } if (this.minHarvest > 1 || this.maxHarvest > 1) { num1 = random.Next(this.minHarvest, Math.Min(this.minHarvest + 1, this.maxHarvest + 1 + Game1.player.FarmingLevel / this.maxHarvestIncreasePerFarmingLevel)); } if (this.chanceForExtraCrops > 0.0) { while (random.NextDouble() < Math.Min(0.9, this.chanceForExtraCrops)) { ++num1; } } if (this.harvestMethod == 1) { if (junimoHarvester == null) { DelayedAction.playSoundAfterDelay("daggerswipe", 150); } if (junimoHarvester != null && Utility.isOnScreen(junimoHarvester.getTileLocationPoint(), Game1.tileSize, junimoHarvester.currentLocation)) { Game1.playSound("harvest"); } if (junimoHarvester != null && Utility.isOnScreen(junimoHarvester.getTileLocationPoint(), Game1.tileSize, junimoHarvester.currentLocation)) { DelayedAction.playSoundAfterDelay("coin", 260); } for (int index = 0; index < num1; ++index) { if (junimoHarvester != null) { junimoHarvester.tryToAddItemToHut((Item) new ModularCropObject(this.spriteSheet.getHelper(), this.indexOfHarvest, 1, this.cropObjectTexture, this.cropObjectData)); } else { AdditionalCropsFramework.Utilities.createObjectDebris((Item) new ModularCropObject(this.spriteSheet.getHelper(), this.indexOfHarvest, this.getAmountForHarvest(), this.cropObjectTexture, this.cropObjectData), xTile, yTile, xTile, yTile, -1, this.getQualityOfCrop(), 1); } //Game1.createObjectDebris(this.indexOfHarvest, xTile, yTile, -1, num2, 1f, (GameLocation)null); } if (this.regrowAfterHarvest == -1) { return(true); } this.dayOfCurrentPhase = this.regrowAfterHarvest; this.fullyGrown = true; } else { if (junimoHarvester == null) { Farmer player = Game1.player; ModularCropObject @object = new ModularCropObject(this.spriteSheet.getHelper(), this.indexOfHarvest, 1, this.cropObjectTexture, this.cropObjectData); int num7 = 0; if (!player.addItemToInventoryBool((Item)@object, num7 != 0)) { Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:Crop.cs.588")); goto label_86; } } Vector2 vector2 = new Vector2((float)xTile, (float)yTile); if (junimoHarvester == null) { // Game1.player.animateOnce(279 + Game1.player.facingDirection); Game1.player.canMove = false; } else { JunimoHarvester junimoHarvester1 = junimoHarvester; ModularCropObject @object = new ModularCropObject(this.spriteSheet.getHelper(), this.indexOfHarvest, 1, this.cropObjectTexture, this.cropObjectData); junimoHarvester1.tryToAddItemToHut((Item)@object); } if (random.NextDouble() < (double)Game1.player.LuckLevel / 1500.0 + Game1.dailyLuck / 1200.0 + 9.99999974737875E-05) { num1 *= 2; if (junimoHarvester == null || Utility.isOnScreen(junimoHarvester.getTileLocationPoint(), Game1.tileSize, junimoHarvester.currentLocation)) { Game1.playSound("dwoop"); } } else if (this.harvestMethod == 0) { if (junimoHarvester == null || Utility.isOnScreen(junimoHarvester.getTileLocationPoint(), Game1.tileSize, junimoHarvester.currentLocation)) { Game1.playSound("harvest"); } if (junimoHarvester == null || Utility.isOnScreen(junimoHarvester.getTileLocationPoint(), Game1.tileSize, junimoHarvester.currentLocation)) { DelayedAction.playSoundAfterDelay("coin", 260); } if (this.regrowAfterHarvest == -1 && (junimoHarvester == null || junimoHarvester.currentLocation.Equals((object)Game1.currentLocation))) { Game1.currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite(17, new Vector2(vector2.X * (float)Game1.tileSize, vector2.Y * (float)Game1.tileSize), Color.White, 7, Game1.random.NextDouble() < 0.5, 125f, 0, -1, -1f, -1, 0)); Game1.currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite(14, new Vector2(vector2.X * (float)Game1.tileSize, vector2.Y * (float)Game1.tileSize), Color.White, 7, Game1.random.NextDouble() < 0.5, 50f, 0, -1, -1f, -1, 0)); } } if (this.indexOfHarvest == 421) { this.indexOfHarvest = 431; num1 = random.Next(1, 4); } for (int index = 0; index < num1 - 1; ++index) { if (junimoHarvester == null) { AdditionalCropsFramework.Utilities.createObjectDebris((Item) new ModularCropObject(this.spriteSheet.getHelper(), this.indexOfHarvest, this.getAmountForHarvest(), this.cropObjectTexture, this.cropObjectData), xTile, yTile, xTile, yTile, -1, this.getQualityOfCrop(), 1); } else { junimoHarvester.tryToAddItemToHut((Item) new ModularCropObject(this.spriteSheet.getHelper(), this.indexOfHarvest, this.getAmountForHarvest(), this.cropObjectTexture, this.cropObjectData)); } } float num8 = (float)(16.0 * Math.Log(0.018 * (double)Convert.ToInt32(this.experienceGainWhenHarvesting + 1.0), Math.E)); if (junimoHarvester == null) { Game1.player.gainExperience(0, (int)Math.Round((double)num8)); } if (this.regrowAfterHarvest == -1) { return(true); } this.dayOfCurrentPhase = this.regrowAfterHarvest; this.fullyGrown = true; } } label_86: return(false); }
/// <summary>Get whether the dirt has any fertilizer of the given type.</summary> /// <param name="dirt">The dirt to check.</param> /// <param name="fertilizer">The fertilizer data.</param> public static bool HasFertilizer(this HoeDirt dirt, FertilizerData fertilizer) { return(fertilizer != null && dirt.HasFertilizer(fertilizer.Key)); }
/// <summary> /// Override to lift the pot back when an empty spot on the tool bar is selected. /// </summary> /// <param name="__result"></param> /// <returns></returns> public static bool PressUseToolButton(ref bool __result) { if (Game1.fadeToBlack) { return(false); } Game1.player.toolPower = 0; Game1.player.toolHold = 0; if (Game1.player.CurrentTool == null && Game1.player.ActiveObject == null) { Vector2 key = key = Game1.currentCursorTile; if (!Game1.currentLocation.Objects.ContainsKey(key) || !(Game1.currentLocation.Objects[key] is IndoorPot) || !Utility.tileWithinRadiusOfPlayer((int)key.X, (int)key.Y, 1, Game1.player)) { key = Game1.player.GetToolLocation(false) / 64f; key.X = (float)(int)key.X; key.Y = (float)(int)key.Y; } if (Game1.currentLocation.Objects.ContainsKey(key)) { Object @object = Game1.currentLocation.Objects[key]; if (@object is IndoorPot pot) { pot.performRemoveAction(pot.TileLocation, Game1.currentLocation); Game1.currentLocation.Objects.Remove(pot.TileLocation); HoeDirt potHoeDirt = pot.hoeDirt.Value; if (potHoeDirt.crop != null) { CurrentHeldIndoorPot = new HeldIndoorPot(pot.TileLocation); HoeDirt holdenHoeDirt = CurrentHeldIndoorPot.hoeDirt.Value; holdenHoeDirt.crop = potHoeDirt.crop; holdenHoeDirt.fertilizer.Value = potHoeDirt.fertilizer.Value; ShakeCrop(holdenHoeDirt, pot.TileLocation); Game1.player.Stamina -= ((float)DataLoader.ModConfig.CropTransplantEnergyCost - (float)Game1.player.FarmingLevel * DataLoader.ModConfig.CropTransplantEnergyCost / 20f); Game1.player.ActiveObject = CurrentHeldIndoorPot; Events.GameLoop.UpdateTicked += OnUpdateTicked; } else if (pot.bush.Value is Bush bush) { CurrentHeldIndoorPot = new HeldIndoorPot(pot.TileLocation); CurrentHeldIndoorPot.bush.Value = bush; Bush holdenBush = CurrentHeldIndoorPot.bush.Value; ShakeBush(holdenBush); Game1.player.Stamina -= ((float)DataLoader.ModConfig.CropTransplantEnergyCost - (float)Game1.player.FarmingLevel * DataLoader.ModConfig.CropTransplantEnergyCost / 20f); Game1.player.ActiveObject = CurrentHeldIndoorPot; Events.GameLoop.UpdateTicked += OnUpdateTicked; } else { Game1.player.ActiveObject = (Object)RegularPotObject.getOne(); } __result = true; return(false); } } } return(true); }
private static void DrawMultiFertilizer(SpriteBatch spriteBatch, Texture2D tex, Vector2 pos, Rectangle?sourceRect, Color col, float rot, Vector2 origin, float scale, SpriteEffects fx, float depth, HoeDirt __instance) { List <FertilizerData> fertilizers = new List <FertilizerData>(); foreach (string type in DirtHelper.GetFertilizerTypes()) { if (__instance.TryGetFertilizer(type, out FertilizerData fertilizer)) { fertilizers.Add(fertilizer); } } foreach (FertilizerData fertilizer in fertilizers) { spriteBatch.Draw(Game1.mouseCursors, pos, new Rectangle(173 + fertilizer.SpriteIndex / 3 * 16, 462 + fertilizer.SpriteIndex % 3 * 16, 16, 16), Color.White, 0f, Vector2.Zero, 4f, SpriteEffects.None, 1.89E-08f); } // Draw custom fertilizer, if needed. if (__instance.fertilizer.Value > 0) { spriteBatch.Draw(tex, pos, sourceRect, col, rot, origin, scale, fx, depth); } }
private static bool HasPaddyFertilizer(HoeDirt dirt) { ModEntry.ModMonitor.DebugOnlyLog($"Checking {dirt.fertilizer.Value} against ID {ModEntry.PaddyCropFertilizerID}"); return(ModEntry.PaddyCropFertilizerID != -1 && dirt.fertilizer.Value == ModEntry.PaddyCropFertilizerID); }
public static void NewGrowthDays(GameLocation location, Vector2 relativeVector, bool isScarecrow, int offset, Farmer who) { //Find all HoeDirt within radius //relativeVector is Vector of HoeDirt having seed planted or scarecrow being placed //Create a list of KVP's of Hoedirts that are growing pumpkins List <KeyValuePair <Vector2, HoeDirt> > hoeDirtList = new List <KeyValuePair <Vector2, HoeDirt> >(); if (isScarecrow) { foreach (KeyValuePair <Vector2, TerrainFeature> pair in location.terrainFeatures.Pairs) { TerrainFeature terrain = pair.Value; Crop crop = (terrain is HoeDirt ? (terrain as HoeDirt).crop : null); bool isGrowingPumpkin = crop != null && crop.indexOfHarvest.Value == 276 && !crop.fullyGrown.Value; if (isGrowingPumpkin && Vector2.Distance(pair.Key, relativeVector) < 9.0) { hoeDirtList.Add(new KeyValuePair <Vector2, HoeDirt>(pair.Key, (pair.Value as HoeDirt))); } } } else { HoeDirt dirt = (location.terrainFeatures[relativeVector] is HoeDirt ? location.terrainFeatures[relativeVector] as HoeDirt : null); if (dirt != null) { hoeDirtList.Add(new KeyValuePair <Vector2, HoeDirt>(relativeVector, dirt)); } } //Set new phaseDays foreach (KeyValuePair <Vector2, HoeDirt> dirtPair in hoeDirtList) { //Get number of scarecrows in range of each HoeDirt int numScarecrows = 0; foreach (KeyValuePair <Vector2, StardewValley.Object> objPair in location.objects.Pairs) { if (objPair.Value.Name.Contains("The Pumpkin King") && Vector2.Distance(dirtPair.Key, objPair.Key) < 9.0) { numScarecrows++; } } numScarecrows += offset; Crop crop = dirtPair.Value.crop; int fertlizerType = dirtPair.Value.fertilizer.Value; int pumpkinGrowthDays = 13; int growthDayChange = 0; // Get total change for all modifiers // Max change is 60% (5 day growth) float totalPercentChange = 0.25f * numScarecrows; totalPercentChange += (fertlizerType == 465 ? 0.1f : (fertlizerType == 466 ? 0.25f : 0)); totalPercentChange += (who.professions.Contains(5) ? 0.1f : 0); growthDayChange = (int)Math.Ceiling((double)pumpkinGrowthDays * (double)Math.Min(0.6f, totalPercentChange)); // Reset pumpkin phase days to normal amounts; IList <int> phaseDays = new List <int> { 1, 2, 3, 4, 3, 99999 }; crop.phaseDays.Set(phaseDays); // Set new phaseDays while (growthDayChange > 0) { int i = 0; while (i < crop.phaseDays.Count - 1) { if (crop.phaseDays[i] > 1) { crop.phaseDays[i]--; --growthDayChange; } if (growthDayChange <= 0 || (i == crop.phaseDays.Count - 2 && crop.phaseDays[i] == 1)) { break; } i++; } } } }
public PreDayUpdateHoeDirtEvent(HoeDirt hoeDirt, GameLocation environment, Vector2 tilelocation) { HoeDirt = hoeDirt; Environment = environment; TileLocation = tilelocation; }
public static bool DayUpdatePrefix(HoeDirt __instance, ref int __state) { __state = __instance.state.Value; return(true); }
private static bool TryToPlaceItem(GameLocation location, Item item, int x, int y) { if (item == null || item is Tool) { return(false); } Vector2 key = new Vector2((float)(x / 64), (float)(y / 64)); if (Utility.playerCanPlaceItemHere(location, item, x, y, Game1.player)) { //if (item is Furniture) // Game1.player.ActiveObject = (Object)null; if (((Object)item).placementAction(location, x, y, Game1.player)) { Game1.player.reduceActiveItemByOne(); } else if (item is Furniture) { Game1.player.ActiveObject = (Object)(item as Furniture); } else if (item is Wallpaper) { return(false); } return(true); } if (Utility.isPlacementForbiddenHere(location) && item != null && item.isPlaceable()) { Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:Object.cs.13053")); } else if (item is Furniture) { switch ((item as Furniture).GetAdditionalFurniturePlacementStatus(location, x, y, Game1.player)) { case 1: Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:Furniture.cs.12629")); break; case 2: Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:Furniture.cs.12632")); break; case 3: Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:Furniture.cs.12633")); break; case 4: Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:Furniture.cs.12632")); break; } } if (item.Category == -19 && location.terrainFeatures.ContainsKey(key) && location.terrainFeatures[key] is HoeDirt) { HoeDirt terrainFeature = location.terrainFeatures[key] as HoeDirt; if ((int)((NetFieldBase <int, NetInt>)(location.terrainFeatures[key] as HoeDirt).fertilizer) != 0) { if ((NetFieldBase <int, NetInt>)(location.terrainFeatures[key] as HoeDirt).fertilizer != item.parentSheetIndex) { Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:HoeDirt.cs.13916-2")); } return(false); } if (((int)((NetFieldBase <int, NetInt>)item.parentSheetIndex) == 368 || (int)((NetFieldBase <int, NetInt>)item.parentSheetIndex) == 368) && (terrainFeature.crop != null && (int)((NetFieldBase <int, NetInt>)terrainFeature.crop.currentPhase) != 0)) { Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:HoeDirt.cs.13916")); return(false); } } return(false); }
public static void Postfix(Crop __instance, int xTile, int yTile, HoeDirt soil, JunimoHarvester junimoHarvester) { soil.fertilizer.Value = 0; }
private static void AdvanceCropOneStep(GameLocation loc, HoeDirt h, Vector2 position) { Crop currCrop = h.crop; int xPos = (int)position.X; int yPos = (int)position.Y; if (currCrop == null) { return; } //due to how this will be called, we do need to some checking if (!loc.Name.Equals("Greenhouse") && (currCrop.dead.Value || !currCrop.seasonsToGrowIn.Contains(Game1.currentSeason))) { currCrop.dead.Value = true; } else { if (h.state.Value == HoeDirt.watered) { //get the day of the current phase - if it's fully grown, we can just leave it here. if (currCrop.fullyGrown.Value) { currCrop.dayOfCurrentPhase.Value = currCrop.dayOfCurrentPhase.Value - 1; } else { //check to sere what the count of current days is int phaseCount = 0; //get the count of days in the current phase if (currCrop.phaseDays.Count > 0) { phaseCount = currCrop.phaseDays[Math.Min(currCrop.phaseDays.Count - 1, currCrop.currentPhase.Value)]; } else { phaseCount = 0; } currCrop.dayOfCurrentPhase.Value = Math.Min(currCrop.dayOfCurrentPhase.Value + 1, phaseCount); //check phases if (currCrop.dayOfCurrentPhase.Value >= phaseCount && currCrop.currentPhase.Value < currCrop.phaseDays.Count - 1) { currCrop.currentPhase.Value++; currCrop.dayOfCurrentPhase.Value = 0; } //skip negative day or 0 day crops. while (currCrop.currentPhase.Value < currCrop.phaseDays.Count - 1 && currCrop.phaseDays.Count > 0 && currCrop.phaseDays[currCrop.currentPhase.Value] <= 0) { currCrop.currentPhase.Value++; } //handle wild crops if (currCrop.isWildSeedCrop() && currCrop.phaseToShow.Value == -1 && currCrop.currentPhase.Value > 0) { currCrop.phaseToShow.Value = Game1.random.Next(1, 7); } //and now giant crops double giantChance = new Random((int)Game1.uniqueIDForThisGame + (int)Game1.stats.daysPlayed + xPos * 2000 + yPos).NextDouble(); if (loc is Farm && currCrop.currentPhase.Value == currCrop.phaseDays.Count - 1 && IsValidGiantCrop(currCrop.indexOfHarvest.Value) && giantChance <= 0.01) { for (int i = xPos - 1; i <= xPos + 1; i++) { for (int j = yPos - 1; j <= yPos + 1; j++) { Vector2 tile = new Vector2(i, j); if (!loc.terrainFeatures.ContainsKey(tile) || !(loc.terrainFeatures[tile] is HoeDirt) || (loc.terrainFeatures[tile] as HoeDirt).crop?.indexOfHarvest == currCrop.indexOfHarvest) { return; //no longer needs to process. } } } //replace for giant crops. for (int i = xPos - 1; i <= xPos + 1; i++) { for (int j = yPos - 1; j <= yPos + 1; j++) { Vector2 tile = new Vector2(i, j); (loc.terrainFeatures[tile] as HoeDirt).crop = null; } } (loc as Farm).resourceClumps.Add(new GiantCrop(currCrop.indexOfHarvest.Value, new Vector2(xPos - 1, yPos - 1))); } } } //process some edge cases for non watered crops. if (currCrop.fullyGrown.Value && currCrop.dayOfCurrentPhase.Value > 0 || currCrop.currentPhase.Value < currCrop.phaseDays.Count - 1 || !currCrop.isWildSeedCrop()) { return; //stop processing } //replace wild crops** //remove any object here. o.O loc.objects.Remove(position); string season = Game1.currentSeason; switch (currCrop.whichForageCrop.Value) { case 495: season = "spring"; break; case 496: season = "summer"; break; case 497: season = "fall"; break; case 498: season = "winter"; break; } loc.objects.Add(position, new SObject(position, currCrop.getRandomWildCropForSeason(season), 1) { IsSpawnedObject = true, CanBeGrabbed = true }); //the normal iteration has a safe-call that isn't neded here } }
private void waterHoeDirt(HoeDirt hd) { --wateringCharges.Value; hd.state.Value = HoeDirt.watered; currentLocation.playSound("waterSlosh"); }
// TODO: Make this do IL hooking instead of pre + no execute original public static bool Prefix(HoeDirt __instance, GameLocation environment, Vector2 tileLocation) { dayUpdate(__instance, environment, tileLocation); return(false); }
/// <summary>The method to call after <see cref="Crop.harvest"/>.</summary> private static void After_Harvest(Crop __instance, int xTile, int yTile, HoeDirt soil, JunimoHarvester junimoHarvester, int __state) { soil.fertilizer.Value = __state; }
/// <summary>Get whether the dirt has any fertilizer of the given type.</summary> /// <param name="dirt">The dirt to check.</param> /// <param name="key">The fertilizer type key.</param> public static bool HasFertilizer(this HoeDirt dirt, string key) { return(dirt.modData.ContainsKey(key)); }
private void DrawHoverTooltip(object sender, EventArgs e) { //StardewValley.Object tile = Game1.currentLocation.Objects.SafeGet(Game1.currentCursorTile); //TerrainFeature feature = null; if (_currentTileBuilding != null) { if (_currentTileBuilding is Mill millBuilding) { if (!millBuilding.input.isEmpty()) { int wheatCount = 0; int beetCount = 0; foreach (var item in millBuilding.input.items) { switch (item.Name) { case "Wheat": wheatCount = item.Stack; break; case "Beet": beetCount = item.Stack; break; } } StringBuilder builder = new StringBuilder(); if (wheatCount > 0) { builder.Append(wheatCount + " wheat"); } if (beetCount > 0) { if (wheatCount > 0) { builder.Append(Environment.NewLine); } builder.Append(beetCount + " beets"); } if (builder.Length > 0) { IClickableMenu.drawHoverText( Game1.spriteBatch, builder.ToString(), Game1.smallFont); } } } } else if (_currentTile != null && (!_currentTile.bigCraftable || _currentTile.minutesUntilReady > 0)) { if (_currentTile.bigCraftable && _currentTile.minutesUntilReady > 0 && _currentTile.Name != "Heater") { StringBuilder hoverText = new StringBuilder(); if (_currentTile is Cask) { Cask currentCask = _currentTile as Cask; hoverText.Append((int)(currentCask.daysToMature / currentCask.agingRate)) .Append(" " + _helper.SafeGetString( LanguageKeys.DaysToMature)); } else if (_currentTile is StardewValley.Buildings.Mill) { } else { int hours = _currentTile.minutesUntilReady / 60; int minutes = _currentTile.minutesUntilReady % 60; if (hours > 0) { hoverText.Append(hours).Append(" ") .Append(_helper.SafeGetString( LanguageKeys.Hours)) .Append(", "); } hoverText.Append(minutes).Append(" ") .Append(_helper.SafeGetString( LanguageKeys.Minutes)); } IClickableMenu.drawHoverText( Game1.spriteBatch, hoverText.ToString(), Game1.smallFont); } } else if (_terrain != null) { if (_terrain is HoeDirt) { HoeDirt hoeDirt = _terrain as HoeDirt; if (hoeDirt.crop != null && !hoeDirt.crop.dead) { int num = 0; if (hoeDirt.crop.fullyGrown && hoeDirt.crop.dayOfCurrentPhase > 0) { num = hoeDirt.crop.dayOfCurrentPhase; } else { for (int i = 0; i < hoeDirt.crop.phaseDays.Count - 1; ++i) { if (hoeDirt.crop.currentPhase == i) { num -= hoeDirt.crop.dayOfCurrentPhase; } if (hoeDirt.crop.currentPhase <= i) { num += hoeDirt.crop.phaseDays[i]; } } } if (hoeDirt.crop.indexOfHarvest > 0) { String hoverText = _indexOfCropNames.SafeGet(hoeDirt.crop.indexOfHarvest); if (String.IsNullOrEmpty(hoverText)) { hoverText = new StardewValley.Object(new Debris(hoeDirt.crop.indexOfHarvest, Vector2.Zero, Vector2.Zero).chunkType, 1).DisplayName; _indexOfCropNames.Add(hoeDirt.crop.indexOfHarvest, hoverText); } StringBuilder finalHoverText = new StringBuilder(); finalHoverText.Append(hoverText).Append(": "); if (num > 0) { finalHoverText.Append(num).Append(" ") .Append(_helper.SafeGetString( LanguageKeys.Days)); } else { finalHoverText.Append(_helper.SafeGetString( LanguageKeys.ReadyToHarvest)); } IClickableMenu.drawHoverText( Game1.spriteBatch, finalHoverText.ToString(), Game1.smallFont); } } } else if (_terrain is FruitTree) { FruitTree tree = _terrain as FruitTree; if (tree.daysUntilMature > 0) { IClickableMenu.drawHoverText( Game1.spriteBatch, tree.daysUntilMature + " " + _helper.SafeGetString( LanguageKeys.DaysToMature), Game1.smallFont); } } } }
/// <summary>Get the custom fields for a crop.</summary> /// <param name="dirt">The dirt the crop is planted in, if applicable.</param> /// <param name="crop">The crop to represent.</param> /// <param name="isSeed">Whether the crop being displayed is for an unplanted seed.</param> private IEnumerable <ICustomField> GetCropFields(HoeDirt dirt, Crop crop, bool isSeed) { if (crop == null) { yield break; } var data = new CropDataParser(crop, isPlanted: !isSeed); bool isForage = crop.whichForageCrop.Value > 0 && crop.fullyGrown.Value; // show crop fields for growing mixed seeds // add next-harvest field if (!isSeed) { // get next harvest SDate nextHarvest = data.GetNextHarvest(); // generate field string summary; if (data.CanHarvestNow) { summary = I18n.Generic_Now(); } else if (!Game1.currentLocation.SeedsIgnoreSeasonsHere() && !data.Seasons.Contains(nextHarvest.Season)) { summary = I18n.Crop_Harvest_TooLate(date: this.Stringify(nextHarvest)); } else { summary = $"{this.Stringify(nextHarvest)} ({this.GetRelativeDateStr(nextHarvest)})"; } yield return(new GenericField(I18n.Crop_Harvest(), summary)); } // crop summary if (!isForage) { List <string> summary = new List <string>(); // harvest if (!crop.forageCrop.Value) { summary.Add(data.HasMultipleHarvests ? I18n.Crop_Summary_HarvestOnce(daysToFirstHarvest: data.DaysToFirstHarvest) : I18n.Crop_Summary_HarvestMulti(daysToFirstHarvest: data.DaysToFirstHarvest, daysToNextHarvests: data.DaysToSubsequentHarvest) ); } // seasons summary.Add(I18n.Crop_Summary_Seasons(seasons: string.Join(", ", I18n.GetSeasonNames(data.Seasons)))); // drops if (crop.minHarvest != crop.maxHarvest && crop.chanceForExtraCrops.Value > 0) { summary.Add(I18n.Crop_Summary_DropsXToY(min: crop.minHarvest.Value, max: crop.maxHarvest.Value, percent: (int)Math.Round(crop.chanceForExtraCrops.Value * 100, 2))); } else if (crop.minHarvest.Value > 1) { summary.Add(I18n.Crop_Summary_DropsX(count: crop.minHarvest.Value)); } // crop sale price Item drop = data.GetSampleDrop(); summary.Add(I18n.Crop_Summary_SellsFor(price: GenericField.GetSaleValueString(this.GetSaleValue(drop, false), 1))); // generate field yield return(new GenericField(I18n.Crop_Summary(), "-" + string.Join($"{Environment.NewLine}-", summary))); } // dirt water/fertilizer state if (dirt != null && !isForage) { // watered yield return(new GenericField(I18n.Crop_Watered(), this.Stringify(dirt.state.Value == HoeDirt.watered))); // fertilizer yield return(new GenericField(I18n.Crop_Fertilized(), dirt.fertilizer.Value switch { HoeDirt.noFertilizer => this.Stringify(false), HoeDirt.speedGro => GameI18n.GetObjectName(465), // Speed-Gro HoeDirt.superSpeedGro => GameI18n.GetObjectName(466), // Deluxe Speed-Gro HoeDirt.hyperSpeedGro => GameI18n.GetObjectName(918), // Hyper Speed-Gro HoeDirt.fertilizerLowQuality => GameI18n.GetObjectName(368), // Basic Fertilizer HoeDirt.fertilizerHighQuality => GameI18n.GetObjectName(369), // Quality Fertilizer HoeDirt.fertilizerDeluxeQuality => GameI18n.GetObjectName(919), // Deluxe Fertilizer HoeDirt.waterRetentionSoil => GameI18n.GetObjectName(370), // Basic Retaining Soil HoeDirt.waterRetentionSoilQuality => GameI18n.GetObjectName(371), // Quality Retaining Soil HoeDirt.waterRetentionSoilDeluxe => GameI18n.GetObjectName(920), // Deluxe Retaining Soil _ => I18n.Generic_Unknown() }));
private static void DoImport() { if (!File.Exists(Path.Combine(SHelper.DirectoryPath, "assets", "import.tmx"))) { SMonitor.Log("import file not found", LogLevel.Error); return; } Map map = SHelper.Content.Load <Map>("assets/import.tmx"); if (map == null) { SMonitor.Log("map is null", LogLevel.Error); return; } Dictionary <string, Layer> layersById = AccessTools.FieldRefAccess <Map, Dictionary <string, Layer> >(map, "m_layersById"); if (layersById.TryGetValue("Flooring", out Layer flooringLayer)) { for (int y = 0; y < flooringLayer.LayerHeight; y++) { for (int x = 0; x < flooringLayer.LayerWidth; x++) { if (flooringLayer.Tiles[x, y] != null && flooringLayer.Tiles[x, y].TileIndex >= 0) { Game1.player.currentLocation.terrainFeatures[new Vector2(x, y)] = new Flooring(flooringLayer.Tiles[x, y].TileIndex); } } } } if (trainTrackApi != null && layersById.TryGetValue("TrainTracks", out Layer trackLayer)) { foreach (var v in Game1.player.currentLocation.terrainFeatures.Keys) { trainTrackApi.RemoveTrack(Game1.player.currentLocation, v); } for (int y = 0; y < trackLayer.LayerHeight; y++) { for (int x = 0; x < trackLayer.LayerWidth; x++) { if (trackLayer.Tiles[x, y] != null && trackLayer.Tiles[x, y].TileIndex >= 0) { PropertyValue switchData; PropertyValue speedData; trackLayer.Tiles[x, y].Properties.TryGetValue("Switches", out switchData); if (switchData != null) { SMonitor.Log($"Got switch data for tile {x},{y}: {switchData}"); } trackLayer.Tiles[x, y].Properties.TryGetValue("Speed", out speedData); int speed = -1; if (speedData != null && int.TryParse(speedData, out speed)) { SMonitor.Log($"Got speed for tile {x},{y}: {speed}"); } trainTrackApi.TryPlaceTrack(Game1.currentLocation, new Vector2(x, y), trackLayer.Tiles[x, y].TileIndex, switchData == null ? null : switchData.ToString(), speed, true); } } } } if (layersById.TryGetValue("FluteBlocks", out Layer fluteLayer)) { foreach (var v in Game1.player.currentLocation.objects.Keys) { if (Game1.player.currentLocation.objects[v] is not null && Game1.player.currentLocation.objects[v].Name == "Flute Block") { Game1.player.currentLocation.objects.Remove(v); } } for (int y = 0; y < fluteLayer.LayerHeight; y++) { for (int x = 0; x < fluteLayer.LayerWidth; x++) { if (fluteLayer.Tiles[x, y] != null && fluteLayer.Tiles[x, y].TileIndex >= 0 && !Game1.player.currentLocation.objects.ContainsKey(new Vector2(x, y))) { var block = new Object(new Vector2(x, y), 464, 1); block.preservedParentSheetIndex.Value = fluteLayer.Tiles[x, y].TileIndex % 24 * 100; if (fluteBlockApi != null) { var tone = fluteBlockApi.GetFluteBlockToneFromIndex(fluteLayer.Tiles[x, y].TileIndex / 24); if (tone != null) { block.modData["aedenthorn.AdvancedFluteBlocks/tone"] = tone; } } Game1.player.currentLocation.objects[new Vector2(x, y)] = block; } } } } if (layersById.TryGetValue("DrumBlocks", out Layer drumLayer)) { foreach (var v in Game1.player.currentLocation.objects.Keys) { if (Game1.player.currentLocation.objects[v] is not null && Game1.player.currentLocation.objects[v].Name == "Drum Block") { Game1.player.currentLocation.objects.Remove(v); } } for (int y = 0; y < drumLayer.LayerHeight; y++) { for (int x = 0; x < drumLayer.LayerWidth; x++) { if (drumLayer.Tiles[x, y] != null && drumLayer.Tiles[x, y].TileIndex >= 0 && !Game1.player.currentLocation.objects.ContainsKey(new Vector2(x, y))) { var block = new Object(new Vector2(x, y), 463, 1); block.preservedParentSheetIndex.Value = drumLayer.Tiles[x, y].TileIndex; Game1.player.currentLocation.objects[new Vector2(x, y)] = block; } } } } if (layersById.TryGetValue("Objects", out Layer objLayer)) { var dict = SHelper.Content.Load <Dictionary <int, string> >("Data/Crops", ContentSource.GameContent); for (int y = 0; y < objLayer.LayerHeight; y++) { for (int x = 0; x < objLayer.LayerWidth; x++) { if (objLayer.Tiles[x, y] != null && objLayer.Tiles[x, y].TileIndex >= 0 && !Game1.player.currentLocation.terrainFeatures.ContainsKey(new Vector2(x, y)) && !Game1.player.currentLocation.objects.ContainsKey(new Vector2(x, y)) && !Game1.player.currentLocation.objects.ContainsKey(new Vector2(x, y))) { if (dict.TryGetValue(objLayer.Tiles[x, y].TileIndex, out string cropData)) { Crop crop = new Crop(objLayer.Tiles[x, y].TileIndex, x, y); HoeDirt dirt = new HoeDirt(1, crop); Game1.player.currentLocation.terrainFeatures.Add(new Vector2(x, y), dirt); continue; } var cropkvp = dict.FirstOrDefault(kvp => kvp.Value.Split('/')[3] == objLayer.Tiles[x, y].TileIndex + ""); if (cropkvp.Value != null) { Crop crop = new Crop(cropkvp.Key, x, y); crop.growCompletely(); HoeDirt dirt = new HoeDirt(1, crop); Game1.player.currentLocation.terrainFeatures.Add(new Vector2(x, y), dirt); } else { var obj = new Object(new Vector2(x, y), objLayer.Tiles[x, y].TileIndex, 1); Game1.player.currentLocation.objects[new Vector2(x, y)] = obj; } } } } } if (layersById.TryGetValue("Trees", out Layer treeLayer)) { for (int y = 0; y < treeLayer.LayerHeight; y++) { for (int x = 0; x < treeLayer.LayerWidth; x++) { Tree tree; if (treeLayer.Tiles[x, y] != null && treeLayer.Tiles[x, y].TileIndex >= 9 && !Game1.player.currentLocation.terrainFeatures.ContainsKey(new Vector2(x, y))) { switch (treeLayer.Tiles[x, y].TileIndex) { case 9: tree = new Tree(1, 5); break; case 10: tree = new Tree(2, 5); break; case 11: tree = new Tree(3, 5); break; case 12: tree = new Tree(6, 5); break; case 31: tree = new Tree(7, 5); break; case 32: tree = new Tree(9, 5); break; default: continue; } Game1.player.currentLocation.terrainFeatures[new Vector2(x, y)] = tree; } } } } }
public override void DoFunction(GameLocation location, int x, int y, int power, StardewValley.Farmer who) { this.lastUser = who; //base.DoFunction(location, x, y, power, who); power = who.toolPower; who.stopJittering(); List <Vector2> source = IridiumTiles.AFTiles(new Vector2((float)(x / Game1.tileSize), (float)(y / Game1.tileSize)), power, who); if (location.doesTileHaveProperty(x / Game1.tileSize, y / Game1.tileSize, "Water", "Back") != null || location.doesTileHaveProperty(x / Game1.tileSize, y / Game1.tileSize, "WaterSource", "Back") != null || location is BuildableGameLocation && (location as BuildableGameLocation).getBuildingAt(source.First <Vector2>()) != null && ((location as BuildableGameLocation).getBuildingAt(source.First <Vector2>()).buildingType.Equals("Well") && (location as BuildableGameLocation).getBuildingAt(source.First <Vector2>()).daysOfConstructionLeft <= 0)) { who.jitterStrength = 0.5f; switch (this.upgradeLevel) { case 0: this.waterCanMax = 40; break; case 1: this.waterCanMax = 55; break; case 2: this.waterCanMax = 70; break; case 3: this.waterCanMax = 85; break; case 4: this.waterCanMax = 100; break; } this.waterLeft = this.waterCanMax; Game1.playSound("slosh"); DelayedAction.playSoundAfterDelay("glug", 250); } else if (this.waterLeft > 0) { who.Stamina -= (float)(2 * (power + 1)) - (float)who.FarmingLevel * 0.1f; int num = 0; foreach (Vector2 index in source) { //UP function in process if (location.terrainFeatures.ContainsKey(index)) { if (location.terrainFeatures.ContainsKey(index) && location.terrainFeatures[index].GetType() == typeof(HoeDirt)) { HoeDirt joeDirt = new HoeDirt(); if (location.terrainFeatures.ContainsKey(index) && location.terrainFeatures[index].GetType() == typeof(HoeDirt)) { joeDirt = (HoeDirt)location.terrainFeatures[index]; } IridiumTiles.perfWaterAction(this, 0, index, (GameLocation)null, joeDirt); } location.terrainFeatures[index].performToolAction((Tool)this, 0, index, (GameLocation)null); } if (location.objects.ContainsKey(index)) { location.Objects[index].performToolAction((Tool)this); } location.performToolAction((Tool)this, (int)index.X, (int)index.Y); location.temporarySprites.Add(new TemporaryAnimatedSprite(13, new Vector2(index.X * (float)Game1.tileSize, index.Y * (float)Game1.tileSize), Color.White, 10, Game1.random.NextDouble() < 0.5, 70f, 0, Game1.tileSize, (float)(((double)index.Y * (double)Game1.tileSize + (double)(Game1.tileSize / 2)) / 10000.0 - 0.00999999977648258), -1, 0) { delayBeforeAnimationStart = 200 + num * 10 }); ++num; } this.waterLeft -= power + 1; Vector2 vector2 = new Vector2(who.position.X - (float)(Game1.tileSize / 2) - (float)Game1.pixelZoom, who.position.Y - (float)(Game1.tileSize / 4) - (float)Game1.pixelZoom); switch (who.facingDirection) { case 0: vector2 = Vector2.Zero; break; case 1: vector2.X += (float)(Game1.tileSize * 2 + Game1.pixelZoom * 2); break; case 2: vector2.X += (float)(Game1.tileSize + Game1.pixelZoom * 2); vector2.Y += (float)(Game1.tileSize / 2 + Game1.pixelZoom * 3); break; } if (vector2.Equals(Vector2.Zero)) { return; } for (int index = 0; index < 30; ++index) { location.temporarySprites.Add(new TemporaryAnimatedSprite(Game1.staminaRect, new Microsoft.Xna.Framework.Rectangle(0, 0, 1, 1), 999f, 1, 999, vector2 + new Vector2((float)(Game1.random.Next(-3, 0) * Game1.pixelZoom), (float)(Game1.random.Next(2) * Game1.pixelZoom)), false, false, (float)(who.GetBoundingBox().Bottom + Game1.tileSize / 2) / 10000f, 0.04f, Game1.random.NextDouble() < 0.5 ? Color.DeepSkyBlue : Color.LightBlue, (float)Game1.pixelZoom, 0.0f, 0.0f, 0.0f, false) { delayBeforeAnimationStart = index * 15, motion = new Vector2((float)Game1.random.Next(-10, 11) / 100f, 0.5f), acceleration = new Vector2(0.0f, 0.1f) }); } } else { who.doEmote(4); Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:WateringCan.cs.14335")); } }
public static void DestroyCropReplacement(HoeDirt hoeDirt, Vector2 tileLocation, bool showAnimation, GameLocation location) { // We don't want it to ever do anything. // Crops wither out of season anyways. }
/// <summary>The method to call after <see cref="HoeDirt.applySpeedIncreases"/>.</summary> private static void After_ApplySpeedIncreases(HoeDirt __instance, Farmer who) { __instance.fertilizer.Value = 0; }
public override void DoFunction(GameLocation location, int x, int y, int power, Farmer who) { this.Refresh_Tools(); Tool tool; IDictionary <string, object> properties = this.Get_Properties(x, y); string toolName = ""; int xtile = (int)x / Game1.tileSize; int ytile = (int)y / Game1.tileSize; toolName = (string)properties["string_useTool"]; if (toolName == null) { if ((bool)properties["bool_canPlant"]) { try { if (Game1.player.CurrentItem != null) { HoeDirt dirt = (HoeDirt)properties["hoedirt_dirt"]; if (Game1.player.CurrentItem.Category == StardewValley.Object.SeedsCategory) { dirt.plant(Game1.player.CurrentItem.parentSheetIndex.Get(), xtile, ytile, Game1.player, false, Game1.currentLocation); Game1.player.consumeObject(Game1.player.CurrentItem.parentSheetIndex.Get(), 1); } else if (Game1.player.CurrentItem.Category == StardewValley.Object.fertilizerCategory) { dirt.plant(Game1.player.CurrentItem.parentSheetIndex.Get(), xtile, ytile, Game1.player, true, Game1.currentLocation); Game1.player.consumeObject(Game1.player.CurrentItem.parentSheetIndex.Get(), 1); } } else { location.checkAction(new Location(xtile, ytile), Game1.viewport, Game1.player); } } catch (System.Collections.Generic.KeyNotFoundException) { Game1.addHUDMessage(new HUDMessage($"{Game1.player.CurrentItem} {Game1.player.CurrentItem.parentSheetIndex.Get()} 201")); return; } } return; } try { tool = this.attachedTools[toolName]; } catch (System.Collections.Generic.KeyNotFoundException) { if (toolName == "grab") { location.checkAction(new Location(xtile, ytile), Game1.viewport, Game1.player); } else { Game1.addHUDMessage(new HUDMessage($"{toolName} not found")); } return; } if (toolName == "melee") { //TODO this doesn't land at the right location //this.scythe.DoDamage(Game1.currentLocation, x, y, 0, power, who); return; } else { tool.DoFunction(location, x, y, power, who); return; } }
private static void DrawMultiFertilizer(SpriteBatch spriteBatch, Texture2D tex, Vector2 pos, Rectangle?sourceRect, Color col, float rot, Vector2 origin, float scale, SpriteEffects fx, float depth, HoeDirt __instance) { List <int> fertilizers = new List <int>(); if (__instance.modData.TryGetValue(Mod.KeyFert, out string rawFertValue)) { int level = int.Parse(rawFertValue); int index = 0; switch (level) { case 1: index = 368; break; case 2: index = 369; break; case 3: index = 919; break; } if (index != 0) { fertilizers.Add(index); } } if (__instance.modData.TryGetValue(Mod.KeyRetain, out string rawRetainerValue)) { int level = int.Parse(rawRetainerValue); int index = 0; switch (level) { case 1: index = 370; break; case 2: index = 371; break; case 3: index = 920; break; } if (index != 0) { fertilizers.Add(index); } } if (__instance.modData.TryGetValue(Mod.KeySpeed, out string rawSpeedValue)) { int level = int.Parse(rawSpeedValue); int index = 0; switch (level) { case 1: index = 465; break; case 2: index = 466; break; case 3: index = 918; break; } if (index != 0) { fertilizers.Add(index); } } foreach (int fertilizer in fertilizers) { if (fertilizer != 0) { int fertilizerIndex = 0; switch (fertilizer) { case 369: fertilizerIndex = 1; break; case 370: fertilizerIndex = 3; break; case 371: fertilizerIndex = 4; break; case 920: fertilizerIndex = 5; break; case 465: fertilizerIndex = 6; break; case 466: fertilizerIndex = 7; break; case 918: fertilizerIndex = 8; break; case 919: fertilizerIndex = 2; break; } spriteBatch.Draw(Game1.mouseCursors, pos, new Rectangle(173 + fertilizerIndex / 3 * 16, 462 + fertilizerIndex % 3 * 16, 16, 16), Color.White, 0f, Vector2.Zero, 4f, SpriteEffects.None, 1.9E-08f); } } }
public override void DayUpdate(int dayOfMonth) { base.DayUpdate(dayOfMonth); ICollection <Vector2> objKeys = new List <Vector2>(terrainFeatures.Keys); for (int k = objKeys.Count - 1; k >= 0; k--) { if (terrainFeatures[objKeys.ElementAt(k)] is HoeDirt && (terrainFeatures[objKeys.ElementAt(k)] as HoeDirt).crop == null && Game1.random.NextDouble() <= 0.1) { terrainFeatures.Remove(objKeys.ElementAt(k)); } } for (int j = 0; j < characters.Count; j++) { if (characters[j] != null && characters[j] is Monster) { characters.RemoveAt(j); j--; } } addedSlimesToday.Value = false; List <Vector2> gingerTiles = new List <Vector2>(); foreach (Vector2 v3 in terrainFeatures.Keys) { if (terrainFeatures[v3] is HoeDirt && (terrainFeatures[v3] as HoeDirt).crop != null && (bool)(terrainFeatures[v3] as HoeDirt).crop.forageCrop) { gingerTiles.Add(v3); } } foreach (Vector2 v2 in gingerTiles) { terrainFeatures.Remove(v2); } List <Microsoft.Xna.Framework.Rectangle> gingerLocations = new List <Microsoft.Xna.Framework.Rectangle>(); gingerLocations.Add(new Microsoft.Xna.Framework.Rectangle(31, 43, 7, 6)); gingerLocations.Add(new Microsoft.Xna.Framework.Rectangle(37, 62, 6, 5)); gingerLocations.Add(new Microsoft.Xna.Framework.Rectangle(48, 42, 5, 4)); gingerLocations.Add(new Microsoft.Xna.Framework.Rectangle(71, 12, 5, 4)); gingerLocations.Add(new Microsoft.Xna.Framework.Rectangle(50, 59, 1, 1)); gingerLocations.Add(new Microsoft.Xna.Framework.Rectangle(47, 64, 1, 1)); gingerLocations.Add(new Microsoft.Xna.Framework.Rectangle(36, 58, 1, 1)); gingerLocations.Add(new Microsoft.Xna.Framework.Rectangle(56, 48, 1, 1)); gingerLocations.Add(new Microsoft.Xna.Framework.Rectangle(29, 46, 1, 1)); for (int i = 0; i < 5; i++) { Microsoft.Xna.Framework.Rectangle r = gingerLocations[Game1.random.Next(gingerLocations.Count)]; Vector2 origin = new Vector2(Game1.random.Next(r.X, r.Right), Game1.random.Next(r.Y, r.Bottom)); foreach (Vector2 v in Utility.recursiveFindOpenTiles(this, origin, 16)) { string s = doesTileHaveProperty((int)v.X, (int)v.Y, "Diggable", "Back"); if (!terrainFeatures.ContainsKey(v) && s != null && Game1.random.NextDouble() < (double)(1f - Vector2.Distance(origin, v) * 0.35f)) { HoeDirt d = new HoeDirt(0, new Crop(forageCrop: true, 2, (int)v.X, (int)v.Y)); d.state.Value = 2; terrainFeatures.Add(v, d); } } } if (Game1.MasterPlayer.mailReceived.Contains("Island_Turtle")) { spawnWeedsAndStones(20, weedsOnly: true); if (Game1.dayOfMonth % 7 == 1) { spawnWeedsAndStones(20, weedsOnly: true, spawnFromOldWeeds: false); } } }
private static bool Harvest(int xTile, int yTile, HoeDirt soil, JunimoHarvester junimoHarvester = null) { return(soil.crop.harvest(xTile, yTile, soil, junimoHarvester)); }
public static void Postfix(HoeDirt __instance, Farmer who) { __instance.fertilizer.Value = 0; }