/// <summary> /// Calls tree and mushroom tree growth methods depending on settings like growing them in the winter. /// </summary> /// <param name="tree">current tree</param> /// <param name="location">ingame location (e.g. farm)</param> /// <param name="tileLocation">position in said location</param> private void CalculateTreeGrowth(Tree tree, GameLocation location, Vector2 tileLocation) { // stop if it's a palm tree if (tree.treeType.Value == (int)TreeType.palmTree || tree.treeType.Value == (int)TreeType.palmTree2) { return; } // Cancels out with "if (!Game1.GetSeasonForLocation(this.currentLocation).Equals("winter") || this.treeType == 6 || this.treeType == 9 || environment.CanPlantTreesHere(-1, (int)tileLocation.X, (int)tileLocation.Y) || this.fertilized.Value)" from StardewValley.TerrainFeatures.Tree.dayUpdate // so we get exactly one growth call if the config says to grow in winter if (IsWinter(location) && !location.CanPlantTreesHere(-1, (int)tileLocation.X, (int)tileLocation.Y) && !tree.fertilized.Value) { if (tree.treeType.Value != (int)TreeType.mushroomTree && config.NormalTreesGrowInWinter) { GrowTree(tree, location, tileLocation); } if (tree.treeType.Value == (int)TreeType.mushroomTree && config.MushroomTreesGrowInWinter) { GrowTree(tree, location, tileLocation); } } else { // fixes stage 4 trees that should have grown and buffs mahogany trees if config says so FixAlreadyGrownTree(tree, location, tileLocation); } if (config.FasterNormalTreeGrowth) { if (IsWinter(location)) { if (tree.treeType.Value != (int)TreeType.mushroomTree && (config.NormalTreesGrowInWinter || location.CanPlantTreesHere(-1, (int)tileLocation.X, (int)tileLocation.Y) || tree.fertilized.Value)) { GrowTree(tree, location, tileLocation); } if (tree.treeType.Value == (int)TreeType.mushroomTree && (config.MushroomTreesGrowInWinter || location.CanPlantTreesHere(-1, (int)tileLocation.X, (int)tileLocation.Y) || tree.fertilized.Value)) { GrowTree(tree, location, tileLocation); } } else { GrowTree(tree, location, tileLocation); } } }
public static bool IsValidTileForFruitTree(GameLocation location, int saplingIndex, int x, int y) { return(DataLoader.ModConfig.EnablePlacementOfFruitTreesOnAnyTileType || ( (location is Farm || DataLoader.ModConfig.EnablePlacementOfFruitTreesOutOfTheFarm) && ( location.doesTileHaveProperty(x, y, "Diggable", "Back") != null || location.doesTileHavePropertyNoNull(x, y, "Type", "Back").Equals("Grass") || location.doesTileHavePropertyNoNull(x, y, "Type", "Back").Equals("Dirt")) && !location.doesTileHavePropertyNoNull(x, y, "NoSpawn", "Back").Equals("Tree")) || ( location.CanPlantTreesHere(saplingIndex, x, y) && ( location.doesTileHaveProperty(x, y, "Diggable", "Back") != null || location.doesTileHavePropertyNoNull(x, y, "Type", "Back").Equals("Stone")))); }
/// <summary>Whether a given common tree satisfies all conditions to advance a stage.</summary> /// <param name="tree">The given tree.</param> /// <param name="environment">The tree's game location.</param> /// <param name="tileLocation">The tree's tile location.</param> private static bool _CanThisTreeGrow(Tree tree, GameLocation environment, Vector2 tileLocation) { if (Game1.GetSeasonForLocation(tree.currentLocation).Equals("winter") && !tree.treeType.Value.AnyOf(Tree.palmTree, Tree.palmTree2) && !environment.CanPlantTreesHere(-1, (int)tileLocation.X, (int)tileLocation.Y) && !tree.fertilized.Value) { return(false); } var s = environment.doesTileHaveProperty((int)tileLocation.X, (int)tileLocation.Y, "NoSpawn", "Back"); if (s != null && s.AnyOf("All", "Tree", "True")) { return(false); } var growthRect = new Rectangle((int)((tileLocation.X - 1f) * 64f), (int)((tileLocation.Y - 1f) * 64f), 192, 192); if (tree.growthStage.Value == 4) { foreach (var pair in environment.terrainFeatures.Pairs) { if (pair.Value is Tree value && !value.Equals(tree) && value.growthStage.Value >= 5 && value.getBoundingBox(pair.Key).Intersects(growthRect)) { return(false); } } } else if (tree.growthStage.Value == 0 && environment.objects.ContainsKey(tileLocation)) { return(false); } return(true); }