Skip to content

Commit 2faabb1

Browse files
committed
add check for resource_units
1 parent e178850 commit 2faabb1

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

Runtime/PatchManager.Resources/ResourcesModule.cs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Collections.Generic;
2+
using System.Linq;
23
using JetBrains.Annotations;
34
using KSP.Game;
45
using Newtonsoft.Json.Linq;
@@ -24,14 +25,21 @@ public class ResourcesModule : BaseModule
2425

2526
public override void Load()
2627
{
27-
GameManager.Instance.Assets.LoadByLabel("resource_units", RegisterUnits,
28-
delegate(IList<TextAsset> assetLocations)
29-
{
30-
if (assetLocations != null)
28+
if (GameManager.Instance.Assets.RegisteredResourceLocators.Any(x => x.Keys.Contains("resource_units")))
29+
{
30+
GameManager.Instance.Assets.LoadByLabel("resource_units", RegisterUnits,
31+
delegate(IList<TextAsset> assetLocations)
3132
{
32-
Addressables.Release(assetLocations);
33-
}
34-
});
33+
if (assetLocations != null)
34+
{
35+
Addressables.Release(assetLocations);
36+
}
37+
});
38+
}
39+
else
40+
{
41+
Logging.LogInfo("No custom resource units were defined");
42+
}
3543

3644
PatchManager.Instance.AddComponent<NonStageableResourcesUIController>();
3745
}

0 commit comments

Comments
 (0)