Simplify how None is handled and fixed libs getting loaded too late
This commit is contained in:
@@ -14,7 +14,6 @@ defaultLib["Int64"] = CreateStatic("Barotrauma.LuaInt64", true)
|
||||
defaultLib["UInt64"] = CreateStatic("Barotrauma.LuaUInt64", true)
|
||||
defaultLib["Single"] = CreateStatic("Barotrauma.LuaSingle", true)
|
||||
defaultLib["Double"] = CreateStatic("Barotrauma.LuaDouble", true)
|
||||
defaultLib["none"] = CreateStatic("Barotrauma.LuaNone", true)()
|
||||
|
||||
-- Backward compatibility
|
||||
defaultLib["Float"] = CreateStatic("Barotrauma.LuaSingle", true)
|
||||
@@ -69,7 +68,8 @@ defaultLib["WayPoint"] = CreateStatic("Barotrauma.WayPoint", true)
|
||||
defaultLib["Submarine"] = CreateStatic("Barotrauma.Submarine", true)
|
||||
defaultLib["Client"] = CreateStatic("Barotrauma.Networking.Client", true)
|
||||
defaultLib["Character"] = CreateStatic("Barotrauma.Character")
|
||||
defaultLib["CharacterPrefab"] = CreateStatic("Barotrauma.CharacterPrefab")
|
||||
defaultLib["CharacterHealth"] = CreateStatic("Barotrauma.CharacterHealth", true)
|
||||
defaultLib["CharacterPrefab"] = CreateStatic("Barotrauma.CharacterPrefab", true)
|
||||
defaultLib["CharacterInfo"] = CreateStatic("Barotrauma.CharacterInfo", true)
|
||||
AddCallMetaTable(defaultLib["CharacterInfo"].HeadPreset)
|
||||
AddCallMetaTable(defaultLib["CharacterInfo"].HeadInfo)
|
||||
|
||||
@@ -10,6 +10,8 @@ for key, value in pairs(localizedStrings) do
|
||||
RegisterBarotrauma(value)
|
||||
end
|
||||
|
||||
Register("Steamworks.SteamServer")
|
||||
|
||||
RegisterBarotrauma("Character+TeamChangeEventData")
|
||||
|
||||
RegisterBarotrauma("Networking.GameServer")
|
||||
|
||||
@@ -3,6 +3,7 @@ local RegisterBarotrauma = LuaSetup.LuaUserData.RegisterTypeBarotrauma
|
||||
|
||||
Register("System.TimeSpan")
|
||||
Register("System.Exception")
|
||||
Register("System.Console")
|
||||
|
||||
RegisterBarotrauma("Success`2[[Barotrauma.ContentPackage],[System.Exception]]")
|
||||
RegisterBarotrauma("Failure`2[[Barotrauma.ContentPackage],[System.Exception]]")
|
||||
@@ -17,7 +18,6 @@ RegisterBarotrauma("LuaInt64")
|
||||
RegisterBarotrauma("LuaUInt64")
|
||||
RegisterBarotrauma("LuaSingle")
|
||||
RegisterBarotrauma("LuaDouble")
|
||||
RegisterBarotrauma("LuaNone")
|
||||
|
||||
RegisterBarotrauma("GameMain")
|
||||
RegisterBarotrauma("Networking.BanList")
|
||||
|
||||
@@ -38,6 +38,11 @@ require("DefaultHook")
|
||||
Descriptors = LuaSetup.LuaUserData.Descriptors
|
||||
LuaUserData = LuaSetup.LuaUserData
|
||||
|
||||
require("DefaultLib/Utils/Math")
|
||||
require("DefaultLib/Utils/String")
|
||||
require("DefaultLib/Utils/Util")
|
||||
require("DefaultLib/Utils/SteamApi")
|
||||
|
||||
if false then
|
||||
LuaUserData.RegisterType = function (typeName)
|
||||
local descriptor = Descriptors[typeName]
|
||||
@@ -61,10 +66,6 @@ if false then
|
||||
end
|
||||
end
|
||||
|
||||
require("DefaultLib/Utils/Math")
|
||||
require("DefaultLib/Utils/String")
|
||||
require("DefaultLib/Utils/Util")
|
||||
require("DefaultLib/Utils/SteamApi")
|
||||
|
||||
LuaSetup = nil
|
||||
|
||||
|
||||
@@ -2,11 +2,6 @@
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
public struct LuaNone
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public struct LuaSByte
|
||||
{
|
||||
public readonly sbyte Value;
|
||||
|
||||
@@ -256,14 +256,12 @@ namespace Barotrauma
|
||||
|
||||
Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(dataType, typeof(Option<T>), v =>
|
||||
{
|
||||
if (v.UserData.Object is LuaNone)
|
||||
{
|
||||
return Option<T>.None();
|
||||
}
|
||||
else
|
||||
{
|
||||
return Option<T>.Some(v.ToObject<T>());
|
||||
}
|
||||
return Option<T>.Some(v.ToObject<T>());
|
||||
});
|
||||
|
||||
Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(DataType.Nil, typeof(Option<T>), v =>
|
||||
{
|
||||
return Option<T>.None();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user