Using ItemSpawner to spawn extra cargo (-> clients will be notified of the spawned items)

This commit is contained in:
Regalis
2016-10-05 18:30:48 +03:00
parent 8cac5b2ad2
commit 41c38575b9
2 changed files with 57 additions and 38 deletions

View File

@@ -967,15 +967,15 @@ namespace Barotrauma.Networking
Vector2 position = new Vector2(
cargoSpawnPos.Position.X + Rand.Range(-20.0f, 20.0f, false),
cargoRoom.Rect.Y - cargoRoom.Rect.Height);
foreach (string s in extraCargo.Keys)
{
ItemPrefab itemPrefab = ItemPrefab.list.Find(ip => ip.Name == s) as ItemPrefab;
if (itemPrefab == null) continue;
for (int i = 0; i < extraCargo[s]; i++)
{
var item = new Item(itemPrefab, position, cargoRoom.Submarine);
item.FindHull();
Item.ItemList.Add(item);
Item.Spawner.QueueItem(itemPrefab, position, sub, false);
}
}
}