Use string.IsNullOrEmpty instead

This commit is contained in:
Noah Pilarski 2023-01-16 19:12:07 -05:00
parent addc0041ab
commit 782f344065
2 changed files with 13 additions and 10 deletions

View File

@ -23,23 +23,23 @@ namespace NewHorizons.Builder.Body
Texture2D heightMap, textureMap, emissionMap;
try
{
if (module.heightMap != null && !File.Exists(Path.Combine(mod.ModHelper.Manifest.ModFolderPath, module.heightMap)))
if (!string.IsNullOrEmpty(module.heightMap) && !File.Exists(Path.Combine(mod.ModHelper.Manifest.ModFolderPath, module.heightMap)))
{
Logger.LogError($"Bad path for {planetGO.name} heightMap: {module.heightMap} couldn't be found.");
module.heightMap = null;
}
if (module.textureMap != null && !File.Exists(Path.Combine(mod.ModHelper.Manifest.ModFolderPath, module.textureMap)))
if (!string.IsNullOrEmpty(module.textureMap) && !File.Exists(Path.Combine(mod.ModHelper.Manifest.ModFolderPath, module.textureMap)))
{
Logger.LogError($"Bad path for {planetGO.name} textureMap: {module.textureMap} couldn't be found.");
module.textureMap = null;
}
if (module.emissionMap != null && !File.Exists(Path.Combine(mod.ModHelper.Manifest.ModFolderPath, module.emissionMap)))
if (!string.IsNullOrEmpty(module.emissionMap) && !File.Exists(Path.Combine(mod.ModHelper.Manifest.ModFolderPath, module.emissionMap)))
{
Logger.LogError($"Bad path for {planetGO.name} emissionMap: {module.emissionMap} couldn't be found.");
module.emissionMap = null;
}
if (module.heightMap == null)
if (string.IsNullOrEmpty(module.heightMap))
{
heightMap = Texture2D.whiteTexture;
}
@ -52,7 +52,7 @@ namespace NewHorizons.Builder.Body
heightMap = ImageUtilities.GetTexture(mod, module.heightMap);
}
if (module.textureMap == null)
if (string.IsNullOrEmpty(module.textureMap))
{
textureMap = Texture2D.whiteTexture;
}
@ -61,7 +61,7 @@ namespace NewHorizons.Builder.Body
textureMap = ImageUtilities.GetTexture(mod, module.textureMap);
}
if (module.emissionMap == null)
if (string.IsNullOrEmpty(module.emissionMap))
{
emissionMap = Texture2D.blackTexture;
}

View File

@ -41,10 +41,13 @@ namespace NewHorizons.Builder.Props
{
try
{
// TODO copy what heightmap builder does eventually
heightMapTexture = ImageUtilities.GetTexture(mod, heightMap.heightMap);
// defer remove texture to next frame
Delay.FireOnNextUpdate(() => Object.Destroy(heightMapTexture));
if (!string.IsNullOrEmpty(heightMap.heightMap))
{
// TODO copy what heightmap builder does eventually
heightMapTexture = ImageUtilities.GetTexture(mod, heightMap.heightMap);
// defer remove texture to next frame
Delay.FireOnNextUpdate(() => Object.Destroy(heightMapTexture));
}
}
catch (Exception) { }
if (heightMapTexture == null)