local defaultLib = {}

local AddCallMetaTable = LuaSetup.LuaUserData.AddCallMetaTable
local CreateStatic = LuaSetup.LuaUserData.CreateStatic
local CreateEnum = LuaSetup.LuaUserData.CreateEnumTable

defaultLib["SByte"] = CreateStatic("Barotrauma.LuaSByte", true)
defaultLib["Byte"] = CreateStatic("Barotrauma.LuaByte", true)
defaultLib["Int16"] = CreateStatic("Barotrauma.LuaInt16", true)
defaultLib["UInt16"] = CreateStatic("Barotrauma.LuaUInt16", true)
defaultLib["Int32"] = CreateStatic("Barotrauma.LuaInt32", true)
defaultLib["UInt32"] = CreateStatic("Barotrauma.LuaUInt32", true)
defaultLib["Int64"] = CreateStatic("Barotrauma.LuaInt64", true)
defaultLib["UInt64"] = CreateStatic("Barotrauma.LuaUInt64", true)
defaultLib["Single"] = CreateStatic("Barotrauma.LuaSingle", true)
defaultLib["Double"] = CreateStatic("Barotrauma.LuaDouble", true)

-- Backward compatibility
defaultLib["Float"] = CreateStatic("Barotrauma.LuaSingle", true)
defaultLib["Short"] = CreateStatic("Barotrauma.LuaInt16", true)
defaultLib["UShort"] = CreateStatic("Barotrauma.LuaUInt16", true)

defaultLib["SpawnType"] = CreateEnum("Barotrauma.SpawnType")
defaultLib["ChatMessageType"] = CreateEnum("Barotrauma.Networking.ChatMessageType")
defaultLib["ServerLog_MessageType"] = CreateEnum("Barotrauma.Networking.ServerLog+MessageType")
defaultLib["ServerLogMessageType"] = CreateEnum("Barotrauma.Networking.ServerLog+MessageType")
defaultLib["PositionType"] = CreateEnum("Barotrauma.Level+PositionType")
defaultLib["InvSlotType"] = CreateEnum("Barotrauma.InvSlotType")
defaultLib["LimbType"] = CreateEnum("Barotrauma.LimbType")
defaultLib["ActionType"] = CreateEnum("Barotrauma.ActionType")
defaultLib["AbilityEffectType"] = CreateEnum("Barotrauma.AbilityEffectType")
defaultLib["StatTypes"] = CreateEnum("Barotrauma.StatTypes")
defaultLib["AbilityFlags"] = CreateEnum("Barotrauma.AbilityFlags")
defaultLib["DeliveryMethod"] = CreateEnum("Barotrauma.Networking.DeliveryMethod")
defaultLib["ClientPacketHeader"] = CreateEnum("Barotrauma.Networking.ClientPacketHeader")
defaultLib["ServerPacketHeader"] = CreateEnum("Barotrauma.Networking.ServerPacketHeader")
defaultLib["RandSync"] = CreateEnum("Barotrauma.Rand+RandSync")
defaultLib["DisconnectReason"] = CreateEnum("Barotrauma.Networking.DisconnectReason")
defaultLib["CombatMode"] = CreateEnum("Barotrauma.AIObjectiveCombat+CombatMode")
defaultLib["CauseOfDeathType"] = CreateEnum("Barotrauma.CauseOfDeathType")
defaultLib["CharacterTeamType"] = CreateEnum("Barotrauma.CharacterTeamType")
defaultLib["ClientPermissions"] = CreateEnum("Barotrauma.Networking.ClientPermissions")
defaultLib["OrderCategory"] = CreateEnum("Barotrauma.OrderCategory")
defaultLib["WearableType"] = CreateEnum("Barotrauma.WearableType")
defaultLib["NumberType"] = CreateEnum("Barotrauma.NumberType")
defaultLib["ChatMode"] = CreateEnum("Barotrauma.ChatMode")
defaultLib["CharacterType"] = CreateEnum("Barotrauma.CharacterType")
defaultLib["VoteType"] = CreateEnum("Barotrauma.Networking.VoteType")
defaultLib["CanEnterSubmarine"] = CreateEnum("Barotrauma.CanEnterSubmarine")
defaultLib["InputType"] = CreateStatic("Barotrauma.InputType")

defaultLib["EventPrefab"] = CreateStatic("Barotrauma.EventPrefab", true)
defaultLib["TraitorEventPrefab"] = CreateStatic("Barotrauma.TraitorEventPrefab", true)
defaultLib["TraitorEvent"] = CreateStatic("Barotrauma.TraitorEvent", true)
defaultLib["EventSet"] = CreateStatic("Barotrauma.EventSet", true)
defaultLib["EventManagerSettings"] = CreateStatic("Barotrauma.EventManagerSettings", true)

