- Added setting to disable lua scripts caching in the storage service for scenarios that use extern editors.

This commit is contained in:
MapleWheels
2026-04-02 23:29:21 -04:00
parent 4f2da55a8e
commit 413cc3ed4c
9 changed files with 70 additions and 8 deletions
@@ -9,5 +9,10 @@ namespace Barotrauma.LuaCs;
public interface ILuaScriptLoader : IService, IScriptLoader, ISafeStorageValidation
{
void ClearCaches();
/// <summary>
/// Whether caching is enabled/disabled.
/// </summary>
/// <param name="useCaching"></param>
void SetCachingPolicy(bool useCaching);
Task<Result<ImmutableArray<(ContentPath Path, Result<string>)>>> CacheResourcesAsync(ImmutableArray<ILuaScriptResourceInfo> resourceInfos);
}
@@ -56,6 +56,20 @@ namespace Barotrauma.LuaCs
_storageService?.PurgeCache();
}
public void SetCachingPolicy(bool useCaching)
{
if (_storageService is null)
{
return;
}
if (!useCaching)
{
_storageService.PurgeCache();
}
_storageService.UseCaching = useCaching;
}
public async Task<Result<ImmutableArray<(ContentPath Path, Result<string>)>>> CacheResourcesAsync(ImmutableArray<ILuaScriptResourceInfo> resourceInfos)
{
IService.CheckDisposed(this);