Register IConfigService and add back some missing APIs
This commit is contained in:
@@ -35,4 +35,44 @@ if not CSActive then
|
||||
end
|
||||
end
|
||||
|
||||
if SERVER then
|
||||
Networking.Receive("_luastart", function (message, client)
|
||||
local num = message.ReadUInt16()
|
||||
|
||||
local packages = {}
|
||||
|
||||
for i = 1, num, 1 do
|
||||
table.insert(packages, {
|
||||
Name = message.ReadString(),
|
||||
Version = message.ReadString(),
|
||||
Id = message.ReadUInt64(),
|
||||
Hash = message.ReadString()
|
||||
})
|
||||
end
|
||||
|
||||
Hook.Call("client.packages", client, packages)
|
||||
end)
|
||||
elseif Game.IsMultiplayer then
|
||||
local message = Networking.Start("_luastart")
|
||||
|
||||
local packageCount = 0
|
||||
for package in ContentPackageManager.EnabledPackages.All do packageCount = packageCount + 1 end
|
||||
|
||||
message.WriteUInt16(packageCount)
|
||||
|
||||
for package in ContentPackageManager.EnabledPackages.All do
|
||||
local id = package.UgcId
|
||||
local hash = package.Hash and package.Hash.StringRepresentation or ""
|
||||
|
||||
if id == nil then id = 0 end
|
||||
|
||||
message.WriteString(package.Name)
|
||||
message.WriteString(package.ModVersion)
|
||||
message.WriteUInt64(UInt64(id))
|
||||
message.WriteString(hash)
|
||||
end
|
||||
|
||||
Networking.Send(message)
|
||||
end
|
||||
|
||||
LuaSetup = nil
|
||||
@@ -10,6 +10,8 @@ internal interface ILuaCsNetworking : ILuaCsShim
|
||||
void HttpRequest(string url, LuaCsAction callback, string data = null, string method = "POST", string contentType = "application/json", Dictionary<string, string> headers = null, string savePath = null);
|
||||
void HttpPost(string url, LuaCsAction callback, string data, string contentType = "application/json", Dictionary<string, string> headers = null, string savePath = null);
|
||||
void HttpGet(string url, LuaCsAction callback, Dictionary<string, string> headers = null, string savePath = null);
|
||||
void RequestGetHTTP(string url, LuaCsAction callback, Dictionary<string, string> headers = null, string savePath = null);
|
||||
void RequestPostHTTP(string url, LuaCsAction callback, string data, string contentType = "application/json", Dictionary<string, string> headers = null, string savePath = null);
|
||||
|
||||
void Receive(string netId, LuaCsAction action);
|
||||
#if SERVER
|
||||
|
||||
@@ -366,6 +366,7 @@ class LuaScriptManagementService : ILuaScriptManagementService, ILuaDataService,
|
||||
UserData.RegisterType(typeof(IResourceInfo));
|
||||
UserData.RegisterType(typeof(IUserDataDescriptor));
|
||||
UserData.RegisterType(typeof(INetworkingService));
|
||||
UserData.RegisterType(typeof(IConfigService));
|
||||
|
||||
new LuaConverters(this).RegisterLuaConverters();
|
||||
|
||||
|
||||
@@ -348,12 +348,21 @@ internal partial class NetworkingService : INetworkingService
|
||||
HttpRequest(url, callback, data, "POST", contentType, headers, savePath);
|
||||
}
|
||||
|
||||
public void RequestPostHTTP(string url, LuaCsAction callback, string data, string contentType = "application/json", Dictionary<string, string> headers = null, string savePath = null)
|
||||
{
|
||||
HttpRequest(url, callback, data, "POST", contentType, headers, savePath);
|
||||
}
|
||||
|
||||
public void HttpGet(string url, LuaCsAction callback, Dictionary<string, string> headers = null, string savePath = null)
|
||||
{
|
||||
HttpRequest(url, callback, null, "GET", null, headers, savePath);
|
||||
}
|
||||
|
||||
public void RequestGetHTTP(string url, LuaCsAction callback, Dictionary<string, string> headers = null, string savePath = null)
|
||||
{
|
||||
HttpRequest(url, callback, null, "GET", null, headers, savePath);
|
||||
}
|
||||
|
||||
public void CreateEntityEvent(INetSerializable entity, NetEntityEvent.IData extraData)
|
||||
{
|
||||
GameMain.NetworkMember.CreateEntityEvent(entity, extraData);
|
||||
|
||||
Reference in New Issue
Block a user