All descriptors are now accessible via a global table, for easier access

This commit is contained in:
Evil Factory
2022-03-25 15:06:13 -03:00
parent 469abd6e86
commit f9d7c0c2be
2 changed files with 35 additions and 21 deletions
@@ -1,6 +1,6 @@
local defaultLib = {} local defaultLib = {}
require("DefaultRegister") local descriptors = require("DefaultRegister")
local CreateStatic = function (typeName, addCallMethod) local CreateStatic = function (typeName, addCallMethod)
local staticUserdata = LuaUserData.CreateStatic(typeName) local staticUserdata = LuaUserData.CreateStatic(typeName)
@@ -16,6 +16,8 @@ local CreateStatic = function (typeName, addCallMethod)
return staticUserdata return staticUserdata
end end
defaultLib["Descriptors"] = descriptors
defaultLib["Byte"] = CreateStatic("Barotrauma.LuaByte", true) defaultLib["Byte"] = CreateStatic("Barotrauma.LuaByte", true)
defaultLib["UShort"] = CreateStatic("Barotrauma.LuaUShort", true) defaultLib["UShort"] = CreateStatic("Barotrauma.LuaUShort", true)
defaultLib["Float"] = CreateStatic("Barotrauma.LuaFloat", true) defaultLib["Float"] = CreateStatic("Barotrauma.LuaFloat", true)
@@ -1,8 +1,18 @@
local function RegisterBarotrauma(typeName) local descriptors = {}
return LuaUserData.RegisterType("Barotrauma." .. typeName)
local function Register(typeName)
local descriptor = LuaUserData.RegisterType(typeName)
descriptors[typeName] = descriptor
return descriptor
end end
LuaUserData.RegisterType("System.TimeSpan") local function RegisterBarotrauma(typeName)
return Register("Barotrauma." .. typeName)
end
Register("System.TimeSpan")
if SERVER then if SERVER then
RegisterBarotrauma("Networking.GameServer") RegisterBarotrauma("Networking.GameServer")
@@ -208,10 +218,10 @@ RegisterBarotrauma("Networking.NetEntityEvent")
RegisterBarotrauma("Networking.NetEntityEvent+Type") RegisterBarotrauma("Networking.NetEntityEvent+Type")
RegisterBarotrauma("Networking.INetSerializable") RegisterBarotrauma("Networking.INetSerializable")
RegisterBarotrauma("Networking.DisconnectReason") RegisterBarotrauma("Networking.DisconnectReason")
LuaUserData.RegisterType("Lidgren.Network.NetIncomingMessage") Register("Lidgren.Network.NetIncomingMessage")
LuaUserData.RegisterType("Lidgren.Network.NetConnection") Register("Lidgren.Network.NetConnection")
LuaUserData.RegisterType("System.Net.IPEndPoint") Register("System.Net.IPEndPoint")
LuaUserData.RegisterType("System.Net.IPAddress") Register("System.Net.IPAddress")
RegisterBarotrauma("Rand+RandSync") RegisterBarotrauma("Rand+RandSync")
RegisterBarotrauma("Skill") RegisterBarotrauma("Skill")
@@ -219,9 +229,9 @@ RegisterBarotrauma("SkillPrefab")
RegisterBarotrauma("TraitorMissionPrefab") RegisterBarotrauma("TraitorMissionPrefab")
RegisterBarotrauma("TraitorMissionResult") RegisterBarotrauma("TraitorMissionResult")
LuaUserData.RegisterType("FarseerPhysics.Dynamics.Body") Register("FarseerPhysics.Dynamics.Body")
LuaUserData.RegisterType("FarseerPhysics.Dynamics.World") Register("FarseerPhysics.Dynamics.World")
LuaUserData.RegisterType("FarseerPhysics.Dynamics.Fixture") Register("FarseerPhysics.Dynamics.Fixture")
RegisterBarotrauma("Physics") RegisterBarotrauma("Physics")
RegisterBarotrauma("Camera") RegisterBarotrauma("Camera")
@@ -245,12 +255,12 @@ RegisterBarotrauma("SubmarineInfo")
RegisterBarotrauma("MapCreatures.Behavior.BallastFloraBehavior") RegisterBarotrauma("MapCreatures.Behavior.BallastFloraBehavior")
RegisterBarotrauma("MapCreatures.Behavior.BallastFloraBranch") RegisterBarotrauma("MapCreatures.Behavior.BallastFloraBranch")
LuaUserData.RegisterType("Microsoft.Xna.Framework.Vector2") Register("Microsoft.Xna.Framework.Vector2")
LuaUserData.RegisterType("Microsoft.Xna.Framework.Vector3") Register("Microsoft.Xna.Framework.Vector3")
LuaUserData.RegisterType("Microsoft.Xna.Framework.Vector4") Register("Microsoft.Xna.Framework.Vector4")
LuaUserData.RegisterType("Microsoft.Xna.Framework.Color") Register("Microsoft.Xna.Framework.Color")
LuaUserData.RegisterType("Microsoft.Xna.Framework.Point") Register("Microsoft.Xna.Framework.Point")
LuaUserData.RegisterType("Microsoft.Xna.Framework.Rectangle") Register("Microsoft.Xna.Framework.Rectangle")
if SERVER then if SERVER then
RegisterBarotrauma("Networking.ServerPeer") RegisterBarotrauma("Networking.ServerPeer")
@@ -271,9 +281,9 @@ RegisterBarotrauma("Pivot")
RegisterBarotrauma("Key") RegisterBarotrauma("Key")
RegisterBarotrauma("PlayerInput") RegisterBarotrauma("PlayerInput")
LuaUserData.RegisterType("Microsoft.Xna.Framework.Graphics.Texture2D") Register("Microsoft.Xna.Framework.Graphics.Texture2D")
LuaUserData.RegisterType("EventInput.KeyEventArgs") Register("EventInput.KeyEventArgs")
LuaUserData.RegisterType("Microsoft.Xna.Framework.Input.Keys") Register("Microsoft.Xna.Framework.Input.Keys")
RegisterBarotrauma("Sprite") RegisterBarotrauma("Sprite")
RegisterBarotrauma("GUILayoutGroup") RegisterBarotrauma("GUILayoutGroup")
@@ -289,4 +299,6 @@ RegisterBarotrauma("GUIListBox")
RegisterBarotrauma("GUIScrollBar") RegisterBarotrauma("GUIScrollBar")
RegisterBarotrauma("GUIDropDown") RegisterBarotrauma("GUIDropDown")
end end
return descriptors