forked from SubnauticaModding/Nautilus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Ban custom prefabs from getting cached (SubnauticaModding#545)
* Custom prefabs now can opt-out from cache * Extension method for custom prefab to remove from cache * Use taskResult instead of looking in cache * Added more logs
- Loading branch information
Showing
3 changed files
with
53 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using Nautilus.Utility; | ||
|
||
namespace Nautilus.Assets; | ||
|
||
/// <summary> | ||
/// Represents extension methods for the <see cref="CustomPrefab"/> class. | ||
/// </summary> | ||
public static class CustomPrefabExtensions | ||
{ | ||
/// <summary> | ||
/// Removes the current prefab from the prefab cache and doesn't allow it to get cached later. | ||
/// </summary> | ||
/// <param name="customPrefab">The custom prefab to remove from the prefab cache.</param> | ||
/// <returns>A reference to this instance after the operation has completed.</returns> | ||
public static ICustomPrefab RemoveFromCache(this CustomPrefab customPrefab) | ||
{ | ||
if (customPrefab.Info == default) | ||
{ | ||
return customPrefab; | ||
} | ||
|
||
if (string.IsNullOrWhiteSpace(customPrefab.Info.ClassID)) | ||
{ | ||
InternalLogger.Error($"Couldn't remove prefab '{customPrefab.Info}' from cache because the class ID is null."); | ||
return customPrefab; | ||
} | ||
|
||
ModPrefabCache.RemovePrefabFromCache(customPrefab.Info.ClassID); | ||
|
||
return customPrefab; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters