diff --git a/Barotrauma/BarotraumaClient/ClientSource/Networking/GameClient.cs b/Barotrauma/BarotraumaClient/ClientSource/Networking/GameClient.cs index 9e2cc342f..126512508 100644 --- a/Barotrauma/BarotraumaClient/ClientSource/Networking/GameClient.cs +++ b/Barotrauma/BarotraumaClient/ClientSource/Networking/GameClient.cs @@ -270,7 +270,7 @@ namespace Barotrauma.Networking otherClients = new List(); - serverSettings = new ServerSettings(this, "Server", 0, 0, 0, false, false); + serverSettings = new ServerSettings(this, "Server", 0, 0, 0, false, false, System.Net.IPAddress.Any); Voting = new Voting(); if (steamId == 0) diff --git a/Barotrauma/BarotraumaClient/ClientSource/Screens/MainMenuScreen.cs b/Barotrauma/BarotraumaClient/ClientSource/Screens/MainMenuScreen.cs index f4ce8b7ca..9d0f776da 100644 --- a/Barotrauma/BarotraumaClient/ClientSource/Screens/MainMenuScreen.cs +++ b/Barotrauma/BarotraumaClient/ClientSource/Screens/MainMenuScreen.cs @@ -386,7 +386,7 @@ namespace Barotrauma #endif new GUIButton(new RectTransform(new Point(300, 30), Frame.RectTransform, Anchor.TopLeft) { AbsoluteOffset = new Point(20, 50) }, - "Remove Client-Side Lua", style: "MainMenuGUIButton", color: GUI.Style.Red) + "Remove Client-Side Lua", style: "MainMenuGUIButton", color: GUIStyle.Red) { IgnoreLayoutGroups = true, UserData = Tab.Empty, @@ -407,7 +407,7 @@ namespace Barotrauma return false; } - var msg = new GUIMessageBox("Confirm", "Are you sure you want to remove Client-Side Lua?", new string[] { "Remove", "Cancel" }); + var msg = new GUIMessageBox("Confirm", "Are you sure you want to remove Client-Side Lua?", new LocalizedString[2] { TextManager.Get("Yes"), TextManager.Get("Cancel") }); msg.Buttons[0].OnClicked = (GUIButton button, object obj) => { diff --git a/Barotrauma/BarotraumaServer/ServerSource/DebugConsole.cs b/Barotrauma/BarotraumaServer/ServerSource/DebugConsole.cs index 854878003..6a963e27e 100644 --- a/Barotrauma/BarotraumaServer/ServerSource/DebugConsole.cs +++ b/Barotrauma/BarotraumaServer/ServerSource/DebugConsole.cs @@ -1252,7 +1252,7 @@ namespace Barotrauma commands.Add(new Command("install_cl_lua", "Installs client-Side Lua into your client.", (string[] args) => { - if (!File.Exists("Mods/LuaForBarotrauma/clientside_files.zip")) + if (!System.IO.File.Exists("Mods/LuaForBarotrauma/clientside_files.zip")) { GameMain.Server.SendChatMessage("clientside_files.zip doesn't exist, Github version?", ChatMessageType.ServerMessageBox); diff --git a/Barotrauma/BarotraumaServer/ServerSource/Lua/LuaBarotraumaAdditions.cs b/Barotrauma/BarotraumaServer/ServerSource/Lua/LuaBarotraumaAdditions.cs index 1b625bb7d..7199539f9 100644 --- a/Barotrauma/BarotraumaServer/ServerSource/Lua/LuaBarotraumaAdditions.cs +++ b/Barotrauma/BarotraumaServer/ServerSource/Lua/LuaBarotraumaAdditions.cs @@ -83,47 +83,12 @@ namespace Barotrauma return generic.Invoke(this, new object[]{comp, extraData }); } } - - partial class ItemPrefab - { - public static void AddToSpawnQueue(ItemPrefab itemPrefab, Vector2 position, object spawned = null) - { - EntitySpawner.Spawner.AddToSpawnQueue(itemPrefab, position, onSpawned: (Item item) => - { - GameMain.Lua.CallFunction(spawned, new object[] { item }); - }); - } - - public static void AddToSpawnQueue(ItemPrefab itemPrefab, Inventory inventory, object spawned = null) - { - EntitySpawner.Spawner.AddToSpawnQueue(itemPrefab, inventory, null, null, onSpawned: (Item item) => - { - GameMain.Lua.CallFunction(spawned, new object[] { item }); - }); - } - } } namespace Barotrauma.Items.Components { using Barotrauma.Networking; - partial class CustomInterface - { - public void UpdateClients() - { - - //notify all clients of the new state - GameMain.Server.CreateEntityEvent(item, new object[] - { - NetEntityEvent.Type.ComponentState, - item.GetComponentIndex(this) - }); - - item.CreateServerEvent(this); - } - } - partial struct Signal { public static Signal Create(string value, int stepsTaken = 0, Character sender = null, Item source = null, float power = 0.0f, float strength = 1.0f) diff --git a/Barotrauma/BarotraumaServer/WindowsServer.csproj b/Barotrauma/BarotraumaServer/WindowsServer.csproj index 261fb5a8b..b4a4bf530 100644 --- a/Barotrauma/BarotraumaServer/WindowsServer.csproj +++ b/Barotrauma/BarotraumaServer/WindowsServer.csproj @@ -82,8 +82,18 @@ + + + + + ..\..\Libraries\0Harmony.dll + + + ..\..\Libraries\MoonSharp.Interpreter.dll + + diff --git a/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Signal/Connection.cs b/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Signal/Connection.cs index 6f2f4c099..cf2ab8fc8 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Signal/Connection.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Signal/Connection.cs @@ -325,7 +325,7 @@ namespace Barotrauma.Items.Components object[] obj = new object[] { signal, connection }; GameMain.Lua.hook.Call("signalReceived", obj); - GameMain.Lua.hook.Call("signalReceived." + recipient.item.prefab.Identifier, obj); + GameMain.Lua.hook.Call("signalReceived." + recipient.item.Prefab.Identifier, obj); foreach (ItemComponent ic in recipient.item.Components) { diff --git a/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Signal/CustomInterface.cs b/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Signal/CustomInterface.cs index a9a616b74..dd94cf797 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Signal/CustomInterface.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Signal/CustomInterface.cs @@ -11,13 +11,13 @@ namespace Barotrauma.Items.Components private readonly struct EventData : IEventData { public readonly CustomInterfaceElement BtnElement; - + public EventData(CustomInterfaceElement btnElement) { BtnElement = btnElement; } } - + class CustomInterfaceElement : ISerializableEntity { public bool ContinuousSignal; @@ -141,8 +141,8 @@ namespace Barotrauma.Items.Components public override bool RecreateGUIOnResolutionChange => true; - public readonly List customInterfaceElementList = new List(); - + private readonly List customInterfaceElementList = new List(); + public CustomInterface(Item item, ContentXElement element) : base(item, element) { @@ -260,8 +260,8 @@ namespace Barotrauma.Items.Components partial void UpdateSignalsProjSpecific(); - partial void InitProjSpecific(); - + partial void InitProjSpecific(); + private void ButtonClicked(CustomInterfaceElement btnElement) { if (btnElement == null) return; @@ -342,4 +342,4 @@ namespace Barotrauma.Items.Components return base.Save(parentElement); } } -} +} \ No newline at end of file diff --git a/Barotrauma/BarotraumaShared/SharedSource/Lua/LuaBarotraumaAdditions.cs b/Barotrauma/BarotraumaShared/SharedSource/Lua/LuaBarotraumaAdditions.cs index 756eba466..7907ce025 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Lua/LuaBarotraumaAdditions.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Lua/LuaBarotraumaAdditions.cs @@ -37,32 +37,8 @@ namespace Barotrauma } - partial class AfflictionPrefab - { - public static AfflictionPrefab[] ListArray - { - get - { - return List.ToArray(); - } - } - } - - partial class CharacterInfo - { - public static CharacterInfo Create(string speciesName, string name = "", JobPrefab jobPrefab = null, string ragdollFileName = null, int variant = 0, Rand.RandSync randSync = Rand.RandSync.Unsynced, string npcIdentifier = "") - { - return new CharacterInfo(speciesName, name, name, jobPrefab, ragdollFileName, variant, randSync, npcIdentifier); - } - } - partial class Item { - public static void AddToRemoveQueue(Item item) - { - EntitySpawner.Spawner.AddToRemoveQueue(item); - } - public object GetComponentString(string component) { Type type = Type.GetType("Barotrauma.Items.Components." + component); diff --git a/Barotrauma/BarotraumaShared/SharedSource/Lua/LuaClasses/LuaClasses.cs b/Barotrauma/BarotraumaShared/SharedSource/Lua/LuaClasses/LuaClasses.cs index 816de457e..fd4272b3f 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Lua/LuaClasses/LuaClasses.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Lua/LuaClasses/LuaClasses.cs @@ -315,7 +315,7 @@ namespace Barotrauma } } - public void CreateEntityEvent(INetSerializable entity, object[] extraData) + public void CreateEntityEvent(INetSerializable entity, NetEntityEvent.IData extraData) { GameMain.NetworkMember.CreateEntityEvent(entity, extraData); } diff --git a/Barotrauma/BarotraumaShared/SharedSource/Lua/LuaClasses/LuaGame.cs b/Barotrauma/BarotraumaShared/SharedSource/Lua/LuaClasses/LuaGame.cs index 10e2cd882..59f6a05a1 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Lua/LuaClasses/LuaGame.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Lua/LuaClasses/LuaGame.cs @@ -14,7 +14,6 @@ namespace Barotrauma { public bool IsSingleplayer => GameMain.IsSingleplayer; public bool IsMultiplayer => GameMain.IsMultiplayer; - public GameSettings GameSettings => GameMain.Config; #if CLIENT public bool Paused => GameMain.Instance?.Paused == true; @@ -205,53 +204,6 @@ namespace Barotrauma new Explosion(range, force, damage, structureDamage, itemDamage, empStrength, ballastFloraStrength).Explode(pos, null); } - public static Character Spawn(string name, Vector2 worldPos) - { - Character spawnedCharacter = null; - Vector2 spawnPosition = worldPos; - - string characterLowerCase = name.ToLowerInvariant(); - JobPrefab job = null; - if (!JobPrefab.Prefabs.ContainsKey(characterLowerCase)) - { - job = JobPrefab.Prefabs.Find(jp => jp.Name != null && jp.Name.Equals(characterLowerCase, StringComparison.OrdinalIgnoreCase)); - } - else - { - job = JobPrefab.Prefabs[characterLowerCase]; - } - bool human = job != null || characterLowerCase == CharacterPrefab.HumanSpeciesName; - - - if (string.IsNullOrWhiteSpace(name)) { return null; } - - if (human) - { - var variant = job != null ? Rand.Range(0, job.Variants, Rand.RandSync.Server) : 0; - CharacterInfo characterInfo = new CharacterInfo(CharacterPrefab.HumanSpeciesName, jobPrefab: job, variant: variant); - spawnedCharacter = Character.Create(characterInfo, spawnPosition, ToolBox.RandomSeed(8)); - if (GameMain.GameSession != null) - { - //TODO: a way to select which team to spawn to? - spawnedCharacter.TeamID = Character.Controlled != null ? Character.Controlled.TeamID : CharacterTeamType.Team1; -#if CLIENT - GameMain.GameSession.CrewManager.AddCharacter(spawnedCharacter); -#endif - } - spawnedCharacter.GiveJobItems(null); - spawnedCharacter.Info.StartItemsGiven = true; - } - else - { - if (CharacterPrefab.FindBySpeciesName(name) != null) - { - spawnedCharacter = Character.Create(name, spawnPosition, ToolBox.RandomSeed(8)); - } - } - - return spawnedCharacter; - } - public static string SpawnItem(string name, Vector2 pos, bool inventory = false, Character character = null) { string error; @@ -259,11 +211,6 @@ namespace Barotrauma return error; } - public static void RemoveItem(Item item) - { - EntitySpawner.Spawner.AddToRemoveQueue(item); - } - public static ItemPrefab GetItemPrefab(string itemNameOrId) { ItemPrefab itemPrefab = @@ -273,20 +220,6 @@ namespace Barotrauma return itemPrefab; } - public void AddItemPrefabToSpawnQueue(ItemPrefab itemPrefab, Vector2 position, DynValue spawned = null) - { - EntitySpawner.Spawner.AddToSpawnQueue(itemPrefab, position, onSpawned: (Item item) => { - if (spawned?.Type == DataType.Function) GameMain.Lua.CallFunction(spawned, UserData.Create(item)); - }); - } - - public void AddItemPrefabToSpawnQueue(ItemPrefab itemPrefab, Inventory inventory, DynValue spawned = null) - { - EntitySpawner.Spawner.AddToSpawnQueue(itemPrefab, inventory, onSpawned: (Item item) => { - if (spawned?.Type == DataType.Function) GameMain.Lua.CallFunction(spawned, UserData.Create(item)); - }); - } - public static Submarine GetRespawnSub() { #if SERVER @@ -356,34 +289,6 @@ namespace Barotrauma return new Signal(value, stepsTaken, sender, source, power, strength); } - public static ContentPackage[] GetEnabledContentPackages() - { - return GameMain.Config.AllEnabledPackages.ToArray(); - } - - public static List GetEnabledPackagesDirectlyFromFile() - { - List enabledPackages = new List(); - - XDocument doc = XMLExtensions.LoadXml("config_player.xml"); - var contentPackagesElement = doc.Root.Element("contentpackages"); - - string coreName = contentPackagesElement.Element("core")?.GetAttributeString("name", ""); - enabledPackages.Add(coreName); - - XElement regularElement = contentPackagesElement.Element("regular"); - List subElements = regularElement?.Elements()?.ToList(); - - foreach (var subElement in subElements) - { - if (!bool.TryParse(subElement.GetAttributeString("enabled", "false"), out bool enabled) || !enabled) { continue; } - - string name = subElement.GetAttributeString("name", null); - enabledPackages.Add(name); - } - return enabledPackages; - } - private List luaAddedCommand = new List(); public void RemoveCommand(string name) @@ -450,7 +355,7 @@ namespace Barotrauma GameMain.Server.SendChatMessage(msg, (ChatMessageType)messageType, sender, character); } - public static void SendTraitorMessage(Client client, string msg, string missionid, TraitorMessageType type) + public static void SendTraitorMessage(Client client, string msg, Identifier missionid, TraitorMessageType type) { GameMain.Server.SendTraitorMessage(client, msg, missionid, type); } diff --git a/Barotrauma/BarotraumaShared/SharedSource/Lua/LuaDocs.cs b/Barotrauma/BarotraumaShared/SharedSource/Lua/LuaDocs.cs index f36e55245..8a645d906 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Lua/LuaDocs.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Lua/LuaDocs.cs @@ -97,12 +97,12 @@ namespace Barotrauma GenerateDocs(typeof(WayPoint), "WayPoint.lua", "WayPoint"); } - public static void GenerateDocs(Type type, string name, string? categoryName = null) + public static void GenerateDocs(Type type, string name, string categoryName = null) { GenerateDocs(type, "../../../../docs/baseluadocs/" + name, "../../../../docs/lua/generated/" + name, categoryName); } - public static void GenerateDocs(Type type, string baselua, string fileresult, string? categoryName = null) + public static void GenerateDocs(Type type, string baselua, string fileresult, string categoryName = null) { var sb = new StringBuilder(); diff --git a/Barotrauma/BarotraumaShared/SharedSource/Map/MapEntity.cs b/Barotrauma/BarotraumaShared/SharedSource/Map/MapEntity.cs index 0df46bf55..1f3865f60 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Map/MapEntity.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Map/MapEntity.cs @@ -565,7 +565,7 @@ namespace Barotrauma if (mapEntityUpdateTick % MapEntityUpdateInterval == 0) { - foreach (Hull hull in Hull.hullList) + foreach (Hull hull in Hull.HullList) { hull.Update(deltaTime * MapEntityUpdateInterval, cam); } diff --git a/Libraries/MoonSharp.Interpreter.dll b/Libraries/MoonSharp.Interpreter.dll index 7cac0e3c0..b1b9b605d 100644 Binary files a/Libraries/MoonSharp.Interpreter.dll and b/Libraries/MoonSharp.Interpreter.dll differ