diff --git a/Barotrauma/BarotraumaShared/SharedSource/Lua/LuaSetup.cs b/Barotrauma/BarotraumaShared/SharedSource/Lua/LuaSetup.cs index ab6083103..447640a81 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Lua/LuaSetup.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Lua/LuaSetup.cs @@ -327,6 +327,9 @@ namespace Barotrauma UserData.RegisterType(); UserData.RegisterType(); UserData.RegisterType(); + UserData.RegisterType(); + UserData.RegisterType(); + UserData.RegisterType(); AddCallMetaMember(UserData.RegisterType()); AddCallMetaMember(UserData.RegisterType()); @@ -411,7 +414,8 @@ namespace Barotrauma lua.Globals["DeliveryMethod"] = UserData.CreateStatic(); lua.Globals["ClientPacketHeader"] = UserData.CreateStatic(); lua.Globals["ServerPacketHeader"] = UserData.CreateStatic(); - + lua.Globals["RandSync"] = UserData.CreateStatic(); + #if SERVER #elif CLIENT @@ -434,7 +438,9 @@ namespace Barotrauma lua.Globals["SERVER"] = isServer; lua.Globals["CLIENT"] = !isServer; - + + LuaDocs.GenerateDocs(typeof(JobPrefab)); + if (File.Exists("Lua/MoonsharpSetup.lua")) // try the default loader DoFile("Lua/MoonsharpSetup.lua"); else if (File.Exists("Mods/LuaForBarotrauma/Lua/MoonsharpSetup.lua")) // in case its the workshop version diff --git a/config.ld b/config.ld index 1e7ae04ca..8d2c665fc 100644 --- a/config.ld +++ b/config.ld @@ -62,6 +62,9 @@ tparam_alias("Vector4", "Vector4") tparam_alias("CauseOfDeath", "CauseOfDeath") tparam_alias("CharacterInventory", "CharacterInventory") tparam_alias("PhysicsBody", "PhysicsBody") +tparam_alias("JobPrefab", "JobPrefab") +tparam_alias("Job", "Job") +tparam_alias("Inventory", "Inventory") tparam_alias("string", "string") diff --git a/docs/lua/ItemPrefab.lua b/docs/lua/ItemPrefab.lua index b4e175dfb..069505ba7 100644 --- a/docs/lua/ItemPrefab.lua +++ b/docs/lua/ItemPrefab.lua @@ -34,3 +34,565 @@ function ItemPrefab.GetItemPrefab(itemNameOrId) end -- Identifier, the identifier of the prefab. -- @realm shared -- @string Identifier + + + +------ AUTO DOCS -------- + + +--- RemoveByFile +-- @realm shared +-- @tparam string filePath +function ItemPrefab.RemoveByFile(filePath) end + +--- LoadFromFile +-- @realm shared +-- @tparam ContentFile file +function ItemPrefab.LoadFromFile(file) end + +--- LoadAll +-- @realm shared +-- @tparam IEnumerable`1 files +function ItemPrefab.LoadAll(files) end + +--- InitFabricationRecipes +-- @realm shared +function ItemPrefab.InitFabricationRecipes() end + +--- GenerateLegacyIdentifier +-- @realm shared +-- @tparam string name +-- @treturn string +function ItemPrefab.GenerateLegacyIdentifier(name) end + +--- GetTreatmentSuitability +-- @realm shared +-- @tparam string treatmentIdentifier +-- @treturn number +function GetTreatmentSuitability(treatmentIdentifier) end + +--- GetPriceInfo +-- @realm shared +-- @tparam Location location +-- @treturn PriceInfo +function GetPriceInfo(location) end + +--- CanBeBoughtAtLocation +-- @realm shared +-- @tparam Location location +-- @tparam PriceInfo& priceInfo +-- @treturn bool +function CanBeBoughtAtLocation(location, priceInfo) end + +--- Find +-- @realm shared +-- @tparam string name +-- @tparam string identifier +-- @treturn ItemPrefab +function ItemPrefab.Find(name, identifier) end + +--- GetMinPrice +-- @realm shared +-- @treturn Nullable`1 +function GetMinPrice() end + +--- GetBuyPricesUnder +-- @realm shared +-- @tparam number maxCost +-- @treturn ImmutableDictionary`2 +function GetBuyPricesUnder(maxCost) end + +--- GetSellPricesOver +-- @realm shared +-- @tparam number minCost +-- @tparam bool sellingImportant +-- @treturn ImmutableDictionary`2 +function GetSellPricesOver(minCost, sellingImportant) end + +--- IsContainerPreferred +-- @realm shared +-- @tparam Item item +-- @tparam ItemContainer targetContainer +-- @tparam Boolean& isPreferencesDefined +-- @tparam Boolean& isSecondary +-- @treturn bool +function IsContainerPreferred(item, targetContainer, isPreferencesDefined, isSecondary) end + +--- IsContainerPreferred +-- @realm shared +-- @tparam Item item +-- @tparam String[] identifiersOrTags +-- @tparam Boolean& isPreferencesDefined +-- @tparam Boolean& isSecondary +-- @treturn bool +function IsContainerPreferred(item, identifiersOrTags, isPreferencesDefined, isSecondary) end + +--- IsContainerPreferred +-- @realm shared +-- @tparam IEnumerable`1 preferences +-- @tparam ItemContainer c +-- @treturn bool +function ItemPrefab.IsContainerPreferred(preferences, c) end + +--- IsContainerPreferred +-- @realm shared +-- @tparam IEnumerable`1 preferences +-- @tparam IEnumerable`1 ids +-- @treturn bool +function ItemPrefab.IsContainerPreferred(preferences, ids) end + +--- Dispose +-- @realm shared +function Dispose() end + +--- GetItemNameTextId +-- @realm shared +-- @treturn string +function GetItemNameTextId() end + +--- GetHullNameTextId +-- @realm shared +-- @treturn string +function GetHullNameTextId() end + +--- GetAllowedUpgrades +-- @realm shared +-- @treturn String[] +function GetAllowedUpgrades() end + +--- HasSubCategory +-- @realm shared +-- @tparam string subcategory +-- @treturn bool +function HasSubCategory(subcategory) end + +--- DebugCreateInstance +-- @realm shared +function DebugCreateInstance() end + +--- NameMatches +-- @realm shared +-- @tparam string name +-- @tparam StringComparison comparisonType +-- @treturn bool +function NameMatches(name, comparisonType) end + +--- NameMatches +-- @realm shared +-- @tparam IEnumerable`1 allowedNames +-- @tparam StringComparison comparisonType +-- @treturn bool +function NameMatches(allowedNames, comparisonType) end + +--- IsLinkAllowed +-- @realm shared +-- @tparam MapEntityPrefab target +-- @treturn bool +function IsLinkAllowed(target) end + +--- GetType +-- @realm shared +-- @treturn Type +function GetType() end + +--- ToString +-- @realm shared +-- @treturn string +function ToString() end + +--- Equals +-- @realm shared +-- @tparam Object obj +-- @treturn bool +function Equals(obj) end + +--- GetHashCode +-- @realm shared +-- @treturn number +function GetHashCode() end + +--- +-- Name, Field of type string +-- @realm shared +-- @string Name + +--- +-- ConfigElement, Field of type XElement +-- @realm shared +-- @XElement ConfigElement + +--- +-- DeconstructItems, Field of type table +-- @realm shared +-- @table DeconstructItems + +--- +-- FabricationRecipes, Field of type table +-- @realm shared +-- @table FabricationRecipes + +--- +-- DeconstructTime, Field of type number +-- @realm shared +-- @number DeconstructTime + +--- +-- AllowDeconstruct, Field of type bool +-- @realm shared +-- @bool AllowDeconstruct + +--- +-- InteractDistance, Field of type number +-- @realm shared +-- @number InteractDistance + +--- +-- InteractPriority, Field of type number +-- @realm shared +-- @number InteractPriority + +--- +-- InteractThroughWalls, Field of type bool +-- @realm shared +-- @bool InteractThroughWalls + +--- +-- HideConditionBar, Field of type bool +-- @realm shared +-- @bool HideConditionBar + +--- +-- RequireBodyInsideTrigger, Field of type bool +-- @realm shared +-- @bool RequireBodyInsideTrigger + +--- +-- RequireCursorInsideTrigger, Field of type bool +-- @realm shared +-- @bool RequireCursorInsideTrigger + +--- +-- RequireCampaignInteract, Field of type bool +-- @realm shared +-- @bool RequireCampaignInteract + +--- +-- FocusOnSelected, Field of type bool +-- @realm shared +-- @bool FocusOnSelected + +--- +-- OffsetOnSelected, Field of type number +-- @realm shared +-- @number OffsetOnSelected + +--- +-- Health, Field of type number +-- @realm shared +-- @number Health + +--- +-- AllowSellingWhenBroken, Field of type bool +-- @realm shared +-- @bool AllowSellingWhenBroken + +--- +-- Indestructible, Field of type bool +-- @realm shared +-- @bool Indestructible + +--- +-- DamagedByExplosions, Field of type bool +-- @realm shared +-- @bool DamagedByExplosions + +--- +-- ExplosionDamageMultiplier, Field of type number +-- @realm shared +-- @number ExplosionDamageMultiplier + +--- +-- DamagedByProjectiles, Field of type bool +-- @realm shared +-- @bool DamagedByProjectiles + +--- +-- DamagedByMeleeWeapons, Field of type bool +-- @realm shared +-- @bool DamagedByMeleeWeapons + +--- +-- DamagedByRepairTools, Field of type bool +-- @realm shared +-- @bool DamagedByRepairTools + +--- +-- DamagedByMonsters, Field of type bool +-- @realm shared +-- @bool DamagedByMonsters + +--- +-- FireProof, Field of type bool +-- @realm shared +-- @bool FireProof + +--- +-- WaterProof, Field of type bool +-- @realm shared +-- @bool WaterProof + +--- +-- ImpactTolerance, Field of type number +-- @realm shared +-- @number ImpactTolerance + +--- +-- SonarSize, Field of type number +-- @realm shared +-- @number SonarSize + +--- +-- UseInHealthInterface, Field of type bool +-- @realm shared +-- @bool UseInHealthInterface + +--- +-- DisableItemUsageWhenSelected, Field of type bool +-- @realm shared +-- @bool DisableItemUsageWhenSelected + +--- +-- CargoContainerIdentifier, Field of type string +-- @realm shared +-- @string CargoContainerIdentifier + +--- +-- UseContainedSpriteColor, Field of type bool +-- @realm shared +-- @bool UseContainedSpriteColor + +--- +-- UseContainedInventoryIconColor, Field of type bool +-- @realm shared +-- @bool UseContainedInventoryIconColor + +--- +-- EquipConfirmationText, Field of type string +-- @realm shared +-- @string EquipConfirmationText + +--- +-- AllowRotatingInEditor, Field of type bool +-- @realm shared +-- @bool AllowRotatingInEditor + +--- +-- ShowContentsInTooltip, Field of type bool +-- @realm shared +-- @bool ShowContentsInTooltip + +--- +-- PreferredContainers, Field of type table +-- @realm shared +-- @table PreferredContainers + +--- +-- SwappableItem, Field of type SwappableItem +-- @realm shared +-- @SwappableItem SwappableItem + +--- +-- LevelCommonness, Field of type table +-- @realm shared +-- @table LevelCommonness + +--- +-- LevelQuantity, Field of type table +-- @realm shared +-- @table LevelQuantity + +--- +-- CanFlipX, Field of type bool +-- @realm shared +-- @bool CanFlipX + +--- +-- CanFlipY, Field of type bool +-- @realm shared +-- @bool CanFlipY + +--- +-- IsDangerous, Field of type bool +-- @realm shared +-- @bool IsDangerous + +--- +-- CanSpriteFlipX, Field of type bool +-- @realm shared +-- @bool CanSpriteFlipX + +--- +-- CanSpriteFlipY, Field of type bool +-- @realm shared +-- @bool CanSpriteFlipY + +--- +-- MaxStackSize, Field of type number +-- @realm shared +-- @number MaxStackSize + +--- +-- AllowDroppingOnSwap, Field of type bool +-- @realm shared +-- @bool AllowDroppingOnSwap + +--- +-- AllowDroppingOnSwapWith, Field of type IEnumerable`1 +-- @realm shared +-- @IEnumerable`1 AllowDroppingOnSwapWith + +--- +-- Size, Field of type Vector2 +-- @realm shared +-- @Vector2 Size + +--- +-- CanBeBought, Field of type bool +-- @realm shared +-- @bool CanBeBought + +--- +-- CanBeSold, Field of type bool +-- @realm shared +-- @bool CanBeSold + +--- +-- RandomDeconstructionOutput, Field of type bool +-- @realm shared +-- @bool RandomDeconstructionOutput + +--- +-- RandomDeconstructionOutputAmount, Field of type number +-- @realm shared +-- @number RandomDeconstructionOutputAmount + +--- +-- UIntIdentifier, Field of type number +-- @realm shared +-- @number UIntIdentifier + +--- +-- ResizeHorizontal, Field of type bool +-- @realm shared +-- @bool ResizeHorizontal + +--- +-- ResizeVertical, Field of type bool +-- @realm shared +-- @bool ResizeVertical + +--- +-- OriginalName, Field of type string +-- @realm shared +-- @string OriginalName + +--- +-- Identifier, Field of type string +-- @realm shared +-- @string Identifier + +--- +-- FilePath, Field of type string +-- @realm shared +-- @string FilePath + +--- +-- ContentPackage, Field of type ContentPackage +-- @realm shared +-- @ContentPackage ContentPackage + +--- +-- Tags, Field of type HashSet`1 +-- @realm shared +-- @HashSet`1 Tags + +--- +-- Description, Field of type string +-- @realm shared +-- @string Description + +--- +-- AllowedUpgrades, Field of type string +-- @realm shared +-- @string AllowedUpgrades + +--- +-- HideInMenus, Field of type bool +-- @realm shared +-- @bool HideInMenus + +--- +-- Subcategory, Field of type string +-- @realm shared +-- @string Subcategory + +--- +-- Linkable, Field of type bool +-- @realm shared +-- @bool Linkable + +--- +-- AllowedLinks, Field of type table +-- @realm shared +-- @table AllowedLinks + +--- +-- Category, Field of type MapEntityCategory +-- @realm shared +-- @MapEntityCategory Category + +--- +-- SpriteColor, Field of type Color +-- @realm shared +-- @Color SpriteColor + +--- +-- Scale, Field of type number +-- @realm shared +-- @number Scale + +--- +-- Aliases, Field of type HashSet`1 +-- @realm shared +-- @HashSet`1 Aliases + +--- +-- DefaultPrice, Field of type PriceInfo +-- @realm shared +-- @PriceInfo DefaultPrice + +--- +-- Triggers, Field of type table +-- @realm shared +-- @table Triggers + +--- +-- IsOverride, Field of type bool +-- @realm shared +-- @bool IsOverride + +--- +-- AllowAsExtraCargo, Field of type Nullable`1 +-- @realm shared +-- @Nullable`1 AllowAsExtraCargo + +--- +-- ItemPrefab.Prefabs, Field of type PrefabCollection`1 +-- @realm shared +-- @PrefabCollection`1 ItemPrefab.Prefabs + +--- +-- sprite, Field of type Sprite +-- @realm shared +-- @Sprite sprite + diff --git a/docs/lua/Job.lua b/docs/lua/Job.lua new file mode 100644 index 000000000..dea1e3d4a --- /dev/null +++ b/docs/lua/Job.lua @@ -0,0 +1,93 @@ +-- luacheck: ignore 111 + +--[[-- +Barotrauma Job class with some additional functions and fields + +Barotrauma source code: [Job.cs](https://github.com/evilfactory/Barotrauma-lua-attempt/blob/master/Barotrauma/BarotraumaShared/SharedSource/Characters/Jobs/Job.cs) +]] +-- @code Job +-- @pragma nostrip + +local Job = {} + +--- Random +-- @realm shared +-- @tparam RandSync randSync +-- @treturn Job +function Job.Random(randSync) end + +--- GetSkillLevel +-- @realm shared +-- @tparam string skillIdentifier +-- @treturn number +function GetSkillLevel(skillIdentifier) end + +--- IncreaseSkillLevel +-- @realm shared +-- @tparam string skillIdentifier +-- @tparam number increase +function IncreaseSkillLevel(skillIdentifier, increase) end + +--- GiveJobItems +-- @realm shared +-- @tparam Character character +-- @tparam WayPoint spawnPoint +function GiveJobItems(character, spawnPoint) end + +--- Save +-- @realm shared +-- @tparam XElement parentElement +-- @treturn XElement +function Save(parentElement) end + +--- GetType +-- @realm shared +-- @treturn Type +function GetType() end + +--- ToString +-- @realm shared +-- @treturn string +function ToString() end + +--- Equals +-- @realm shared +-- @tparam Object obj +-- @treturn bool +function Equals(obj) end + +--- GetHashCode +-- @realm shared +-- @treturn number +function GetHashCode() end + +--- +-- Name, Field of type string +-- @realm shared +-- @string Name + +--- +-- Description, Field of type string +-- @realm shared +-- @string Description + +--- +-- Prefab, Field of type JobPrefab +-- @realm shared +-- @JobPrefab Prefab + +--- +-- Skills, Field of type table +-- @realm shared +-- @table Skills + +--- +-- PrimarySkill, Field of type Skill +-- @realm shared +-- @Skill PrimarySkill + +--- +-- Variant, Field of type number +-- @realm shared +-- @number Variant + diff --git a/docs/lua/JobPrefab.lua b/docs/lua/JobPrefab.lua new file mode 100644 index 000000000..fd9328148 --- /dev/null +++ b/docs/lua/JobPrefab.lua @@ -0,0 +1,229 @@ +-- luacheck: ignore 111 + +--[[-- +Barotrauma JobPrefab class with some additional functions and fields + +Barotrauma source code: [JobPrefab.cs](https://github.com/evilfactory/Barotrauma-lua-attempt/blob/master/Barotrauma/BarotraumaShared/SharedSource/Characters/Jobs/JobPrefab.cs) +]] +-- @code JobPrefab +-- @pragma nostrip + +local JobPrefab = {} + +--- Dispose +-- @realm shared +function Dispose() end + +--- Get +-- @realm shared +-- @tparam string identifier +-- @treturn JobPrefab +function JobPrefab.Get(identifier) end + +--- Random +-- @realm shared +-- @tparam RandSync sync +-- @treturn JobPrefab +function JobPrefab.Random(sync) end + +--- LoadAll +-- @realm shared +-- @tparam IEnumerable`1 files +function JobPrefab.LoadAll(files) end + +--- LoadFromFile +-- @realm shared +-- @tparam ContentFile file +function JobPrefab.LoadFromFile(file) end + +--- RemoveByFile +-- @realm shared +-- @tparam string filePath +function JobPrefab.RemoveByFile(filePath) end + +--- GetType +-- @realm shared +-- @treturn Type +function GetType() end + +--- ToString +-- @realm shared +-- @treturn string +function ToString() end + +--- Equals +-- @realm shared +-- @tparam Object obj +-- @treturn bool +function Equals(obj) end + +--- GetHashCode +-- @realm shared +-- @treturn number +function GetHashCode() end + +--- +-- JobPrefab.ItemRepairPriorities, Field of type IReadOnlyDictionary`2 +-- @realm shared +-- @IReadOnlyDictionary`2 JobPrefab.ItemRepairPriorities + +--- +-- UIColor, Field of type Color +-- @realm shared +-- @Color UIColor + +--- +-- Identifier, Field of type string +-- @realm shared +-- @string Identifier + +--- +-- Name, Field of type string +-- @realm shared +-- @string Name + +--- +-- IdleBehavior, Field of type BehaviorType +-- @realm shared +-- @BehaviorType IdleBehavior + +--- +-- OriginalName, Field of type string +-- @realm shared +-- @string OriginalName + +--- +-- ContentPackage, Field of type ContentPackage +-- @realm shared +-- @ContentPackage ContentPackage + +--- +-- Description, Field of type string +-- @realm shared +-- @string Description + +--- +-- OnlyJobSpecificDialog, Field of type bool +-- @realm shared +-- @bool OnlyJobSpecificDialog + +--- +-- InitialCount, Field of type number +-- @realm shared +-- @number InitialCount + +--- +-- AllowAlways, Field of type bool +-- @realm shared +-- @bool AllowAlways + +--- +-- MaxNumber, Field of type number +-- @realm shared +-- @number MaxNumber + +--- +-- MinNumber, Field of type number +-- @realm shared +-- @number MinNumber + +--- +-- MinKarma, Field of type number +-- @realm shared +-- @number MinKarma + +--- +-- PriceMultiplier, Field of type number +-- @realm shared +-- @number PriceMultiplier + +--- +-- Commonness, Field of type number +-- @realm shared +-- @number Commonness + +--- +-- VitalityModifier, Field of type number +-- @realm shared +-- @number VitalityModifier + +--- +-- HiddenJob, Field of type bool +-- @realm shared +-- @bool HiddenJob + +--- +-- PrimarySkill, Field of type SkillPrefab +-- @realm shared +-- @SkillPrefab PrimarySkill + +--- +-- FilePath, Field of type string +-- @realm shared +-- @string FilePath + +--- +-- Element, Field of type XElement +-- @realm shared +-- @XElement Element + +--- +-- ClothingElement, Field of type XElement +-- @realm shared +-- @XElement ClothingElement + +--- +-- Variants, Field of type number +-- @realm shared +-- @number Variants + +--- +-- ItemSets, Field of type table +-- @realm shared +-- @table ItemSets + +--- +-- ItemIdentifiers, Field of type table +-- @realm shared +-- @table ItemIdentifiers + +--- +-- ShowItemPreview, Field of type table +-- @realm shared +-- @table ShowItemPreview + +--- +-- Skills, Field of type table +-- @realm shared +-- @table Skills + +--- +-- AutonomousObjectives, Field of type table +-- @realm shared +-- @table AutonomousObjectives + +--- +-- AppropriateOrders, Field of type table +-- @realm shared +-- @table AppropriateOrders + +--- +-- Icon, Field of type Sprite +-- @realm shared +-- @Sprite Icon + +--- +-- IconSmall, Field of type Sprite +-- @realm shared +-- @Sprite IconSmall + +--- +-- JobPrefab.Prefabs, Field of type PrefabCollection`1 +-- @realm shared +-- @PrefabCollection`1 JobPrefab.Prefabs + +--- +-- JobPrefab.NoJobElement, Field of type XElement +-- @realm shared +-- @XElement JobPrefab.NoJobElement + diff --git a/docs/lua/enums/RandSync.lua b/docs/lua/enums/RandSync.lua new file mode 100644 index 000000000..4857b09a7 --- /dev/null +++ b/docs/lua/enums/RandSync.lua @@ -0,0 +1,19 @@ +--[[-- +RandSync enum. +]] +-- @enum RandSync + +--- +-- RandSync.Unsynced = -1 +-- @realm shared +-- @number RandSync.Unsynced + +--- +-- RandSync.Server = 0 +-- @realm shared +-- @number RandSync.Server + +--- +-- RandSync.ClientOnly = 1 +-- @realm shared +-- @number RandSync.ClientOnly \ No newline at end of file