Fixed RespawnManager not removing respawn items. Closes #234
This commit is contained in:
@@ -10,9 +10,6 @@ namespace Barotrauma.Networking
|
|||||||
{
|
{
|
||||||
class RespawnManager : Entity, IServerSerializable
|
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 readonly float respawnInterval;
|
||||||
private float maxTransportTime;
|
private float maxTransportTime;
|
||||||
|
|
||||||
@@ -30,7 +27,11 @@ namespace Barotrauma.Networking
|
|||||||
private Submarine respawnShuttle;
|
private Submarine respawnShuttle;
|
||||||
private Steering shuttleSteering;
|
private Steering shuttleSteering;
|
||||||
private List<Door> shuttleDoors;
|
private List<Door> shuttleDoors;
|
||||||
|
|
||||||
|
//items created during respawn
|
||||||
|
//any respawn items left in the shuttle are removed when the shuttle despawns
|
||||||
|
private List<Item> respawnItems = new List<Item>();
|
||||||
|
|
||||||
public bool UsingShuttle
|
public bool UsingShuttle
|
||||||
{
|
{
|
||||||
get { return respawnShuttle != null; }
|
get { return respawnShuttle != null; }
|
||||||
@@ -367,17 +368,16 @@ namespace Barotrauma.Networking
|
|||||||
foreach (Item item in Item.ItemList)
|
foreach (Item item in Item.ItemList)
|
||||||
{
|
{
|
||||||
if (item.Submarine != respawnShuttle) continue;
|
if (item.Submarine != respawnShuttle) continue;
|
||||||
// Ignore the respawn items, defined in RespawnCharacters method.
|
|
||||||
if (item.HasTag(respawnItemTag)) continue;
|
//remove respawn items that have been left in the shuttle
|
||||||
|
if (respawnItems.Contains(item))
|
||||||
if (item.body != null && item.body.Enabled && item.ParentInventory == null)
|
|
||||||
{
|
{
|
||||||
Entity.Spawner.AddToRemoveQueue(item);
|
Spawner.AddToRemoveQueue(item);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//restore other items to full condition and recharge batteries
|
||||||
item.Condition = item.Prefab.Health;
|
item.Condition = item.Prefab.Health;
|
||||||
|
|
||||||
var powerContainer = item.GetComponent<PowerContainer>();
|
var powerContainer = item.GetComponent<PowerContainer>();
|
||||||
if (powerContainer != null)
|
if (powerContainer != null)
|
||||||
{
|
{
|
||||||
@@ -506,10 +506,7 @@ namespace Barotrauma.Networking
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
Vector2 pos = cargoSp == null ? character.Position : cargoSp.Position;
|
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<Item>();
|
|
||||||
if (divingSuitPrefab != null && oxyPrefab != null)
|
if (divingSuitPrefab != null && oxyPrefab != null)
|
||||||
{
|
{
|
||||||
var divingSuit = new Item(divingSuitPrefab, pos, respawnSub);
|
var divingSuit = new Item(divingSuitPrefab, pos, respawnSub);
|
||||||
@@ -542,7 +539,6 @@ namespace Barotrauma.Networking
|
|||||||
respawnItems.Add(scooter);
|
respawnItems.Add(scooter);
|
||||||
respawnItems.Add(battery);
|
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
|
//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]);
|
||||||
|
|||||||
Reference in New Issue
Block a user