Fixed errors in RespawnManager.ClientRead when not using a shuttle, extra diving gear does not spawn when respawning in main sub (TODO: automatically give and equip diving gear if the sub is flooded?)

This commit is contained in:
Joonas Rikkonen
2018-07-30 11:41:03 +03:00
parent c66098ca4e
commit 8c598db10b
@@ -353,6 +353,11 @@ namespace Barotrauma.Networking
private IEnumerable<object> ForceShuttleToPos(Vector2 position, float speed) private IEnumerable<object> ForceShuttleToPos(Vector2 position, float speed)
{ {
if (respawnShuttle == null)
{
yield return CoroutineStatus.Success;
}
respawnShuttle.PhysicsBody.FarseerBody.IgnoreCollisionWith(Level.Loaded.TopBarrier); respawnShuttle.PhysicsBody.FarseerBody.IgnoreCollisionWith(Level.Loaded.TopBarrier);
while (Math.Abs(position.Y - respawnShuttle.WorldPosition.Y) > 100.0f) while (Math.Abs(position.Y - respawnShuttle.WorldPosition.Y) > 100.0f)
@@ -374,6 +379,8 @@ namespace Barotrauma.Networking
shuttleTransportTimer = maxTransportTime; shuttleTransportTimer = maxTransportTime;
shuttleReturnTimer = maxTransportTime; shuttleReturnTimer = maxTransportTime;
if (respawnShuttle == null) return;
foreach (Item item in Item.ItemList) foreach (Item item in Item.ItemList)
{ {
if (item.Submarine != respawnShuttle) continue; if (item.Submarine != respawnShuttle) continue;
@@ -448,7 +455,7 @@ namespace Barotrauma.Networking
var server = networkMember as GameServer; var server = networkMember as GameServer;
if (server == null) return; if (server == null) return;
var respawnSub = respawnShuttle != null ? respawnShuttle : Submarine.MainSub; var respawnSub = respawnShuttle ?? Submarine.MainSub;
var clients = GetClientsToRespawn(); var clients = GetClientsToRespawn();
foreach (Client c in clients) foreach (Client c in clients)
@@ -514,8 +521,9 @@ namespace Barotrauma.Networking
} }
#endif #endif
if (respawnShuttle != null)
{
Vector2 pos = cargoSp == null ? character.Position : cargoSp.Position; Vector2 pos = cargoSp == null ? character.Position : cargoSp.Position;
if (divingSuitPrefab != null && oxyPrefab != null) if (divingSuitPrefab != null && oxyPrefab != null)
{ {
var divingSuit = new Item(divingSuitPrefab, pos, respawnSub); var divingSuit = new Item(divingSuitPrefab, pos, respawnSub);
@@ -540,6 +548,7 @@ namespace Barotrauma.Networking
respawnItems.Add(scooter); respawnItems.Add(scooter);
respawnItems.Add(battery); respawnItems.Add(battery);
} }
}
//give the character the items they would've gotten if they had spawned in the main sub //give the character the items they would've gotten if they had spawned in the main sub
character.GiveJobItems(mainSubSpawnPoints[i]); character.GiveJobItems(mainSubSpawnPoints[i]);