[Milestone] PackageManagementService completed.
- ContentPackageInfoLookup Service completed. - Implemented ModConfigService.cs - Implemented some of the resource processors.
This commit is contained in:
@@ -815,7 +815,7 @@ namespace Barotrauma
|
||||
|
||||
var tempBuffer = new ReadWriteMessage();
|
||||
WriteStatus(tempBuffer, forceAfflictionData: true);
|
||||
if (msgLengthBeforeStatus + tempBuffer.LengthBytes >= 255 && restrictMessageSize && GameMain.LuaCs.Networking.RestrictMessageSize)
|
||||
if (msgLengthBeforeStatus + tempBuffer.LengthBytes >= 255 && restrictMessageSize && (GameMain.LuaCs.RestrictMessageSize?.Value ?? false))
|
||||
{
|
||||
msg.WriteBoolean(false);
|
||||
if (msgLengthBeforeStatus < 255)
|
||||
|
||||
@@ -10,6 +10,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using Barotrauma.Steam;
|
||||
using Barotrauma.Extensions;
|
||||
using Barotrauma.LuaCs.Events;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
@@ -1292,7 +1293,8 @@ namespace Barotrauma
|
||||
{
|
||||
try
|
||||
{
|
||||
GameMain.LuaCs.Lua.DoString(string.Join(" ", args));
|
||||
throw new NotImplementedException();
|
||||
//GameMain.LuaCs.Lua.DoString(string.Join(" ", args));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -1302,7 +1304,8 @@ namespace Barotrauma
|
||||
|
||||
commands.Add(new Command("reloadlua|reloadcs|reloadluacs", "Re-initializes the LuaCs environment.", (string[] args) =>
|
||||
{
|
||||
GameMain.LuaCs.Initialize();
|
||||
//GameMain.LuaCs.Initialize();
|
||||
GameMain.LuaCs.EventService.PublishEvent<IEventReloadAllPackages>(sub => sub.OnReloadAllPackages());
|
||||
}));
|
||||
|
||||
commands.Add(new Command("toggleluadebug", "Toggles the MoonSharp Debug Server.", (string[] args) =>
|
||||
@@ -1314,7 +1317,8 @@ namespace Barotrauma
|
||||
int.TryParse(args[0], out port);
|
||||
}
|
||||
|
||||
GameMain.LuaCs.ToggleDebugger(port);
|
||||
throw new NotImplementedException();
|
||||
//GameMain.LuaCs.ToggleDebugger(port);
|
||||
}));
|
||||
|
||||
commands.Add(new Command("install_cl_lua|install_cl|install_cl_cs|install_cl_luacs", "Installs Client-Side LuaCs into your client.", (string[] args) =>
|
||||
|
||||
@@ -132,8 +132,6 @@ namespace Barotrauma
|
||||
NetLobbyScreen = new NetLobbyScreen();
|
||||
|
||||
CheckContentPackage();
|
||||
|
||||
LuaCs = new LuaCsSetup();
|
||||
}
|
||||
|
||||
|
||||
@@ -454,7 +452,18 @@ namespace Barotrauma
|
||||
public void Exit()
|
||||
{
|
||||
ShouldRun = false;
|
||||
GameMain.LuaCs.Dispose();
|
||||
try
|
||||
{
|
||||
if (_luaCs is not null)
|
||||
{
|
||||
_luaCs.Dispose();
|
||||
_luaCs = null;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
DebugConsole.ThrowError($"Error while disposing of LuaCsForBarotrauma: {e.Message} | {e.StackTrace}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,9 @@ namespace Barotrauma
|
||||
{
|
||||
public static void Install()
|
||||
{
|
||||
ContentPackage luaPackage = LuaCsSetup.GetPackage(LuaCsSetup.LuaForBarotraumaId);
|
||||
throw new NotImplementedException();
|
||||
// TODO: Refactor the installer to not be dependent on LuaCsSetup.
|
||||
/*ContentPackage luaPackage = LuaCsSetup.GetPackage();
|
||||
|
||||
if (luaPackage == null)
|
||||
{
|
||||
@@ -64,7 +66,7 @@ namespace Barotrauma
|
||||
return;
|
||||
}
|
||||
|
||||
GameMain.Server.SendChatMessage("Client-Side LuaCs installed, restart your game to apply changes.", ChatMessageType.ServerMessageBox);
|
||||
GameMain.Server.SendChatMessage("Client-Side LuaCs installed, restart your game to apply changes.", ChatMessageType.ServerMessageBox);*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
|
||||
using Barotrauma.Networking;
|
||||
|
||||
namespace Barotrauma.LuaCs.Services;
|
||||
|
||||
internal partial interface INetworkingService : IReusableService
|
||||
{
|
||||
void NetMessageReceived(IReadMessage message, ClientPacketHeader header, Client client);
|
||||
}
|
||||
@@ -4,9 +4,10 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Barotrauma.LuaCs.Networking;
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace Barotrauma.LuaCs.Services;
|
||||
|
||||
partial class NetworkingService
|
||||
partial class NetworkingService : INetworkingService
|
||||
{
|
||||
private const int MaxRegisterPerClient = 1000;
|
||||
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
using System.Collections.Generic;
|
||||
using Barotrauma.LuaCs.Data;
|
||||
using Barotrauma.LuaCs.Services.Processing;
|
||||
|
||||
namespace Barotrauma.LuaCs.Services;
|
||||
|
||||
public partial class PackageManagementService
|
||||
{
|
||||
public PackageManagementService(
|
||||
IConverterServiceAsync<ContentPackage, IModConfigInfo> modConfigParserService,
|
||||
IProcessorService<IReadOnlyList<IAssemblyResourceInfo>, IAssembliesResourcesInfo> assemblyInfoConverter,
|
||||
IProcessorService<IReadOnlyList<IConfigResourceInfo>, IConfigsResourcesInfo> configsInfoConverter,
|
||||
IProcessorService<IReadOnlyList<IConfigProfileResourceInfo>, IConfigProfilesResourcesInfo> configProfilesConverter,
|
||||
IProcessorService<IReadOnlyList<ILocalizationResourceInfo>, ILocalizationsResourcesInfo> localizationsConverter,
|
||||
IProcessorService<IReadOnlyList<ILuaScriptResourceInfo>, ILuaScriptsResourcesInfo> luaScriptsConverter,
|
||||
IPackageInfoLookupService packageInfoLookupService)
|
||||
{
|
||||
_modConfigParserService = modConfigParserService;
|
||||
_assemblyInfoConverter = assemblyInfoConverter;
|
||||
_configsInfoConverter = configsInfoConverter;
|
||||
_configProfilesConverter = configProfilesConverter;
|
||||
_localizationsConverter = localizationsConverter;
|
||||
_luaScriptsConverter = luaScriptsConverter;
|
||||
_packageInfoLookupService = packageInfoLookupService;
|
||||
}
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
using Barotrauma.LuaCs.Data;
|
||||
using FluentResults;
|
||||
|
||||
namespace Barotrauma.LuaCs.Services.Processing;
|
||||
|
||||
public partial class ModConfigService
|
||||
{
|
||||
private partial async Task<Result<IModConfigInfo>> GetModConfigInfoAsync(ContentPackage package, XElement root)
|
||||
{
|
||||
var asm = root.GetChildElements("Assembly").ToImmutableArray();
|
||||
var loc = root.GetChildElements("Localization").ToImmutableArray();
|
||||
var cfg = root.GetChildElements("Config").ToImmutableArray();
|
||||
var lua = root.GetChildElements("Lua").ToImmutableArray();
|
||||
|
||||
return FluentResults.Result.Ok<IModConfigInfo>(new ModConfigInfo()
|
||||
{
|
||||
Package = package,
|
||||
PackageName = package.Name,
|
||||
Assemblies = asm.Any() ? GetAssemblies(package, asm) : ImmutableArray<IAssemblyResourceInfo>.Empty,
|
||||
Localizations = loc.Any() ? GetLocalizations(package, loc) : ImmutableArray<ILocalizationResourceInfo>.Empty,
|
||||
Configs = cfg.Any() ? GetConfigs(package, cfg) : ImmutableArray<IConfigResourceInfo>.Empty,
|
||||
ConfigProfiles = cfg.Any() ? GetConfigProfiles(package, cfg) : ImmutableArray<IConfigProfileResourceInfo>.Empty,
|
||||
LuaScripts = lua.Any() ? GetLuaScripts(package, lua) : ImmutableArray<ILuaScriptResourceInfo>.Empty
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -245,7 +245,6 @@ namespace Barotrauma.Networking
|
||||
|
||||
VoipServer = new VoipServer(serverPeer);
|
||||
|
||||
GameMain.LuaCs.Initialize();
|
||||
Log("Server started", ServerLog.MessageType.ServerMessage);
|
||||
|
||||
GameMain.NetLobbyScreen.Select();
|
||||
@@ -838,7 +837,7 @@ namespace Barotrauma.Networking
|
||||
|
||||
ClientPacketHeader header = (ClientPacketHeader)inc.ReadByte();
|
||||
|
||||
GameMain.LuaCs.Networking.NetMessageReceived(inc, header, connectedClient);
|
||||
GameMain.LuaCs.NetworkingService.NetMessageReceived(inc, header, connectedClient);
|
||||
|
||||
switch (header)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user