Cargo spawning fix again: items are spawned slightly above the bottom of the cargo room (because the item is only inside the hull if pos.Y > hull.rect.bottom)
This commit is contained in:
@@ -70,7 +70,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
Vector2 position = new Vector2(
|
Vector2 position = new Vector2(
|
||||||
cargoSpawnPos.Position.X + Rand.Range(-20.0f, 20.0f, false),
|
cargoSpawnPos.Position.X + Rand.Range(-20.0f, 20.0f, false),
|
||||||
cargoRoom.Rect.Y - cargoRoom.Rect.Height);
|
cargoRoom.Rect.Y - cargoRoom.Rect.Height + itemPrefab.Size.Y / 2);
|
||||||
|
|
||||||
var item = new Item(itemPrefab, position, cargoRoom.Submarine);
|
var item = new Item(itemPrefab, position, cargoRoom.Submarine);
|
||||||
item.FindHull();
|
item.FindHull();
|
||||||
|
|||||||
@@ -5,14 +5,14 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
class CargoManager
|
class CargoManager
|
||||||
{
|
{
|
||||||
private List<MapEntityPrefab> purchasedItems;
|
private List<ItemPrefab> purchasedItems;
|
||||||
|
|
||||||
public CargoManager()
|
public CargoManager()
|
||||||
{
|
{
|
||||||
purchasedItems = new List<MapEntityPrefab>();
|
purchasedItems = new List<ItemPrefab>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddItem(MapEntityPrefab item)
|
public void AddItem(ItemPrefab item)
|
||||||
{
|
{
|
||||||
purchasedItems.Add(item);
|
purchasedItems.Add(item);
|
||||||
}
|
}
|
||||||
@@ -35,11 +35,11 @@ namespace Barotrauma
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (MapEntityPrefab prefab in purchasedItems)
|
foreach (ItemPrefab prefab in purchasedItems)
|
||||||
{
|
{
|
||||||
Vector2 position = new Vector2(
|
Vector2 position = new Vector2(
|
||||||
Rand.Range(cargoRoom.Rect.X + 20, cargoRoom.Rect.Right - 20),
|
Rand.Range(cargoRoom.Rect.X + 20, cargoRoom.Rect.Right - 20),
|
||||||
Rand.Range(cargoRoom.Rect.Y - cargoRoom.Rect.Height, cargoRoom.Rect.Y));
|
cargoRoom.Rect.Y - cargoRoom.Rect.Height + prefab.Size.Y/2);
|
||||||
|
|
||||||
new Item(prefab as ItemPrefab, position, wp.Submarine);
|
new Item(prefab as ItemPrefab, position, wp.Submarine);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -987,7 +987,7 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
for (int i = 0; i < extraCargo[s]; i++)
|
for (int i = 0; i < extraCargo[s]; i++)
|
||||||
{
|
{
|
||||||
Item.Spawner.QueueItem(itemPrefab, position, sub, false);
|
Item.Spawner.QueueItem(itemPrefab, position + (Vector2.UnitX * itemPrefab.Size.Y/2), sub, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -330,10 +330,10 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
GUIComponent child = selectedItemList.children[i];
|
GUIComponent child = selectedItemList.children[i];
|
||||||
|
|
||||||
MapEntityPrefab ep = child.UserData as MapEntityPrefab;
|
ItemPrefab ip = child.UserData as ItemPrefab;
|
||||||
if (ep == null) continue;
|
if (ip == null) continue;
|
||||||
|
|
||||||
gameMode.CargoManager.AddItem(ep);
|
gameMode.CargoManager.AddItem(ip);
|
||||||
|
|
||||||
selectedItemList.RemoveChild(child);
|
selectedItemList.RemoveChild(child);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user