use GetLocations logic more consistently in asset propagation

This commit is contained in:
Jesse Plamondon-Willard 2019-12-08 11:31:20 -05:00
parent 04b9a810dd
commit 194b96a79c
No known key found for this signature in database
GPG Key ID: CF8B1456B3E29F49
1 changed files with 6 additions and 5 deletions

View File

@ -611,7 +611,7 @@ namespace StardewModdingAPI.Metadata
{
// get buildings
string type = Path.GetFileName(key);
Building[] buildings = Game1.locations
Building[] buildings = this.GetLocations(buildingInteriors: false)
.OfType<BuildableGameLocation>()
.SelectMany(p => p.buildings)
.Where(p => p.buildingType.Value == type)
@ -706,7 +706,7 @@ namespace StardewModdingAPI.Metadata
{
Grass[] grasses =
(
from location in Game1.locations
from location in this.GetLocations()
from grass in location.terrainFeatures.Values.OfType<Grass>()
let textureName = this.NormalizeAssetNameIgnoringEmpty(
this.Reflection.GetMethod(grass, "textureName").Invoke<string>()
@ -804,7 +804,7 @@ namespace StardewModdingAPI.Metadata
/// <returns>Returns whether any textures were reloaded.</returns>
private bool ReloadTreeTextures(LocalizedContentManager content, string key, int type)
{
Tree[] trees = Game1.locations
Tree[] trees = this.GetLocations()
.SelectMany(p => p.terrainFeatures.Values.OfType<Tree>())
.Where(tree => tree.treeType.Value == type)
.ToArray();
@ -909,7 +909,8 @@ namespace StardewModdingAPI.Metadata
}
/// <summary>Get all locations in the game.</summary>
private IEnumerable<GameLocation> GetLocations()
/// <param name="buildingInteriors">Whether to also get the interior locations for constructable buildings.</param>
private IEnumerable<GameLocation> GetLocations(bool buildingInteriors = true)
{
// get available root locations
IEnumerable<GameLocation> rootLocations = Game1.locations;
@ -921,7 +922,7 @@ namespace StardewModdingAPI.Metadata
{
yield return location;
if (location is BuildableGameLocation buildableLocation)
if (buildingInteriors && location is BuildableGameLocation buildableLocation)
{
foreach (Building building in buildableLocation.buildings)
{