defaultLib["NetConfig"] = CreateStatic("Barotrauma.Networking.NetConfig")
defaultLib["NetworkConnection"] = CreateStatic("Barotrauma.Networking.NetworkConnection")
defaultLib["Inventory"] = CreateStatic("Barotrauma.Inventory", true)
defaultLib["CharacterInventory"] = CreateStatic("Barotrauma.CharacterInventory", true)
defaultLib["ItemInventory"] = CreateStatic("Barotrauma.ItemInventory", true)
defaultLib["ContentPackageManager"] = CreateStatic("Barotrauma.ContentPackageManager")
defaultLib["GameSettings"] = CreateStatic("Barotrauma.GameSettings")
defaultLib["RichString"] = CreateStatic("Barotrauma.RichString", true)
defaultLib["Identifier"] = CreateStatic("Barotrauma.Identifier", true)
defaultLib["LanguageIdentifier"] = CreateStatic("Barotrauma.LanguageIdentifier", true)
defaultLib["ContentPackage"] = CreateStatic("Barotrauma.ContentPackage", true)
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["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)
defaultLib["CharacterInfoPrefab"] = CreateStatic("Barotrauma.CharacterInfoPrefab")
defaultLib["Item"] = CreateStatic("Barotrauma.Item", true)
AddCallMetaTable(defaultLib["Item"].ChangePropertyEventData)
defaultLib["MapEntityPrefab"] = CreateStatic("Barotrauma.MapEntityPrefab")
defaultLib["ItemPrefab"] = CreateStatic("Barotrauma.ItemPrefab", true)
defaultLib["TalentTree"] = CreateStatic("Barotrauma.TalentTree", true)
defaultLib["TalentPrefab"] = CreateStatic("Barotrauma.TalentPrefab", true)
defaultLib["FactionPrefab"] = CreateStatic("Barotrauma.FactionPrefab", true)
defaultLib["MissionPrefab"] = CreateStatic("Barotrauma.MissionPrefab", true)
defaultLib["Mission"] = CreateStatic("Barotrauma.Mission", true)
defaultLib["Level"] = CreateStatic("Barotrauma.Level")
defaultLib["LevelGenerationParams"] = CreateStatic("Barotrauma.LevelGenerationParams", true)
defaultLib["OutpostGenerationParams"] = CreateStatic("Barotrauma.OutpostGenerationParams", true)
defaultLib["RuinGenerationParams"] = CreateStatic("Barotrauma.RuinGeneration.RuinGenerationParams", true)
defaultLib["Job"] = CreateStatic("Barotrauma.Job", true)
defaultLib["JobPrefab"] = CreateStatic("Barotrauma.JobPrefab", true)
defaultLib["JobVariant"] = CreateStatic("Barotrauma.JobVariant", true)
defaultLib["AfflictionPrefab"] = CreateStatic("Barotrauma.AfflictionPrefab", true)
defaultLib["SkillSettings"] = CreateStatic("Barotrauma.SkillSettings", true)
defaultLib["ChatMessage"] = CreateStatic("Barotrauma.Networking.ChatMessage")
defaultLib["Structure"] = CreateStatic("Barotrauma.Structure", true)
defaultLib["Hull"] = CreateStatic("Barotrauma.Hull", true)
defaultLib["Gap"] = CreateStatic("Barotrauma.Gap", true)
defaultLib["Signal"] = CreateStatic("Barotrauma.Items.Components.Signal", true)
defaultLib["SubmarineInfo"] = CreateStatic("Barotrauma.SubmarineInfo", true)
defaultLib["Entity"] = CreateStatic("Barotrauma.Entity", true)
defaultLib["MapEntity"] = CreateStatic("Barotrauma.MapEntity", true)
defaultLib["Physics"] = CreateStatic("Barotrauma.Physics")
defaultLib["FireSource"] = CreateStatic("Barotrauma.FireSource", true)
defaultLib["TextManager"] = CreateStatic("Barotrauma.TextManager")
defaultLib["NetEntityEvent"] = CreateStatic("Barotrauma.Networking.NetEntityEvent")
defaultLib["Screen"] = CreateStatic("Barotrauma.Screen")
defaultLib["AttackResult"] = CreateStatic("Barotrauma.AttackResult", true)
defaultLib["TempClient"] = CreateStatic("Barotrauma.Networking.TempClient", true)
defaultLib["DecalManager"] = CreateStatic("Barotrauma.DecalManager", true)
defaultLib["AutoItemPlacer"] = CreateStatic("Barotrauma.AutoItemPlacer")
defaultLib["PropertyConditional"] = CreateStatic("Barotrauma.PropertyConditional", true)
defaultLib["StatusEffect"] = CreateStatic("Barotrauma.StatusEffect", true)
defaultLib["OutpostGenerator"] = CreateStatic("Barotrauma.OutpostGenerator")
defaultLib["DamageModifier"] = CreateStatic("Barotrauma.DamageModifier", true)
defaultLib["TraitorManager"] = CreateStatic("Barotrauma.TraitorManager", true)
AddCallMetaTable(defaultLib["TraitorManager"].TraitorResults)

defaultLib["Md5Hash"] = CreateStatic("Barotrauma.Md5Hash", true)
defaultLib["ContentXElement"] = CreateStatic("Barotrauma.ContentXElement", true)
defaultLib["ContentPath"] = CreateStatic("Barotrauma.ContentPath", true)
defaultLib["XElement"] = CreateStatic("System.Xml.Linq.XElement", true)
defaultLib["XName"] = CreateStatic("System.Xml.Linq.XName", true)
defaultLib["XAttribute"] = CreateStatic("System.Xml.Linq.XAttribute", true)
defaultLib["XContainer"] = CreateStatic("System.Xml.Linq.XContainer", true)
defaultLib["XDocument"] = CreateStatic("System.Xml.Linq.XDocument", true)
defaultLib["XNode"] = CreateStatic("System.Xml.Linq.XNode", true)
defaultLib["SoundsFile"] = CreateStatic("Barotrauma.SoundsFile", true)

defaultLib["Voting"] = CreateStatic("Barotrauma.Voting")
defaultLib["TimeSpan"] = CreateStatic("System.TimeSpan")
defaultLib["IPAddress"] = CreateStatic("System.Net.IPAddress")
defaultLib["ContentPackageId"] = CreateStatic("Barotrauma.ContentPackageId")
defaultLib["Address"] = CreateStatic("Barotrauma.Networking.Address")
defaultLib["AccountId"] = CreateStatic("Barotrauma.Networking.AccountId")
defaultLib["Endpoint"] = CreateStatic("Barotrauma.Networking.Endpoint")

defaultLib["Explosion"] = CreateStatic("Barotrauma.Explosion", true)

defaultLib["ConvertUnits"] = CreateStatic("FarseerPhysics.ConvertUnits")
defaultLib["ToolBox"] = CreateStatic("Barotrauma.ToolBox")

defaultLib["AIObjective"] = CreateStatic("Barotrauma.AIObjective", true)
defaultLib["AIObjectiveChargeBatteries"] = CreateStatic("Barotrauma.AIObjectiveChargeBatteries", true)
defaultLib["AIObjectiveCleanupItem"] = CreateStatic("Barotrauma.AIObjectiveCleanupItem", true)
defaultLib["AIObjectiveCleanupItems"] = CreateStatic("Barotrauma.AIObjectiveCleanupItems", true)
defaultLib["AIObjectiveCombat"] = CreateStatic("Barotrauma.AIObjectiveCombat", true)
defaultLib["AIObjectiveContainItem"] = CreateStatic("Barotrauma.AIObjectiveContainItem", true)
defaultLib["AIObjectiveDecontainItem"] = CreateStatic("Barotrauma.AIObjectiveDecontainItem", true)
defaultLib["AIObjectiveEscapeHandcuffs"] = CreateStatic("Barotrauma.AIObjectiveEscapeHandcuffs", true)
defaultLib["AIObjectiveExtinguishFire"] = CreateStatic("Barotrauma.AIObjectiveExtinguishFire", true)
defaultLib["AIObjectiveExtinguishFires"] = CreateStatic("Barotrauma.AIObjectiveExtinguishFires", true)
defaultLib["AIObjectiveFightIntruders"] = CreateStatic("Barotrauma.AIObjectiveFightIntruders", true)
defaultLib["AIObjectiveFindDivingGear"] = CreateStatic("Barotrauma.AIObjectiveFindDivingGear", true)
defaultLib["AIObjectiveFindSafety"] = CreateStatic("Barotrauma.AIObjectiveFindSafety", true)
defaultLib["AIObjectiveFixLeak"] = CreateStatic("Barotrauma.AIObjectiveFixLeak", true)
defaultLib["AIObjectiveFixLeaks"] = CreateStatic("Barotrauma.AIObjectiveFixLeaks", true)
defaultLib["AIObjectiveGetItem"] = CreateStatic("Barotrauma.AIObjectiveGetItem", true)
defaultLib["AIObjectiveGoTo"] = CreateStatic("Barotrauma.AIObjectiveGoTo", true)
defaultLib["AIObjectiveIdle"] = CreateStatic("Barotrauma.AIObjectiveIdle", true)
defaultLib["AIObjectiveOperateItem"] = CreateStatic("Barotrauma.AIObjectiveOperateItem", true)
defaultLib["AIObjectiveOperateItem"] = CreateStatic("Barotrauma.AIObjectiveOperateItem", true)
defaultLib["AIObjectivePumpWater"] = CreateStatic("Barotrauma.AIObjectivePumpWater", true)
defaultLib["AIObjectiveRepairItem"] = CreateStatic("Barotrauma.AIObjectiveRepairItem", true)
defaultLib["AIObjectiveRepairItems"] = CreateStatic("Barotrauma.AIObjectiveRepairItems", true)
defaultLib["AIObjectiveRescue"] = CreateStatic("Barotrauma.AIObjectiveRescue", true)
defaultLib["AIObjectiveRescueAll"] = CreateStatic("Barotrauma.AIObjectiveRescueAll", true)
defaultLib["AIObjectiveReturn"] = CreateStatic("Barotrauma.AIObjectiveReturn", true)
defaultLib["AITarget"] = CreateStatic("Barotrauma.AITarget", true)

defaultLib["Order"] = CreateStatic("Barotrauma.Order", true)
defaultLib["OrderPrefab"] = CreateStatic("Barotrauma.OrderPrefab", true)
defaultLib["OrderTarget"] = CreateStatic("Barotrauma.OrderTarget", true)

local componentsToReference = { "DockingPort", "Door", "GeneticMaterial", "Growable", "Holdable", "LevelResource", "ItemComponent", "ItemLabel", "LightComponent", "Controller", "Deconstructor", "Engine", "Fabricator", "OutpostTerminal", "Pump", "Reactor", "Steering", "PowerContainer", "Projectile", "Repairable", "Rope", "Scanner", "ButtonTerminal", "ConnectionPanel", "CustomInterface", "MemoryComponent", "Terminal", "WifiComponent", "Wire", "TriggerComponent", "ElectricalDischarger", "EntitySpawnerComponent", "ProducedItem", "VineTile", "GrowthSideExtension", "IdCard", "MeleeWeapon", "Pickable", "Propulsion", "RangedWeapon", "RepairTool", "Sprayer", "Throwable", "ItemContainer", "Ladder", "LimbPos", "MiniMap", "OxygenGenerator", "Sonar", "SonarTransducer", "Vent", "NameTag", "Planter", "Powered", "PowerTransfer", "Quality", "RemoteController", "AdderComponent", "AndComponent", "ArithmeticComponent", "ColorComponent", "ConcatComponent", "Connection", "DelayComponent", "DivideComponent", "EqualsComponent", "ExponentiationComponent", "FunctionComponent", "GreaterComponent", "ModuloComponent", "MotionSensor", "MultiplyComponent", "NotComponent", "OrComponent", "OscillatorComponent", "OxygenDetector", "RegExFindComponent", "RelayComponent", "SignalCheckComponent", "SmokeDetector", "StringComponent", "SubtractComponent", "TrigonometricFunctionComponent", "WaterDetector", "XorComponent", "StatusHUD", "Turret", "Wearable", "CustomInterface"
}

defaultLib["Components"] = {}

for key, value in pairs(componentsToReference) do
	defaultLib["Components"][value] = CreateStatic("Barotrauma.Items.Components." .. value, true)
end

defaultLib["Vector2"] = CreateStatic("Microsoft.Xna.Framework.Vector2", true)
defaultLib["Vector3"] = CreateStatic("Microsoft.Xna.Framework.Vector3", true)
defaultLib["Vector4"] = CreateStatic("Microsoft.Xna.Framework.Vector4", true)
defaultLib["Color"] = CreateStatic("Microsoft.Xna.Framework.Color", true)
defaultLib["Point"] = CreateStatic("Microsoft.Xna.Framework.Point", true)
defaultLib["Rectangle"] = CreateStatic("Microsoft.Xna.Framework.Rectangle", true)
defaultLib["Matrix"] = CreateStatic("Microsoft.Xna.Framework.Matrix", true)

return defaultLib
