- EntitySpawner recursively deletes contained items when an item is deleted

- items in the inventories of the characters inside the shuttle are deleted when resetting the respawn shuttle
- fixed host's character not being taken into account when assigning jobs for respawning characters if the host is not respawning
This commit is contained in:
Regalis
2017-03-24 18:49:03 +02:00
parent ccc09560a1
commit 067db912f4
4 changed files with 32 additions and 24 deletions
+13 -2
View File
@@ -118,12 +118,23 @@ namespace Barotrauma
removeQueue.Enqueue(entity);
}
public void Update()
public void AddToRemoveQueue(Item item)
{
if (GameMain.Client != null) return;
if (!spawnQueue.Any()) return;
removeQueue.Enqueue(item);
if (item.ContainedItems == null) return;
foreach (Item containedItem in item.ContainedItems)
{
if (containedItem != null) AddToRemoveQueue(containedItem);
}
}
public void Update()
{
if (GameMain.Client != null) return;
while (spawnQueue.Count>0)
{
var entitySpawnInfo = spawnQueue.Dequeue();
@@ -1891,6 +1891,10 @@ namespace Barotrauma.Networking
assignedClientCount[JobPrefab.List.IndexOf(myCharacter.Info.Job.Prefab)] = 1;
}
}
else if (myCharacter != null && !myCharacter.IsDead)
{
assignedClientCount[JobPrefab.List.IndexOf(myCharacter.Info.Job.Prefab)]++;
}
//count the clients who already have characters with an assigned job
foreach (Client c in connectedClients)
+11 -2
View File
@@ -324,7 +324,8 @@ namespace Barotrauma.Networking
if (item.body != null && item.body.Enabled && item.ParentInventory == null)
{
Item.Spawner.AddToRemoveQueue(item);
Entity.Spawner.AddToRemoveQueue(item);
continue;
}
item.Condition = 100.0f;
@@ -362,9 +363,17 @@ namespace Barotrauma.Networking
if (c.Submarine == respawnShuttle)
{
if (Character.Controlled == c) Character.Controlled = null;
//if (networkMember.Character == c) networkMember.Character = null;
c.Enabled = false;
if (c.Inventory != null)
{
foreach (Item item in c.Inventory.Items)
{
if (item == null) continue;
Entity.Spawner.AddToRemoveQueue(item);
}
}
c.Kill(CauseOfDeath.Damage, true);
}
}