(a1ebc2642) Use lazy loading to ensure that the list is assigned when it's needed. Fixes null reference exceptions when pumping water or charging batteries.

This commit is contained in:
Joonas Rikkonen
2019-05-16 05:15:34 +03:00
parent 108e42edb0
commit 82d74f7481
11 changed files with 174 additions and 283 deletions
@@ -162,6 +162,23 @@ namespace Barotrauma
}
}
/// <summary>
/// Returns the file paths of all files of the given type in the content packages.
/// </summary>
/// <param name="type"></param>
/// <param name="searchAllContentPackages">If true, also returns files in content packages that are installed but not currently selected.</param>
public IEnumerable<string> GetFilesOfType(ContentType type, bool searchAllContentPackages = false)
{
if (searchAllContentPackages)
{
return ContentPackage.GetFilesOfType(ContentPackage.List, type);
}
else
{
return ContentPackage.GetFilesOfType(SelectedPackages, type);
}
}
/// <summary>
/// Returns the file paths of all files of the given type in the currently selected content packages.
/// </summary>