- Deleted unused service IPackageListRetrievalService.cs

- Added caching function to LuaScriptLoader.cs
- Added sample async code to LuaScriptManagementService.cs
- Removed most of the State functions in LuaCsSetup.cs (requires rewrite).
- Fixed CsEnabled check.
- Moved IsRunningWorkshop check to client-only project.
This commit is contained in:
MapleWheels
2026-01-14 08:50:09 -05:00
committed by Maplewheels
parent 0bfceacaf3
commit 055a508901
10 changed files with 94 additions and 295 deletions
@@ -1,12 +1,15 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Text;
using System.IO;
using MoonSharp.Interpreter;
using MoonSharp.Interpreter.Loaders;
using System.Linq;
using System.Threading.Tasks;
using Barotrauma.LuaCs.Data;
using Barotrauma.LuaCs.Services.Safe;
using FluentResults;
namespace Barotrauma.LuaCs.Services.Safe
{
@@ -59,6 +62,15 @@ namespace Barotrauma.LuaCs.Services.Safe
_storageService?.PurgeCache();
}
public async Task<Result<ImmutableArray<(ContentPath Path, Result<string>)>>> CacheResourcesAsync(ImmutableArray<ILuaScriptResourceInfo> resourceInfos)
{
// TODO: Needs an async lock?
IService.CheckDisposed(this);
if (!_storageService.UseCaching)
return FluentResults.Result.Fail($"Caching is not enabled.");
return await this._storageService.LoadPackageTextFilesAsync([..resourceInfos.SelectMany(ri => ri.FilePaths)]);
}
public override bool ScriptFileExists(string file)
{
((IService)this).CheckDisposed();