/*** * Gets a fruit from a FruitTree and updates the tree accordingly. ***/ private StardewValley.Object GetFruitFromTree(FruitTree tree) { if (tree.fruitsOnTree == 0) { return(null); } int num1 = 0; if (tree.daysUntilMature <= -112) { num1 = 1; } if (tree.daysUntilMature <= -224) { num1 = 2; } if (tree.daysUntilMature <= -336) { num1 = 4; } if (tree.struckByLightningCountdown > 0) { num1 = 0; } int harvestAmount = FruitTreeAwareJunimoHut.TreeHarvestAmount(); tree.fruitsOnTree -= harvestAmount; return(new StardewValley.Object(Vector2.Zero, tree.struckByLightningCountdown > 0 ? 382 : tree.indexOfFruit, harvestAmount) { quality = num1 }); }
/*** * Gets the first adjacent FruitTree with fruits on it. Returns whether such a tree was found, and puts the result in result. ***/ private bool GetAdjacentReadyToHarvestFruitTree(Vector2 position, GameLocation location, out KeyValuePair <Vector2, FruitTree> result) { Vector2 treePos = Utility.getAdjacentTileLocations(position) .Where(pos => location.terrainFeatures.ContainsKey(pos) && location.terrainFeatures[pos] is FruitTree tree && FruitTreeAwareJunimoHut.CanTreeBeHarvested(tree)).FirstOrDefault(); if (treePos == default(Vector2)) { result = new KeyValuePair <Vector2, FruitTree>(Vector2.Zero, default(FruitTree)); return(false); } else { result = new KeyValuePair <Vector2, FruitTree>(treePos, location.terrainFeatures[treePos] as FruitTree); return(true); } }