diff --git a/Barotrauma/BarotraumaServer/ServerSource/Networking/RespawnManager.cs b/Barotrauma/BarotraumaServer/ServerSource/Networking/RespawnManager.cs index 6f569364e..c6724222f 100644 --- a/Barotrauma/BarotraumaServer/ServerSource/Networking/RespawnManager.cs +++ b/Barotrauma/BarotraumaServer/ServerSource/Networking/RespawnManager.cs @@ -166,11 +166,6 @@ namespace Barotrauma.Networking partial void UpdateWaiting(TeamSpecificState teamSpecificState) { - if (!GameMain.LuaCs.Game.overrideRespawnSub) - { - RespawnShuttle.Velocity = Vector2.Zero; - } - //no respawns in the first minute of the round - otherwise it can be that bots //are respawned to "fill" the spots of players who are taking a long time to load in if (GameMain.GameSession is { RoundDuration: < 60 }) @@ -180,7 +175,7 @@ namespace Barotrauma.Networking var teamId = teamSpecificState.TeamID; var respawnShuttle = GetShuttle(teamId); - if (respawnShuttle != null) + if (respawnShuttle != null && !GameMain.LuaCs.Game.overrideRespawnSub) { respawnShuttle.Velocity = Vector2.Zero; } @@ -228,7 +223,7 @@ namespace Barotrauma.Networking } } - private void DispatchShuttle(TeamSpecificState teamSpecificState) + public void DispatchShuttle(TeamSpecificState teamSpecificState) { if (RespawnShuttles.Any()) { diff --git a/Barotrauma/BarotraumaShared/Lua/DefaultLib/LibShared.lua b/Barotrauma/BarotraumaShared/Lua/DefaultLib/LibShared.lua index 52b38faac..7f0536555 100644 --- a/Barotrauma/BarotraumaShared/Lua/DefaultLib/LibShared.lua +++ b/Barotrauma/BarotraumaShared/Lua/DefaultLib/LibShared.lua @@ -45,7 +45,6 @@ defaultLib["WearableType"] = CreateEnum("Barotrauma.WearableType") defaultLib["NumberType"] = CreateEnum("Barotrauma.NumberType") defaultLib["ChatMode"] = CreateEnum("Barotrauma.ChatMode") defaultLib["CharacterType"] = CreateEnum("Barotrauma.CharacterType") -defaultLib["MissionType"] = CreateEnum("Barotrauma.MissionType") defaultLib["VoteType"] = CreateEnum("Barotrauma.Networking.VoteType") defaultLib["CanEnterSubmarine"] = CreateEnum("Barotrauma.CanEnterSubmarine") defaultLib["InputType"] = CreateStatic("Barotrauma.InputType") diff --git a/Barotrauma/BarotraumaShared/Lua/DefaultRegister/RegisterShared.lua b/Barotrauma/BarotraumaShared/Lua/DefaultRegister/RegisterShared.lua index a06e6de63..a3603fe58 100644 --- a/Barotrauma/BarotraumaShared/Lua/DefaultRegister/RegisterShared.lua +++ b/Barotrauma/BarotraumaShared/Lua/DefaultRegister/RegisterShared.lua @@ -65,6 +65,7 @@ RegisterBarotrauma("DestructibleLevelWall") RegisterBarotrauma("Biome") RegisterBarotrauma("Map") RegisterBarotrauma("Networking.RespawnManager") +RegisterBarotrauma("Networking.RespawnManager+TeamSpecificState") RegisterBarotrauma("Character") RegisterBarotrauma("CharacterPrefab") diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Lua/LuaClasses/LuaGame.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Lua/LuaClasses/LuaGame.cs index ca354e221..fc515c8bd 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Lua/LuaClasses/LuaGame.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Lua/LuaClasses/LuaGame.cs @@ -340,13 +340,11 @@ namespace Barotrauma public static Submarine GetRespawnSub() { #if SERVER - if (GameMain.Server.RespawnManager == null) - return null; - return GameMain.Server.RespawnManager.RespawnShuttle; + if (GameMain.Server.RespawnManager == null) { return null; } + return GameMain.Server.RespawnManager.GetShuttle(CharacterTeamType.Team1); #else - if (GameMain.Client.RespawnManager == null) - return null; - return GameMain.Client.RespawnManager.RespawnShuttle; + if (GameMain.Client.RespawnManager == null) { return null; } + return GameMain.Client.RespawnManager.GetShuttle(CharacterTeamType.Team1); #endif } @@ -470,18 +468,18 @@ namespace Barotrauma public void SaveGame(string path) { if (!LuaCsFile.CanWriteToPath(path)) { throw new ScriptRuntimeException($"Saving files to {path} is disallowed."); } - SaveUtil.SaveGame(path); + SaveUtil.SaveGame(CampaignDataPath.CreateRegular(path)); } public void LoadGame(string path) { - SaveUtil.LoadGame(path); + SaveUtil.LoadGame(CampaignDataPath.CreateRegular(path)); } #if SERVER public void LoadCampaign(string path, Client client = null) { - MultiPlayerCampaign.LoadCampaign(path, client); + MultiPlayerCampaign.LoadCampaign(CampaignDataPath.CreateRegular(path), client); } public static void SendMessage(string msg, ChatMessageType? messageType = null, Client sender = null, Character character = null) @@ -513,10 +511,10 @@ namespace Barotrauma public static void DispatchRespawnSub() { - GameMain.Server.RespawnManager.DispatchShuttle(); + GameMain.Server.RespawnManager.DispatchShuttle(GameMain.Server.RespawnManager.GetTeamSpecificState(CharacterTeamType.Team1)); } - public static bool StartGame() + public static GameServer.TryStartGameResult StartGame() { return GameMain.Server.TryStartGame(); } diff --git a/Barotrauma/BarotraumaShared/SharedSource/Networking/RespawnManager.cs b/Barotrauma/BarotraumaShared/SharedSource/Networking/RespawnManager.cs index 79107de69..2bab13e6a 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Networking/RespawnManager.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Networking/RespawnManager.cs @@ -44,7 +44,7 @@ namespace Barotrauma.Networking private readonly Dictionary> shuttleDoors = new Dictionary>(); private readonly Dictionary> respawnContainers = new Dictionary>(); - private class TeamSpecificState + public class TeamSpecificState { public readonly CharacterTeamType TeamID; @@ -267,7 +267,7 @@ namespace Barotrauma.Networking partial void UpdateReturningProjSpecific(TeamSpecificState teamSpecificState, float deltaTime); - private Submarine GetShuttle(CharacterTeamType team) + public Submarine GetShuttle(CharacterTeamType team) { if (respawnShuttles.TryGetValue(team, out Submarine sub)) { @@ -276,6 +276,16 @@ namespace Barotrauma.Networking return null; } + public TeamSpecificState GetTeamSpecificState(CharacterTeamType team) + { + if (teamSpecificStates.TryGetValue(team, out TeamSpecificState state)) + { + return state; + } + + return null; + } + private void ResetShuttle(TeamSpecificState teamSpecificState) { teamSpecificState.ReturnTime = DateTime.Now + new TimeSpan(0, 0, 0, 0, milliseconds: (int)(maxTransportTime * 1000));