From 3aeaae0595c056a76b8231e78c9709c82bc7ebbf Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Wed, 4 Apr 2018 18:53:23 +0300 Subject: [PATCH] Fixed RespawnManager not removing respawn items. Closes #234 --- .../Source/Networking/RespawnManager.cs | 26 ++++++++----------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/Barotrauma/BarotraumaShared/Source/Networking/RespawnManager.cs b/Barotrauma/BarotraumaShared/Source/Networking/RespawnManager.cs index 78a334ae3..8e30cb8e1 100644 --- a/Barotrauma/BarotraumaShared/Source/Networking/RespawnManager.cs +++ b/Barotrauma/BarotraumaShared/Source/Networking/RespawnManager.cs @@ -10,9 +10,6 @@ namespace Barotrauma.Networking { class RespawnManager : Entity, IServerSerializable { - // TODO: Instead of hard-coding the tags in the code, maybe they should be defined in a config file? - private static string respawnItemTag = "respawn"; - private readonly float respawnInterval; private float maxTransportTime; @@ -30,7 +27,11 @@ namespace Barotrauma.Networking private Submarine respawnShuttle; private Steering shuttleSteering; private List shuttleDoors; - + + //items created during respawn + //any respawn items left in the shuttle are removed when the shuttle despawns + private List respawnItems = new List(); + public bool UsingShuttle { get { return respawnShuttle != null; } @@ -367,17 +368,16 @@ namespace Barotrauma.Networking foreach (Item item in Item.ItemList) { if (item.Submarine != respawnShuttle) continue; - // Ignore the respawn items, defined in RespawnCharacters method. - if (item.HasTag(respawnItemTag)) continue; - - if (item.body != null && item.body.Enabled && item.ParentInventory == null) + + //remove respawn items that have been left in the shuttle + if (respawnItems.Contains(item)) { - Entity.Spawner.AddToRemoveQueue(item); + Spawner.AddToRemoveQueue(item); continue; } + //restore other items to full condition and recharge batteries item.Condition = item.Prefab.Health; - var powerContainer = item.GetComponent(); if (powerContainer != null) { @@ -506,10 +506,7 @@ namespace Barotrauma.Networking #endif Vector2 pos = cargoSp == null ? character.Position : cargoSp.Position; - - // Temp list to hold all respawn items. - // TODO: Instead of tags, wouldn't it be better to keep a local reference to the list that we create and simple filter out the items on it, before clearing the items in ResetShuttle method? - var respawnItems = new List(); + if (divingSuitPrefab != null && oxyPrefab != null) { var divingSuit = new Item(divingSuitPrefab, pos, respawnSub); @@ -542,7 +539,6 @@ namespace Barotrauma.Networking respawnItems.Add(scooter); respawnItems.Add(battery); } - respawnItems.ForEach(item => item.AddTag(respawnItemTag)); //give the character the items they would've gotten if they had spawned in the main sub character.GiveJobItems(mainSubSpawnPoints[i]);